private Rollout WaitForRolloutTermination( string rolloutName, AzureDeploymentManagerClient deploymentManagerClient, DeploymentManagerClientHelper clientHelper) { Rollout rollout; do { DeploymentManagerTestUtilities.Sleep(TimeSpan.FromMinutes(1)); rollout = deploymentManagerClient.Rollouts.Get( resourceGroupName: clientHelper.ResourceGroupName, rolloutName: rolloutName); } while (rollout.Status == "Running"); return(rollout); }
public void TopologyAndRolloutScenarioTest() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (var context = MockContext.Start(typeof(EndToEndFunctionalTests).FullName)) { var deploymentManagerClient = DeploymentManagerTestUtilities.GetDeploymentManagerClient(context, handler); var clientHelper = new DeploymentManagerClientHelper(this, context); var te = TestEnvironmentFactory.GetTestEnvironment(); EndToEndFunctionalTests.subscriptionId = te.SubscriptionId; var location = clientHelper.GetProviderLocation("Microsoft.DeploymentManager", "serviceTopologies"); try { // Create resource group clientHelper.TryCreateResourceGroup(location); var artifactSourceName = clientHelper.ResourceGroupName + "ArtifactSource"; var updatedArtifactSourceName = clientHelper.ResourceGroupName + "UpdatedArtifactSource"; var storageAccountName = clientHelper.ResourceGroupName + "stgacct"; // Create artifact source var artifactSource = this.CreateArtifactSource( storageAccountName, artifactSourceName, location, deploymentManagerClient, clientHelper, setupContainer: true); // Test Create service topology. var serviceTopologyName = clientHelper.ResourceGroupName + "ServiceTopology"; var inputTopology = new ServiceTopologyResource( location: location, name: serviceTopologyName, artifactSourceId: artifactSource.Id); var createTopologyResponse = deploymentManagerClient.ServiceTopologies.CreateOrUpdate( resourceGroupName: clientHelper.ResourceGroupName, serviceTopologyName: serviceTopologyName, serviceTopologyInfo: inputTopology); this.ValidateTopology(inputTopology, createTopologyResponse); // Test Get topology. var serviceTopology = deploymentManagerClient.ServiceTopologies.Get( resourceGroupName: clientHelper.ResourceGroupName, serviceTopologyName: serviceTopologyName); this.ValidateTopology(inputTopology, serviceTopology); // Test CRUD operations on services. this.ServiceCrudTests(artifactSource, serviceTopology, location, deploymentManagerClient, clientHelper); // Create another artifact source to test update topology. artifactSource = this.CreateArtifactSource( storageAccountName, updatedArtifactSourceName, location, deploymentManagerClient, clientHelper); // Test Update topology. serviceTopology.ArtifactSourceId = artifactSource.Id; var updatedStepResource = deploymentManagerClient.ServiceTopologies.CreateOrUpdate( resourceGroupName: clientHelper.ResourceGroupName, serviceTopologyName: serviceTopologyName, serviceTopologyInfo: serviceTopology); this.ValidateTopology(serviceTopology, updatedStepResource); // Test Delete topology. deploymentManagerClient.ServiceTopologies.Delete( resourceGroupName: clientHelper.ResourceGroupName, serviceTopologyName: serviceTopologyName); var cloudException = Assert.Throws <CloudException>(() => deploymentManagerClient.ServiceTopologies.Get( resourceGroupName: clientHelper.ResourceGroupName, serviceTopologyName: serviceTopologyName)); Assert.Equal(HttpStatusCode.NotFound, cloudException.Response.StatusCode); // Cleanup artifact source this.CleanupArtifactSources(artifactSourceName, location, deploymentManagerClient, clientHelper); this.CleanupArtifactSources(updatedArtifactSourceName, location, deploymentManagerClient, clientHelper); cloudException = Assert.Throws <CloudException>(() => deploymentManagerClient.ArtifactSources.Get( resourceGroupName: clientHelper.ResourceGroupName, artifactSourceName: artifactSourceName)); Assert.Equal(HttpStatusCode.NotFound, cloudException.Response.StatusCode); } finally { clientHelper.DeleteResourceGroup(); } } }