public static string GenerateName( string prefix = TestPrefix, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "GenerateName_failed") { try { return(HttpMockServer.GetAssetName(methodName, prefix)); } catch (KeyNotFoundException e) { throw new KeyNotFoundException(string.Format("Generated name not found for calling method: {0}", methodName), e); } }
public void TestReserveIPWithIPTagsNegative() { using (var undoContext = AZT.UndoContext.Current) { undoContext.Start(); using (NetworkTestBase _testFixture = new NetworkTestBase()) { var managementClient = _testFixture.ManagementClient; bool storageAccountCreated = false; string storageAccountName = HttpMockServer.GetAssetName("tststr1234", "tststr").ToLower(); string reserveIpName = HttpMockServer.GetAssetName("res", "testresIPtagNegative").ToLower(); string location = managementClient.GetDefaultLocation("Storage", "Compute"); // Create an IPTag Value that doesn't exist IPTag iptag = new IPTag(); iptag.IPTagType = "FirstPartyUsage"; iptag.Value = "MyVip"; List <IPTag> iptags = new List <IPTag>(); iptags.Add(iptag); try { _testFixture.CreateStorageAccount(location, storageAccountName, out storageAccountCreated); NetworkReservedIPCreateParameters reservedIpCreatePars = new NetworkReservedIPCreateParameters { Name = reserveIpName, Label = "TestResTagNegLabel", Location = location, IPTags = iptags }; OperationStatusResponse reserveIpCreate = _testFixture.NetworkClient.ReservedIPs.Create(reservedIpCreatePars); } catch (Exception ex) { Console.WriteLine("TestReserveIPWithIPTagsNegative test did not succeed with error being ," + ex.Message); Assert.NotNull(ex); } finally { if (storageAccountCreated) { _testFixture.StorageClient.StorageAccounts.Delete(storageAccountName); } } } } }
public void TestRecordingWithTwoMethodsWritesAllData() { HttpMockServer.Initialize(this.GetType(), "testA", HttpRecorderMode.Record); FakeHttpClient client1 = CreateClient(); FakeHttpClient client2 = CreateClient(); var result1 = client1.DoStuffA().Result; var result2 = client2.DoStuffA().Result; var name = HttpMockServer.GetAssetName("testA", "tst"); HttpMockServer.Flush(currentDir); RecordEntryPack pack = RecordEntryPack.Deserialize(Path.Combine(HttpMockServer.CallerIdentity, "testA.json")); Assert.NotNull(name); Assert.True(File.Exists(Path.Combine(HttpMockServer.CallerIdentity, "testA.json"))); Assert.Equal(2, pack.Entries.Count); Assert.Equal(1, pack.Names["testA"].Count); }
public void TestAssociateReserveIP() { using (var undoContext = AZT.UndoContext.Current) { undoContext.Start(); using (NetworkTestBase _testFixture = new NetworkTestBase()) { ComputeManagementClient computeClient = _testFixture.GetComputeManagementClient(); StorageManagementClient storageClient = _testFixture.GetStorageManagementClient(); var managementClient = _testFixture.ManagementClient; bool storageAccountCreated = false; bool hostedServiceCreated = false; bool reserveIpCreated = false; string storageAccountName = HttpMockServer.GetAssetName("teststorage1234", "teststorage").ToLower(); string serviceName = AZT.TestUtilities.GenerateName("testsvc"); string deploymentName = string.Format("{0}Prod", serviceName); string reserveIpName = HttpMockServer.GetAssetName("rip", "testrip").ToLower(); string location = managementClient.GetDefaultLocation("Storage", "Compute"); const string usWestLocStr = "West US"; try { AssociateReservedIP(managementClient, usWestLocStr, location, storageClient, storageAccountName, ref storageAccountCreated, computeClient, serviceName, deploymentName, reserveIpName, _testFixture, ref hostedServiceCreated, ref reserveIpCreated); } catch (Exception) { throw; } finally { if (storageAccountCreated) { storageClient.StorageAccounts.Delete(storageAccountName); } if (hostedServiceCreated) { computeClient.HostedServices.DeleteAll(serviceName); } if (reserveIpCreated) { _testFixture.NetworkClient.ReservedIPs.Delete(reserveIpName); } } } } }
public void TestPlaybackWithOneClient() { HttpMockServer.RecordsDirectory = currentDir; HttpMockServer.Initialize(this.GetType(), TestUtilities.GetCurrentMethodName(), HttpRecorderMode.Record); FakeHttpClient client1 = CreateClient(); var result1A = client1.DoStuffA().Result; var result1B = client1.DoStuffB().Result; string assetName1 = HttpMockServer.GetAssetName(TestUtilities.GetCurrentMethodName(), "tst"); string assetName2 = HttpMockServer.GetAssetName(TestUtilities.GetCurrentMethodName(), "tst"); HttpMockServer.Flush(currentDir); HttpMockServer.Initialize(this.GetType(), TestUtilities.GetCurrentMethodName(), HttpRecorderMode.None); FakeHttpClient client2 = CreateClientWithBadResult(); var result2 = client2.DoStuffA().Result; HttpMockServer.Flush(currentDir); HttpMockServer.Initialize(this.GetType(), TestUtilities.GetCurrentMethodName(), HttpRecorderMode.Playback); FakeHttpClient client3 = CreateClientWithBadResult(); var result3B = client3.DoStuffB().Result; var result3A = client3.DoStuffA().Result; string assetName1Playback = HttpMockServer.GetAssetName(TestUtilities.GetCurrentMethodName(), "tst"); string assetName2Playback = HttpMockServer.GetAssetName(TestUtilities.GetCurrentMethodName(), "tst"); HttpMockServer.Flush(currentDir); string result1AConent = JObject.Parse(result1A.Content.ReadAsStringAsync().Result).ToString(); string result3AConent = JObject.Parse(result3A.Content.ReadAsStringAsync().Result).ToString(); Assert.True(File.Exists(Path.Combine(HttpMockServer.CallerIdentity, TestUtilities.GetCurrentMethodName() + ".json"))); Assert.Equal(result1A.StatusCode, result3A.StatusCode); Assert.Equal(result1A.RequestMessage.RequestUri.AbsoluteUri, result3A.RequestMessage.RequestUri.AbsoluteUri); Assert.Equal(result1AConent, result3AConent); Assert.Equal(HttpStatusCode.Conflict, result2.StatusCode); Assert.Equal(assetName1, assetName1Playback); Assert.Equal(assetName2, assetName2Playback); }
public void CanCreateUpdateGetAndDeleteStorageAccounts() { TestLogTracingInterceptor.Current.Start(); using (var undoContext = UndoContext.Current) { undoContext.Start(); var mgmt = TestBase.GetServiceClient <ManagementClient>(); var storage = TestBase.GetServiceClient <StorageManagementClient>(); try { var location = mgmt.GetDefaultLocation("Storage"); const string westUS = "West US"; if (mgmt.Locations.List().Any( c => string.Equals(c.Name, westUS, StringComparison.OrdinalIgnoreCase))) { location = westUS; } var storageAccountName = HttpMockServer.GetAssetName( "teststorage1234", "teststorage").ToLower(); Assert.True(storage.StorageAccounts .CheckNameAvailability(storageAccountName).IsAvailable); // Create var storageCreateParams = new StorageAccountCreateParameters { Location = location, AffinityGroup = null, Label = "Test测试1", Description = "Test测试2", Name = storageAccountName, AccountType = StorageAccountTypes.StandardGRS, ExtendedProperties = new Dictionary <string, string> { { "foo1", "bar" }, { "foo2", "baz" } } }; var st1 = storage.StorageAccounts.Create(storageCreateParams); // Get var storageCreated = storage.StorageAccounts .Get(storageAccountName).StorageAccount; VerifyStorageAccount( storageCreated, storageCreateParams.Name, storageCreateParams.Label, storageCreateParams.Description, storageCreateParams.Location, storageCreateParams.AccountType); Assert.True(storageCreated.ExtendedProperties["foo1"] == "bar"); Assert.True(storageCreated.ExtendedProperties["foo2"] == "baz"); // Update var storageUpdateParams = new StorageAccountUpdateParameters { Label = "Test测试3", Description = "Test测试4", AccountType = StorageAccountTypes.StandardRAGRS }; var st2 = storage.StorageAccounts.Update( storageAccountName, storageUpdateParams); // List var storageUpdated = storage.StorageAccounts.List() .First(s => s.Name == storageAccountName); VerifyStorageAccount( storageUpdated, storageAccountName, storageUpdateParams.Label, storageUpdateParams.Description, storageCreateParams.Location, storageUpdateParams.AccountType); // Keys var st3 = storage.StorageAccounts.GetKeys(storageAccountName); var st4 = storage.StorageAccounts.RegenerateKeys( new StorageAccountRegenerateKeysParameters { Name = storageAccountName, KeyType = StorageKeyType.Primary }); var st5 = storage.StorageAccounts.GetKeys(storageAccountName); Assert.True(st5.PrimaryKey != st3.PrimaryKey && st5.SecondaryKey == st3.SecondaryKey); // Delete var st6 = storage.StorageAccounts.Delete(storageAccountName); Assert.True(!storage.StorageAccounts.List() .StorageAccounts.Any(s => s.Name == storageAccountName)); } finally { undoContext.Dispose(); mgmt.Dispose(); storage.Dispose(); TestLogTracingInterceptor.Current.Stop(); } } }
private void CreateImageTestHelper(string originalTestLocation, string diskEncryptionSetId) { VirtualMachine inputVM = null; // Create resource group var rgName = ComputeManagementTestUtilities.GenerateName(TestPrefix); var imageName = ComputeManagementTestUtilities.GenerateName("imageTest"); // Create a VM, so we can use its OS disk for creating the image string storageAccountName = ComputeManagementTestUtilities.GenerateName(TestPrefix); string asName = ComputeManagementTestUtilities.GenerateName("as"); ImageReference imageRef = GetPlatformVMImage(useWindowsImage: true); try { // Create Storage Account var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName); // Add data disk to the VM. Action <VirtualMachine> addDataDiskToVM = vm => { string containerName = HttpMockServer.GetAssetName("TestImageOperations", TestPrefix); var vhdContainer = "https://" + storageAccountName + ".blob.core.windows.net/" + containerName; var vhduri = vhdContainer + string.Format("/{0}.vhd", HttpMockServer.GetAssetName("TestImageOperations", TestPrefix)); vm.HardwareProfile.VmSize = VirtualMachineSizeTypes.StandardA4; vm.StorageProfile.DataDisks = new List <DataDisk>(); foreach (int index in new int[] { 1, 2 }) { var diskName = "dataDisk" + index; var ddUri = vhdContainer + string.Format("/{0}{1}.vhd", diskName, HttpMockServer.GetAssetName("TestImageOperations", TestPrefix)); var dd = new DataDisk { Caching = CachingTypes.None, Image = null, DiskSizeGB = 10, CreateOption = DiskCreateOptionTypes.Empty, Lun = 1 + index, Name = diskName, Vhd = new VirtualHardDisk { Uri = ddUri } }; vm.StorageProfile.DataDisks.Add(dd); } var testStatus = new InstanceViewStatus { Code = "test", Message = "test" }; var testStatusList = new List <InstanceViewStatus> { testStatus }; }; // Create the VM, whose OS disk will be used in creating the image var createdVM = CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM, addDataDiskToVM); int expectedDiskLunWithDiskEncryptionSet = createdVM.StorageProfile.DataDisks[0].Lun; // Create the Image var imageInput = new Image() { Location = m_location, Tags = new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" }, }, StorageProfile = new ImageStorageProfile() { OsDisk = new ImageOSDisk() { BlobUri = createdVM.StorageProfile.OsDisk.Vhd.Uri, DiskEncryptionSet = diskEncryptionSetId == null ? null : new DiskEncryptionSetParameters() { Id = diskEncryptionSetId }, OsState = OperatingSystemStateTypes.Generalized, OsType = OperatingSystemTypes.Windows, }, DataDisks = new List <ImageDataDisk>() { new ImageDataDisk() { BlobUri = createdVM.StorageProfile.DataDisks[0].Vhd.Uri, DiskEncryptionSet = diskEncryptionSetId == null ? null: new DiskEncryptionSetParameters() { Id = diskEncryptionSetId }, Lun = expectedDiskLunWithDiskEncryptionSet, } } }, HyperVGeneration = HyperVGeneration.V1 }; var image = m_CrpClient.Images.CreateOrUpdate(rgName, imageName, imageInput); var getImage = m_CrpClient.Images.Get(rgName, imageName); ValidateImage(imageInput, getImage); if (diskEncryptionSetId != null) { Assert.True(getImage.StorageProfile.OsDisk.DiskEncryptionSet != null, "OsDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getImage.StorageProfile.OsDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "getImage.StorageProfile.OsDisk.DiskEncryptionSet is not matching with expected DiskEncryptionSet resource"); Assert.Equal(1, getImage.StorageProfile.DataDisks.Count); Assert.True(getImage.StorageProfile.DataDisks[0].DiskEncryptionSet != null, ".DataDisks.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getImage.StorageProfile.DataDisks[0].DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "DataDisks.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); } ImageUpdate updateParams = new ImageUpdate() { Tags = getImage.Tags }; string tagKey = "UpdateTag"; updateParams.Tags.Add(tagKey, "TagValue"); m_CrpClient.Images.Update(rgName, imageName, updateParams); getImage = m_CrpClient.Images.Get(rgName, imageName); Assert.True(getImage.Tags.ContainsKey(tagKey)); var listResponse = m_CrpClient.Images.ListByResourceGroup(rgName); Assert.Single(listResponse); m_CrpClient.Images.Delete(rgName, image.Name); } finally { Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", originalTestLocation); if (inputVM != null) { m_CrpClient.VirtualMachines.Delete(rgName, inputVM.Name); } m_ResourcesClient.ResourceGroups.Delete(rgName); } }
public void CanListRoleSizeInfo() { using (var undoContext = UndoContext.Current) { undoContext.Start(); string affinityGroupName = HttpMockServer.GetAssetName("CanListRoleSizeInfo", "testag"); var mgmt = this.GetManagementClient(); var roleSizeList = mgmt.RoleSizes.List(); foreach (var loc in mgmt.Locations.List()) { Assert.True(loc.ComputeCapabilities != null); Assert.True(loc.ComputeCapabilities.VirtualMachinesRoleSizes.Any()); foreach (var r in loc.ComputeCapabilities.VirtualMachinesRoleSizes) { Assert.True(roleSizeList.Any(s => string.Equals(r, s.Name, StringComparison.OrdinalIgnoreCase))); } Assert.True(loc.ComputeCapabilities.WebWorkerRoleSizes.Any()); foreach (var r in loc.ComputeCapabilities.WebWorkerRoleSizes) { Assert.True(roleSizeList.Any(s => string.Equals(r, s.Name, StringComparison.OrdinalIgnoreCase))); } Assert.True(loc.StorageCapabilities.StorageAccountTypes.Any()); Assert.True(loc.StorageCapabilities.StorageAccountTypes.Any( s => string.Equals("Standard_LRS", s, StringComparison.OrdinalIgnoreCase))); Assert.True(loc.StorageCapabilities.StorageAccountTypes.Any( s => string.Equals("Standard_GRS", s, StringComparison.OrdinalIgnoreCase))); Assert.True(loc.StorageCapabilities.StorageAccountTypes.Any( s => string.Equals("Standard_RAGRS", s, StringComparison.OrdinalIgnoreCase))); Assert.True(loc.StorageCapabilities.StorageAccountTypes.Any( s => string.Equals("Standard_ZRS", s, StringComparison.OrdinalIgnoreCase))); } var locName = mgmt.Locations.List().First().Name; var agParam = new AffinityGroupCreateParameters { Name = affinityGroupName, Label = affinityGroupName + "Label", Description = affinityGroupName + "Description", Location = locName }; mgmt.AffinityGroups.Create(agParam); var agGetResult = mgmt.AffinityGroups.Get(affinityGroupName); Assert.True(agGetResult.Name.Equals(agParam.Name)); Assert.True(agGetResult.Label.Equals(agParam.Label)); Assert.True(agGetResult.Description.Equals(agParam.Description)); Assert.True(agGetResult.Location.Equals(agParam.Location)); var ag = mgmt.AffinityGroups.List().First(g => g.Name.Equals(affinityGroupName)); Assert.True(ag.ComputeCapabilities != null); Assert.True(ag.ComputeCapabilities.VirtualMachinesRoleSizes.Any()); foreach (var r in ag.ComputeCapabilities.VirtualMachinesRoleSizes) { Assert.True(roleSizeList.Any(s => string.Equals(r, s.Name, StringComparison.OrdinalIgnoreCase))); } Assert.True(ag.ComputeCapabilities.WebWorkerRoleSizes.Any()); foreach (var r in ag.ComputeCapabilities.WebWorkerRoleSizes) { Assert.True(roleSizeList.Any(s => string.Equals(r, s.Name, StringComparison.OrdinalIgnoreCase))); } } }
public void TestAddAndRemoveVip() { using (var undoContext = AZT.UndoContext.Current) { undoContext.Start(); using (NetworkTestBase _testFixture = new NetworkTestBase()) { bool hostedServiceCreated = false; bool storageAccountCreated = false; string storageAccountName = HttpMockServer.GetAssetName("tststr1234", "tststr").ToLower(); string serviceName = AZT.TestUtilities.GenerateName("testser"); string virtualIPName1 = AZT.TestUtilities.GenerateName("vip1"); string virtualIPName2 = AZT.TestUtilities.GenerateName("vip2"); string virtualIPName3 = AZT.TestUtilities.GenerateName("vip2"); string deploymentName = AZT.TestUtilities.GenerateName("dep"); ComputeManagementClient computeClient = _testFixture.GetComputeManagementClient(); ManagementClient managementClient = _testFixture.ManagementClient; StorageManagementClient storageClient = _testFixture.GetStorageManagementClient(); try { string location = Utilities.GetTestLocation(managementClient); Assert.True(!string.IsNullOrEmpty(location)); // Create hosted service Utilities.CreateHostedService(location, computeClient, serviceName, out hostedServiceCreated); Assert.True(hostedServiceCreated); // Create storage account storageAccountName = HttpMockServer.GetAssetName("tststr1234", "tststr").ToLower(); Utilities.CreateStorageAccount(location, storageClient, storageAccountName, out storageAccountCreated); Assert.True(storageAccountCreated); // Create a new VM Utilities.CreateAzureVirtualMachine(computeClient, serviceName, deploymentName, storageAccountName, "blob.core.windows.net"); // Add and assert vip status OperationStatusResponse virtualIPCreate1 = _testFixture.NetworkClient.VirtualIPs.Add(serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName1); Assert.True(virtualIPCreate1.StatusCode == HttpStatusCode.OK); Utilities.AssertLogicalVipWithoutIPPresentOrAbsent(computeClient, serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName1, expectedVipCount: 2, present: true); OperationStatusResponse virtualIPCreate2 = _testFixture.NetworkClient.VirtualIPs.Add(serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName2); Assert.True(virtualIPCreate2.StatusCode == HttpStatusCode.OK); Utilities.AssertLogicalVipWithoutIPPresentOrAbsent(computeClient, serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName2, expectedVipCount: 3, present: true); OperationStatusResponse virtualIPCreate3 = _testFixture.NetworkClient.VirtualIPs.Add(serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName3); Assert.True(virtualIPCreate3.StatusCode == HttpStatusCode.OK); Utilities.AssertLogicalVipWithoutIPPresentOrAbsent(computeClient, serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName3, expectedVipCount: 4, present: true); // Remove and assert vip status OperationStatusResponse virtualIPRemove1 = _testFixture.NetworkClient.VirtualIPs.Remove(serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName1); Assert.True(virtualIPRemove1.StatusCode == HttpStatusCode.OK); Utilities.AssertLogicalVipWithoutIPPresentOrAbsent(computeClient, serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName1, expectedVipCount: 3, present: false); OperationStatusResponse virtualIPRemove3 = _testFixture.NetworkClient.VirtualIPs.Remove(serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName3); Assert.True(virtualIPRemove3.StatusCode == HttpStatusCode.OK); Utilities.AssertLogicalVipWithoutIPPresentOrAbsent(computeClient, serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName3, expectedVipCount: 2, present: false); OperationStatusResponse virtualIPRemove2 = _testFixture.NetworkClient.VirtualIPs.Remove(serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName2); Assert.True(virtualIPRemove2.StatusCode == HttpStatusCode.OK); Utilities.AssertLogicalVipWithoutIPPresentOrAbsent(computeClient, serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName2, expectedVipCount: 1, present: false); } finally { if (hostedServiceCreated) { computeClient.HostedServices.DeleteAll(serviceName); } } } } }
public void TestAdditionalVipLifeCycle() { using (var undoContext = AZT.UndoContext.Current) { undoContext.Start(); using (NetworkTestBase _testFixture = new NetworkTestBase()) { bool hostedServiceCreated = false; bool storageAccountCreated = false; string storageAccountName = HttpMockServer.GetAssetName("tststr1234", "tststr").ToLower(); string serviceName = AZT.TestUtilities.GenerateName("testser"); string virtualIPName1 = AZT.TestUtilities.GenerateName("vip1"); string deploymentName = AZT.TestUtilities.GenerateName("dep"); ComputeManagementClient computeClient = _testFixture.GetComputeManagementClient(); ManagementClient managementClient = _testFixture.ManagementClient; StorageManagementClient storageClient = _testFixture.GetStorageManagementClient(); try { string location = Utilities.GetTestLocation(managementClient); Assert.True(!string.IsNullOrEmpty(location)); // Create hosted service Utilities.CreateHostedService(location, computeClient, serviceName, out hostedServiceCreated); Assert.True(hostedServiceCreated); // Create storage account storageAccountName = HttpMockServer.GetAssetName("tststr1234", "tststr").ToLower(); Utilities.CreateStorageAccount(location, storageClient, storageAccountName, out storageAccountCreated); Assert.True(storageAccountCreated); // Create a new VM Utilities.CreateAzureVirtualMachine(computeClient, serviceName, deploymentName, storageAccountName, "blob.core.windows.net"); DeploymentGetResponse depRetrieved = computeClient.Deployments.GetByName(serviceName: serviceName, deploymentName: deploymentName); IEnumerable <ConfigurationSet> endpointCfgSets = new List <ConfigurationSet> { new ConfigurationSet { ConfigurationSetType = "NetworkConfiguration", InputEndpoints = new List <InputEndpoint> { new InputEndpoint() { LocalPort = 3387, Name = "RDP2", Port = 52777, Protocol = InputEndpointTransportProtocol.Tcp, EnableDirectServerReturn = false }, } } }; // Update with single endpoint var updateParams = Utilities.GetVMUpdateParameters(depRetrieved.Roles.First(), storageAccountName, endpointCfgSets, preserveOriginalConfigSets: false); computeClient.VirtualMachines.Update( serviceName, deploymentName, depRetrieved.Roles.First().RoleName, updateParams); // Add and assert vip status OperationStatusResponse virtualIPCreate1 = _testFixture.NetworkClient.VirtualIPs.Add(serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName1); Assert.True(virtualIPCreate1.StatusCode == HttpStatusCode.OK); depRetrieved = Utilities.AssertLogicalVipWithoutIPPresentOrAbsent(computeClient, serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName1, expectedVipCount: 2, present: true); endpointCfgSets = new List <ConfigurationSet> { new ConfigurationSet { ConfigurationSetType = "NetworkConfiguration", InputEndpoints = new List <InputEndpoint> { new InputEndpoint() { LocalPort = 3387, Name = "RDP2", Port = 52777, Protocol = InputEndpointTransportProtocol.Tcp, EnableDirectServerReturn = false, }, new InputEndpoint() { LocalPort = 3379, Name = "RDP", Port = 52728, Protocol = InputEndpointTransportProtocol.Tcp, EnableDirectServerReturn = false, VirtualIPName = virtualIPName1, } } } }; updateParams = Utilities.GetVMUpdateParameters(depRetrieved.Roles.First(), storageAccountName, endpointCfgSets, preserveOriginalConfigSets: false); computeClient.VirtualMachines.Update( serviceName, deploymentName, depRetrieved.Roles.First().RoleName, updateParams); var depRetrievedAfterUpdate = Utilities.AssertLogicalVipWithIPPresent(computeClient, serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName1, expectedVipCount: 2); endpointCfgSets = new List <ConfigurationSet> { new ConfigurationSet { ConfigurationSetType = "NetworkConfiguration", InputEndpoints = new List <InputEndpoint> { new InputEndpoint() { LocalPort = 3387, Name = "RDP2", Port = 52777, Protocol = InputEndpointTransportProtocol.Tcp, EnableDirectServerReturn = false, }, } } }; updateParams = Utilities.GetVMUpdateParameters(depRetrieved.Roles.First(), storageAccountName, endpointCfgSets, preserveOriginalConfigSets: false); computeClient.VirtualMachines.Update( serviceName, deploymentName, depRetrieved.Roles.First().RoleName, updateParams); depRetrieved = Utilities.AssertLogicalVipWithoutIPPresentOrAbsent(computeClient, serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName1, expectedVipCount: 2, present: true); // Remove and assert vip status OperationStatusResponse virtualIPRemove1 = _testFixture.NetworkClient.VirtualIPs.Remove(serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName1); Assert.True(virtualIPRemove1.StatusCode == HttpStatusCode.OK); Utilities.AssertLogicalVipWithoutIPPresentOrAbsent(computeClient, serviceName: serviceName, deploymentName: deploymentName, virtualIPName: virtualIPName1, expectedVipCount: 3, present: false); } finally { if (hostedServiceCreated) { computeClient.HostedServices.DeleteAll(serviceName); } } } } }
public void TestAssociateDisassociateOnMultivipIaaSDeployment() { using (var undoContext = AZT.UndoContext.Current) { undoContext.Start(); using (NetworkTestBase _testFixture = new NetworkTestBase()) { bool hostedServiceCreated = false; bool storageAccountCreated = false; string storageAccountName = HttpMockServer.GetAssetName("tststr1234", "tststr").ToLower(); string serviceName = AZT.TestUtilities.GenerateName("testser"); string deploymentName = AZT.TestUtilities.GenerateName("dep"); ComputeManagementClient computeClient = _testFixture.GetComputeManagementClient(); ManagementClient managementClient = _testFixture.ManagementClient; StorageManagementClient storageClient = _testFixture.GetStorageManagementClient(); List <string> createdRips = new List <string>(); try { string location = Utilities.GetTestLocation(managementClient); Assert.True(!string.IsNullOrEmpty(location)); // Create hosted service Utilities.CreateHostedService(location, computeClient, serviceName, out hostedServiceCreated); Assert.True(hostedServiceCreated); // Create storage account storageAccountName = HttpMockServer.GetAssetName("tststr1234", "tststr").ToLower(); Utilities.CreateStorageAccount(location, storageClient, storageAccountName, out storageAccountCreated); Assert.True(storageAccountCreated); List <string> vipNames = new List <string>() { AZT.TestUtilities.GenerateName("VipA"), AZT.TestUtilities.GenerateName("VipB"), AZT.TestUtilities.GenerateName("VipC"), AZT.TestUtilities.GenerateName("VipD"), AZT.TestUtilities.GenerateName("VipE") }; List <string> reservedIPNames = new List <string>() { AZT.TestUtilities.GenerateName("RipA"), AZT.TestUtilities.GenerateName("RipB"), AZT.TestUtilities.GenerateName("RipC"), AZT.TestUtilities.GenerateName("RipD"), AZT.TestUtilities.GenerateName("RipE") }; CreateMultivipDeploymentAndAssertSuccess(_testFixture.NetworkClient, computeClient, vipNames, serviceName, deploymentName, storageAccountName, location); // Associate 5 reserved IPs for (int i = 0; i < 5; i++) { string reserveIpName = reservedIPNames[i]; string vipName = vipNames[i]; NetworkReservedIPCreateParameters reservedIpCreatePars = new NetworkReservedIPCreateParameters { Name = reserveIpName, Location = location, Label = "SampleReserveIPLabel" }; OperationStatusResponse reserveIpCreate = _testFixture.NetworkClient.ReservedIPs.Create(reservedIpCreatePars); Assert.True(reserveIpCreate.StatusCode == HttpStatusCode.OK); createdRips.Add(reserveIpName); NetworkReservedIPGetResponse reserveIpCreationResponse = _testFixture.NetworkClient.ReservedIPs.Get(reserveIpName); Assert.True(reserveIpCreationResponse.StatusCode == HttpStatusCode.OK); NetworkReservedIPMobilityParameters pars = new NetworkReservedIPMobilityParameters { ServiceName = serviceName, DeploymentName = deploymentName, VirtualIPName = vipName }; OperationStatusResponse responseAssociateRip = _testFixture.NetworkClient.ReservedIPs.Associate(reserveIpName, pars); Assert.True(responseAssociateRip.StatusCode == HttpStatusCode.OK); DeploymentGetResponse deploymentResponse = computeClient.Deployments.GetByName(serviceName: serviceName, deploymentName: deploymentName); NetworkReservedIPGetResponse receivedReservedIpFromRdfe = _testFixture.NetworkClient.ReservedIPs.Get(reserveIpName); Assert.True(receivedReservedIpFromRdfe.StatusCode == HttpStatusCode.OK); Assert.True(serviceName == receivedReservedIpFromRdfe.ServiceName); Assert.True(receivedReservedIpFromRdfe.InUse == true); Assert.True(deploymentName == receivedReservedIpFromRdfe.DeploymentName); Assert.True(reserveIpName == receivedReservedIpFromRdfe.Name); Assert.True(vipName == receivedReservedIpFromRdfe.VirtualIPName); var vipAssociated = deploymentResponse.VirtualIPAddresses.FirstOrDefault(vip => vip.Name == vipName); Assert.NotNull(vipAssociated); Assert.True(vipAssociated.ReservedIPName == reserveIpName); } // Disassociate the associated IPs for (int i = 0; i < 5; i++) { string reserveIpName = reservedIPNames[i]; string vipName = vipNames[i]; NetworkReservedIPMobilityParameters pars = new NetworkReservedIPMobilityParameters { ServiceName = serviceName, DeploymentName = deploymentName, VirtualIPName = vipName }; OperationStatusResponse responseDisassociateRip = _testFixture.NetworkClient.ReservedIPs.Disassociate(reserveIpName, pars); Assert.True(responseDisassociateRip.StatusCode == HttpStatusCode.OK); DeploymentGetResponse deploymentResponse = computeClient.Deployments.GetByName(serviceName: serviceName, deploymentName: deploymentName); NetworkReservedIPGetResponse receivedReservedIpFromRdfe = _testFixture.NetworkClient.ReservedIPs.Get(reserveIpName); Assert.True(receivedReservedIpFromRdfe.StatusCode == HttpStatusCode.OK); Assert.True(string.IsNullOrEmpty(receivedReservedIpFromRdfe.ServiceName)); Assert.True(receivedReservedIpFromRdfe.InUse == false); Assert.True(string.IsNullOrEmpty(receivedReservedIpFromRdfe.DeploymentName)); Assert.True(reserveIpName == receivedReservedIpFromRdfe.Name); Assert.True(string.IsNullOrEmpty(receivedReservedIpFromRdfe.VirtualIPName)); var vipAssociated = deploymentResponse.VirtualIPAddresses.FirstOrDefault(vip => vip.Name == vipName); Assert.NotNull(vipAssociated); Assert.True(string.IsNullOrEmpty(vipAssociated.ReservedIPName)); } } finally { if (hostedServiceCreated) { computeClient.HostedServices.DeleteAll(serviceName); } if (createdRips.Any()) { foreach (var rip in createdRips) { // Clean up created Reserved IPs _testFixture.NetworkClient.ReservedIPs.Delete(rip); } } } } } }
public void TestReservingExistingDeploymentIP() { using (var undoContext = AZT.UndoContext.Current) { undoContext.Start(); using (NetworkTestBase _testFixture = new NetworkTestBase()) { var managementClient = _testFixture.ManagementClient; bool storageAccountCreated = false; bool hostedServiceCreated = false; string storageAccountName = HttpMockServer.GetAssetName("tststr1234", "tststr").ToLower(); string serviceName = AZT.TestUtilities.GenerateName("testser"); string deploymentName = string.Format("{0}Prd", serviceName); string reserveIpName = HttpMockServer.GetAssetName("res", "testres").ToLower(); string location = managementClient.GetDefaultLocation("Storage", "Compute"); bool reservedIpCreated = false; try { _testFixture.CreateStorageAccount(location, storageAccountName, out storageAccountCreated); _testFixture.CreateHostedService(location, serviceName, out hostedServiceCreated); var deployment = _testFixture.CreatePaaSDeployment(storageAccountName, serviceName, deploymentName, NetworkTestConstants.OneWebOneWorkerPkgFilePath, "OneWebOneWorker.cscfg", startDeployment: true); NetworkReservedIPCreateParameters reservedIpCreatePars = new NetworkReservedIPCreateParameters { Name = reserveIpName, Label = "TestLabel", DeploymentName = deploymentName, ServiceName = serviceName, Location = location }; OperationStatusResponse reserveIpCreate = _testFixture.NetworkClient.ReservedIPs.Create(reservedIpCreatePars); Assert.True(reserveIpCreate.StatusCode == HttpStatusCode.OK); reservedIpCreated = true; NetworkReservedIPGetResponse reserveIpCreationResponse = _testFixture.NetworkClient.ReservedIPs.Get(reserveIpName); Assert.True(reserveIpCreationResponse.StatusCode == HttpStatusCode.OK); Assert.True(reserveIpCreationResponse.ServiceName == serviceName); Assert.True(reserveIpCreationResponse.DeploymentName == deploymentName); Assert.True(reserveIpCreationResponse.InUse == true); Assert.True(reserveIpCreationResponse.Address == deployment.VirtualIPAddresses[0].Address); } catch (Exception) { throw; } finally { if (storageAccountCreated) { _testFixture.StorageClient.StorageAccounts.Delete(storageAccountName); } if (hostedServiceCreated) { _testFixture.ComputeClient.HostedServices.DeleteAll(serviceName); } if (reservedIpCreated) { _testFixture.NetworkClient.ReservedIPs.Delete(reserveIpName); } } } } }
public void TestReserveIPWithIPTagsSimple() { using (var undoContext = AZT.UndoContext.Current) { undoContext.Start(); using (NetworkTestBase _testFixture = new NetworkTestBase()) { var managementClient = _testFixture.ManagementClient; bool storageAccountCreated = false; string storageAccountName = HttpMockServer.GetAssetName("tststr1234", "tststr").ToLower(); string reserveIpName = HttpMockServer.GetAssetName("res", "testresIPtag").ToLower(); string location = "West Central US"; bool reservedIpCreated = false; IPTag iptag = new IPTag(); iptag.IPTagType = "FirstPartyUsage"; iptag.Value = "/tagTypes/SystemService/operators/Microsoft/platforms/Azure/services/Microsoft.AzureAD"; List <IPTag> iptags = new List <IPTag>(); iptags.Add(iptag); try { _testFixture.CreateStorageAccount(location, storageAccountName, out storageAccountCreated); NetworkReservedIPCreateParameters reservedIpCreatePars = new NetworkReservedIPCreateParameters { Name = reserveIpName, Label = "TestResTagLabel", Location = location, IPTags = iptags }; OperationStatusResponse reserveIpCreate = _testFixture.NetworkClient.ReservedIPs.Create(reservedIpCreatePars); Assert.True(reserveIpCreate.StatusCode == HttpStatusCode.OK); reservedIpCreated = true; NetworkReservedIPGetResponse reserveIpCreationResponse = _testFixture.NetworkClient.ReservedIPs.Get(reserveIpName); Assert.True(reserveIpCreationResponse.StatusCode == HttpStatusCode.OK); Assert.True(reserveIpCreationResponse.IPTags.Count == iptags.Count); foreach (var iptag1 in iptags) { Assert.True(reserveIpCreationResponse.IPTags.Any(x => x.IPTagType == iptag1.IPTagType && x.Value == iptag1.Value)); } } catch (Exception ex) { Console.WriteLine("TestReserveIPWithIPTagsSimple test did not succeed with error being ," + ex.Message); throw; } finally { if (storageAccountCreated) { _testFixture.StorageClient.StorageAccounts.Delete(storageAccountName); } if (reservedIpCreated) { _testFixture.NetworkClient.ReservedIPs.Delete(reserveIpName); } } } } }
public void CanAbortStorageAccountMigrationToSrp() { TestLogTracingInterceptor.Current.Start(); using (var undoContext = UndoContext.Current) { undoContext.Start(); var mgmt = TestBase.GetServiceClient <ManagementClient>(); var storage = TestBase.GetServiceClient <StorageManagementClient>(); try { var location = mgmt.GetDefaultLocation("Storage"); const string westUS = "West US"; if (mgmt.Locations.List().Any( c => string.Equals(c.Name, westUS, StringComparison.OrdinalIgnoreCase))) { location = westUS; } var storageAccountName = HttpMockServer.GetAssetName( "teststorage1234", "teststorage").ToLower(); Assert.True(storage.StorageAccounts .CheckNameAvailability(storageAccountName).IsAvailable); // Create var storageCreateParams = new StorageAccountCreateParameters { Location = location, AffinityGroup = null, Label = "Test测试1", Description = "Test测试2", Name = storageAccountName, AccountType = StorageAccountTypes.StandardGRS, ExtendedProperties = new Dictionary <string, string> { { "foo1", "bar" }, { "foo2", "baz" } } }; var st1 = storage.StorageAccounts.Create(storageCreateParams); // Get var storageCreated = storage.StorageAccounts .Get(storageAccountName).StorageAccount; VerifyStorageAccount( storageCreated, storageCreateParams.Name, storageCreateParams.Label, storageCreateParams.Description, storageCreateParams.Location, storageCreateParams.AccountType); Assert.True(storageCreated.ExtendedProperties["foo1"] == "bar"); Assert.True(storageCreated.ExtendedProperties["foo2"] == "baz"); var response = storage.StorageAccounts.PrepareMigration(storageAccountName); Assert.Equal(OperationStatus.Succeeded, response.Status); storageCreated = storage.StorageAccounts.Get(storageAccountName).StorageAccount; Assert.Equal(IaaSClassicToArmMigrationState.Prepared, storageCreated.MigrationState); response = storage.StorageAccounts.AbortMigration(storageAccountName); Assert.Equal(OperationStatus.Succeeded, response.Status); } finally { undoContext.Dispose(); mgmt.Dispose(); storage.Dispose(); TestLogTracingInterceptor.Current.Stop(); } } }
public void TestVMDataDiskScenario() { using (MockContext context = MockContext.Start(this.GetType())) { EnsureClientsInitialized(context); ImageReference imgageRef = GetPlatformVMImage(useWindowsImage: true); // Create resource group var rgName = ComputeManagementTestUtilities.GenerateName(TestPrefix); string storageAccountName = ComputeManagementTestUtilities.GenerateName(TestPrefix); string asName = ComputeManagementTestUtilities.GenerateName("as"); VirtualMachine inputVM; bool passed = false; try { // Create Storage Account, so that both the VMs can share it var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName); Action <VirtualMachine> addDataDiskToVM = vm => { string containerName = HttpMockServer.GetAssetName("TestVMDataDiskScenario", TestPrefix); var vhdContainer = "https://" + storageAccountName + ".blob.core.windows.net/" + containerName; var vhduri = vhdContainer + string.Format("/{0}.vhd", HttpMockServer.GetAssetName("TestVMDataDiskScenario", TestPrefix)); vm.HardwareProfile.VmSize = VirtualMachineSizeTypes.StandardA1V2; vm.StorageProfile.DataDisks = new List <DataDisk>(); foreach (int index in new int[] { 1, 2 }) { var diskName = "dataDisk" + index; var ddUri = vhdContainer + string.Format("/{0}{1}.vhd", diskName, HttpMockServer.GetAssetName("TestVMDataDiskScenario", TestPrefix)); var dd = new DataDisk { Caching = CachingTypes.None, Image = null, DiskSizeGB = 10, CreateOption = DiskCreateOptionTypes.Empty, Lun = 1 + index, Name = diskName, Vhd = new VirtualHardDisk { Uri = ddUri } }; vm.StorageProfile.DataDisks.Add(dd); } var testStatus = new InstanceViewStatus { Code = "test", Message = "test" }; var testStatusList = new List <InstanceViewStatus> { testStatus }; // Negative tests for a bug in 5.0.0 that read-only fields have side-effect on the request body /* vm.InstanceView = new VirtualMachineInstanceView * { * Statuses = testStatusList, * VmAgent = new VirtualMachineAgentInstanceView * { * Statuses = testStatusList, * ExtensionHandlers = new List<VirtualMachineExtensionHandlerInstanceView> * { * new VirtualMachineExtensionHandlerInstanceView * { * Status = testStatus, * Type = "test", * TypeHandlerVersion = "test" * } * }, * VmAgentVersion = "test" * }, * Disks = new List<DiskInstanceView> * { * new DiskInstanceView * { * Statuses = testStatusList, * Name = "test" * } * }, * Extensions = new List<VirtualMachineExtensionInstanceView> * { * new VirtualMachineExtensionInstanceView * { * Statuses = testStatusList * } * } * }; */ }; var vm1 = CreateVM(rgName, asName, storageAccountOutput, imgageRef, out inputVM, addDataDiskToVM); var getVMWithInstanceViewResponse = m_CrpClient.VirtualMachines.Get(rgName, inputVM.Name, InstanceViewTypes.InstanceView); Assert.True(getVMWithInstanceViewResponse != null, "VM in Get"); ValidateVMInstanceView(inputVM, getVMWithInstanceViewResponse); var vm2 = getVMWithInstanceViewResponse; var vmReCreateResponse = m_CrpClient.VirtualMachines.CreateOrUpdate(rgName, getVMWithInstanceViewResponse.Name, getVMWithInstanceViewResponse); m_CrpClient.VirtualMachines.Delete(rgName, inputVM.Name); passed = true; } catch (Exception e) { throw e; } finally { m_ResourcesClient.ResourceGroups.Delete(rgName); Assert.True(passed); } } }
public static string GenerateName(string prefix = null, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "GenerateName_failed") { return(HttpMockServer.GetAssetName(methodName, prefix)); }
public void CanCreateServiceDeployments() { TestLogTracingInterceptor.Current.Start(); using (var undoContext = UndoContext.Current) { undoContext.Start(); var mgmt = fixture.GetManagementClient(); var compute = fixture.GetComputeManagementClient(); var storage = fixture.GetStorageManagementClient(); try { var storageAccountName = HttpMockServer.GetAssetName("teststorage1234", "teststorage").ToLower(); string serviceName = TestUtilities.GenerateName("testsvc"); string deploymentName = string.Format("{0}Prod", serviceName); string location = mgmt.GetDefaultLocation("Storage", "Compute"); const string usWestLocStr = "West US"; if (mgmt.Locations.List().Any( c => string.Equals(c.Name, usWestLocStr, StringComparison.OrdinalIgnoreCase))) { location = usWestLocStr; } var st1 = storage.StorageAccounts.Create( new StorageAccountCreateParameters { Location = location, Label = storageAccountName, Name = storageAccountName, AccountType = "Standard_LRS" }); var st2 = compute.HostedServices.Create( new HostedServiceCreateParameters { Location = location, Label = serviceName, ServiceName = serviceName }); var cfgFilePath = "OneWebOneWorker.cscfg"; var containerStr = TestUtilities.GenerateName("cspkg"); var pkgFileName = "OneWebOneWorker.cspkg"; var pkgFilePath = ".\\" + pkgFileName; var blobUri = StorageTestUtilities.UploadFileToBlobStorage( storageAccountName, containerStr, pkgFilePath); var blobUriStr = blobUri.ToString(); var containerUriStr = blobUriStr.Substring(0, blobUriStr.IndexOf("/" + pkgFileName)); containerUriStr = containerUriStr.Replace("https", "http"); var containerUri = new Uri(containerUriStr); var st3 = compute.Deployments.Create( serviceName, DeploymentSlot.Production, new DeploymentCreateParameters { Configuration = File.ReadAllText(cfgFilePath), PackageUri = blobUri, Name = deploymentName, Label = serviceName, ExtendedProperties = null, StartDeployment = true, TreatWarningsAsError = false, ExtensionConfiguration = null }); Assert.True(st3.StatusCode == HttpStatusCode.OK); var st4 = compute.Deployments.GetPackageByName( serviceName, deploymentName, new DeploymentGetPackageParameters { OverwriteExisting = true, ContainerUri = containerUri }); Assert.True(st4.StatusCode == HttpStatusCode.OK); var roles = compute.Deployments .GetBySlot(serviceName, DeploymentSlot.Production) .Roles.ToList(); Assert.True(roles.TrueForAll(r => !string.IsNullOrEmpty(r.OSVersion))); var roleInstanceNames = compute.Deployments .GetBySlot(serviceName, DeploymentSlot.Production) .RoleInstances.Select(r => r.InstanceName).ToList(); Assert.True(roleInstanceNames.Any(r => r.StartsWith("WebRole1")) && roleInstanceNames.Any(r => r.StartsWith("WorkerRole1"))); // Check Rebuild Role Instance APIs var instName1 = roleInstanceNames.First(r => r.StartsWith("WebRole1")); var instName2 = roleInstanceNames.First(r => r.StartsWith("WorkerRole1")); WaitForReadyRoleInstance(compute, serviceName, deploymentName, instName1); var modifiedTimeBefore = compute.Deployments.GetByName(serviceName, deploymentName) .LastModifiedTime; compute.Deployments.RebuildRoleInstanceByDeploymentName( serviceName, deploymentName, instName1, RoleInstanceRebuildResourceTypes.AllLocalDrives); var inStatus = compute.Deployments.GetByName(serviceName, deploymentName) .RoleInstances.First(r => r.InstanceName == instName1) .InstanceStatus; Assert.True(inStatus != RoleInstanceStatus.ReadyRole); WaitForReadyRoleInstance(compute, serviceName, deploymentName, instName1); var modifiedTimeAfter = compute.Deployments.GetByName(serviceName, deploymentName) .LastModifiedTime; Assert.True(!modifiedTimeAfter.Equals(modifiedTimeBefore)); WaitForReadyRoleInstance(compute, serviceName, deploymentName, instName2); modifiedTimeBefore = compute.Deployments.GetByName(serviceName, deploymentName) .LastModifiedTime; compute.Deployments.RebuildRoleInstanceByDeploymentSlot( serviceName, DeploymentSlot.Production.ToString(), instName2, RoleInstanceRebuildResourceTypes.AllLocalDrives); inStatus = compute.Deployments.GetByName(serviceName, deploymentName) .RoleInstances.First(r => r.InstanceName == instName2) .InstanceStatus; Assert.True(inStatus != RoleInstanceStatus.ReadyRole); WaitForReadyRoleInstance(compute, serviceName, deploymentName, instName2); modifiedTimeAfter = compute.Deployments.GetByName(serviceName, deploymentName) .LastModifiedTime; Assert.True(!modifiedTimeAfter.Equals(modifiedTimeBefore)); // Check Upgrade Deployment API compute.Deployments.UpgradeByName( serviceName, deploymentName, new DeploymentUpgradeParameters { Configuration = File.ReadAllText(cfgFilePath), PackageUri = blobUri, Force = true, Label = "UpgradeByName", Mode = DeploymentUpgradeMode.Auto, RoleToUpgrade = null, ExtendedProperties = null, ExtensionConfiguration = null }); Assert.True(compute.Deployments.GetByName(serviceName, deploymentName).Label == "UpgradeByName"); compute.Deployments.UpgradeBySlot( serviceName, DeploymentSlot.Production, new DeploymentUpgradeParameters { Configuration = File.ReadAllText(cfgFilePath), PackageUri = blobUri, Force = true, Label = "UpgradeBySlot", Mode = DeploymentUpgradeMode.Auto, RoleToUpgrade = null, ExtendedProperties = null, ExtensionConfiguration = null }); Assert.True(compute.Deployments.GetByName(serviceName, deploymentName).Label == "UpgradeBySlot"); // Check Delete Role Instance APIs compute.Deployments.DeleteRoleInstanceByDeploymentName( serviceName, deploymentName, new DeploymentDeleteRoleInstanceParameters { Name = new List <string> { instName1 } }); compute.Deployments.DeleteRoleInstanceByDeploymentSlot( serviceName, DeploymentSlot.Production.ToString(), new DeploymentDeleteRoleInstanceParameters { Name = new List <string> { instName2 } }); roleInstanceNames = compute.Deployments .GetBySlot(serviceName, DeploymentSlot.Production) .RoleInstances.Select(r => r.InstanceName).ToList(); Assert.True(!roleInstanceNames.Any(r => r == instName1 || r == instName2)); } finally { undoContext.Dispose(); mgmt.Dispose(); compute.Dispose(); storage.Dispose(); TestLogTracingInterceptor.Current.Stop(); } } }