Skip to content
2 changes: 2 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aab

Check warning on line 1 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

Skipping `.github/actions/spelling/expect.txt` because it seems to have more noise (362) than unique words (0) (total: 363 / 0). (noisy-file)
AAFFBB
aarch
abe
Expand Down Expand Up @@ -210,6 +210,7 @@
prandom
predef
prefmaxlen
preprovisioned
printk
PROCESSINFOCLASS
proxyagent
Expand Down Expand Up @@ -342,6 +343,7 @@
wireserverand
wireserverandimds
WMI
workarounds
WORKDIR
WScript
wsf
Expand All @@ -358,3 +360,3 @@
xxxx
xxxxxxxx
xxxxxxxxxxx
Expand Down
9 changes: 6 additions & 3 deletions e2etest/GuestProxyAgentTest/GuestProxyAgentScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class GuestProxyAgentScenarioTests
public async Task StartAsync(List<TestScenarioSetting> testScenarioList)
{
var groupTestResultBuilderMap = new Dictionary<string, JunitTestResultBuilder>();
foreach(var testGroupName in testScenarioList.Select(x => x.testGroupName).ToHashSet())
foreach (var testGroupName in testScenarioList.Select(x => x.testGroupName).ToHashSet())
{
groupTestResultBuilderMap[testGroupName] = new JunitTestResultBuilder(TestSetting.Instance.testResultFolder, testGroupName);
}
Expand Down Expand Up @@ -57,7 +57,6 @@ public async Task StartAsync(List<TestScenarioSetting> testScenarioList)
testScenarioStatusDetails.Status = ScenarioTestStatus.Completed;
testScenarioStatusDetails.ErrorMessage = "Failed to create the scenario class instance: " + testScenario.testScenarioClassName;
}

}
catch (Exception ex)
{
Expand All @@ -72,6 +71,10 @@ public async Task StartAsync(List<TestScenarioSetting> testScenarioList)
{
taskList.Add(testScenarioTask);
}
var message = string.Format("Test Group: {0}, Test Scenario: {1}: {2} ({3})"
, testScenario.testGroupName, testScenario.testScenarioName
, testScenarioStatusDetails.Result, testScenarioStatusDetails.ErrorMessage);
Console.WriteLine(message);
}
}
var stopMonitor = new ManualResetEvent(false);
Expand All @@ -91,7 +94,7 @@ public async Task StartAsync(List<TestScenarioSetting> testScenarioList)
{
Console.WriteLine($"Test execution exception: {ex.Message}");
}

stopMonitor.Set();

foreach (var groupName in groupTestResultBuilderMap.Keys)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public string TestCasesErrorMessage
{
get
{
return FailedCases.Count() == 0? "": $"Test Scenario:{ScenarioName} failed by test cases: {string.Join(',', FailedCases)}, Check the test case log for error details.";
return FailedCases.Count() == 0 ? "" : $"Test Scenario:{ScenarioName} failed by test cases: {string.Join(',', FailedCases)}, Check the test case log for error details.";
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions e2etest/GuestProxyAgentTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ static async Task Main(string[] args)
var testConfigFilePath = args[0];
var testResultFolder = args[1];
var guestProxyAgentZipFilePath = args[2];
var proxyAgentVersion = args[3];
var test_arm64 = false;
if (args.Length > 3 && args[3].Equals("arm64", StringComparison.InvariantCultureIgnoreCase))
if (args.Length > 4 && args[4].Equals("arm64", StringComparison.InvariantCultureIgnoreCase))
{
test_arm64 = true;
}


TestCommonUtilities.TestSetup(guestProxyAgentZipFilePath, testConfigFilePath, testResultFolder);
TestCommonUtilities.TestSetup(guestProxyAgentZipFilePath, testConfigFilePath, testResultFolder, proxyAgentVersion);

VMHelper.Instance.CleanupOldTestResourcesAndForget();

Expand Down
9 changes: 9 additions & 0 deletions e2etest/GuestProxyAgentTest/Settings/TestScenarioSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,14 @@ public class VMImageDetails
public string Offer { get; set; } = null!;
public string Sku { get; set; } = null!;
public string Version { get; set; } = null!;

public bool IsArm64
{
get
{
return (Offer == null ? false : Offer.Contains("arm64", StringComparison.OrdinalIgnoreCase)) ||
(Sku == null ? false : Sku.Contains("arm64", StringComparison.OrdinalIgnoreCase));
}
}
}
}
4 changes: 3 additions & 1 deletion e2etest/GuestProxyAgentTest/Settings/TestSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static TestSetting Instance
internal string zipFilePath = null!;
internal string sharedStorageAccountUrl = null!;
internal string testResultFolder = null!;
internal string proxyAgentVersion = null!;
internal int testMapTimeoutMilliseconds = 1000 * 60 * 180;
internal string windowsInVmWireServerAccessControlProfileReferenceId = null!;
internal string windowsInVmIMDSAccessControlProfileReferenceId = null!;
Expand All @@ -53,7 +54,7 @@ internal string InVmIMDSAccessControlProfileReferenceId

