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

Publish end-to-end tests as a standalone executable #7342

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion test/Microsoft.Azure.Devices.Edge.Test.Common/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace Microsoft.Azure.Devices.Edge.Test.Common
using System.IO;
using System.Linq;
using System.Net;
using Microsoft.Azure.Devices.Edge.Test.Common;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Configuration;

Expand Down
6 changes: 3 additions & 3 deletions test/Microsoft.Azure.Devices.Edge.Test.Common/EdgeLogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ public static class EdgeLogs
{
// Make an effort to collect logs, but swallow any exceptions to prevent tests/fixtures
// from failing if this function fails.
public static async Task<IEnumerable<string>> CollectAsync(DateTime testStartTime, string filePrefix, IotedgeCli cli, CancellationToken token)
public static async Task<IEnumerable<string>> CollectAsync(DateTime testStartTime, string filePrefix, CancellationToken token)
{
var paths = new List<string>();

// Save module logs
try
{
string[] output = await cli.RunAsync("list", token);
string[] output = await Process.RunAsync("iotedge", "list", token);
string[] modules = output.Select(ln => ln.Split(null as char[], StringSplitOptions.RemoveEmptyEntries).First()).Skip(1).ToArray();

foreach (string name in modules)
{
string moduleLog = $"{filePrefix}-{name}.log";
output = await cli.RunAsync($"logs {name}", token, logCommand: true, logOutput: false);
output = await Process.RunAsync("iotedge", $"logs {name}", token, logCommand: true, logOutput: false);
await File.WriteAllLinesAsync(moduleLog, output, token);
paths.Add(moduleLog);
}
Expand Down
8 changes: 4 additions & 4 deletions test/Microsoft.Azure.Devices.Edge.Test.Common/EdgeModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public EdgeModule(string id, string deviceId, IotHub iotHub)
this.iotHub = iotHub;
}

public static Task WaitForStatusAsync(IEnumerable<EdgeModule> modules, EdgeModuleStatus desired, IotedgeCli cli, CancellationToken token)
public static Task WaitForStatusAsync(IEnumerable<EdgeModule> modules, EdgeModuleStatus desired, CancellationToken token)
{
string[] moduleIds = modules.Select(m => m.Id.TrimStart('$')).Distinct().ToArray();

Expand All @@ -45,7 +45,7 @@ async Task WaitForStatusAsync()
await Retry.Do(
async () =>
{
string[] output = await cli.RunAsync("list", token);
string[] output = await Process.RunAsync("iotedge", "list", token);

return output
.Where(
Expand Down Expand Up @@ -89,8 +89,8 @@ static bool DaemonNotReady(string details) =>
desired.ToString().ToLower());
}

public Task WaitForStatusAsync(EdgeModuleStatus desired, IotedgeCli cli, CancellationToken token) =>
WaitForStatusAsync(new[] { this }, desired, cli, token);
public Task WaitForStatusAsync(EdgeModuleStatus desired, CancellationToken token) =>
WaitForStatusAsync(new[] { this }, desired, token);

public Task<string> WaitForEventsReceivedAsync(
DateTime seekTime,
Expand Down
9 changes: 3 additions & 6 deletions test/Microsoft.Azure.Devices.Edge.Test.Common/EdgeRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ namespace Microsoft.Azure.Devices.Edge.Test.Common
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -40,7 +38,6 @@ public EdgeRuntime(string deviceId, Option<string> agentImage, Option<string> hu
// receive it and start up all the modules.
public async Task<EdgeDeployment> DeployConfigurationAsync(
Action<EdgeConfigBuilder> addConfig,
IotedgeCli cli,
CancellationToken token,
bool nestedEdge)
{
Expand Down Expand Up @@ -79,12 +76,12 @@ public async Task<EdgeDeployment> DeployConfigurationAsync(
EdgeModule[] modules = edgeConfiguration.ModuleNames
.Select(id => new EdgeModule(id, this.DeviceId, this.iotHub))
.ToArray();
await EdgeModule.WaitForStatusAsync(modules, EdgeModuleStatus.Running, cli, token);
await EdgeModule.WaitForStatusAsync(modules, EdgeModuleStatus.Running, token);
await edgeConfiguration.VerifyAsync(this.iotHub, token);
return new EdgeDeployment(deployTime, modules);
}

public Task<EdgeDeployment> DeployConfigurationAsync(IotedgeCli cli, CancellationToken token, bool nestedEdge) =>
this.DeployConfigurationAsync(_ => { }, cli, token, nestedEdge);
public Task<EdgeDeployment> DeployConfigurationAsync(CancellationToken token, bool nestedEdge) =>
this.DeployConfigurationAsync(_ => { }, token, nestedEdge);
}
}
2 changes: 0 additions & 2 deletions test/Microsoft.Azure.Devices.Edge.Test.Common/IEdgeDaemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@ Task ConfigureAsync(
Task UninstallAsync(CancellationToken token);

string GetCertificatesPath();

IotedgeCli GetCli();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ public interface IServiceManager
Task StopAsync(CancellationToken token);
Task ConfigureAsync(CancellationToken token);
string ConfigurationPath();
string GetCliName();
}
}
36 changes: 0 additions & 36 deletions test/Microsoft.Azure.Devices.Edge.Test.Common/IotedgeCli.cs

This file was deleted.

2 changes: 0 additions & 2 deletions test/Microsoft.Azure.Devices.Edge.Test.Common/LeafDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Devices.Edge.Test.Common
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
Expand All @@ -17,7 +16,6 @@ namespace Microsoft.Azure.Devices.Edge.Test.Common
using Microsoft.Azure.Devices.Edge.Test.Common.Certs;
using Microsoft.Azure.Devices.Edge.Test.Common.Config;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Edge.Util.TransientFaultHandling;
using Serilog;

public class LeafDevice
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
namespace Microsoft.Azure.Devices.Edge.Test.Common.Certs
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography.X509Certificates;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
namespace Microsoft.Azure.Devices.Edge.Test.Common.Certs
{
using System.IO;

public sealed class FixedPaths
{
public sealed class DeviceIdentityCert
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
namespace Microsoft.Azure.Devices.Edge.Test.Common.Certs
{
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Edge.Test.Common;
Expand Down
16 changes: 10 additions & 6 deletions test/Microsoft.Azure.Devices.Edge.Test.Common/linux/EdgeDaemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ void ThrowUnsupportedOs() =>
? SupportedPackageExtension.Snap
: SupportedPackageExtension.Deb;
break;
case "ubuntu-core":
if (!detectedSnap)
{
throw new ArgumentException(
"packagesPath parameter is required on Ubuntu Core, and it must point to snap packages");
}

packageExtension = SupportedPackageExtension.Snap;
break;
case "debian":
if (version != "11")
{
Expand Down Expand Up @@ -182,7 +191,7 @@ async Task InternalStartAsync(CancellationToken token)
await Retry.Do(
async () =>
{
string[] output = await this.GetCli().RunAsync("list", token);
string[] output = await Process.RunAsync("iotedge", "list", token);
return output;
},
output => true,
Expand Down Expand Up @@ -245,10 +254,5 @@ await Profiler.Run(
}

public string GetCertificatesPath() => this.certsPath;

public IotedgeCli GetCli()
{
return new IotedgeCli(this.serviceManager.GetCliName());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public string[] GetInstallCommandsFromLocal(string path)
"snap connect azure-iot-edge:run-iotedge",
"snap connect azure-iot-edge:aziotctl-executables azure-iot-identity:aziotctl-executables",
"snap connect azure-iot-edge:identity-service azure-iot-identity:identity-service",
"snap connect azure-iot-edge:docker docker:docker-daemon"
"snap connect azure-iot-edge:docker docker:docker-daemon",
"snap alias azure-iot-edge.iotedge iotedge"
},
_ => throw new NotImplementedException($"Don't know how to install daemon on for '.{this.PackageExtension}'"),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ await Process.RunAsync(

public string ConfigurationPath() =>
"/var/snap/azure-iot-identity/current/shared/config/aziot/config-e2e.toml";
public string GetCliName() => "azure-iot-edge.iotedge";

async Task WaitForStatusAsync(ServiceStatus desired, CancellationToken token)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace Microsoft.Azure.Devices.Edge.Test.Common.Linux
{
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -35,7 +34,6 @@ public async Task ConfigureAsync(CancellationToken token)
}

public string ConfigurationPath() => "/etc/aziot/config.toml";
public string GetCliName() => "iotedge";

async Task WaitForStatusAsync(ServiceStatus desired, CancellationToken token)
{
Expand Down
Loading
Loading