예제 #1
0
        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_TARGET_PLATFORM);

            if (string.IsNullOrEmpty(testAgentHost) || string.IsNullOrWhiteSpace(testAgentHost) || testAgentHost.ToUpper().Equals("LOCAL"))
            {
                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);
            }
        }
예제 #2
0
 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();
 }