Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ccbf
cicd
cimv
cla
closehandle
cmds
codeofconduct
codeql
Expand Down Expand Up @@ -120,6 +121,7 @@ gpalinuxdev
gpawindev
guestproxyagentmsis
guiddef
handleapi
hklm
hlist
hostga
Expand Down Expand Up @@ -195,6 +197,7 @@ ntdll
NTSTATUS
onscreen
onebranch
openprocess
oneshot
opencode
opensource
Expand All @@ -210,8 +213,10 @@ pprev
prandom
predef
prefmaxlen
preprovisioned
printk
PROCESSINFOCLASS
processthreadsapi
proxyagent
proxyagentextensionvalidation
proxyagentvalidation
Expand Down Expand Up @@ -342,6 +347,7 @@ wireserver
wireserverand
wireserverandimds
WMI
workarounds
WORKDIR
WScript
wsf
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ xcopy /Y %out_dir%\proxy_agent_setup.pdb %out_package_dir%\

echo ======= copy to ProxyAgent folder
xcopy /Y %out_dir%\azure-proxy-agent.exe %out_package_proxyagent_dir%\GuestProxyAgent.exe*
xcopy /Y %out_dir%\azure_proxy_agent.pdb %out_package_proxyagent_dir%\GuestProxyAgent.pdb*
REM do NOT rename pdb file, as it is used by the debugger to load the symbols automatically
xcopy /Y %out_dir%\azure_proxy_agent.pdb %out_package_proxyagent_dir%\
xcopy /Y %out_dir%\GuestProxyAgent.json %out_package_proxyagent_dir%\

SET out_package_proxyagent_extension_dir=%out_package_dir%\ProxyAgent_Extension
Expand All @@ -254,7 +255,7 @@ for %%F in (%extension_src_path%\*.cmd) do (
echo Found file: %%F
xcopy /Y %%F %out_package_proxyagent_extension_dir%\
)
xcopy /Y %out_dir%\ProxyAgentExt.exe %out_package_proxyagent_extension_dir%\
xcopy /Y %out_dir%\ProxyAgentExt.* %out_package_proxyagent_extension_dir%\

echo ======= copy e2e test project to Package folder
SET out_package_e2etest_dir=%out_package_dir%\e2etest
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
2 changes: 1 addition & 1 deletion proxy_agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "azure-proxy-agent"
version = "1.0.35" # always 3-number version
version = "1.0.36" # always 3-number version
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
4 changes: 4 additions & 0 deletions proxy_agent/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ impl Process {
println!("Failed to query basic process info: {e}");
}
}
// close the handle
if let Err(e) = windows::close_process_handler(handler) {
println!("Failed to close process handler: {e}");
}
}
#[cfg(not(windows))]
{
Expand Down
Loading
Loading