-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
2,875 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
sdk/compute/Microsoft.Azure.Management.Compute/tests/ScenarioTests/VMDeleteOptionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using Xunit; | ||
using Microsoft.Rest.ClientRuntime.Azure.TestFramework; | ||
using Microsoft.Azure.Management.Compute.Models; | ||
using Microsoft.Azure.Management.ResourceManager; | ||
using Microsoft.Azure.Management.Compute; | ||
using System; | ||
|
||
namespace Compute.Tests | ||
{ | ||
public class VMDeleteOptionTests : VMTestBase | ||
{ | ||
[Fact] | ||
[Trait("Name", "TestDeleteOptionForDisks")] | ||
public void TestDeleteOptionForDisks() | ||
{ | ||
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION"); | ||
using (MockContext context = MockContext.Start(this.GetType())) | ||
{ | ||
// Hard code the location to "eastus2euap". | ||
// 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", "eastus2euap"); | ||
EnsureClientsInitialized(context); | ||
|
||
ImageReference imageRef = GetPlatformVMImage(useWindowsImage: true); | ||
|
||
// Create resource group | ||
var rgName = ComputeManagementTestUtilities.GenerateName(TestPrefix); | ||
string storageAccountName = ComputeManagementTestUtilities.GenerateName(TestPrefix); | ||
string asName = ComputeManagementTestUtilities.GenerateName("as"); | ||
|
||
try | ||
{ | ||
// Create Storage Account, so that both the VMs can share it | ||
var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName); | ||
|
||
VirtualMachine inputVM; | ||
CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM, hasManagedDisks: true); | ||
|
||
Assert.Equal(DiskDeleteOptionTypes.Detach, inputVM.StorageProfile.OsDisk.DeleteOption); | ||
|
||
foreach (DataDisk disk in inputVM.StorageProfile.DataDisks) | ||
{ | ||
Assert.Equal(DiskDeleteOptionTypes.Detach, disk.DeleteOption); | ||
} | ||
|
||
m_CrpClient.VirtualMachines.Delete(rgName, inputVM.Name); | ||
} | ||
finally | ||
{ | ||
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", originalTestLocation); | ||
m_ResourcesClient.ResourceGroups.Delete(rgName); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.