public static void SetupInfrastrucuture(TestContext testContext) { var testAgentHost = EnvironmentHelper.GetEnvironmentVariable(ENVIRONMENT_TEST_VARIABLE.YUNIQL_TEST_HOST); var targetPlatform = EnvironmentHelper.GetEnvironmentVariable(ENVIRONMENT_TEST_VARIABLE.YUNIQL_TEST_PLATFORM); if (string.IsNullOrEmpty(testAgentHost) || string.IsNullOrWhiteSpace(testAgentHost) || testAgentHost.ToUpper().Equals("CONTAINER")) { var containerFactory = new ContainerFactory(); var container = containerFactory.Create(targetPlatform.ToLower()); var image = new DockerImage { Image = container.Image, Tag = container.Tag }; var dockerService = new DockerService(); var foundContainer = dockerService.FindByName(container.Name).FirstOrDefault(); if (null != foundContainer) { dockerService.Remove(foundContainer); } dockerService.Pull(image); dockerService.Run(container); //TODO: implement connection ping with timeout Thread.Sleep(1000 * 30); } }
public void Pull(DockerImage image) { _dockerClient.Images .CreateImageAsync(new ImagesCreateParameters { FromImage = image.Image, Tag = string.IsNullOrEmpty(image.Tag) ? "latest" : image.Tag }, new AuthConfig(), new Progress <JSONMessage>()) .ConfigureAwait(false) .GetAwaiter() .GetResult(); }