Exemple #1
0
        public string BuildAndTestImage(
            ImageDescriptor imageDescriptor,
            IEnumerable <string> buildArgs,
            string appDescriptor,
            string runCommand,
            string testUrl,
            string optionalRunArgs = null)
        {
            string appId   = $"{appDescriptor}-{DateTime.Now.ToFileTime()}";
            string workDir = Path.Combine(
                Directory.GetCurrentDirectory(),
                "projects",
                $"{appDescriptor}-{imageDescriptor.Version}");

            string output;

            try
            {
                DockerHelper.Build(
                    tag: appId,
                    dockerfile: Path.Combine(workDir, "Dockerfile"),
                    contextDir: workDir,
                    buildArgs: buildArgs.ToArray());

                output = DockerHelper.Run(image: appId, name: appId, command: runCommand, optionalRunArgs: optionalRunArgs, detach: !string.IsNullOrEmpty(testUrl));
                if (!string.IsNullOrEmpty(testUrl))
                {
                    VerifyHttpResponseFromContainer(appId, testUrl);
                }
            }
            finally
            {
                DockerHelper.DeleteContainer(appId, !string.IsNullOrEmpty(testUrl));
                DockerHelper.DeleteImage(appId);
            }

            return(output);
        }
Exemple #2
0
 public ImageTests(ITestOutputHelper outputHelper)
 {
     DockerHelper = new DockerHelper(outputHelper);
 }
 public ImageTestHelper(ITestOutputHelper outputHelper)
 {
     _outputHelper = outputHelper;
     DockerHelper  = new DockerHelper(outputHelper);
 }