public async Task TestDedicatedHostOperations() { EnsureClientsInitialized(LocationEastUs2UpperCase.ToLower()); string baseRGName = Recording.GenerateAssetName(TestPrefix); string rgName = baseRGName + "DH"; string dhgName = "DHG-1"; string dhName = "DH-1"; // Create a dedicated host group, then get the dedicated host group and validate that they match DedicatedHostGroup createdDHG = await CreateDedicatedHostGroup(rgName, dhgName); DedicatedHostGroup returnedDHG = await DedicatedHostGroupsOperations.GetAsync(rgName, dhgName); ValidateDedicatedHostGroup(createdDHG, returnedDHG); // Update existing dedicated host group DedicatedHostGroupUpdate updateDHGInput = new DedicatedHostGroupUpdate() { Tags = { { "testKey", "testValue" } } }; createdDHG.Tags.InitializeFrom(updateDHGInput.Tags); updateDHGInput.PlatformFaultDomainCount = returnedDHG.PlatformFaultDomainCount; // There is a bug in PATCH. PlatformFaultDomainCount is a required property now. returnedDHG = await DedicatedHostGroupsOperations.UpdateAsync(rgName, dhgName, updateDHGInput); ValidateDedicatedHostGroup(createdDHG, returnedDHG); //List DedicatedHostGroups by subscription and by resourceGroup var listDHGsResponse = DedicatedHostGroupsOperations.ListByResourceGroupAsync(rgName); var listDHGsResponseRes = await listDHGsResponse.ToEnumerableAsync(); Assert.IsTrue(listDHGsResponseRes.Count() == 1); //Assert.Single(listDHGsResponse); ValidateDedicatedHostGroup(createdDHG, listDHGsResponseRes.First()); listDHGsResponse = DedicatedHostGroupsOperations.ListBySubscriptionAsync(); listDHGsResponseRes = await listDHGsResponse.ToEnumerableAsync(); //There might be multiple dedicated host groups in the subscription, we only care about the one that we created. returnedDHG = listDHGsResponseRes.First(dhg => dhg.Id == createdDHG.Id); Assert.NotNull(returnedDHG); ValidateDedicatedHostGroup(createdDHG, returnedDHG); //Create DedicatedHost within the DedicatedHostGroup and validate var createdDH = await CreateDedicatedHost(rgName, dhgName, dhName); var returnedDH = await DedicatedHostsOperations.GetAsync(rgName, dhgName, dhName); ValidateDedicatedHost(createdDH, returnedDH); //List DedicatedHosts var listDHsResponse = DedicatedHostsOperations.ListByHostGroupAsync(rgName, dhgName); var listDHsResponseRes = await listDHsResponse.ToEnumerableAsync(); Assert.IsTrue(listDHsResponseRes.Count() == 1); ValidateDedicatedHost(createdDH, listDHsResponseRes.First()); //Delete DedicatedHosts and DedicatedHostGroups await WaitForCompletionAsync(await DedicatedHostsOperations.StartDeleteAsync(rgName, dhgName, dhName)); await DedicatedHostGroupsOperations.DeleteAsync(rgName, dhgName); WaitMinutes(1); }
//[Trait("Name", "TestCreateImage_without_DiskEncryptionSet")] public async Task TestCreateImage_without_DiskEncryptionSet() { EnsureClientsInitialized(LocationEastUs2UpperCase.ToLower()); await CreateImageTestHelper(DefaultLocation, diskEncryptionSetId : null); }