From dd7ab5df3d2d62405066d4cc20dca5a88c8668f5 Mon Sep 17 00:00:00 2001 From: Priya shet Date: Thu, 26 Sep 2024 12:34:41 -0700 Subject: [PATCH] Include KubernetesCluster Feature and Kubernetescluster agentpool tests recording Include Cluster Manager tests recording --- .../assets.json | 2 +- .../tests/Scenario/AgentPoolTests.cs | 3 +- .../Scenario/KubernetesClusterFeatureTests.cs | 79 +++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/Scenario/KubernetesClusterFeatureTests.cs diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/assets.json b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/assets.json index 4ee11890c33c5..4467ad37700e2 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/assets.json +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/networkcloud/Azure.ResourceManager.NetworkCloud", - "Tag": "net/networkcloud/Azure.ResourceManager.NetworkCloud_9efbb40e1f" + "Tag": "net/networkcloud/Azure.ResourceManager.NetworkCloud_a281995009" } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/Scenario/AgentPoolTests.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/Scenario/AgentPoolTests.cs index 8f2e34258aa1a..a1fe54024236b 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/Scenario/AgentPoolTests.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/Scenario/AgentPoolTests.cs @@ -39,12 +39,13 @@ public async Task AgentPool() AdminUsername = "azure", SshPublicKeys = { - new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= fake-public-key") + new NetworkCloudSshPublicKey("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDHvXnJdrBmW052RUfpkGLj30ndi6jf4+i161ECfrVcUglfKmAlU8cfDCW/s6Bfppz80GkFscZpOH8h0erfigggPpFq5/2XblFitooqQ0Hxm091/rswg4t/27N49l5fiom8sD3kki4zRkmpgenwHTcZgUpBpQjd4DUrJxZ5zYF1wLop9Qu3ptsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsnv4ixQyU00X5Dt1G/3nLUdrz9A3s3b7K1w+BdB5E9v9gdBVSF2+XwZI9ooaAxfuOb0f/jP3CYLJ43SXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@test-vm") }, }, AgentOptions = new NetworkCloudAgentConfiguration(12) { HugepagesSize = HugepagesSize.TwoM, + HugepagesCount = 2 }, UpgradeMaxSurge = "1", Tags = diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/Scenario/KubernetesClusterFeatureTests.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/Scenario/KubernetesClusterFeatureTests.cs new file mode 100644 index 0000000000000..e5d6dab534a11 --- /dev/null +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/Scenario/KubernetesClusterFeatureTests.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.NetworkCloud.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.NetworkCloud.Tests.ScenarioTests +{ + public class KubernetesClusterFeatureTests : NetworkCloudManagementTestBase + { + public KubernetesClusterFeatureTests (bool isAsync, RecordedTestMode mode) : base(isAsync, mode) {} + public KubernetesClusterFeatureTests (bool isAsync) : base(isAsync) {} + + [Test, MaxTime(1800000)] + [RecordedTest] + public async Task KubernetesClusterFeature() + { + string featureName = Recording.GenerateAssetName("csi-volume"); + ResourceIdentifier featureId = NetworkCloudKubernetesClusterFeatureResource.CreateResourceIdentifier(TestEnvironment.SubscriptionId, TestEnvironment.KubernetesClusterRG, TestEnvironment.KubernetesClusterName, featureName); + NetworkCloudKubernetesClusterFeatureResource feature = Client.GetNetworkCloudKubernetesClusterFeatureResource(featureId); + + NetworkCloudKubernetesClusterResource kubernetesCluster = Client.GetNetworkCloudKubernetesClusterResource(TestEnvironment.KubernetesClusterId); + kubernetesCluster = await kubernetesCluster.GetAsync(); + NetworkCloudKubernetesClusterFeatureCollection collection = kubernetesCluster.GetNetworkCloudKubernetesClusterFeatures(); + + // Create + NetworkCloudKubernetesClusterFeatureData data = new NetworkCloudKubernetesClusterFeatureData(TestEnvironment.Location) + { + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2", +}, + Options = +{ +new StringKeyValuePair("featureOptionName","featureOptionValue") +}, + }; + // Create + ArmOperation createResult = await collection.CreateOrUpdateAsync(WaitUntil.Completed, featureName, data); + Assert.AreEqual(featureName, createResult.Value.Data.Name); + + // Get + var getResult = await feature.GetAsync(); + Assert.AreEqual(featureName, getResult.Value.Data.Name); + + // List + var listByKubernetesCluster = new List(); + await foreach (NetworkCloudKubernetesClusterFeatureResource item in collection.GetAllAsync()) + { + listByKubernetesCluster.Add(item); + } + Assert.IsNotEmpty(listByKubernetesCluster); + + // Update + NetworkCloudKubernetesClusterFeaturePatch patch = new NetworkCloudKubernetesClusterFeaturePatch() + { + Tags = + { + ["key1"] = "newvalue1", + ["key2"] = "newvalue2", + } + }; + ArmOperation updateResult = await feature.UpdateAsync(WaitUntil.Completed, patch); + Assert.AreEqual(patch.Tags, updateResult.Value.Data.Tags); + + // Delete + ArmOperation deleteResult = await feature.DeleteAsync(WaitUntil.Completed); + NetworkCloudOperationStatusResult result = deleteResult.Value; + Assert.IsNotNull(result); + } + } +}