Skip to content

Commit

Permalink
update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
erich-wang committed Jun 17, 2020
1 parent e8b1d75 commit ac273f0
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ namespace Azure.ResourceManager
[NonParallelizable]
public abstract class ComputeClientBase : ManagementRecordedTestBase<ComputeManagementTestEnvironment>
{
protected string LocationEastUs2 = "EastUS2";
protected string LocationSouthAsia = "southeastasia";
protected string LocationWestCentralUs = "westcentralus";

public ResourceGroupsOperations ResourceGroupsOperations { get; set; }
public ProvidersOperations ProvidersOperations { get; set; }
public DeploymentsOperations DeploymentsOperations { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,8 @@

namespace Azure.ResourceManager.Compute.Tests
{
public class ComputeManagementTestUtilities : ComputeClientBase
public class ComputeManagementTestUtilities
{
public ComputeManagementTestUtilities(bool isAsync)
: base(isAsync)
{
}

public static string DefaultLocations = "southeastasia";

public string GenerateName(string prefix = null,
[System.Runtime.CompilerServices.CallerMemberName]
string methodName="GenerateName_failed")
{
return Recording.GetVariable(methodName, prefix);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ public async Task CleanupResourceGroup()
[Test]
public async Task TestOperations()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", "westcentralus");
EnsureClientsInitialized(false);
EnsureClientsInitialized(LocationWestCentralUs);
await Initialize();
// Attempt to Create Availability Set with out of bounds FD and UD values
await VerifyInvalidFDUDValuesFail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class GalleryTests : VMTestBase
public GalleryTests(bool isAsync)
: base(isAsync)
{
computeManagementTestUtilities = new ComputeManagementTestUtilities(isAsync);
}

[SetUp]
public void ClearChallengeCacheforRecord()
{
Expand All @@ -48,7 +48,7 @@ public async Task CleanupResourceGroup()
[Test]
public async Task Gallery_CRUD_Tests()
{
EnsureClientsInitialized(true);
EnsureClientsInitialized(galleryHomeLocation);
string rgName = Recording.GenerateAssetName(ResourceGroupPrefix);
string rgName2 = rgName + "New";

Expand All @@ -75,7 +75,7 @@ public async Task Gallery_CRUD_Tests()
string galleryName2 = galleryName + "New";
await ResourceGroupsOperations.CreateOrUpdateAsync(rgName2, new ResourceGroup(galleryHomeLocation));
Trace.TraceInformation("Created the resource group: " + rgName2);
computeManagementTestUtilities.WaitSeconds(10);
WaitSeconds(10);
await WaitForCompletionAsync(await GalleriesOperations.StartCreateOrUpdateAsync(rgName2, galleryName2, galleryIn));
Trace.TraceInformation(string.Format("Created the gallery: {0} in resource group: {1}", galleryName2, rgName2));
List<Gallery> listGalleriesInRgResult = await (GalleriesOperations.ListByResourceGroupAsync(rgName)).ToEnumerableAsync();
Expand All @@ -97,7 +97,7 @@ public async Task Gallery_CRUD_Tests()
[Test]
public async Task GalleryImage_CRUD_Tests()
{
EnsureClientsInitialized(true);
EnsureClientsInitialized(galleryHomeLocation);
string rgName = Recording.GenerateAssetName(ResourceGroupPrefix);

await ResourceGroupsOperations.CreateOrUpdateAsync(rgName, new ResourceGroup(galleryHomeLocation));
Expand Down Expand Up @@ -142,9 +142,7 @@ public async Task GalleryImage_CRUD_Tests()
[Test]
public async Task GalleryImageVersion_CRUD_Tests()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", galleryHomeLocation);
EnsureClientsInitialized(false);
EnsureClientsInitialized(galleryHomeLocation);
string rgName = Recording.GenerateAssetName(ResourceGroupPrefix);
VirtualMachine vm = null;
string imageName = Recording.GenerateAssetName("psTestSourceImage");
Expand Down Expand Up @@ -206,7 +204,7 @@ await WaitForCompletionAsync(await GalleryImageVersionsOperations.StartCreateOrU
Trace.TraceInformation(string.Format("Deleted the gallery image version: {0} in gallery image: {1}",
galleryImageVersionName, galleryImageName));

computeManagementTestUtilities.WaitMinutes(5);
this.WaitMinutes(5);
await WaitForCompletionAsync(await ImagesOperations.StartDeleteAsync(rgName, imageName));
Trace.TraceInformation("Deleted the CRP image.");
await WaitForCompletionAsync(await VirtualMachinesOperations.StartDeleteAsync(rgName, vm.Name));
Expand All @@ -222,8 +220,8 @@ await WaitForCompletionAsync(await GalleryImageVersionsOperations.StartCreateOrU
[Test]
public async Task GalleryApplication_CRUD_Tests()
{
string location = ComputeManagementTestUtilities.DefaultLocations;
EnsureClientsInitialized(true);
string location = LocationSouthAsia;
EnsureClientsInitialized(location);
string rgName = Recording.GenerateAssetName(ResourceGroupPrefix);

await ResourceGroupsOperations.CreateOrUpdateAsync(rgName, new ResourceGroup(location));
Expand Down Expand Up @@ -264,10 +262,8 @@ public async Task GalleryApplication_CRUD_Tests()
[Ignore("need to be skipped")]
public async Task GalleryApplicationVersion_CRUD_Tests()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");
string location = computeManagementTestUtilities.DefaultLocation;
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", location);
EnsureClientsInitialized(false);
string location = LocationSouthAsia;
EnsureClientsInitialized(LocationSouthAsia);
string rgName = Recording.GenerateAssetName(ResourceGroupPrefix);
string applicationName = Recording.GenerateAssetName("psTestSourceApplication");
string galleryName = Recording.GenerateAssetName(GalleryNamePrefix);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class VMTestBase : ComputeClientBase
public VMTestBase(bool isAsync)
: base(isAsync)
{
computeManagementTestUtilities = new ComputeManagementTestUtilities(isAsync);
}
protected const string TestPrefix = "crptestar";
protected const string PLACEHOLDER = "[PLACEHOLDEr1]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public VMScaleSetNetworkProfileTests(bool isAsync)
[Test]
public async Task TestVMScaleSetWithApplciationGateway()
{
EnsureClientsInitialized(true);
EnsureClientsInitialized(LocationSouthAsia);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);

Expand Down Expand Up @@ -71,7 +71,7 @@ public async Task TestVMScaleSetWithApplciationGateway()
[Test]
public async Task TestVMScaleSetWithDnsSettings()
{
EnsureClientsInitialized(true);
EnsureClientsInitialized(LocationSouthAsia);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);

Expand Down Expand Up @@ -126,8 +126,6 @@ public async Task TestVMScaleSetWithDnsSettings()
[Test]
public async Task TestVMScaleSetWithPublicIP()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");

// Create resource group
string rgName = Recording.GenerateAssetName(TestPrefix) + 1;
var vmssName = Recording.GenerateAssetName("vmss");
Expand All @@ -140,8 +138,7 @@ public async Task TestVMScaleSetWithPublicIP()
// This is because NRP is still deploying to other regions and is not available worldwide.
// Before changing the default location, we have to save it to be reset it at the end of the test.
// Since ComputeManagementTestUtilities.DefaultLocation is a static variable and can affect other tests if it is not reset.
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", "westcentralus");
EnsureClientsInitialized(false);
EnsureClientsInitialized(LocationWestCentralUs);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);
var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName);
Expand Down Expand Up @@ -182,8 +179,6 @@ public async Task TestVMScaleSetWithPublicIP()
[Ignore("this case should be tested by compute team because of ex '[4:46 PM] Lipeng You (Wicresoft North America Ltd)'message': 'Subscription /subscriptions/c9cbd920-c00c-427c-852b-8aaf38badaeb/resourceGroups//providers/Microsoft.Network/subscriptions/ is not registered for feature Microsoft.Network/AllowBringYourOwnPublicIpAddress required to carry out the requested operation.'")]
public async Task TestVMScaleSetWithPublicIPAndIPTags()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");

// Create resource group
string rgName = Recording.GenerateAssetName(TestPrefix) + 1;
var vmssName = Recording.GenerateAssetName("vmss");
Expand All @@ -195,8 +190,7 @@ public async Task TestVMScaleSetWithPublicIPAndIPTags()
// This is because NRP is still deploying to other regions and is not available worldwide.
// Before changing the default location, we have to save it to be reset it at the end of the test.
// Since ComputeManagementTestUtilities.DefaultLocation is a static variable and can affect other tests if it is not reset.
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", "westcentralus");
EnsureClientsInitialized(false);
EnsureClientsInitialized(LocationWestCentralUs);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);
var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName);
Expand Down Expand Up @@ -249,12 +243,6 @@ public async Task TestVMScaleSetWithPublicIPAndIPTags()
[Test]
public async Task TestVMScaleSetWithPublicIPAndPublicIPPrefix()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");
if (originalTestLocation == null)
{
originalTestLocation = String.Empty;
}

// Create resource group
string rgName = Recording.GenerateAssetName(TestPrefix) + 1;
var vmssName = Recording.GenerateAssetName("vmss");
Expand All @@ -263,7 +251,7 @@ public async Task TestVMScaleSetWithPublicIPAndPublicIPPrefix()
VirtualMachineScaleSet inputVMScaleSet;

bool passed = false;
EnsureClientsInitialized(true);
EnsureClientsInitialized(LocationWestCentralUs);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);
var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName);
Expand Down Expand Up @@ -307,7 +295,7 @@ public async Task TestVMScaleSetWithPublicIPAndPublicIPPrefix()
[Test]
public async Task TestVMScaleSetWithnNsg()
{
EnsureClientsInitialized(true);
EnsureClientsInitialized(LocationSouthAsia);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);

Expand Down Expand Up @@ -360,7 +348,7 @@ public async Task TestVMScaleSetWithnNsg()
[Test]
public async Task TestVMScaleSetWithnIpv6()
{
EnsureClientsInitialized(true);
EnsureClientsInitialized(LocationSouthAsia);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);

Expand Down Expand Up @@ -410,7 +398,7 @@ public async Task TestVMScaleSetWithnIpv6()
[Test]
public async Task TestVMSSWithMultiCA()
{
EnsureClientsInitialized(true);
EnsureClientsInitialized(LocationWestCentralUs);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);

Expand Down Expand Up @@ -461,7 +449,7 @@ public async Task TestVMSSWithMultiCA()
[Test]
public async Task TestVMSSAccelNtwkng()
{
EnsureClientsInitialized(true);
EnsureClientsInitialized(LocationWestCentralUs);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task TestVMScaleSetOperations_ManagedDisks()

private async Task TestVMScaleSetOperationsInternal(bool hasManagedDisks = false)
{
EnsureClientsInitialized(true);
EnsureClientsInitialized(LocationEastUs2);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);

Expand Down Expand Up @@ -97,16 +97,13 @@ private async Task TestVMScaleSetOperationsInternal(bool hasManagedDisks = false
[Test]
public async Task TestVMScaleSetOperations_Redeploy()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");

string rgName = Recording.GenerateAssetName(TestPrefix) + 1;
string vmssName = Recording.GenerateAssetName("vmss");
string storageAccountName = Recording.GenerateAssetName(TestPrefix);
VirtualMachineScaleSet inputVMScaleSet;

bool passed = false;
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", "EastUS2");
EnsureClientsInitialized(false);
EnsureClientsInitialized(LocationEastUs2);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);
StorageAccount storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName);
Expand Down Expand Up @@ -139,7 +136,7 @@ public async Task TestVMScaleSetOperations_PowerOffWithSkipShutdown()
VirtualMachineScaleSet inputVMScaleSet;

bool passed = false;
EnsureClientsInitialized(true);
EnsureClientsInitialized(LocationEastUs2);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);
StorageAccount storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName);
Expand All @@ -158,8 +155,6 @@ public async Task TestVMScaleSetOperations_PowerOffWithSkipShutdown()
[Test]
public async Task TestVMScaleSetOperations_PerformMaintenance()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");

string rgName = Recording.GenerateAssetName(TestPrefix) + 1;
string vmssName = Recording.GenerateAssetName("vmss");
string storageAccountName = Recording.GenerateAssetName(TestPrefix);
Expand All @@ -170,8 +165,7 @@ public async Task TestVMScaleSetOperations_PerformMaintenance()

try
{
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", "EastUS2");
EnsureClientsInitialized(false);
EnsureClientsInitialized(LocationEastUs2);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);
StorageAccount storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName);
Expand Down Expand Up @@ -214,7 +208,7 @@ public async Task TestVMScaleSetOperations_PerformMaintenance()
[Test]
public async Task TestVMScaleSetBatchOperations()
{
EnsureClientsInitialized(true);
EnsureClientsInitialized(LocationSouthAsia);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);

Expand Down Expand Up @@ -262,16 +256,13 @@ public async Task TestVMScaleSetBatchOperations()
[Test]
public async Task TestVMScaleSetBatchOperations_Redeploy()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");

string rgName = Recording.GenerateAssetName(TestPrefix) + 1;
string vmssName = Recording.GenerateAssetName("vmss");
string storageAccountName = Recording.GenerateAssetName(TestPrefix);
VirtualMachineScaleSet inputVMScaleSet;

bool passed = false;
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", "EastUS2");
EnsureClientsInitialized(false);
EnsureClientsInitialized(LocationEastUs2);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);
StorageAccount storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName);
Expand All @@ -292,8 +283,6 @@ public async Task TestVMScaleSetBatchOperations_Redeploy()
[Test]
public async Task TestVMScaleSetBatchOperations_PerformMaintenance()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");

string rgName = Recording.GenerateAssetName(TestPrefix) + 1;
string vmssName = Recording.GenerateAssetName("vmss");
string storageAccountName = Recording.GenerateAssetName(TestPrefix);
Expand All @@ -303,8 +292,7 @@ public async Task TestVMScaleSetBatchOperations_PerformMaintenance()
bool passed = false;
try
{
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", "EastUS2");
EnsureClientsInitialized(false);
EnsureClientsInitialized(LocationEastUs2);

ImageReference imageRef = await GetPlatformVMImage(useWindowsImage: true);
StorageAccount storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName);
Expand Down
Loading

0 comments on commit ac273f0

Please sign in to comment.