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
4 changes: 3 additions & 1 deletion .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 (378) than unique words (1) (total: 379 / 1). (noisy-file)
AAFFBB
aarch
abe
Expand Down Expand Up @@ -100,7 +100,7 @@
examplevmname
exthandlers
fde
FFF
fff
FFFF
FFFFFFFF
fffi
Expand Down Expand Up @@ -211,6 +211,7 @@
pgrep
pidof
pkgversion
pls
portaddr
portpair
postinst
Expand Down Expand Up @@ -319,6 +320,7 @@
unregisters
unspec
uzers
VCpus
vcruntime
vendored
vflji
Expand Down Expand Up @@ -375,3 +377,3 @@
xxxx
xxxxxxxx
xxxxxxxxxxx
Expand Down
8 changes: 4 additions & 4 deletions e2etest/GuestProxyAgentTest/Extensions/ModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace GuestProxyAgentTest.Extensions
/// </summary>
public static class ModelExtensions
{
public static TestCaseResultDetails ToTestResultDetails(this RunCommandOutputDetails runCommandOutputDetails, Action<string> logger = null!, bool downloadContentFromBlob = true)
public static TestCaseResultDetails ToTestResultDetails(this RunCommandOutputDetails runCommandOutputDetails, TestLogger logger = null!, bool downloadContentFromBlob = true)
{
return new TestCaseResultDetails
{
Expand All @@ -24,7 +24,7 @@ public static TestCaseResultDetails ToTestResultDetails(this RunCommandOutputDet
}.DownloadContentIfFromBlob(logger);
}

public static TestCaseResultDetails DownloadContentIfFromBlob(this TestCaseResultDetails testCaseResultDetails, Action<string> logger = null!)
public static TestCaseResultDetails DownloadContentIfFromBlob(this TestCaseResultDetails testCaseResultDetails, TestLogger logger = null!)
{
if(!testCaseResultDetails.FromBlob)
{
Expand Down Expand Up @@ -96,15 +96,15 @@ public static void WriteJUnitTestResult(this TestCaseResultDetails testCaseResul
/// <typeparam name="T"></typeparam>
/// <param name="testCaseResultDetails"></param>
/// <returns></returns>
public static T SafeDeserializedCustomOutAs<T>(this TestCaseResultDetails testCaseResultDetails) where T: class
public static T SafeDeserializedCustomOutAs<T>(this TestCaseResultDetails testCaseResultDetails, TestLogger logger) where T: class
{
try
{
return JsonConvert.DeserializeObject<T>(testCaseResultDetails.CustomOut);
}
catch (Exception ex)
{
Console.WriteLine("Deserialized custom out json string failed with exception: " + ex.ToString());
logger.Log("Deserialized custom out json string failed with exception: " + ex.ToString());
}
return null;
}
Expand Down
16 changes: 11 additions & 5 deletions e2etest/GuestProxyAgentTest/GuestProxyAgentScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ namespace GuestProxyAgentTest
/// </summary>
public class GuestProxyAgentScenarioTests
{
private readonly TestLogger logger;
public GuestProxyAgentScenarioTests(TestLogger logger)
{
this.logger = logger;
}

/// <summary>
/// Main function to start each scenario test
/// </summary>
Expand Down Expand Up @@ -74,7 +80,7 @@ public async Task StartAsync(List<TestScenarioSetting> testScenarioList)
var message = string.Format("Test Group: {0}, Test Scenario: {1}: {2} ({3})"
, testScenario.testGroupName, testScenario.testScenarioName
, testScenarioStatusDetails.Result, testScenarioStatusDetails.ErrorMessage);
Console.WriteLine(message);
logger.Log(message);
}
}
var stopMonitor = new ManualResetEvent(false);
Expand All @@ -92,14 +98,14 @@ public async Task StartAsync(List<TestScenarioSetting> testScenarioList)
}
catch (Exception ex)
{
Console.WriteLine($"Test execution exception: {ex.Message}");
logger.Log($"Test execution exception: {ex.Message}");
}

stopMonitor.Set();

foreach (var groupName in groupTestResultBuilderMap.Keys)
{
Console.WriteLine("building test result report for test group: " + groupName);
logger.Log("building test result report for test group: " + groupName);
groupTestResultBuilderMap[groupName].Build();
}

Expand All @@ -114,7 +120,7 @@ private void ConsolePrintTestScenariosStatusSummary(IEnumerable<TestScenarioStat
$", running {testScenarioStatusDetailsList.Where(x => x.Status == ScenarioTestStatus.Running).Count()}" +
$", failed {testScenarioStatusDetailsList.Where(x => x.Status == ScenarioTestStatus.Completed && x.Result == ScenarioTestResult.Failed).Count()}" +
$", success {testScenarioStatusDetailsList.Where(x => x.Status == ScenarioTestStatus.Completed && x.Result == ScenarioTestResult.Succeed).Count()}. ";
Console.WriteLine(message);
logger.Log(message);
}

private void ConsolePrintTestScenariosDetailsSummary(IEnumerable<TestScenarioStatusDetails> testScenariosStatusDetailsList)
Expand All @@ -130,7 +136,7 @@ private void ConsolePrintTestScenariosDetailsSummary(IEnumerable<TestScenarioSta
+ $"Failed Test Cases Summary: {fc.TestCasesErrorMessage}" + Environment.NewLine;
i++;
}
Console.WriteLine(message);
logger.Log(message);
}
}
}
7 changes: 4 additions & 3 deletions e2etest/GuestProxyAgentTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Program
/// </param>
static async Task Main(string[] args)
{
TestLogger logger = new TestLogger("GuestProxyAgentTests");
var testConfigFilePath = args[0];
var testResultFolder = args[1];
var guestProxyAgentZipFilePath = args[2];
Expand All @@ -29,14 +30,14 @@ static async Task Main(string[] args)
{
test_arm64 = true;
}


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

VMHelper.Instance.CleanupOldTestResourcesAndForget();

await new GuestProxyAgentScenarioTests().StartAsync(TestMapReader.ReadFlattenTestScenarioSettingFromTestMap(test_arm64));
Console.WriteLine("E2E Test run completed.");
await new GuestProxyAgentScenarioTests(logger).StartAsync(TestMapReader.ReadFlattenTestScenarioSettingFromTestMap(test_arm64));
logger.Log("E2E Test run completed.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,16 @@ if ($guestProxyAgentExtensionVersion) {
$proxyAgentStatus = $json.status.substatus[1].formattedMessage.message
$jsonObject = $proxyAgentStatus | ConvertFrom-json
$extractedVersion = $jsonObject.version
# Compare the extracted version with the version obtained from the executable
if ($extractedVersion -ne $proxyAgentVersion) {
Write-Output "$((Get-Date).ToUniversalTime()) - Error, the proxy agent version [ $extractedVersions ] does not match the version [ $proxyAgentVersion ]"
Write-Output "$((Get-Date).ToUniversalTime()) - Error, the proxy agent version [ $extractedVersion ] does not match the version [ $proxyAgentVersion ]"
$guestProxyAgentExtensionVersion = $false
}
if ($expectedProxyAgentVersion -ne "0") {
$cleanExpectedProxyAgentVersion = $expectedProxyAgentVersion.Trim()
if ($extractedVersion -eq $cleanExpectedProxyAgentVersion){
# Compare only the major, minor, and patch versions, ignoring any additional labels
# as the inputted expectedProxyAgentVersion only contains 3 parts, but the extractedVersion, it is file version, starts to have 4 parts in windows
if (([System.Version]$extractedVersion).ToString(3) -eq ([System.Version]$cleanExpectedProxyAgentVersion).ToString(3)){
Write-Output "$((Get-Date).ToUniversalTime()) - After Update Version check: The proxy agent version matches the expected and extracted version"
} else {
Write-Output "$((Get-Date).ToUniversalTime()) - After Update Version check: Error, the proxy agent version [ $extractedVersion ] does not match expected version [ $cleanExpectedProxyAgentVersion ]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public override async Task StartAsync(TestCaseExecutionContext context)
{
List<(string, string)> parameterList = new List<(string, string)>();
parameterList.Add(("expectedProxyAgentVersion", expectedProxyAgentVersion));
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, Constants.GUEST_PROXY_AGENT_EXTENSION_VALIDATION_SCRIPT_NAME, parameterList)).ToTestResultDetails(ConsoleLog);
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, Constants.GUEST_PROXY_AGENT_EXTENSION_VALIDATION_SCRIPT_NAME, parameterList)).ToTestResultDetails(context.Logger);
if (context.TestResultDetails.Succeed && context.TestResultDetails.CustomOut != null)
{
var validationDetails = context.TestResultDetails.SafeDeserializedCustomOutAs<GuestProxyAgentExtensionValidationDetails>();
var validationDetails = context.TestResultDetails.SafeDeserializedCustomOutAs<GuestProxyAgentExtensionValidationDetails>(context.Logger);
if (validationDetails != null
&& validationDetails.guestProxyAgentExtensionServiceExist
&& validationDetails.guestProxyAgentExtensionProcessExist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public override async Task StartAsync(TestCaseExecutionContext context)
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, "GuestProxyAgentLoadedModulesValidation.ps1", new List<(string, string)>
{
("loadedModulesBaseLineSAS", System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(baseLineModulesSas)))
})).ToTestResultDetails(ConsoleLog);
})).ToTestResultDetails(context.Logger);

