private async Task <TestCaseFinishedArgs> HandleFinished(string containerId) { var console = containers[containerId].console; console.CloseStream(); var inspect = await dockerClient.Containers.InspectContainerAsync(containerId); console.WriteLine("Exit Code: " + inspect.State.ExitCode); var args = new TestCaseFinishedArgs { ExitCode = (int)inspect.State.ExitCode, OutputData = console.cleanLog, ErrorData = inspect.State.ExitCode != 0 ? console.cleanLog : string.Empty, }; var rmParams = new Docker.DotNet.Models.ContainerRemoveParameters { Force = true, RemoveLinks = false, RemoveVolumes = false, }; await dockerClient.Containers.RemoveContainerAsync(containerId, rmParams); containers.Remove(containerId); if (inspect.State.ExitCode != 0 && Application.isPlaying) { SimulatorConsole.Instance.Visible = true; SimulatorConsole.Instance.ChangeTab(console); } return(args); }
/// <summary> /// Performs the playback of actions in this module. /// </summary> /// <remarks>You should not call this method directly, instead pass the module /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method /// that will in turn invoke this method.</remarks> void ITestModule.Run() { ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => true; DockerClient client = null; if (certFile.Length > 0) { var credentials = new CertificateCredentials(new X509Certificate2(certFile)); client = new DockerClientConfiguration(new Uri(dockerURL), credentials).CreateClient(); } else { client = new DockerClientConfiguration(new Uri(dockerURL)).CreateClient(); } var id = TestSuite.CurrentTestContainer.Parameters["containerID"]; var stopParams = new Docker.DotNet.Models.ContainerStopParameters() { WaitBeforeKillSeconds = 10 }; CancellationToken token = new CancellationToken(); var stopTask = client.Containers.StopContainerAsync(id, stopParams, token); stopTask.Wait(); var remParams = new Docker.DotNet.Models.ContainerRemoveParameters(); var deleteTask = client.Containers.RemoveContainerAsync(id, remParams); deleteTask.Wait(new TimeSpan(0, 0, 15)); }