diff --git a/smoke/IotEdgeQuickstart/Program.cs b/smoke/IotEdgeQuickstart/Program.cs index 43597344fb1..409ee25fd4a 100644 --- a/smoke/IotEdgeQuickstart/Program.cs +++ b/smoke/IotEdgeQuickstart/Program.cs @@ -42,8 +42,8 @@ Option Default value --eventhub-endpoint get the value from Key Vault --leave-running none (or 'all' if given as a switch) --password anonymous, or Key Vault if --registry is specified - --registry DockerHub (anonymous) - --tag '1.0-preview' + --registry mcr.microsoft.com (anonymous) + --tag '1.0' --use-http if --bootstrapper=iotedged then use Unix Domain Sockets, otherwise N/A switch form uses local IP address as hostname @@ -142,7 +142,7 @@ async Task OnExecuteAsync() string endpoint = this.EventHubCompatibleEndpointWithEntityPath ?? await SecretsHelper.GetSecretFromConfigKey("eventHubConnStrKey"); - string tag = this.ImageTag ?? "1.0-preview"; + string tag = this.ImageTag ?? "1.0"; var test = new Quickstart( bootstrapper, diff --git a/smoke/IotEdgeQuickstart/Quickstart.cs b/smoke/IotEdgeQuickstart/Quickstart.cs index 365374d2aae..608fc817b1a 100644 --- a/smoke/IotEdgeQuickstart/Quickstart.cs +++ b/smoke/IotEdgeQuickstart/Quickstart.cs @@ -67,13 +67,13 @@ public async Task RunAsync() if (this.leaveRunning == LeaveRunning.None) { await StopBootstrapper(); + await ResetBootstrapper(); } } finally { if (this.leaveRunning == LeaveRunning.None) { - await this.ResetBootstrapper(); // only remove the identity if we created it; if it already existed in IoT Hub then leave it alone await MaybeDeleteEdgeDeviceIdentity(); } diff --git a/smoke/IotEdgeQuickstart/details/Details.cs b/smoke/IotEdgeQuickstart/details/Details.cs index b4fff3fc1fc..f8a4559603a 100644 --- a/smoke/IotEdgeQuickstart/details/Details.cs +++ b/smoke/IotEdgeQuickstart/details/Details.cs @@ -4,7 +4,6 @@ namespace IotEdgeQuickstart.Details { using System; using System.Collections.Generic; - using System.Linq; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -272,23 +271,23 @@ protected Task MaybeDeleteEdgeDeviceIdentity() string EdgeAgentImage() { - return this.BuildImageName("microsoft/azureiotedge-agent"); + return this.BuildImageName("azureiotedge-agent"); } string EdgeHubImage() { - return this.BuildImageName("microsoft/azureiotedge-hub"); + return this.BuildImageName("azureiotedge-hub"); } string TempSensorImage() { - return this.BuildImageName("microsoft/azureiotedge-simulated-temperature-sensor"); + return this.BuildImageName("azureiotedge-simulated-temperature-sensor"); } string BuildImageName(string name) { - string registry = this.credentials.Match(c => $"{c.Address}/", () => string.Empty); - return $"{registry}{name}:{this.imageTag}"; + string prefix = this.credentials.Match(c => $"{c.Address}/microsoft", () => "mcr.microsoft.com"); + return $"{prefix}/{name}:{this.imageTag}"; } (string, string[]) DeploymentJson() @@ -317,6 +316,9 @@ string BuildImageName(string name) return (deployJson, new [] { edgeAgentImage, edgeHubImage, tempSensorImage }); } + // TODO: Remove Env (SSL_CERTIFICATE_PATH and SSL_CERTIFICATE_NAME) from + // modulesContent.$edgeAgent.systemModules.edgeHub.settings.createOptions + // once Azure/iot-edge-v1#632 is fixed and available on mcr.microsoft.com const string DeployJson = @" { ""modulesContent"": { @@ -344,7 +346,7 @@ string BuildImageName(string name) ""restartPolicy"": ""always"", ""settings"": { ""image"": """", - ""createOptions"": ""{\""HostConfig\"":{\""PortBindings\"":{\""8883/tcp\"":[{\""HostPort\"":\""8883\""}],\""443/tcp\"":[{\""HostPort\"":\""443\""}]}}}"" + ""createOptions"": ""{\""HostConfig\"":{\""PortBindings\"":{\""8883/tcp\"":[{\""HostPort\"":\""8883\""}],\""443/tcp\"":[{\""HostPort\"":\""443\""}]}},\""Env\"":[\""SSL_CERTIFICATE_PATH=/mnt/edgehub\"",\""SSL_CERTIFICATE_NAME=edge-hub-server.cert.pfx\""]}"" } } }, diff --git a/smoke/IotEdgeQuickstart/details/Iotedgectl.cs b/smoke/IotEdgeQuickstart/details/Iotedgectl.cs index 94bbb1b50df..1aa25592044 100644 --- a/smoke/IotEdgeQuickstart/details/Iotedgectl.cs +++ b/smoke/IotEdgeQuickstart/details/Iotedgectl.cs @@ -56,7 +56,7 @@ public async Task VerifyModuleIsRunning(string name) $"ps --quiet --filter \"name = {name}\"", cts.Token); - if (status.First().Trim() != string.Empty) break; + if (!string.IsNullOrWhiteSpace(status.FirstOrDefault())) break; errorMessage = "Not found"; } @@ -86,7 +86,7 @@ public Task Install() public async Task Configure(string connectionString, string image, string hostname) { - Console.WriteLine($"Setting up iotedgectl with container registry '{this.credentials.Match(c => c.Address, () => "")}'"); + Console.WriteLine($"Setting up iotedgectl with agent image '{image}'"); string registryArgs = this.credentials.Match( c => $"--docker-registries {c.Address} {c.User} {c.Password}", diff --git a/smoke/IotEdgeQuickstart/details/Iotedged.cs b/smoke/IotEdgeQuickstart/details/Iotedged.cs index 6a3f11ae287..ef83292c41f 100644 --- a/smoke/IotEdgeQuickstart/details/Iotedged.cs +++ b/smoke/IotEdgeQuickstart/details/Iotedged.cs @@ -3,11 +3,9 @@ namespace IotEdgeQuickstart.Details { using System; - using System.ComponentModel; using System.IO; using System.Linq; using System.Net; - using System.Net.NetworkInformation; using System.Net.Sockets; using System.Threading; using System.Threading.Tasks; @@ -15,8 +13,8 @@ namespace IotEdgeQuickstart.Details public class HttpUris { - const int managementPort = 15580; - const int workloadPort = 15581; + const int ManagementPort = 15580; + const int WorkloadPort = 15581; public string ConnectManagement { get; } public string ConnectWorkload { get; } @@ -27,10 +25,10 @@ public HttpUris() : this(GetIpAddress()) {} public HttpUris(string hostname) { - this.ConnectManagement = $"http://{hostname}:{managementPort}"; - this.ConnectWorkload = $"http://{hostname}:{workloadPort}"; - this.ListenManagement = $"http://0.0.0.0:{managementPort}"; - this.ListenWorkload = $"http://0.0.0.0:{workloadPort}"; + this.ConnectManagement = $"http://{hostname}:{ManagementPort}"; + this.ConnectWorkload = $"http://{hostname}:{WorkloadPort}"; + this.ListenManagement = $"http://0.0.0.0:{ManagementPort}"; + this.ListenWorkload = $"http://0.0.0.0:{WorkloadPort}"; } static string GetIpAddress() @@ -39,20 +37,20 @@ static string GetIpAddress() // of the public-facing address. The output of this command would be // a good candidate: // docker network inspect --format='{{(index .IPAM.Config 0).Gateway}}' bridge - const string server = "microsoft.com"; - const int port = 443; + const string Server = "microsoft.com"; + const int Port = 443; - IPHostEntry entry = Dns.GetHostEntry(server); + IPHostEntry entry = Dns.GetHostEntry(Server); foreach (IPAddress address in entry.AddressList) { - IPEndPoint endpoint = new IPEndPoint(address, port); - using (Socket s = new Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) + var endpoint = new IPEndPoint(address, Port); + using (var s = new Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) { s.Connect(endpoint); if (s.Connected) { - return (s.LocalEndPoint as IPEndPoint).Address.ToString(); + return (s.LocalEndPoint as IPEndPoint)?.Address.ToString(); } } } @@ -104,7 +102,7 @@ public async Task VerifyModuleIsRunning(string name) $"{options}list", cts.Token); - var status = result + string status = result .Where(ln => ln.Split(null as char[], StringSplitOptions.RemoveEmptyEntries).First() == name) .DefaultIfEmpty("name status") .Single() @@ -141,7 +139,7 @@ public Task Install() public async Task Configure(string connectionString, string image, string hostname) { - Console.WriteLine($"Setting up iotedged with container registry '{this.credentials.Match(c => c.Address, () => "")}'"); + Console.WriteLine($"Setting up iotedged with agent image '{image}'"); const string YamlPath = "/etc/iotedge/config.yaml"; Task text = File.ReadAllTextAsync(YamlPath); @@ -158,22 +156,21 @@ public async Task Configure(string connectionString, string image, string hostna doc.Replace("agent.config.auth.password", c.Password); } - this.httpUris.Match( - some: uris => { - doc.Replace("connect.management_uri", uris.ConnectManagement); - doc.Replace("connect.workload_uri", uris.ConnectWorkload); - doc.Replace("listen.management_uri", uris.ListenManagement); - doc.Replace("listen.workload_uri", uris.ListenWorkload); - return 0; - }, - none: () => { - doc.Replace("connect.management_uri", "unix:///var/run/iotedge/mgmt.sock"); - doc.Replace("connect.workload_uri", "unix:///var/run/iotedge/workload.sock"); - doc.Replace("listen.management_uri", "fd://iotedge.mgmt.socket"); - doc.Replace("listen.workload_uri", "fd://iotedge.socket"); - return 0; - } - ); + if (this.httpUris.HasValue) + { + HttpUris uris = this.httpUris.OrDefault(); + doc.Replace("connect.management_uri", uris.ConnectManagement); + doc.Replace("connect.workload_uri", uris.ConnectWorkload); + doc.Replace("listen.management_uri", uris.ListenManagement); + doc.Replace("listen.workload_uri", uris.ListenWorkload); + } + else + { + doc.Replace("connect.management_uri", "unix:///var/run/iotedge/mgmt.sock"); + doc.Replace("connect.workload_uri", "unix:///var/run/iotedge/workload.sock"); + doc.Replace("listen.management_uri", "fd://iotedge.mgmt.socket"); + doc.Replace("listen.workload_uri", "fd://iotedge.socket"); + } string result = doc.ToString(); diff --git a/smoke/docker/linux/amd64/Dockerfile b/smoke/docker/linux/amd64/Dockerfile index b2522ddc4dd..e33a9a267c4 100644 --- a/smoke/docker/linux/amd64/Dockerfile +++ b/smoke/docker/linux/amd64/Dockerfile @@ -6,6 +6,8 @@ RUN apt-get update && \ apt-get --yes --no-install-recommends install \ # .NET Core dependencies, see https://github.com/dotnet/dotnet-docker/blob/d5c80ab/2.1/runtime-deps/bionic/amd64/Dockerfile libc6 libgcc1 libgssapi-krb5-2 libicu60 liblttng-ust0 libssl1.0.0 libstdc++6 zlib1g \ + # Used when adding Microsoft's repository to the Apt sources list (when installing iotedged) + curl \ # Needed to install iotedged ca-certificates \ # Needed to get the IP address used for iotedged's management endpoint