if (context.TestResultDetails.Succeed && context.TestResultDetails.CustomOut != null)
{
var validationDetails = context.TestResultDetails.SafeDeserializedCustomOutAs<LoadedModulesValidationDetails>();
var validationDetails = context.TestResultDetails.SafeDeserializedCustomOutAs<LoadedModulesValidationDetails>(context.Logger);
// if the validation result is match or no new added modules, then consider the case as succeed.
if (validationDetails != null
&& (validationDetails.IsMatch || validationDetails.NewAddedModules == null || validationDetails.NewAddedModules.Count == 0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public override async Task StartAsync(TestCaseExecutionContext context)
{
List<(string, string)> parameterList = new List<(string, string)>();
parameterList.Add(("expectedSecureChannelState", expectedSecureChannelState));
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, Constants.GUEST_PROXY_AGENT_VALIDATION_SCRIPT_NAME, parameterList)).ToTestResultDetails(ConsoleLog);
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, Constants.GUEST_PROXY_AGENT_VALIDATION_SCRIPT_NAME, parameterList)).ToTestResultDetails(context.Logger);
if (context.TestResultDetails.Succeed && context.TestResultDetails.CustomOut != null)
{
var validationDetails = context.TestResultDetails.SafeDeserializedCustomOutAs<GuestProxyAgentValidationDetails>();
var validationDetails = context.TestResultDetails.SafeDeserializedCustomOutAs<GuestProxyAgentValidationDetails>(context.Logger);
// check the validation json output, if the guest proxy agent service was installed and runing and guest proxy agent process exists and log was generate,
// then consider it as succeed, otherwise fail the case.
if (validationDetails != null
Expand Down
2 changes: 1 addition & 1 deletion e2etest/GuestProxyAgentTest/TestCases/IMDSPingTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override async Task StartAsync(TestCaseExecutionContext context)
{
List<(string, string)> parameterList = new List<(string, string)>();
parameterList.Add(("imdsSecureChannelEnabled", ImdsSecureChannelEnabled.ToString()));
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, Constants.IMDS_PING_TEST_SCRIPT_NAME, parameterList, false)).ToTestResultDetails(ConsoleLog);
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, Constants.IMDS_PING_TEST_SCRIPT_NAME, parameterList, false)).ToTestResultDetails(context.Logger);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public InstallOrUpdateGuestProxyAgentCase() : base("InstallOrUpdateGuestProxyAge

public override async Task StartAsync(TestCaseExecutionContext context)
{
var runCommandRes = await RunCommandRunner.ExecuteRunCommandOnVM(context.VirtualMachineResource, new RunCommandSettingBuilder()
var runCommandRes = await RunCommandRunner.ExecuteRunCommandOnVM(context.Logger, context.VirtualMachineResource, new RunCommandSettingBuilder()
.TestScenarioSetting(context.ScenarioSetting)
.RunCommandName("InstallOrUpdateProxyAgentMsi")
.ScriptFullPath(Path.Combine(TestSetting.Instance.scriptsFolder, Constants.INSTALL_GUEST_PROXY_AGENT_SCRIPT_NAME))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public InstallOrUpdateGuestProxyAgentExtensionCase() : base("InstallOrUpdateGues

public override async Task StartAsync(TestCaseExecutionContext context)
{
var runCommandRes = await RunCommandRunner.ExecuteRunCommandOnVM(context.VirtualMachineResource, new RunCommandSettingBuilder()
var runCommandRes = await RunCommandRunner.ExecuteRunCommandOnVM(context.Logger, context.VirtualMachineResource, new RunCommandSettingBuilder()
.TestScenarioSetting(context.ScenarioSetting)
.RunCommandName("InstallGuestProxyAgentExtension")
.ScriptFullPath(Path.Combine(TestSetting.Instance.scriptsFolder, Constants.INSTALL_GUEST_PROXY_AGENT_EXTENSION_SCRIPT_NAME))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public InstallOrUpdateGuestProxyAgentPackageCase() : base("InstallOrUpdateGuestP

public override async Task StartAsync(TestCaseExecutionContext context)
{
var runCommandRes = await RunCommandRunner.ExecuteRunCommandOnVM(context.VirtualMachineResource, new RunCommandSettingBuilder()
var runCommandRes = await RunCommandRunner.ExecuteRunCommandOnVM(context.Logger, context.VirtualMachineResource, new RunCommandSettingBuilder()
.TestScenarioSetting(context.ScenarioSetting)
.RunCommandName("InstallOrUpdateProxyAgentPackage")
.ScriptFullPath(Path.Combine(TestSetting.Instance.scriptsFolder, Constants.INSTALL_LINUX_GUEST_PROXY_AGENT_PACKAGE_SCRIPT_NAME))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override async Task StartAsync(TestCaseExecutionContext context)
{
List<(string, string)> parameterList = new List<(string, string)>();
parameterList.Add(("imdsSecureChannelEnabled", ImdsSecureChannelEnabled.ToString()));
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, "PingTestOnBindingLocalIP.ps1", parameterList, false)).ToTestResultDetails(ConsoleLog);
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, "PingTestOnBindingLocalIP.ps1", parameterList, false)).ToTestResultDetails(context.Logger);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public TCPPortScalabilityCase(bool imdsSecureChannelEnabled) : base("TCPPortScal

public override async Task StartAsync(TestCaseExecutionContext context)
{
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, "ConfigTCPPortScalability.ps1", null!, false)).ToTestResultDetails(ConsoleLog);
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, "ConfigTCPPortScalability.ps1", null!, false)).ToTestResultDetails(context.Logger);
if(!context.TestResultDetails.Succeed)
{
return;
Expand All @@ -26,7 +26,7 @@ public override async Task StartAsync(TestCaseExecutionContext context)
await vmr.RestartAsync(Azure.WaitUntil.Completed);
List<(string, string)> parameterList = new List<(string, string)>();
parameterList.Add(("imdsSecureChannelEnabled", ImdsSecureChannelEnabled.ToString()));
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, "IMDSPingTest.ps1", parameterList, false)).ToTestResultDetails(ConsoleLog);
context.TestResultDetails = (await RunScriptViaRunCommandV2Async(context, "IMDSPingTest.ps1", parameterList, false)).ToTestResultDetails(context.Logger);
}
}
}
6 changes: 2 additions & 4 deletions e2etest/GuestProxyAgentTest/TestCases/TestCaseBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ protected async Task<RunCommandOutputDetails> RunScriptViaRunCommandV2Async(Test
if (includeCustomJsonOutputSasParam)
{
var custJsonPath = Path.Combine(Path.GetTempPath(), $"{testScenarioSetting.testGroupName}_{testScenarioSetting.testScenarioName}_{TestCaseName}.json");
using (File.CreateText(custJsonPath)) ConsoleLog("Created empty test file for customized json output file.");
using (File.CreateText(custJsonPath)) context.Logger.Log("Created empty test file for customized json output file.");
custJsonSas = StorageHelper.Instance.Upload2SharedBlob(Constants.SHARED_E2E_TEST_OUTPUT_CONTAINER_NAME, custJsonPath, "customOutputJson.json", testScenarioSetting.TestScenarioStorageFolderPrefix);
}
return await RunCommandRunner.ExecuteRunCommandOnVM(context.VirtualMachineResource, new RunCommandSettingBuilder()
return await RunCommandRunner.ExecuteRunCommandOnVM(context.Logger, context.VirtualMachineResource, new RunCommandSettingBuilder()
.TestScenarioSetting(testScenarioSetting)
.RunCommandName(TestCaseName)
.ScriptFullPath(Path.Combine(TestSetting.Instance.scriptsFolder, scriptFileName))
Expand All @@ -78,8 +78,6 @@ protected async Task<RunCommandOutputDetails> RunScriptViaRunCommandV2Async(Test
.AddParameters(parameterList));
}

protected void ConsoleLog(string message) { Console.WriteLine($"[{TestCaseName}]: " + message); }

protected string FormatVMExtensionData(VirtualMachineExtensionData data)
{
if (data == null)
Expand Down
Loading
Loading