Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVS 2023-09-01 SDK Tests #46831

Merged
2 changes: 1 addition & 1 deletion sdk/avs/Azure.ResourceManager.Avs/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/avs/Azure.ResourceManager.Avs",
"Tag": "net/avs/Azure.ResourceManager.Avs_0cfa07cc25"
"Tag": "net/avs/Azure.ResourceManager.Avs_a243329cff"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ public class AvsManagementTestBase : ManagementRecordedTestBase<AvsManagementTes

protected AzureLocation DefaultLocation => AzureLocation.EastUS;

public const string RESOURCE_GROUP_NAME = "avs-sdk-test";
public const string PRIVATE_CLOUD_NAME = "avs-sdk-test";
public const string RESOURCE_GROUP_NAME = "avs-dotnet-test";
public const string PRIVATE_CLOUD_NAME = "avs-dotnet-test-w2";
public const string CLUSTER1_NAME = "Cluster-1";
public const string CLUSTER2_NAME = "Cluster-2";
public const string ISCSI_PATH_NAME = "default";
public const string WORKLOAD_NETWORK_NAME = "a8b7ddce-a5d6-11e8-a7e5-43344e310957";

protected AvsManagementTestBase(bool isAsync, RecordedTestMode mode)
: base(isAsync, mode)
{
Expand Down Expand Up @@ -66,5 +69,26 @@ protected async Task<AvsPrivateCloudClusterResource> getAvsPrivateCloudClusterRe
avsPrivateCloudCluster = await avsPrivateCloudCluster.GetAsync();
return avsPrivateCloudCluster;
}
protected IscsiPathResource getIscsiPathResource()
{
string subscriptionId = DefaultSubscription.Data.SubscriptionId;
ResourceIdentifier iscsiPathResourceId = IscsiPathResource.CreateResourceIdentifier(subscriptionId, RESOURCE_GROUP_NAME, PRIVATE_CLOUD_NAME);
IscsiPathResource iscsiPath = Client.GetIscsiPathResource(iscsiPathResourceId);
return iscsiPath;
}
protected WorkloadNetworkResource getWorkloadNetworkResource()
{
string subscriptionId = DefaultSubscription.Data.SubscriptionId;
ResourceIdentifier workloadNetworkResourceId = WorkloadNetworkResource.CreateResourceIdentifier(subscriptionId, RESOURCE_GROUP_NAME, PRIVATE_CLOUD_NAME);
WorkloadNetworkResource workloadNetwork = Client.GetWorkloadNetworkResource(workloadNetworkResourceId);
return workloadNetwork;
}
protected AvsPrivateCloudResource getWorkloadNetworkResourceOld()
{
string subscriptionId = DefaultSubscription.Data.SubscriptionId;
ResourceIdentifier avsPrivateCloudResourceId = AvsPrivateCloudResource.CreateResourceIdentifier(subscriptionId, RESOURCE_GROUP_NAME, PRIVATE_CLOUD_NAME);
AvsPrivateCloudResource avsPrivateCloud = Client.GetAvsPrivateCloudResource(avsPrivateCloudResourceId);
return avsPrivateCloud;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.TestFramework;
using Azure.ResourceManager.Avs.Models;
using NUnit.Framework;

namespace Azure.ResourceManager.Avs.Tests.Scenario
{
public class IscsiPathResourceTest : AvsManagementTestBase
{
public IscsiPathResourceTest(bool isAsync) : base(isAsync)
{
}

[TestCase, Order(1)]
[RecordedTest]
public async Task Create()
{
IscsiPathData data = new IscsiPathData()
{
NetworkBlock = "172.16.0.0/24",
};
ArmOperation<IscsiPathResource> lro = await getIscsiPathResource().CreateOrUpdateAsync(WaitUntil.Completed, data);
IscsiPathResource result = lro.Value;
Assert.AreEqual(result.Data.Name, ISCSI_PATH_NAME);
}

[TestCase, Order(2)]
[RecordedTest]
public async Task Get()
{
IscsiPathResource iscsiPath = await getIscsiPathResource().GetAsync();
Assert.AreEqual(iscsiPath.Data.Name, ISCSI_PATH_NAME);
}

[TestCase, Order(3)]
[RecordedTest]
public async Task Delete()
{
ArmOperation lro = await getIscsiPathResource().DeleteAsync(WaitUntil.Started);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ protected async Task<PlacementPolicyCollection> GetPlacementPolicyCollectionAsyn
[AsyncOnly]
public async Task Create() {
var collection = await GetPlacementPolicyCollectionAsync();
string placementPolicyName = "policy1";
string placementPolicyName = "policy2";
PlacementPolicyData data = new PlacementPolicyData()
{
Properties = new VmHostPlacementPolicyProperties(new ResourceIdentifier[]
{
new ResourceIdentifier($"/subscriptions/{DefaultSubscription.Data.SubscriptionId}/resourceGroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.AVS/privateClouds/{PRIVATE_CLOUD_NAME}/clusters/{CLUSTER1_NAME}/virtualMachines/vm-1818")
new ResourceIdentifier($"/subscriptions/{DefaultSubscription.Data.SubscriptionId}/resourceGroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.AVS/privateClouds/{PRIVATE_CLOUD_NAME}/clusters/{CLUSTER1_NAME}/virtualMachines/vm-153")
}, new string[]
{"esx05-r20.p04.eastus.avs.azure.com"
{"esx01-r09.p02.westus2.avs.azure.com"
}, AvsPlacementPolicyAffinityType.Affinity)
};
ArmOperation<PlacementPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, placementPolicyName, data);
Expand All @@ -60,4 +60,4 @@ public async Task GetCollection()
Assert.IsTrue(policies.Any());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected async Task<AvsPrivateCloudCollection> GetPrivateCloudCollectionAsync(
public async Task CreateOrUpdate()
{
var collection = await GetPrivateCloudCollectionAsync();
string privateCloudName = Recording.GenerateAssetName("avs-sdk-test-");
string privateCloudName = Recording.GenerateAssetName("avs-dotnet-test-");
AvsPrivateCloudData data = new AvsPrivateCloudData(DefaultLocation, new AvsSku("AV36"))
{
ManagementCluster = new AvsManagementCluster()
Expand Down Expand Up @@ -89,4 +89,4 @@ public async Task Get()
Assert.AreEqual(result.Data.Name, PRIVATE_CLOUD_NAME);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public async Task RotateNsxtPassword()
ArmOperation lro = await privateCloudResource.RotateNsxtPasswordAsync(WaitUntil.Started);
}

// [TestCase]
// [RecordedTest]
[TestCase]
[RecordedTest]
public async Task Delete()
{
var privateCloudResource = await getAvsPrivateCloudResource();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.TestFramework;
using Azure.ResourceManager.Avs.Models;
using NUnit.Framework;

namespace Azure.ResourceManager.Avs.Tests.Scenario
{
public class WorkloadNetworkVmGroupCollectionTest: AvsManagementTestBase
{
public WorkloadNetworkVmGroupCollectionTest(bool isAsync) : base(isAsync)
{
}

[TestCase, Order(1)]
[RecordedTest]
public async Task GetCollection()
{
WorkloadNetworkVmGroupCollection collection = getWorkloadNetworkResource().GetWorkloadNetworkVmGroups();
var workloadNetworksList = new List<WorkloadNetworkVmGroupResource>();
await foreach (WorkloadNetworkVmGroupResource item in collection.GetAllAsync())
{
workloadNetworksList.Add(item);
}

Assert.IsTrue(workloadNetworksList.Any());
}

[TestCase, Order(1)]
[RecordedTest]
public async Task GetCollectionOld()
{
WorkloadNetworkVmGroupCollection collection = getWorkloadNetworkResourceOld().GetWorkloadNetworkVmGroups();
var workloadNetworksList = new List<WorkloadNetworkVmGroupResource>();
await foreach (WorkloadNetworkVmGroupResource item in collection.GetAllAsync())
{
workloadNetworksList.Add(item);
}

Assert.IsTrue(workloadNetworksList.Any());
}

[TestCase, Order(2)]
[RecordedTest]
public async Task GetResource()
{
WorkloadNetworkVmGroupCollection collection = getWorkloadNetworkResource().GetWorkloadNetworkVmGroups();
WorkloadNetworkVmGroupResource result = await collection.GetAsync(WORKLOAD_NETWORK_NAME);
Assert.AreEqual(result.Data.Name, WORKLOAD_NETWORK_NAME);
}

[TestCase, Order(3)]
[RecordedTest]
public async Task resourceExisits()
{
WorkloadNetworkVmGroupCollection collection = getWorkloadNetworkResource().GetWorkloadNetworkVmGroups();
bool result = await collection.ExistsAsync(WORKLOAD_NETWORK_NAME);
Assert.True(result);
result = await collection.ExistsAsync("wn1");
Assert.False(result);
}
[TestCase, Order(4)]
[RecordedTest]
public async Task getIfExisits()
{
WorkloadNetworkVmGroupCollection collection = getWorkloadNetworkResource().GetWorkloadNetworkVmGroups();
NullableResponse<WorkloadNetworkVmGroupResource> response = await collection.GetIfExistsAsync(WORKLOAD_NETWORK_NAME);
WorkloadNetworkVmGroupResource result = response.HasValue ? response.Value : null;
Assert.NotNull(result);
Assert.AreEqual(result.Data.Name, WORKLOAD_NETWORK_NAME);
}
}
}