private TestSetting() { }

public static void Init(TestConfig testConfig, string zipFilePath, string testResultFolder)
public static void Init(TestConfig testConfig, string zipFilePath, string testResultFolder, string proxyAgentVersion)
{
var scriptsFolder = Constants.IS_WINDOWS() ? "Scripts" : "LinuxScripts";

Expand All @@ -78,6 +79,7 @@ public static void Init(TestConfig testConfig, string zipFilePath, string testRe
linuxInVmIMDSAccessControlProfileReferenceId = testConfig.LinuxInVmIMDSAccessControlProfileReferenceId,
zipFilePath = zipFilePath,
testResultFolder = testResultFolder,
proxyAgentVersion = proxyAgentVersion,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override async Task StartAsync(TestCaseExecutionContext context)
{
Location = GuestProxyAgentTest.Settings.TestSetting.Instance.location,
Publisher = "Microsoft.CPlat.ProxyAgent",
ExtensionType = "ProxyAgentLinuxTest",
ExtensionType = context.ScenarioSetting.VMImageDetails.IsArm64 ? "ProxyAgentLinuxARM64Test" : "ProxyAgentLinuxTest",
TypeHandlerVersion = "1.0",
AutoUpgradeMinorVersion = false,
EnableAutomaticUpgrade = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ scenarios:
name: BVTScenario
- name: LinuxPackageScenario
className: GuestProxyAgentTest.TestScenarios.LinuxPackageScenario
- name: ProxyAgentExtension
className: GuestProxyAgentTest.TestScenarios.ProxyAgentExtension
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ scenarios:
- className: GuestProxyAgentTest.TestScenarios.BVTScenario
name: BVTScenario
- name: LinuxPackageScenario
className: GuestProxyAgentTest.TestScenarios.LinuxPackageScenario
className: GuestProxyAgentTest.TestScenarios.LinuxPackageScenario
- name: ProxyAgentExtension
className: GuestProxyAgentTest.TestScenarios.ProxyAgentExtension
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ scenarios:
className: GuestProxyAgentTest.TestScenarios.BVTScenario
- name: BugFixesScenario
className: GuestProxyAgentTest.TestScenarios.BugFixesScenario
- name: ProxyAgentExtension
className: GuestProxyAgentTest.TestScenarios.ProxyAgentExtension

36 changes: 6 additions & 30 deletions e2etest/GuestProxyAgentTest/TestScenarios/ProxyAgentExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,23 @@ public override void TestScenarioSetup()
string zipFile = Settings.TestSetting.Instance.zipFilePath;
string withoutExt = Path.GetFileNameWithoutExtension(zipFile);
string extractPath = Path.Combine(Path.GetDirectoryName(zipFile), withoutExt);
string proxyAgentVersion = "";
string exePath = "";
try
{
ZipFile.ExtractToDirectory(zipFile, extractPath);
Console.WriteLine("Extraction successful!");
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
// Passing in 0 version number for the first validation case
string proxyAgentVersionBeforeUpdate = "0";
string proxyAgentVersion = Settings.TestSetting.Instance.proxyAgentVersion;
ConsoleLog(string.Format("Received ProxyAgent Version:{0}", proxyAgentVersion));

if (!Constants.IS_WINDOWS())
{
AddTestCase(new SetupCGroup2TestCase("SetupCGroup2"));
AddTestCase(new RebootVMCase("RebootVMCaseAfterSetupCGroup2"));
AddTestCase(new AddLinuxVMExtensionCase("AddLinuxVMExtensionCase"));
AddTestCase(new EnableProxyAgentCase());
exePath = extractPath + "/ProxyAgent/ProxyAgent/azure-proxy-agent";
}
else
{
EnableProxyAgentForNewVM = true;
exePath = extractPath + "\\ProxyAgent\\ProxyAgent\\GuestProxyAgent.exe";
}
var process = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = exePath,
Arguments = "--version",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
}
};
process.Start();
proxyAgentVersion = process.StandardOutput.ReadToEnd();
process.WaitForExit();
// Passing in 0 version number for the first validation case
string proxyAgentVersionBeforeUpdate = "0";

AddTestCase(new GuestProxyAgentExtensionValidationCase("GuestProxyAgentExtensionValidationCaseBeforeUpdate", proxyAgentVersionBeforeUpdate));
AddTestCase(new InstallOrUpdateGuestProxyAgentExtensionCase());
AddTestCase(new GuestProxyAgentExtensionValidationCase("GuestProxyAgentExtensionValidationCaseAfterUpdate", proxyAgentVersion));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ private string LogPrefix
{
get
{
return "Test Group: " + _testScenarioSetting.testGroupName + ", Test Scenario: " + _testScenarioSetting.testScenarioName + ": ";
// _testScenarioSetting may still null in constructor functions
return "Test Group: " + _testScenarioSetting?.testGroupName + ", Test Scenario: " + _testScenarioSetting?.testScenarioName + ": ";
}
}

Expand Down Expand Up @@ -153,6 +154,7 @@ private async Task DoStartAsync(TestScenarioStatusDetails testScenarioStatusDeta
var vmCreateTestName = "CreateVM";
try
{
ConsoleLog(string.Format("Creating {0} VM...", _testScenarioSetting.VMImageDetails.IsArm64 ? "ARM64" : "AMD64"));
vmr = await _vmBuilder.Build(this.EnableProxyAgentForNewVM, cancellationToken);
ConsoleLog("VM Create succeed");
sw.Stop();
Expand Down
11 changes: 3 additions & 8 deletions e2etest/GuestProxyAgentTest/Utilities/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MIT
using Azure.Core;
using Azure.ResourceManager.Network.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace GuestProxyAgentTest.Utilities
{
Expand All @@ -23,6 +16,8 @@ public static class Constants
public static readonly string RUNCOMMAND_ERROR_OUTPUT_FILE_NAME = "runCommandErr.txt";
public static readonly string RUNCOMMAND_CUSTOM_OUTPUT_SAS_PARAMETER_NAME = "customOutputJsonSAS";
public static readonly string COULD_CLEANUP_TAG_NAME = "CouldCleanup";
public static readonly string TAGS_ENFORCE_ARCHITECTURE_TYPE_FOR_EXTENSIONS = "EnforceArchitectureTypeForExtensions";
public static readonly string TAGS_MUST_NOT_REUSE_PREPROVISIONED_VM = "MustNotReusePreprovisionedVM";
public const string INSTALL_LINUX_GUEST_PROXY_AGENT_PACKAGE_SCRIPT_NAME = "InstallGuestProxyAgentPackage.sh";
public static readonly string GUEST_PROXY_AGENT_E2E_ACCESS_TOKEN_ENV = "GuestProxyAgentE2EAccessToken";
public static readonly string GUEST_PROXY_AGENT_E2E_ACCESS_TOKEN_STORAGE_ACCOUNT_ENV = "GuestProxyAgentE2EAccessTokenForStorageAccount";
Expand Down Expand Up @@ -59,7 +54,7 @@ static Constants()

public static bool IS_WINDOWS()
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
}
}
}
4 changes: 2 additions & 2 deletions e2etest/GuestProxyAgentTest/Utilities/TestCommonUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public static class TestCommonUtilities
/// <param name="guestProxyAgentZipFilePath"></param>
/// <param name="testConfigFilePath"></param>
/// <param name="testResultFolder"></param>
public static void TestSetup(string guestProxyAgentZipFilePath, string testConfigFilePath, string testResultFolder)
public static void TestSetup(string guestProxyAgentZipFilePath, string testConfigFilePath, string testResultFolder, string proxyAgentVersion)
{
TestSetting.Init(YamlUtils.DeserializeYaml<TestConfig>(testConfigFilePath), guestProxyAgentZipFilePath, testResultFolder);
TestSetting.Init(YamlUtils.DeserializeYaml<TestConfig>(testConfigFilePath), guestProxyAgentZipFilePath, testResultFolder, proxyAgentVersion);
StorageHelper.Init(TestSetting.Instance.tenantId, TestSetting.Instance.appClientId);
VMHelper.Init(TestSetting.Instance.tenantId, TestSetting.Instance.appClientId, TestSetting.Instance.subscriptionId);

Expand Down
9 changes: 8 additions & 1 deletion e2etest/GuestProxyAgentTest/Utilities/VMBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,14 @@ private async Task<VirtualMachineData> DoCreateVMData(ResourceGroupResource rgr,
Product = this.testScenarioSetting.VMImageDetails.Offer,
};
}


if (this.testScenarioSetting.VMImageDetails.IsArm64)
{
// workarounds to use ARM64 VM Extension
vmData.Tags.Add(Constants.TAGS_ENFORCE_ARCHITECTURE_TYPE_FOR_EXTENSIONS, "true");
vmData.Tags.Add(Constants.TAGS_MUST_NOT_REUSE_PREPROVISIONED_VM, "true");
}

return vmData;
}

Expand Down
Loading