public async Task Controller_ShouldCopyParentLeaseProperties_IfPartitionSplitHappened() { //arrange Dictionary <string, string> customProperties = new Dictionary <string, string> { { "key", "value" } }; DocumentServiceLease lease = Mock.Of <DocumentServiceLease>(l => l.CurrentLeaseToken == PartitionId && l.Properties == customProperties); PartitionSynchronizer synchronizer = Mock.Of <PartitionSynchronizer>(); DocumentServiceLease leaseChild1 = this.CreateMockLease(); DocumentServiceLease leaseChild2 = this.CreateMockLease(); Mock.Get(synchronizer) .Setup(s => s.HandlePartitionGoneAsync(It.Is <DocumentServiceLease>(l => l.CurrentLeaseToken == PartitionId && l.ContinuationToken == LastContinuationToken))) .ReturnsAsync((new[] { leaseChild1, leaseChild2 }, true)); PartitionSupervisor partitionSupervisor = Mock.Of <PartitionSupervisor>(o => o.RunAsync(It.IsAny <CancellationToken>()) == Task.FromException(new FeedRangeGoneException("message", LastContinuationToken))); PartitionSupervisorFactory partitionSupervisorFactory = Mock.Of <PartitionSupervisorFactory>(f => f.Create(lease) == partitionSupervisor); DocumentServiceLeaseManager leaseManager = Mock.Of <DocumentServiceLeaseManager>(manager => manager.AcquireAsync(lease) == Task.FromResult(lease)); DocumentServiceLeaseContainer leaseContainer = Mock.Of <DocumentServiceLeaseContainer>(); PartitionControllerCore sut = new PartitionControllerCore(leaseContainer, leaseManager, partitionSupervisorFactory, synchronizer, Mock.Of <ChangeFeedProcessorHealthMonitor>()); await sut.InitializeAsync().ConfigureAwait(false); //act await sut.AddOrUpdateLeaseAsync(lease).ConfigureAwait(false); await sut.ShutdownAsync().ConfigureAwait(false); Mock.Get(leaseChild1) .VerifySet(l => l.Properties = customProperties, Times.Once); Mock.Get(leaseChild2) .VerifySet(l => l.Properties = customProperties, Times.Once); }
public async Task Controller_ShouldPassLastKnownContinuationTokenToSynchronizer_IfPartitionSplitHappened() { //arrange DocumentServiceLease lease = Mock.Of <DocumentServiceLease>(l => l.CurrentLeaseToken == PartitionId && l.ContinuationToken == InitialContinuationToken); PartitionSynchronizer synchronizer = Mock.Of <PartitionSynchronizer>(); Mock.Get(synchronizer) .Setup(s => s.HandlePartitionGoneAsync(It.Is <DocumentServiceLease>(l => l.CurrentLeaseToken == PartitionId && l.ContinuationToken == LastContinuationToken))) .ReturnsAsync((new[] { this.CreateMockLease(), this.CreateMockLease() }, true)); PartitionSupervisor partitionSupervisor = Mock.Of <PartitionSupervisor>(o => o.RunAsync(It.IsAny <CancellationToken>()) == Task.FromException(new FeedRangeGoneException("message", LastContinuationToken))); PartitionSupervisorFactory partitionSupervisorFactory = Mock.Of <PartitionSupervisorFactory>(f => f.Create(lease) == partitionSupervisor); DocumentServiceLeaseManager leaseManager = Mock.Of <DocumentServiceLeaseManager>(manager => manager.AcquireAsync(lease) == Task.FromResult(lease)); DocumentServiceLeaseContainer leaseContainer = Mock.Of <DocumentServiceLeaseContainer>(); PartitionControllerCore sut = new PartitionControllerCore(leaseContainer, leaseManager, partitionSupervisorFactory, synchronizer, Mock.Of <ChangeFeedProcessorHealthMonitor>()); await sut.InitializeAsync().ConfigureAwait(false); //act await sut.AddOrUpdateLeaseAsync(lease).ConfigureAwait(false); //assert await sut.ShutdownAsync().ConfigureAwait(false); Mock.Get(synchronizer).VerifyAll(); }
public async Task Controller_ShouldDeleteParentLease_IfChildLeaseAcquireThrows() { //arrange DocumentServiceLease lease = this.CreateMockLease(PartitionId); PartitionSynchronizer synchronizer = Mock.Of <PartitionSynchronizer>(); DocumentServiceLease leaseChild2 = this.CreateMockLease(); Mock.Get(synchronizer) .Setup(s => s.SplitPartitionAsync(lease)) .ReturnsAsync(new[] { this.CreateMockLease(), leaseChild2 }); PartitionSupervisor partitionSupervisor = Mock.Of <PartitionSupervisor>(o => o.RunAsync(It.IsAny <CancellationToken>()) == Task.FromException(new FeedSplitException("message", LastContinuationToken))); PartitionSupervisorFactory partitionSupervisorFactory = Mock.Of <PartitionSupervisorFactory>(f => f.Create(lease) == partitionSupervisor); DocumentServiceLeaseManager leaseManager = Mock.Of <DocumentServiceLeaseManager>(manager => manager.AcquireAsync(lease) == Task.FromResult(lease) && manager.AcquireAsync(leaseChild2) == Task.FromException <DocumentServiceLease>(new LeaseLostException()) ); DocumentServiceLeaseContainer leaseContainer = Mock.Of <DocumentServiceLeaseContainer>(); PartitionControllerCore sut = new PartitionControllerCore(leaseContainer, leaseManager, partitionSupervisorFactory, synchronizer); await sut.InitializeAsync().ConfigureAwait(false); //act await sut.AddOrUpdateLeaseAsync(lease).ConfigureAwait(false); //assert await sut.ShutdownAsync().ConfigureAwait(false); Mock.Get(leaseManager).Verify(manager => manager.DeleteAsync(lease), Times.Once); }
public PartitionControllerTests() { this.lease = Mock.Of <DocumentServiceLease>(); Mock.Get(this.lease) .Setup(l => l.CurrentLeaseToken) .Returns("partitionId"); this.partitionProcessor = MockPartitionProcessor(); this.leaseRenewer = MockRenewer(); this.observer = Mock.Of <ChangeFeedObserver>(); this.partitionSupervisorFactory = Mock.Of <PartitionSupervisorFactory>(f => f.Create(this.lease) == new PartitionSupervisorCore(this.lease, this.observer, this.partitionProcessor, this.leaseRenewer)); this.leaseManager = Mock.Of <DocumentServiceLeaseManager>(); Mock.Get(this.leaseManager).Reset(); // Reset implicit/by default setup of properties. Mock.Get(this.leaseManager) .Setup(manager => manager.AcquireAsync(this.lease)) .ReturnsAsync(this.lease); Mock.Get(this.leaseManager) .Setup(manager => manager.ReleaseAsync(this.lease)) .Returns(Task.CompletedTask); DocumentServiceLeaseContainer leaseContainer = Mock.Of <DocumentServiceLeaseContainer>(); this.synchronizer = Mock.Of <PartitionSynchronizer>(); this.sut = new PartitionControllerCore(leaseContainer, this.leaseManager, this.partitionSupervisorFactory, this.synchronizer); }
public async Task Controller_ShouldSignalSynchronizerSplitPartition_IfPartitionSplitHappened() { //arrange DocumentServiceLease lease = CreateMockLease(PartitionId); PartitionSynchronizer synchronizer = Mock.Of <PartitionSynchronizer>(); Mock.Get(synchronizer) .Setup(s => s.SplitPartitionAsync(lease)) .ReturnsAsync(new[] { CreateMockLease(), CreateMockLease() }); PartitionSupervisor partitionSupervisor = Mock.Of <PartitionSupervisor>(o => o.RunAsync(It.IsAny <CancellationToken>()) == Task.FromException(new FeedSplitException("message", LastContinuationToken))); PartitionSupervisorFactory partitionSupervisorFactory = Mock.Of <PartitionSupervisorFactory>(f => f.Create(lease) == partitionSupervisor); DocumentServiceLeaseManager leaseManager = Mock.Of <DocumentServiceLeaseManager>(manager => manager.AcquireAsync(lease) == Task.FromResult(lease)); DocumentServiceLeaseContainer leaseContainer = Mock.Of <DocumentServiceLeaseContainer>(); PartitionControllerCore sut = new PartitionControllerCore(leaseContainer, leaseManager, partitionSupervisorFactory, synchronizer); await sut.InitializeAsync().ConfigureAwait(false); //act await sut.AddOrUpdateLeaseAsync(lease).ConfigureAwait(false); //assert await sut.ShutdownAsync().ConfigureAwait(false); Mock.Get(synchronizer).VerifyAll(); }
public async Task Controller_ShouldDeleteParentLease_IfChildLeasesCreatedByAnotherHost() { //arrange DocumentServiceLease lease = this.CreateMockLease(PartitionId); PartitionSynchronizer synchronizer = Mock.Of <PartitionSynchronizer>(); Mock.Get(synchronizer) .Setup(s => s.HandlePartitionGoneAsync(lease)) .ReturnsAsync((new DocumentServiceLease[] { }, true)); PartitionSupervisor partitionSupervisor = Mock.Of <PartitionSupervisor>(o => o.RunAsync(It.IsAny <CancellationToken>()) == Task.FromException(new FeedRangeGoneException("message", LastContinuationToken))); PartitionSupervisorFactory partitionSupervisorFactory = Mock.Of <PartitionSupervisorFactory>(f => f.Create(lease) == partitionSupervisor); DocumentServiceLeaseManager leaseManager = Mock.Of <DocumentServiceLeaseManager>(manager => manager.AcquireAsync(lease) == Task.FromResult(lease) ); DocumentServiceLeaseContainer leaseContainer = Mock.Of <DocumentServiceLeaseContainer>(); PartitionControllerCore sut = new PartitionControllerCore(leaseContainer, leaseManager, partitionSupervisorFactory, synchronizer, Mock.Of <ChangeFeedProcessorHealthMonitor>()); await sut.InitializeAsync().ConfigureAwait(false); //act await sut.AddOrUpdateLeaseAsync(lease).ConfigureAwait(false); //assert await sut.ShutdownAsync().ConfigureAwait(false); Mock.Get(leaseManager).Verify(manager => manager.DeleteAsync(lease), Times.Once); }
public PartitionSupervisorFactoryCore( ChangeFeedObserverFactory <T> observerFactory, DocumentServiceLeaseManager leaseManager, FeedProcessorFactory <T> partitionProcessorFactory, ChangeFeedLeaseOptions options) { if (observerFactory == null) { throw new ArgumentNullException(nameof(observerFactory)); } if (leaseManager == null) { throw new ArgumentNullException(nameof(leaseManager)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (partitionProcessorFactory == null) { throw new ArgumentNullException(nameof(partitionProcessorFactory)); } this.observerFactory = observerFactory; this.leaseManager = leaseManager; this.changeFeedLeaseOptions = options; this.partitionProcessorFactory = partitionProcessorFactory; }
async Task InitializeAsync() { this.documentClient = new DocumentClient(this.collectionLocation.Uri, this.collectionLocation.MasterKey, this.collectionLocation.ConnectionPolicy); Uri databaseUri = UriFactory.CreateDatabaseUri(this.collectionLocation.DatabaseName); Database database = await this.documentClient.ReadDatabaseAsync(databaseUri); Uri collectionUri = UriFactory.CreateDocumentCollectionUri(this.collectionLocation.DatabaseName, this.collectionLocation.CollectionName); ResourceResponse <DocumentCollection> collectionResponse = await this.documentClient.ReadDocumentCollectionAsync( collectionUri, new RequestOptions { PopulateQuotaInfo = true }); DocumentCollection collection = collectionResponse.Resource; this.collectionSelfLink = collection.SelfLink; // Grab the options-supplied prefix if present otherwise leave it empty. string optionsPrefix = this.options.LeasePrefix ?? string.Empty; // Beyond this point all access to collection is done via this self link: if collection is removed, we won't access new one using same name by accident. this.leasePrefix = string.Format(CultureInfo.InvariantCulture, "{0}{1}_{2}_{3}", optionsPrefix, this.collectionLocation.Uri.Host, database.ResourceId, collection.ResourceId); var leaseManager = new DocumentServiceLeaseManager( this.auxCollectionLocation, this.leasePrefix, this.options.LeaseExpirationInterval, this.options.LeaseRenewInterval); await leaseManager.InitializeAsync(); this.leaseManager = leaseManager; this.checkpointManager = (ICheckpointManager)leaseManager; if (this.options.DiscardExistingLeases) { TraceLog.Warning(string.Format("Host '{0}': removing all leases, as requested by ChangeFeedHostOptions", this.HostName)); await this.leaseManager.DeleteAllAsync(); } // Note: lease store is never stale as we use monitored colleciton Rid as id prefix for aux collection. // Collection was removed and re-created, the rid would change. // If it's not deleted, it's not stale. If it's deleted, it's not stale as it doesn't exist. await this.leaseManager.CreateLeaseStoreIfNotExistsAsync(); var ranges = new Dictionary <string, PartitionKeyRange>(); foreach (var range in await this.EnumPartitionKeyRangesAsync(this.collectionSelfLink)) { ranges.Add(range.Id, range); } TraceLog.Informational(string.Format("Source collection: '{0}', {1} partition(s), {2} document(s)", this.collectionLocation.CollectionName, ranges.Count, GetDocumentCount(collectionResponse))); await this.CreateLeases(ranges); this.partitionManager = new PartitionManager <DocumentServiceLease>(this.HostName, this.leaseManager, this.options); await this.partitionManager.SubscribeAsync(this); await this.partitionManager.InitializeAsync(); }
public PartitionControllerCore( DocumentServiceLeaseContainer leaseContainer, DocumentServiceLeaseManager leaseManager, PartitionSupervisorFactory partitionSupervisorFactory, PartitionSynchronizer synchronizer) { this.leaseContainer = leaseContainer; this.leaseManager = leaseManager; this.partitionSupervisorFactory = partitionSupervisorFactory; this.synchronizer = synchronizer; }
public async Task Controller_ShouldIgnoreProcessingChildPartition_IfPartitionAlreadyAdded() { //arrange DocumentServiceLease lease = this.CreateMockLease(PartitionId); PartitionSynchronizer synchronizer = Mock.Of <PartitionSynchronizer>(); DocumentServiceLease leaseChild1 = this.CreateMockLease(); DocumentServiceLease leaseChild2 = this.CreateMockLease(); Mock.Get(synchronizer) .Setup(s => s.HandlePartitionGoneAsync(It.Is <DocumentServiceLease>(l => l.CurrentLeaseToken == PartitionId && l.ContinuationToken == LastContinuationToken))) .ReturnsAsync((new[] { leaseChild1, leaseChild2 }, true)); PartitionSupervisor partitionSupervisor = Mock.Of <PartitionSupervisor>(o => o.RunAsync(It.IsAny <CancellationToken>()) == Task.FromException(new FeedRangeGoneException("message", LastContinuationToken))); PartitionSupervisor partitionSupervisor1 = Mock.Of <PartitionSupervisor>(); Mock.Get(partitionSupervisor1).Setup(o => o.RunAsync(It.IsAny <CancellationToken>())).Returns <CancellationToken>(token => Task.Delay(TimeSpan.FromHours(1), token)); PartitionSupervisor partitionSupervisor2 = Mock.Of <PartitionSupervisor>(); Mock.Get(partitionSupervisor2).Setup(o => o.RunAsync(It.IsAny <CancellationToken>())).Returns <CancellationToken>(token => Task.Delay(TimeSpan.FromHours(1), token)); PartitionSupervisorFactory partitionSupervisorFactory = Mock.Of <PartitionSupervisorFactory>(f => f.Create(lease) == partitionSupervisor && f.Create(leaseChild1) == partitionSupervisor1 && f.Create(leaseChild2) == partitionSupervisor2); DocumentServiceLeaseManager leaseManager = Mock.Of <DocumentServiceLeaseManager>(manager => manager.AcquireAsync(lease) == Task.FromResult(lease)); DocumentServiceLeaseContainer leaseContainer = Mock.Of <DocumentServiceLeaseContainer>(); PartitionControllerCore sut = new PartitionControllerCore(leaseContainer, leaseManager, partitionSupervisorFactory, synchronizer, Mock.Of <ChangeFeedProcessorHealthMonitor>()); await sut.InitializeAsync().ConfigureAwait(false); //act await sut.AddOrUpdateLeaseAsync(lease).ConfigureAwait(false); await sut.AddOrUpdateLeaseAsync(leaseChild2).ConfigureAwait(false); await sut.AddOrUpdateLeaseAsync(leaseChild2).ConfigureAwait(false); await sut.AddOrUpdateLeaseAsync(leaseChild2).ConfigureAwait(false); await sut.AddOrUpdateLeaseAsync(leaseChild2).ConfigureAwait(false); await sut.AddOrUpdateLeaseAsync(leaseChild2).ConfigureAwait(false); //assert await sut.ShutdownAsync().ConfigureAwait(false); Mock.Get(leaseManager) .Verify(manager => manager.AcquireAsync(leaseChild2), Times.Once); Mock.Get(leaseManager) .Verify(manager => manager.UpdatePropertiesAsync(leaseChild2), Times.Exactly(5)); Mock.Get(partitionSupervisorFactory) .Verify(f => f.Create(leaseChild2), Times.Once); }
async Task InitializeAsync() { this.documentClient = new DocumentClient(this.collectionLocation.Uri, this.collectionLocation.MasterKey, this.collectionLocation.ConnectionPolicy); Uri databaseUri = UriFactory.CreateDatabaseUri(this.collectionLocation.DatabaseName); Database database = await this.documentClient.ReadDatabaseAsync(databaseUri); Uri collectionUri = UriFactory.CreateDocumentCollectionUri(this.collectionLocation.DatabaseName, this.collectionLocation.CollectionName); DocumentCollection collection = await this.documentClient.ReadDocumentCollectionAsync(collectionUri); this.collectionSelfLink = collection.SelfLink; // Beyond this point all access to colleciton is done via this self link: if collection is removed, we won't access new one using same name by accident. this.leasePrefix = string.Format(CultureInfo.InvariantCulture, "{0}_{1}_{2}", this.collectionLocation.Uri.Host, database.ResourceId, collection.ResourceId); var leaseManager = new DocumentServiceLeaseManager( this.auxCollectionLocation, this.leasePrefix, this.options.LeaseExpirationInterval, this.options.LeaseRenewInterval); await leaseManager.InitializeAsync(); this.leaseManager = leaseManager; this.checkpointManager = (ICheckpointManager)leaseManager; if (this.options.DiscardExistingLeases) { TraceLog.Warning(string.Format("Host '{0}': removing all leases, as requested by ChangeFeedHostOptions", this.HostName)); await this.leaseManager.DeleteAllAsync(); } // Note: lease store is never stale as we use monitored colleciton Rid as id prefix for aux collection. // Collection was removed and re-created, the rid would change. // If it's not deleted, it's not stale. If it's deleted, it's not stale as it doesn't exist. await this.leaseManager.CreateLeaseStoreIfNotExistsAsync(); string[] rangeIds = await this.EnumPartitionKeyRangeIds(this.collectionSelfLink); Parallel.ForEach(rangeIds, async rangeId => { this.statsSinceLastCheckpoint.AddOrUpdate( rangeId, new CheckpointStats(), (partitionId, existingStats) => existingStats); await this.leaseManager.CreateLeaseIfNotExistAsync(rangeId); }); this.partitionManager = new PartitionManager <DocumentServiceLease>(this.HostName, this.leaseManager, this.options); await this.partitionManager.SubscribeAsync(this); await this.partitionManager.InitializeAsync(); }
public PartitionSynchronizerCore( ContainerCore container, DocumentServiceLeaseContainer leaseContainer, DocumentServiceLeaseManager leaseManager, int degreeOfParallelism, int maxBatchSize) { this.container = container; this.leaseContainer = leaseContainer; this.leaseManager = leaseManager; this.degreeOfParallelism = degreeOfParallelism; this.maxBatchSize = maxBatchSize; }
public PartitionControllerCore( DocumentServiceLeaseContainer leaseContainer, DocumentServiceLeaseManager leaseManager, PartitionSupervisorFactory partitionSupervisorFactory, PartitionSynchronizer synchronizer, ChangeFeedProcessorHealthMonitor monitor) { this.leaseContainer = leaseContainer; this.leaseManager = leaseManager; this.partitionSupervisorFactory = partitionSupervisorFactory; this.synchronizer = synchronizer; this.monitor = monitor; }
public PartitionSynchronizerCore( ContainerInternal container, DocumentServiceLeaseContainer leaseContainer, DocumentServiceLeaseManager leaseManager, int degreeOfParallelism, Routing.PartitionKeyRangeCache partitionKeyRangeCache, string containerRid) { this.container = container; this.leaseContainer = leaseContainer; this.leaseManager = leaseManager; this.degreeOfParallelism = degreeOfParallelism; this.partitionKeyRangeCache = partitionKeyRangeCache; this.containerRid = containerRid; }
public async Task Controller_ShouldRunProcessingOnChildPartitions_IfHappyPath() { //arrange DocumentServiceLease lease = CreateMockLease(PartitionId); PartitionSynchronizer synchronizer = Mock.Of <PartitionSynchronizer>(); DocumentServiceLease leaseChild1 = CreateMockLease(); DocumentServiceLease leaseChild2 = CreateMockLease(); Mock.Get(synchronizer) .Setup(s => s.SplitPartitionAsync(It.Is <DocumentServiceLease>(l => l.CurrentLeaseToken == PartitionId && l.ContinuationToken == LastContinuationToken))) .ReturnsAsync(new[] { leaseChild1, leaseChild2 }); PartitionSupervisor partitionSupervisor = Mock.Of <PartitionSupervisor>(o => o.RunAsync(It.IsAny <CancellationToken>()) == Task.FromException(new FeedSplitException("message", LastContinuationToken))); var partitionSupervisor1 = Mock.Of <PartitionSupervisor>(); Mock.Get(partitionSupervisor1).Setup(o => o.RunAsync(It.IsAny <CancellationToken>())).Returns <CancellationToken>(token => Task.Delay(TimeSpan.FromHours(1), token)); var partitionSupervisor2 = Mock.Of <PartitionSupervisor>(); Mock.Get(partitionSupervisor2).Setup(o => o.RunAsync(It.IsAny <CancellationToken>())).Returns <CancellationToken>(token => Task.Delay(TimeSpan.FromHours(1), token)); PartitionSupervisorFactory partitionSupervisorFactory = Mock.Of <PartitionSupervisorFactory>(f => f.Create(lease) == partitionSupervisor && f.Create(leaseChild1) == partitionSupervisor1 && f.Create(leaseChild2) == partitionSupervisor2); DocumentServiceLeaseManager leaseManager = Mock.Of <DocumentServiceLeaseManager>(manager => manager.AcquireAsync(lease) == Task.FromResult(lease)); DocumentServiceLeaseContainer leaseContainer = Mock.Of <DocumentServiceLeaseContainer>(); PartitionControllerCore sut = new PartitionControllerCore(leaseContainer, leaseManager, partitionSupervisorFactory, synchronizer); await sut.InitializeAsync().ConfigureAwait(false); //act await sut.AddOrUpdateLeaseAsync(lease).ConfigureAwait(false); //assert await sut.ShutdownAsync().ConfigureAwait(false); Mock.Get(leaseManager).Verify(manager => manager.AcquireAsync(leaseChild1), Times.Once); Mock.Get(leaseManager).Verify(manager => manager.AcquireAsync(leaseChild2), Times.Once); Mock.Get(partitionSupervisorFactory).Verify(f => f.Create(leaseChild1), Times.Once); Mock.Get(partitionSupervisorFactory).Verify(f => f.Create(leaseChild2), Times.Once); Mock.Get(partitionSupervisor1).Verify(p => p.RunAsync(It.IsAny <CancellationToken>()), Times.Once); Mock.Get(partitionSupervisor2).Verify(p => p.RunAsync(It.IsAny <CancellationToken>()), Times.Once); }
public async Task Controller_ShouldKeepParentLease_IfSplitThrows() { //arrange DocumentServiceLease lease = this.CreateMockLease(PartitionId); PartitionSynchronizer synchronizer = Mock.Of <PartitionSynchronizer>(s => s.HandlePartitionGoneAsync(lease) == Task.FromException <(IEnumerable <DocumentServiceLease>, bool)>(new InvalidOperationException())); PartitionSupervisor partitionSupervisor = Mock.Of <PartitionSupervisor>(o => o.RunAsync(It.IsAny <CancellationToken>()) == Task.FromException(new FeedRangeGoneException("message", LastContinuationToken))); PartitionSupervisorFactory partitionSupervisorFactory = Mock.Of <PartitionSupervisorFactory>(f => f.Create(lease) == partitionSupervisor); DocumentServiceLeaseManager leaseManager = Mock.Of <DocumentServiceLeaseManager>(); DocumentServiceLeaseContainer leaseContainer = Mock.Of <DocumentServiceLeaseContainer>(); PartitionControllerCore sut = new PartitionControllerCore(leaseContainer, leaseManager, partitionSupervisorFactory, synchronizer, Mock.Of <ChangeFeedProcessorHealthMonitor>()); await sut.InitializeAsync().ConfigureAwait(false); //act await sut.AddOrUpdateLeaseAsync(lease).ConfigureAwait(false); //assert await sut.ShutdownAsync().ConfigureAwait(false); Mock.Get(leaseManager).Verify(manager => manager.DeleteAsync(lease), Times.Never); }
public LeaseRenewerCore(DocumentServiceLease lease, DocumentServiceLeaseManager leaseManager, TimeSpan leaseRenewInterval) { this.lease = lease; this.leaseManager = leaseManager; this.leaseRenewInterval = leaseRenewInterval; }