示例#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 static void TearDownInfrastructure()
        {
            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 dockerService = new DockerService();
                var container     = dockerService.FindByName($"{targetPlatform.ToLower()}-test-infra").First();;
                dockerService.Remove(container);
            }
        }