public TrackingService(ITrackingStore store) { if (store == null) { throw new ArgumentNullException(nameof(store)); } this.store = store; }
public OrchestrationSessionManager( string storageAccountName, AzureStorageOrchestrationServiceSettings settings, AzureStorageOrchestrationServiceStats stats, ITrackingStore trackingStore) { this.storageAccountName = storageAccountName; this.settings = settings; this.stats = stats; this.trackingStore = trackingStore; this.fetchRuntimeStateQueue = new DispatchQueue(this.settings.MaxStorageOperationConcurrency); }
async Task <AzureStorageOrchestrationService> EnsureTaskHubAsync( string testName, bool testDeletion, bool deleteBeforeCreate = true, string workerId = "test") { string storageConnectionString = TestHelpers.GetTestStorageAccountConnectionString(); var storageAccount = CloudStorageAccount.Parse(storageConnectionString); string taskHubName = testName; var settings = new AzureStorageOrchestrationServiceSettings { TaskHubName = taskHubName, StorageConnectionString = storageConnectionString, WorkerId = workerId, }; Trace.TraceInformation($"Task Hub name: {taskHubName}"); var service = new AzureStorageOrchestrationService(settings); if (deleteBeforeCreate) { await service.CreateAsync(); } else { await service.CreateIfNotExistsAsync(); } // Control queues Assert.IsNotNull(service.AllControlQueues, "Control queue collection was not initialized."); ControlQueue[] controlQueues = service.AllControlQueues.ToArray(); Assert.AreEqual(4, controlQueues.Length, "Expected to see the default four control queues created."); foreach (ControlQueue queue in controlQueues) { Assert.IsTrue(await queue.InnerQueue.ExistsAsync(), $"Queue {queue.Name} was not created."); } // Work-item queue WorkItemQueue workItemQueue = service.WorkItemQueue; Assert.IsNotNull(workItemQueue, "Work-item queue client was not initialized."); Assert.IsTrue(await workItemQueue.InnerQueue.ExistsAsync(), $"Queue {workItemQueue.Name} was not created."); // TrackingStore ITrackingStore trackingStore = service.TrackingStore; Assert.IsNotNull(trackingStore, "Tracking Store was not initialized."); try { Assert.IsTrue(trackingStore.ExistsAsync().Result, $"Tracking Store was not created."); } catch (NotSupportedException) { } string expectedContainerName = taskHubName.ToLowerInvariant() + "-leases"; CloudBlobContainer taskHubContainer = storageAccount.CreateCloudBlobClient().GetContainerReference(expectedContainerName); Assert.IsTrue(await taskHubContainer.ExistsAsync(), $"Task hub blob container {expectedContainerName} was not created."); // Task Hub config blob CloudBlob infoBlob = taskHubContainer.GetBlobReference("taskhub.json"); Assert.IsTrue(await infoBlob.ExistsAsync(), $"The blob {infoBlob.Name} was not created."); // Task Hub lease container CloudBlobDirectory leaseDirectory = taskHubContainer.GetDirectoryReference("default"); IListBlobItem[] leaseBlobs = (await this.ListBlobsAsync(leaseDirectory)).ToArray(); Assert.AreEqual(controlQueues.Length, leaseBlobs.Length, "Expected to see the same number of control queues and lease blobs."); foreach (IListBlobItem blobItem in leaseBlobs) { string path = blobItem.Uri.AbsolutePath; Assert.IsTrue( controlQueues.Where(q => path.Contains(q.Name)).Any(), $"Could not find any known control queue name in the lease name {path}"); } if (testDeletion) { await service.DeleteAsync(); foreach (ControlQueue queue in controlQueues) { Assert.IsFalse(await queue.InnerQueue.ExistsAsync(), $"Queue {queue.Name} was not deleted."); } Assert.IsFalse(await workItemQueue.InnerQueue.ExistsAsync(), $"Queue {workItemQueue.Name} was not deleted."); try { Assert.IsFalse(trackingStore.ExistsAsync().Result, $"Tracking Store was not deleted."); } catch (NotSupportedException) { } Assert.IsFalse(await taskHubContainer.ExistsAsync(), $"Task hub blob container {taskHubContainer.Name} was not deleted."); } return(service); }