Example #1
0
        protected async Task RunTestAsync(
            string platformName,
            string platformVersion,
            string samplePath,
            int containerPort        = 8000,
            bool specifyBindPortFlag = true,
            string buildImageName    = Settings.BuildImageName)
        {
            var volume           = DockerVolume.CreateMirror(samplePath);
            var appDir           = volume.ContainerDir;
            var entrypointScript = "./run.sh";
            var bindPortFlag     = specifyBindPortFlag ? $"-bindPort {containerPort}" : string.Empty;
            var scriptBuilder    = new ShellScriptBuilder()
                                   .AddCommand($"cd {appDir}");

            scriptBuilder = scriptBuilder.AddCommand($"oryx create-script -appPath {appDir} {bindPortFlag}");
            var script = scriptBuilder.AddCommand(entrypointScript)
                         .ToString();

            var runtimeImageName = _imageHelper.GetRuntimeImage(platformName, platformVersion);

            if (string.Equals(platformName, "nodejs", StringComparison.OrdinalIgnoreCase))
            {
                runtimeImageName = _imageHelper.GetRuntimeImage("node", platformVersion);
            }

            string link = $"{_dbFixture.DbServerContainerName}:{Constants.InternalDbLinkName}";

            await EndToEndTestHelper.BuildRunAndAssertAppAsync(
                _output,
                new List <DockerVolume> {
                volume
            },
                buildImageName,
                "oryx", new[] { "build", appDir, "--platform", platformName, "--platform-version", platformVersion },
                runtimeImageName,
                _dbFixture.GetCredentialsAsEnvVars(),
                containerPort,
                link,
                "/bin/sh", new[] { "-c", script },
                async (hostPort) =>
            {
                var data = await _httpClient.GetStringAsync($"http://localhost:{hostPort}/");
                Assert.Equal(
                    DbContainerFixtureBase.GetSampleDataAsJson(),
                    data.Trim(),
                    ignoreLineEndingDifferences: true,
                    ignoreWhiteSpaceDifferences: true);
            });
        }
Example #2
0
        public void GetTestRuntimeImage_Validate_BothImageBaseAndTagSuffixSet()
        {
            // Arrange
            var platformName    = "test";
            var platformVersion = "1.0";
            var imageBaseValue  = "oryxtest";
            var tagSuffixValue  = "-buildNumber";
            var imageHelper     = new ImageTestHelper(_output, imageBaseValue, tagSuffixValue);

            // Act
            var runtimeImage = imageHelper.GetRuntimeImage(platformName, platformVersion);

            // Assert
            var expectedImage = $"{imageBaseValue}/{platformName}:{platformVersion}{tagSuffixValue}";

            Assert.Equal(expectedImage, runtimeImage);
        }
Example #3
0
        public void GetTestRuntimeImage_Validate_NoImageBaseOrTagSuffixSet()
        {
            // Arrange
            var platformName    = "test";
            var platformVersion = "1.0";
            var imageBaseValue  = string.Empty;
            var tagSuffixValue  = string.Empty;
            var imageHelper     = new ImageTestHelper(_output, imageBaseValue, tagSuffixValue);

            // Act
            var runtimeImage = imageHelper.GetRuntimeImage(platformName, platformVersion);

            // Assert
            var expectedImage = $"{_defaultImageBase}/{platformName}:{platformVersion}";

            Assert.Equal(expectedImage, runtimeImage);
        }