Skip to content

Commit 4be8233

Browse files
erich-wangYouri970410YouriHarveyLink
authored
add test cases for compute track 2 mgmt sdk (Azure#12809)
* Youri/compute (#16) * add compute test * fix tetbas * add all recorded files * change compute case * fix some json issue * change csproj * update test cases * update test cases * update test cases * minor update * update test cases * Fix for location initialize (#20) * change DiskRPTest Location[C (#21) * code refactoring * Re-record GalleryImageVersion_CRUD_Tests (#22) * Fix for location initialize * Re-record GalleryImageVersion_CRUD_Tests * Youri/compute.test (#23) * change DiskRPTest Location[C * add OSProfile json * update change log and disable test TestVMScaleSetServiceFabric Co-authored-by: Youri970410 <[email protected]> Co-authored-by: Youri <[email protected]> Co-authored-by: Harvey Chen <[email protected]>
1 parent 0257f67 commit 4be8233

File tree

343 files changed

+7279348
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+7279348
-11
lines changed

sdk/compute/Azure.ResourceManager.Compute/CHANGELOG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ using Azure.ResourceManager.Network.Models;
160160
var computeClient = new ComputeManagementClient(subscriptionId, new DefaultAzureCredential());
161161
var networkClient = new NetworkManagementClient(subscriptionId, new DefaultAzureCredential());
162162

163-
var availabilitySetsClient = computeClient.GetAvailabilitySetsClient();
164-
var virtualNetworksClient = networkClient.GetVirtualNetworksClient();
165-
var networkInterfaceClient = networkClient.GetNetworkInterfacesClient();
166-
var virtualMachinesClient = computeClient.GetVirtualMachinesClient();
163+
var availabilitySetsClient = computeClient.AvailabilitySets;
164+
var virtualNetworksClient = networkClient.VirtualNetworks;
165+
var networkInterfaceClient = networkClient.NetworkInterfaces;
166+
var virtualMachinesClient = computeClient.VirtualMachines;
167167

168168
var location = "westus";
169169
// Create AvailabilitySet
@@ -279,4 +279,4 @@ var vmExtension = new VirtualMachineExtension(
279279
"Microsoft.Compute",
280280
"VMAccessAgent", "2.0", true, "{}", "{}", null, null
281281
);
282-
```
282+
```

sdk/compute/Azure.ResourceManager.Compute/src/Azure.ResourceManager.Compute.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<PropertyGroup>
10-
<!-- TODO: Temp workaround. Should be fixed prio release -->
11-
<NoWarn>$(NoWarn);AZC0001;AZC0008;CS1591</NoWarn>
10+
<!-- TODO: Temp workaround. Should be fixed prior to release -->
11+
<NoWarn>$(NoWarn);AZC0001;AZC0008</NoWarn>
1212
</PropertyGroup>
1313
</Project>

sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/AccessLevel.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/GrantAccessData.cs

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineImage.cs

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/compute/Azure.ResourceManager.Compute/src/autorest.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@ azure-arm: true
77
require: https://github.com/Azure/azure-rest-api-specs/blob/e25881196fcf84fca4dfaedc9fc45a00db4e0541/specification/compute/resource-manager/readme.md
88
modelerfour:
99
lenient-model-deduplication: true
10+
directive:
11+
- from: compute.json
12+
where: $.definitions.VirtualMachineImageProperties.properties.dataDiskImages
13+
transform: $.description="The list of data disk images information."
14+
- from: disk.json
15+
where: $.definitions.GrantAccessData.properties.access
16+
transform: $.description="The Access Level, accepted values include None, Read, Write."
1017
```

sdk/compute/Azure.ResourceManager.Compute/tests/Azure.ResourceManager.Compute.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TestHelperProjects>Resources201705;Network202004;Storage201906;</TestHelperProjects>
4+
</PropertyGroup>
25
<ItemGroup>
36
<ProjectReference Include="..\src\Azure.ResourceManager.Compute.csproj" />
47
</ItemGroup>
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.Threading.Tasks;
6+
using Azure.Core.TestFramework;
7+
using Azure.Management.Network;
8+
using Azure.Management.Resources;
9+
using Azure.Management.Storage;
10+
using Azure.ResourceManager.Compute;
11+
using Azure.ResourceManager.Compute.Tests;
12+
using Azure.ResourceManager.TestFramework;
13+
using NUnit.Framework;
14+
using Operations = Azure.ResourceManager.Compute.Operations;
15+
16+
namespace Azure.ResourceManager
17+
{
18+
[RunFrequency(RunTestFrequency.Manually)]
19+
[ClientTestFixture]
20+
[NonParallelizable]
21+
public abstract class ComputeClientBase : ManagementRecordedTestBase<ComputeManagementTestEnvironment>
22+
{
23+
protected string DefaultLocation = "southeastasia";
24+
protected string LocationEastUs2UpperCase = "EastUS2";
25+
protected string LocationEastUs2 = "eastus2";
26+
protected string LocationWestCentralUs = "westcentralus";
27+
protected string LocationAustraliaSouthEast = "australiasoutheast";
28+
protected string LocationNorthEurope = "northeurope";
29+
protected string LocationCentralUs = "centralus";
30+
protected string LocationCentralUsEuap = "centraluseuap";
31+
protected string LocationSouthCentralUs = "southcentralus";
32+
33+
public ResourceGroupsOperations ResourceGroupsOperations { get; set; }
34+
public ProvidersOperations ProvidersOperations { get; set; }
35+
public DeploymentsOperations DeploymentsOperations { get; set; }
36+
public TagsOperations TagsOperations { get; set; }
37+
public ResourcesOperations ResourcesOperations { get; set; }
38+
public VirtualMachineImagesOperations VirtualMachineImagesOperations { get; set; }
39+
public AvailabilitySetsOperations AvailabilitySetsOperations { get; set; }
40+
public ContainerServicesOperations ContainerServicesOperations { get; set; }
41+
public DedicatedHostGroupsOperations DedicatedHostGroupsOperations { get; set; }
42+
public DedicatedHostsOperations DedicatedHostsOperations { get; set; }
43+
public VirtualMachineExtensionImagesOperations VirtualMachineExtensionImagesOperations { get; set; }
44+
public ResourceSkusOperations ResourceSkusOperations { get; set; }
45+
public LogAnalyticsOperations LogAnalyticsOperations { get; set; }
46+
public Operations Operations { get; set; }
47+
public ProximityPlacementGroupsOperations ProximityPlacementGroupsOperations { get; set; }
48+
public VirtualMachinesOperations VirtualMachinesOperations { get; set; }
49+
public VirtualMachineRunCommandsOperations VirtualMachineRunCommandsOperations { get; set; }
50+
public VirtualMachineScaleSetExtensionsOperations VirtualMachineScaleSetExtensionsOperations { get; set; }
51+
public VirtualMachineScaleSetsOperations VirtualMachineScaleSetsOperations { get; set; }
52+
public VirtualMachineScaleSetVMsOperations VirtualMachineScaleSetVMsOperations { get; set; }
53+
public VirtualMachineScaleSetRollingUpgradesOperations VirtualMachineScaleSetRollingUpgradesOperations { get; set; }
54+
public DisksOperations DisksOperations { get; set; }
55+
public VirtualMachineSizesOperations VirtualMachineSizesOperations { get; set; }
56+
public SnapshotsOperations SnapshotsOperations { get; set; }
57+
public DiskEncryptionSetsOperations DiskEncryptionSetsOperations { get; set; }
58+
public VirtualNetworksOperations VirtualNetworksOperations { get; set; }
59+
public PublicIPAddressesOperations PublicIPAddressesOperations { get; set; }
60+
public StorageAccountsOperations StorageAccountsOperations { get; set; }
61+
public SubnetsOperations SubnetsOperations { get; set; }
62+
public NetworkInterfacesOperations NetworkInterfacesOperations { get; set; }
63+
public VirtualMachineExtensionsOperations VirtualMachineExtensionsOperations { get; set; }
64+
public GalleriesOperations GalleriesOperations { get; set; }
65+
public GalleryImagesOperations GalleryImagesOperations { get; set; }
66+
public GalleryImageVersionsOperations GalleryImageVersionsOperations { get; set; }
67+
public ImagesOperations ImagesOperations { get; set; }
68+
public GalleryApplicationsOperations GalleryApplicationsOperations { get; set; }
69+
public GalleryApplicationVersionsOperations GalleryApplicationVersionsOperations { get; set; }
70+
public BlobContainersOperations BlobContainersOperations { get; set; }
71+
public UsageOperations UsageClient { get; set; }
72+
public ApplicationGatewaysOperations ApplicationGatewaysOperations { get; set; }
73+
public LoadBalancersOperations LoadBalancersOperations { get; set; }
74+
public NetworkSecurityGroupsOperations NetworkSecurityGroupsOperations { get; set; }
75+
public PublicIPPrefixesOperations PublicIPPrefixesOperations { get; set; }
76+
public ComputeManagementClient ComputeManagementClient { get; set; }
77+
78+
protected ComputeClientBase(bool isAsync)
79+
: base(isAsync)
80+
{
81+
}
82+
83+
protected void InitializeBase()
84+
{
85+
var resourceManagementClient = GetResourceManagementClient();
86+
ResourceGroupsOperations = resourceManagementClient.ResourceGroups;
87+
ProvidersOperations = resourceManagementClient.Providers;
88+
DeploymentsOperations = resourceManagementClient.Deployments;
89+
TagsOperations = resourceManagementClient.Tags;
90+
ResourcesOperations = resourceManagementClient.Resources;
91+
ComputeManagementClient = GetComputeManagementClient();
92+
VirtualMachineImagesOperations = ComputeManagementClient.VirtualMachineImages;
93+
AvailabilitySetsOperations = ComputeManagementClient.AvailabilitySets;
94+
ContainerServicesOperations = ComputeManagementClient.ContainerServices;
95+
DedicatedHostGroupsOperations = ComputeManagementClient.DedicatedHostGroups;
96+
DedicatedHostsOperations = ComputeManagementClient.DedicatedHosts;
97+
VirtualMachineExtensionImagesOperations = ComputeManagementClient.VirtualMachineExtensionImages;
98+
ResourceSkusOperations = ComputeManagementClient.ResourceSkus;
99+
LogAnalyticsOperations = ComputeManagementClient.LogAnalytics;
100+
Operations = ComputeManagementClient.Operations;
101+
ProximityPlacementGroupsOperations = ComputeManagementClient.ProximityPlacementGroups;
102+
VirtualMachinesOperations = ComputeManagementClient.VirtualMachines;
103+
VirtualMachineRunCommandsOperations = ComputeManagementClient.VirtualMachineRunCommands;
104+
VirtualMachineScaleSetExtensionsOperations = ComputeManagementClient.VirtualMachineScaleSetExtensions;
105+
VirtualMachineScaleSetsOperations = ComputeManagementClient.VirtualMachineScaleSets;
106+
VirtualMachineScaleSetVMsOperations = ComputeManagementClient.VirtualMachineScaleSetVMs;
107+
VirtualMachineScaleSetRollingUpgradesOperations = ComputeManagementClient.VirtualMachineScaleSetRollingUpgrades;
108+
DisksOperations = ComputeManagementClient.Disks;
109+
VirtualMachineSizesOperations = ComputeManagementClient.VirtualMachineSizes;
110+
SnapshotsOperations = ComputeManagementClient.Snapshots;
111+
DiskEncryptionSetsOperations = ComputeManagementClient.DiskEncryptionSets;
112+
VirtualMachineExtensionsOperations = ComputeManagementClient.VirtualMachineExtensions;
113+
GalleriesOperations = ComputeManagementClient.Galleries;
114+
GalleryImagesOperations = ComputeManagementClient.GalleryImages;
115+
GalleryImageVersionsOperations = ComputeManagementClient.GalleryImageVersions;
116+
ImagesOperations = ComputeManagementClient.Images;
117+
GalleryApplicationsOperations = ComputeManagementClient.GalleryApplications;
118+
GalleryApplicationVersionsOperations = ComputeManagementClient.GalleryApplicationVersions;
119+
UsageClient = ComputeManagementClient.Usage;
120+
var NetworkManagementClient = GetNetworkManagementClient();
121+
PublicIPAddressesOperations = NetworkManagementClient.PublicIPAddresses;
122+
SubnetsOperations = NetworkManagementClient.Subnets;
123+
NetworkInterfacesOperations = NetworkManagementClient.NetworkInterfaces;
124+
ApplicationGatewaysOperations = NetworkManagementClient.ApplicationGateways;
125+
LoadBalancersOperations = NetworkManagementClient.LoadBalancers;
126+
NetworkSecurityGroupsOperations = NetworkManagementClient.NetworkSecurityGroups;
127+
PublicIPPrefixesOperations = NetworkManagementClient.PublicIPPrefixes;
128+
VirtualNetworksOperations = NetworkManagementClient.VirtualNetworks;
129+
var StorageManagementClient = GetStorageManagementClient();
130+
StorageAccountsOperations = StorageManagementClient.StorageAccounts;
131+
BlobContainersOperations = StorageManagementClient.BlobContainers;
132+
}
133+
internal ComputeManagementClient GetComputeManagementClient()
134+
{
135+
return CreateClient<ComputeManagementClient>(this.TestEnvironment.SubscriptionId,
136+
TestEnvironment.Credential,
137+
Recording.InstrumentClientOptions(new ComputeManagementClientOptions()));
138+
}
139+
internal NetworkManagementClient GetNetworkManagementClient()
140+
{
141+
return CreateClient<NetworkManagementClient>(this.TestEnvironment.SubscriptionId,
142+
TestEnvironment.Credential,
143+
Recording.InstrumentClientOptions(new NetworkManagementClientOptions()));
144+
}
145+
internal StorageManagementClient GetStorageManagementClient()
146+
{
147+
return CreateClient<StorageManagementClient>(this.TestEnvironment.SubscriptionId,
148+
TestEnvironment.Credential,
149+
Recording.InstrumentClientOptions(new StorageManagementClientOptions()));
150+
}
151+
152+
public void WaitSeconds(int seconds)
153+
{
154+
SleepInTest(seconds * 1000);
155+
}
156+
157+
public void WaitMinutes(int minutes)
158+
{
159+
WaitSeconds(minutes * 60);
160+
}
161+
}
162+
}

sdk/compute/Azure.ResourceManager.Compute/tests/ComputeManagementTestEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Azure.ResourceManager.Compute.Tests
77
{
88
public class ComputeManagementTestEnvironment : TestEnvironment
99
{
10-
public ComputeManagementTestEnvironment() : base("computemgmt")
10+
public ComputeManagementTestEnvironment() : base("compute")
1111
{
1212
}
1313
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.Threading.Tasks;
6+
using Azure.Core.TestFramework;
7+
using Azure.ResourceManager.Compute.Models;
8+
using Azure.Management.Resources;
9+
using NUnit.Framework;
10+
using NUnit.Framework.Internal;
11+
12+
namespace Azure.ResourceManager.Compute.Tests
13+
{
14+
public class ContainerServiceOperationalTests : ContainerServiceTestsBase
15+
{
16+
public ContainerServiceOperationalTests(bool isAsync)
17+
: base(isAsync)
18+
{
19+
}
20+
21+
[SetUp]
22+
public void ClearChallengeCacheforRecord()
23+
{
24+
if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
25+
{
26+
InitializeBase();
27+
}
28+
}
29+
30+
[TearDown]
31+
public async Task CleanupResourceGroup()
32+
{
33+
await CleanupResourceGroupsAsync();
34+
}
35+
36+
[Test]
37+
[Ignore("TRACK2: compute team will help to record because of ex 'Address prefix string for resource /subscriptions/c9cbd920-c00c-427c-852b-8aaf38badaeb/resourceGroups/crptestar12191/providers/Microsoft.Network/virtualNetworks/dcos-vnet-35162761 cannot be null or empty' when record in track2")]
38+
public async Task TestDCOSOperations()
39+
{
40+
// Create resource group
41+
var rgName = Recording.GenerateAssetName(TestPrefix) + 1;
42+
var csName = Recording.GenerateAssetName(ContainerServiceNamePrefix);
43+
var masterDnsPrefixName = Recording.GenerateAssetName(MasterProfileDnsPrefix);
44+
var agentPoolDnsPrefixName = Recording.GenerateAssetName(AgentPoolProfileDnsPrefix);
45+
EnsureClientsInitialized(LocationAustraliaSouthEast);
46+
47+
ContainerService inputContainerService;
48+
var getTwocontainerService = await CreateContainerService_NoAsyncTracking(
49+
rgName,
50+
csName,
51+
masterDnsPrefixName,
52+
agentPoolDnsPrefixName,
53+
//out inputContainerService,
54+
cs => cs.OrchestratorProfile.OrchestratorType = ContainerServiceOrchestratorTypes.Dcos);
55+
var containerService = getTwocontainerService.Item1;
56+
inputContainerService = getTwocontainerService.Item2;
57+
await WaitForCompletionAsync(await ContainerServicesOperations.StartDeleteAsync(rgName, containerService.Name));
58+
}
59+
60+
/// <summary>
61+
/// Covers following Operations:
62+
/// Create RG
63+
/// Create Container Service
64+
/// Get Container Service
65+
/// Delete Container Service
66+
/// Delete RG
67+
/// </summary>
68+
[Test]
69+
[Ignore("TRACK2: compute team will help to record")]
70+
public async Task TestSwarmOperations()
71+
{
72+
// Create resource group
73+
var rgName = Recording.GenerateAssetName(TestPrefix) + 1;
74+
var csName = Recording.GenerateAssetName(ContainerServiceNamePrefix);
75+
var masterDnsPrefixName = Recording.GenerateAssetName(MasterProfileDnsPrefix);
76+
var agentPoolDnsPrefixName = Recording.GenerateAssetName(AgentPoolProfileDnsPrefix);
77+
EnsureClientsInitialized(LocationAustraliaSouthEast);
78+
ContainerService inputContainerService;
79+
var getTwocontainerService = await CreateContainerService_NoAsyncTracking(
80+
rgName,
81+
csName,
82+
masterDnsPrefixName,
83+
agentPoolDnsPrefixName,
84+
//out inputContainerService,
85+
cs => cs.OrchestratorProfile.OrchestratorType = ContainerServiceOrchestratorTypes.Swarm);
86+
var containerService = getTwocontainerService.Item1;
87+
inputContainerService = getTwocontainerService.Item2;
88+
await WaitForCompletionAsync(await ContainerServicesOperations.StartDeleteAsync(rgName, containerService.Name));
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)