Skip to content

Commit

Permalink
add test cases for compute track 2 mgmt sdk (Azure#12809)
Browse files Browse the repository at this point in the history
* 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 <62531040+Youri970410@users.noreply.github.com>
Co-authored-by: Youri <v-lipyo@microsoft.com>
Co-authored-by: Harvey Chen <30464227+HarveyLink@users.noreply.github.com>
  • Loading branch information
4 people authored Jun 18, 2020
1 parent 0257f67 commit 4be8233
Show file tree
Hide file tree
Showing 343 changed files with 7,279,348 additions and 11 deletions.
10 changes: 5 additions & 5 deletions sdk/compute/Azure.ResourceManager.Compute/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ using Azure.ResourceManager.Network.Models;
var computeClient = new ComputeManagementClient(subscriptionId, new DefaultAzureCredential());
var networkClient = new NetworkManagementClient(subscriptionId, new DefaultAzureCredential());

var availabilitySetsClient = computeClient.GetAvailabilitySetsClient();
var virtualNetworksClient = networkClient.GetVirtualNetworksClient();
var networkInterfaceClient = networkClient.GetNetworkInterfacesClient();
var virtualMachinesClient = computeClient.GetVirtualMachinesClient();
var availabilitySetsClient = computeClient.AvailabilitySets;
var virtualNetworksClient = networkClient.VirtualNetworks;
var networkInterfaceClient = networkClient.NetworkInterfaces;
var virtualMachinesClient = computeClient.VirtualMachines;

var location = "westus";
// Create AvailabilitySet
Expand Down Expand Up @@ -279,4 +279,4 @@ var vmExtension = new VirtualMachineExtension(
"Microsoft.Compute",
"VMAccessAgent", "2.0", true, "{}", "{}", null, null
);
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions sdk/compute/Azure.ResourceManager.Compute/src/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ azure-arm: true
require: https://github.com/Azure/azure-rest-api-specs/blob/e25881196fcf84fca4dfaedc9fc45a00db4e0541/specification/compute/resource-manager/readme.md
modelerfour:
lenient-model-deduplication: true
directive:
- from: compute.json
where: $.definitions.VirtualMachineImageProperties.properties.dataDiskImages
transform: $.description="The list of data disk images information."
- from: disk.json
where: $.definitions.GrantAccessData.properties.access
transform: $.description="The Access Level, accepted values include None, Read, Write."
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TestHelperProjects>Resources201705;Network202004;Storage201906;</TestHelperProjects>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\src\Azure.ResourceManager.Compute.csproj" />
</ItemGroup>
Expand Down
162 changes: 162 additions & 0 deletions sdk/compute/Azure.ResourceManager.Compute/tests/ComputeClientBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
using Azure.Management.Network;
using Azure.Management.Resources;
using Azure.Management.Storage;
using Azure.ResourceManager.Compute;
using Azure.ResourceManager.Compute.Tests;
using Azure.ResourceManager.TestFramework;
using NUnit.Framework;
using Operations = Azure.ResourceManager.Compute.Operations;

namespace Azure.ResourceManager
{
[RunFrequency(RunTestFrequency.Manually)]
[ClientTestFixture]
[NonParallelizable]
public abstract class ComputeClientBase : ManagementRecordedTestBase<ComputeManagementTestEnvironment>
{
protected string DefaultLocation = "southeastasia";
protected string LocationEastUs2UpperCase = "EastUS2";
protected string LocationEastUs2 = "eastus2";
protected string LocationWestCentralUs = "westcentralus";
protected string LocationAustraliaSouthEast = "australiasoutheast";
protected string LocationNorthEurope = "northeurope";
protected string LocationCentralUs = "centralus";
protected string LocationCentralUsEuap = "centraluseuap";
protected string LocationSouthCentralUs = "southcentralus";

public ResourceGroupsOperations ResourceGroupsOperations { get; set; }
public ProvidersOperations ProvidersOperations { get; set; }
public DeploymentsOperations DeploymentsOperations { get; set; }
public TagsOperations TagsOperations { get; set; }
public ResourcesOperations ResourcesOperations { get; set; }
public VirtualMachineImagesOperations VirtualMachineImagesOperations { get; set; }
public AvailabilitySetsOperations AvailabilitySetsOperations { get; set; }
public ContainerServicesOperations ContainerServicesOperations { get; set; }
public DedicatedHostGroupsOperations DedicatedHostGroupsOperations { get; set; }
public DedicatedHostsOperations DedicatedHostsOperations { get; set; }
public VirtualMachineExtensionImagesOperations VirtualMachineExtensionImagesOperations { get; set; }
public ResourceSkusOperations ResourceSkusOperations { get; set; }
public LogAnalyticsOperations LogAnalyticsOperations { get; set; }
public Operations Operations { get; set; }
public ProximityPlacementGroupsOperations ProximityPlacementGroupsOperations { get; set; }
public VirtualMachinesOperations VirtualMachinesOperations { get; set; }
public VirtualMachineRunCommandsOperations VirtualMachineRunCommandsOperations { get; set; }
public VirtualMachineScaleSetExtensionsOperations VirtualMachineScaleSetExtensionsOperations { get; set; }
public VirtualMachineScaleSetsOperations VirtualMachineScaleSetsOperations { get; set; }
public VirtualMachineScaleSetVMsOperations VirtualMachineScaleSetVMsOperations { get; set; }
public VirtualMachineScaleSetRollingUpgradesOperations VirtualMachineScaleSetRollingUpgradesOperations { get; set; }
public DisksOperations DisksOperations { get; set; }
public VirtualMachineSizesOperations VirtualMachineSizesOperations { get; set; }
public SnapshotsOperations SnapshotsOperations { get; set; }
public DiskEncryptionSetsOperations DiskEncryptionSetsOperations { get; set; }
public VirtualNetworksOperations VirtualNetworksOperations { get; set; }
public PublicIPAddressesOperations PublicIPAddressesOperations { get; set; }
public StorageAccountsOperations StorageAccountsOperations { get; set; }
public SubnetsOperations SubnetsOperations { get; set; }
public NetworkInterfacesOperations NetworkInterfacesOperations { get; set; }
public VirtualMachineExtensionsOperations VirtualMachineExtensionsOperations { get; set; }
public GalleriesOperations GalleriesOperations { get; set; }
public GalleryImagesOperations GalleryImagesOperations { get; set; }
public GalleryImageVersionsOperations GalleryImageVersionsOperations { get; set; }
public ImagesOperations ImagesOperations { get; set; }
public GalleryApplicationsOperations GalleryApplicationsOperations { get; set; }
public GalleryApplicationVersionsOperations GalleryApplicationVersionsOperations { get; set; }
public BlobContainersOperations BlobContainersOperations { get; set; }
public UsageOperations UsageClient { get; set; }
public ApplicationGatewaysOperations ApplicationGatewaysOperations { get; set; }
public LoadBalancersOperations LoadBalancersOperations { get; set; }
public NetworkSecurityGroupsOperations NetworkSecurityGroupsOperations { get; set; }
public PublicIPPrefixesOperations PublicIPPrefixesOperations { get; set; }
public ComputeManagementClient ComputeManagementClient { get; set; }

protected ComputeClientBase(bool isAsync)
: base(isAsync)
{
}

protected void InitializeBase()
{
var resourceManagementClient = GetResourceManagementClient();
ResourceGroupsOperations = resourceManagementClient.ResourceGroups;
ProvidersOperations = resourceManagementClient.Providers;
DeploymentsOperations = resourceManagementClient.Deployments;
TagsOperations = resourceManagementClient.Tags;
ResourcesOperations = resourceManagementClient.Resources;
ComputeManagementClient = GetComputeManagementClient();
VirtualMachineImagesOperations = ComputeManagementClient.VirtualMachineImages;
AvailabilitySetsOperations = ComputeManagementClient.AvailabilitySets;
ContainerServicesOperations = ComputeManagementClient.ContainerServices;
DedicatedHostGroupsOperations = ComputeManagementClient.DedicatedHostGroups;
DedicatedHostsOperations = ComputeManagementClient.DedicatedHosts;
VirtualMachineExtensionImagesOperations = ComputeManagementClient.VirtualMachineExtensionImages;
ResourceSkusOperations = ComputeManagementClient.ResourceSkus;
LogAnalyticsOperations = ComputeManagementClient.LogAnalytics;
Operations = ComputeManagementClient.Operations;
ProximityPlacementGroupsOperations = ComputeManagementClient.ProximityPlacementGroups;
VirtualMachinesOperations = ComputeManagementClient.VirtualMachines;
VirtualMachineRunCommandsOperations = ComputeManagementClient.VirtualMachineRunCommands;
VirtualMachineScaleSetExtensionsOperations = ComputeManagementClient.VirtualMachineScaleSetExtensions;
VirtualMachineScaleSetsOperations = ComputeManagementClient.VirtualMachineScaleSets;
VirtualMachineScaleSetVMsOperations = ComputeManagementClient.VirtualMachineScaleSetVMs;
VirtualMachineScaleSetRollingUpgradesOperations = ComputeManagementClient.VirtualMachineScaleSetRollingUpgrades;
DisksOperations = ComputeManagementClient.Disks;
VirtualMachineSizesOperations = ComputeManagementClient.VirtualMachineSizes;
SnapshotsOperations = ComputeManagementClient.Snapshots;
DiskEncryptionSetsOperations = ComputeManagementClient.DiskEncryptionSets;
VirtualMachineExtensionsOperations = ComputeManagementClient.VirtualMachineExtensions;
GalleriesOperations = ComputeManagementClient.Galleries;
GalleryImagesOperations = ComputeManagementClient.GalleryImages;
GalleryImageVersionsOperations = ComputeManagementClient.GalleryImageVersions;
ImagesOperations = ComputeManagementClient.Images;
GalleryApplicationsOperations = ComputeManagementClient.GalleryApplications;
GalleryApplicationVersionsOperations = ComputeManagementClient.GalleryApplicationVersions;
UsageClient = ComputeManagementClient.Usage;
var NetworkManagementClient = GetNetworkManagementClient();
PublicIPAddressesOperations = NetworkManagementClient.PublicIPAddresses;
SubnetsOperations = NetworkManagementClient.Subnets;
NetworkInterfacesOperations = NetworkManagementClient.NetworkInterfaces;
ApplicationGatewaysOperations = NetworkManagementClient.ApplicationGateways;
LoadBalancersOperations = NetworkManagementClient.LoadBalancers;
NetworkSecurityGroupsOperations = NetworkManagementClient.NetworkSecurityGroups;
PublicIPPrefixesOperations = NetworkManagementClient.PublicIPPrefixes;
VirtualNetworksOperations = NetworkManagementClient.VirtualNetworks;
var StorageManagementClient = GetStorageManagementClient();
StorageAccountsOperations = StorageManagementClient.StorageAccounts;
BlobContainersOperations = StorageManagementClient.BlobContainers;
}
internal ComputeManagementClient GetComputeManagementClient()
{
return CreateClient<ComputeManagementClient>(this.TestEnvironment.SubscriptionId,
TestEnvironment.Credential,
Recording.InstrumentClientOptions(new ComputeManagementClientOptions()));
}
internal NetworkManagementClient GetNetworkManagementClient()
{
return CreateClient<NetworkManagementClient>(this.TestEnvironment.SubscriptionId,
TestEnvironment.Credential,
Recording.InstrumentClientOptions(new NetworkManagementClientOptions()));
}
internal StorageManagementClient GetStorageManagementClient()
{
return CreateClient<StorageManagementClient>(this.TestEnvironment.SubscriptionId,
TestEnvironment.Credential,
Recording.InstrumentClientOptions(new StorageManagementClientOptions()));
}

public void WaitSeconds(int seconds)
{
SleepInTest(seconds * 1000);
}

public void WaitMinutes(int minutes)
{
WaitSeconds(minutes * 60);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Azure.ResourceManager.Compute.Tests
{
public class ComputeManagementTestEnvironment : TestEnvironment
{
public ComputeManagementTestEnvironment() : base("computemgmt")
public ComputeManagementTestEnvironment() : base("compute")
{
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
using Azure.ResourceManager.Compute.Models;
using Azure.Management.Resources;
using NUnit.Framework;
using NUnit.Framework.Internal;

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

[SetUp]
public void ClearChallengeCacheforRecord()
{
if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
{
InitializeBase();
}
}

[TearDown]
public async Task CleanupResourceGroup()
{
await CleanupResourceGroupsAsync();
}

[Test]
[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")]
public async Task TestDCOSOperations()
{
// Create resource group
var rgName = Recording.GenerateAssetName(TestPrefix) + 1;
var csName = Recording.GenerateAssetName(ContainerServiceNamePrefix);
var masterDnsPrefixName = Recording.GenerateAssetName(MasterProfileDnsPrefix);
var agentPoolDnsPrefixName = Recording.GenerateAssetName(AgentPoolProfileDnsPrefix);
EnsureClientsInitialized(LocationAustraliaSouthEast);

ContainerService inputContainerService;
var getTwocontainerService = await CreateContainerService_NoAsyncTracking(
rgName,
csName,
masterDnsPrefixName,
agentPoolDnsPrefixName,
//out inputContainerService,
cs => cs.OrchestratorProfile.OrchestratorType = ContainerServiceOrchestratorTypes.Dcos);
var containerService = getTwocontainerService.Item1;
inputContainerService = getTwocontainerService.Item2;
await WaitForCompletionAsync(await ContainerServicesOperations.StartDeleteAsync(rgName, containerService.Name));
}

/// <summary>
/// Covers following Operations:
/// Create RG
/// Create Container Service
/// Get Container Service
/// Delete Container Service
/// Delete RG
/// </summary>
[Test]
[Ignore("TRACK2: compute team will help to record")]
public async Task TestSwarmOperations()
{
// Create resource group
var rgName = Recording.GenerateAssetName(TestPrefix) + 1;
var csName = Recording.GenerateAssetName(ContainerServiceNamePrefix);
var masterDnsPrefixName = Recording.GenerateAssetName(MasterProfileDnsPrefix);
var agentPoolDnsPrefixName = Recording.GenerateAssetName(AgentPoolProfileDnsPrefix);
EnsureClientsInitialized(LocationAustraliaSouthEast);
ContainerService inputContainerService;
var getTwocontainerService = await CreateContainerService_NoAsyncTracking(
rgName,
csName,
masterDnsPrefixName,
agentPoolDnsPrefixName,
//out inputContainerService,
cs => cs.OrchestratorProfile.OrchestratorType = ContainerServiceOrchestratorTypes.Swarm);
var containerService = getTwocontainerService.Item1;
inputContainerService = getTwocontainerService.Item2;
await WaitForCompletionAsync(await ContainerServicesOperations.StartDeleteAsync(rgName, containerService.Name));
}
}
}
Loading

0 comments on commit 4be8233

Please sign in to comment.