예제 #1
0
        public async Task SinglePackageInManifest_RunAsync_CopiesAppToTargetFolder()
        {
            using var outputDir = new TempOutputDir();
            var manifest = TestManifestBuilder
                           .From("http://localhost:19080")
                           .WithTempDir(outputDir.TempDir)
                           .WithGroup(new DeploymentItem
            {
                PackagePath = Path.Combine(TestInfo.OutputDir, "Support", "Packages", "App1")
            })
                           .Build();
            var command = new CopyPackagesLocallyCommand(
                new CommandContext {
                Manifest = manifest, Logger = Logger.Object
            }, InnerCommand.Object);

            await command.RunAsync();

            DirectoryExists(outputDir.TempDir, "App1");
            FileExists(outputDir.TempDir, "App1", "ApplicationManifest.xml");
            DirectoryExists(outputDir.TempDir, "App1", "StatusServicePkg");
            FileExists(outputDir.TempDir, "App1", "StatusServicePkg", "ServiceManifest.xml");
            DirectoryExists(outputDir.TempDir, "App1", "StatusServicePkg", "Code");
            FileExists(outputDir.TempDir, "App1", "StatusServicePkg", "Code", "StatusService.dll");
            FileExists(outputDir.TempDir, "App1", "StatusServicePkg", "Code", "StatusService.exe");
            FileExists(outputDir.TempDir, "App1", "StatusServicePkg", "Code", "StatusService.pdb");
            DirectoryExists(outputDir.TempDir, "App1", "StatusServicePkg", "Config");
            FileExists(outputDir.TempDir, "App1", "StatusServicePkg", "Config", "Settings.xml");
        }
        public async Task SinglePackage_RunAsync_ReturnsSuccess()
        {
            var packages = new[] { new PackageInfo("App1Type", "1.0.0", "fabric:/app1") };

            try
            {
                await SetupAsync(packages);

                var manifest = TestManifestBuilder
                               .From(TestInfo.Connection)
                               .WithGroup(new DeploymentItem
                {
                    PackagePath            = packages[0].TestPackagePath,
                    ParameterFile          = packages[0].TestParameterPath,
                    RemoveApplicationFirst = true
                })
                               .Build();

                var success = await DeploymentService.RunAsync(manifest, new[] { "File" });

                success.ShouldBeTrue();
            }
            finally
            {
                await TearDownAsync(packages);
            }
        }
        public async Task SinglePackage_RunAsync_LogContainsPreparationMessages()
        {
            var packages = new[] { new PackageInfo("App1Type", "1.0.0", "fabric:/app1") };

            try
            {
                await SetupAsync(packages);

                var manifest = TestManifestBuilder
                               .From(TestInfo.Connection)
                               .WithGroup(new DeploymentItem
                {
                    PackagePath            = packages[0].TestPackagePath,
                    ParameterFile          = packages[0].TestParameterPath,
                    RemoveApplicationFirst = true
                })
                               .Build();

                await DeploymentService.RunAsync(manifest, new[] { "File" });

                var log = OutputParser.Parse(_outputPath);
                ShouldContainPreparationMessage(log, "Processing the manifest");
                ShouldContainPreparationMessage(log, "Populating the manifest with calculated values");
                ShouldContainPreparationMessage(log, "About to run the deployment on the manifest...");
                ShouldContainPreparationMessage(log, "Created a fabric client to connect to the cluster");
                ShouldContainPreparationMessage(log, "Checking the connection to the cluster...");
                ShouldContainPreparationMessage(log, "Connection to the cluster succeeded");
                ShouldContainPreparationMessage(log, "Checking the cluster is healthy...");
                ShouldContainPreparationMessage(log, "Cluster is healthy");
            }
            finally
            {
                await TearDownAsync(packages);
            }
        }
        public async Task SinglePackage_RunAsync_LogContainsCleanupMessages()
        {
            var packages = new[] { new PackageInfo("App1Type", "1.0.0", "fabric:/app1") };

            try
            {
                await SetupAsync(packages);

                var manifest = TestManifestBuilder
                               .From(TestInfo.Connection)
                               .WithGroup(new DeploymentItem
                {
                    PackagePath            = packages[0].TestPackagePath,
                    ParameterFile          = packages[0].TestParameterPath,
                    RemoveApplicationFirst = true
                })
                               .Build();

                await DeploymentService.RunAsync(manifest, new[] { "File" });

                var log = OutputParser.Parse(_outputPath);
                ShouldContainCleanupMessage(log, "Checking the cluster is healthy...");
                ShouldContainCleanupMessage(log, "Cluster is healthy");
                ShouldContainCleanupMessage(log, "Local folder has been cleaned");
            }
            finally
            {
                await TearDownAsync(packages);
            }
        }
        public async Task SinglePackage_RunAsync_LogContainsNoErrors()
        {
            var packages = new[] { new PackageInfo("App1Type", "1.0.0", "fabric:/app1") };

            try
            {
                await SetupAsync(packages);

                var manifest = TestManifestBuilder
                               .From(TestInfo.Connection)
                               .WithGroup(new DeploymentItem
                {
                    PackagePath            = packages[0].TestPackagePath,
                    ParameterFile          = packages[0].TestParameterPath,
                    RemoveApplicationFirst = true
                })
                               .Build();

                await DeploymentService.RunAsync(manifest, new[] { "File" });

                var log = OutputParser.Parse(_outputPath);
                ShouldContainNoErrors(log);
            }
            finally
            {
                await TearDownAsync(packages);
            }
        }
예제 #6
0
        public void NullGroups_Validate_ReturnsSuccessAsFalse()
        {
            var manifest = TestManifestBuilder.From("http://localhost:19080").Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeFalse();
        }
        public void InvalidThumbprint_Validate_ReturnsSuccessAsFalse()
        {
            var manifest = TestManifestBuilder.From("http://localhost:19080").WithThumbprint(null).Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeFalse();
        }
        public void ValidThumbprint_Validate_ReturnsSuccessAsTrue(string thumbprint)
        {
            var manifest = TestManifestBuilder.From("http://localhost:19080").WithThumbprint(thumbprint).Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeTrue();
        }
예제 #9
0
        public void WithGroups_Validate_ReturnsNoErrors()
        {
            var manifest = TestManifestBuilder.From("http://localhost:19080").WithGroup(new DeploymentItem()).Build();

            var result = _validator.Validate(manifest);

            result.Errors.ShouldBeEmpty();
        }
예제 #10
0
        public void WithGroups_Validate_ReturnsSuccessAsTrue()
        {
            var manifest = TestManifestBuilder.From("http://localhost:19080").WithGroup(new DeploymentItem()).Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeTrue();
        }
        public void ValidConnection_Validate_ReturnsSuccessAsTrue(string connection)
        {
            var manifest = TestManifestBuilder.From(connection).Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeTrue();
        }
예제 #12
0
        public void DefaultWorkingDirectory_Validate_ReturnsSuccessAsTrue()
        {
            var manifest = TestManifestBuilder.From("http://localhost:19080").Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeTrue();
        }
예제 #13
0
        public void InvalidClusterHealthWaitTime_Validate_ReturnsSuccessAsFalse()
        {
            var manifest = TestManifestBuilder
                           .From("http://localhost:19080")
                           .WithClusterHealthWaitTime(0)
                           .Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeFalse();
        }
        public void FromManifest_Create_ReturnsCommand()
        {
            var manifest = TestManifestBuilder
                           .From("http://localhost:19080")
                           .WithGroup(new DeploymentItem())
                           .Build();

            var command = Subject.Create(manifest);

            command.ShouldBeOfType <CheckClusterConnectionCommand>();
        }
        public void InvalidConnection_Validate_ReturnsError()
        {
            var manifest = TestManifestBuilder.From("http://localhost").Build();

            var result = _validator.Validate(manifest);

            var error = result.Errors.FirstOrDefault(
                e => e.Property == "Connection" &&
                e.Error == "The cluster connection is in an incorrect format.");

            error.ShouldNotBeNull();
        }
        public void InvalidThumbprint_Validate_ReturnsError()
        {
            var manifest = TestManifestBuilder.From("http://localhost:19080").WithThumbprint(null).Build();

            var result = _validator.Validate(manifest);

            var error = result.Errors.FirstOrDefault(
                e => e.Property == "FindByValue" &&
                e.Error == "The find by value has not been provided.");

            error.ShouldNotBeNull();
        }
예제 #17
0
        public void EmptyGroups_Validate_ReturnsError()
        {
            var manifest = TestManifestBuilder.From("http://localhost:19080").WithEmptyGroups().Build();

            var result = _validator.Validate(manifest);

            var error = result.Errors.FirstOrDefault(
                e => e.Property == "Groups" &&
                e.Error == "No deployment groups have been provided.");

            error.ShouldNotBeNull();
        }
예제 #18
0
        public void InvalidPackagePathVersion_Validate_ReturnsSuccessAsFalse(string packagePath)
        {
            var manifest = TestManifestBuilder
                           .From("http://localhost:19080")
                           .WithGroup(new DeploymentItem {
                PackagePath = packagePath
            })
                           .Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeFalse();
        }
        public void ManifestWithNoErrors_Handle_ReturnsTrue()
        {
            var manifest  = TestManifestBuilder.From("http://localhost:19080").Build();
            var validator = new Mock <IValidator>();
            var logger    = new Mock <ILogger>();

            validator.Setup(v => v.Validate(manifest)).Returns(new ValidationResult());
            var service = new ValidateManifestHandler(new[] { validator.Object }, logger.Object);

            var success = service.Handle(manifest);

            success.ShouldBeTrue();
        }
예제 #20
0
        public void UnknownPackagePath_Validate_ReturnsSuccessAsFalse()
        {
            var packagePath = Path.Combine(TestInfo.OutputDir, "TestPackage");
            var manifest    = TestManifestBuilder
                              .From("http://localhost:19080")
                              .WithGroup(new DeploymentItem {
                PackagePath = packagePath
            })
                              .Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeFalse();
        }
예제 #21
0
        public void InvalidParameterFile_Validate_ReturnsSuccessAsFalse(string file)
        {
            var packagePath = Path.Combine(TestInfo.OutputDir, "Support", "Packages", "App1");
            var manifest    = TestManifestBuilder
                              .From("http://localhost:19080")
                              .WithGroup(new DeploymentItem {
                PackagePath = packagePath, ParameterFile = file
            })
                              .Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeFalse();
        }
        public void ManifestWithError_Handle_ReturnsFalse()
        {
            var manifest        = TestManifestBuilder.From("http://localhost:19080").Build();
            var validator       = new Mock <IValidator>();
            var logger          = new Mock <ILogger>();
            var validatorResult = new ValidationResult();

            validatorResult.AddError("Connection", "Invalid format.");
            validator.Setup(v => v.Validate(manifest)).Returns(validatorResult);
            var service = new ValidateManifestHandler(new[] { validator.Object }, logger.Object);

            var success = service.Handle(manifest);

            success.ShouldBeFalse();
        }
예제 #23
0
        public void UnknownWorkingDirectory_Validate_ReturnsError()
        {
            var manifest = TestManifestBuilder
                           .From("http://*****:*****@"q:\xyz\abc")
                           .Build();

            var result = _validator.Validate(manifest);

            var error = result.Errors.FirstOrDefault(
                e => e.Property == "WorkingDirectory" &&
                e.Error == "The working directory is invalid or cannot be found.");

            error.ShouldNotBeNull();
        }
예제 #24
0
        public void UnknownApplicationManifestFile_Validate_ReturnsSuccessAsFalse()
        {
            var packagePath   = Path.Combine(TestInfo.OutputDir, "Support", "Packages", "Empty");
            var parameterFile = Path.Combine(packagePath, "Parameters", "Cloud.xml");
            var manifest      = TestManifestBuilder
                                .From("http://localhost:19080")
                                .WithGroup(new DeploymentItem {
                PackagePath = packagePath, ParameterFile = parameterFile
            })
                                .Build();

            var result = _validator.Validate(manifest);

            result.Success.ShouldBeFalse();
        }
예제 #25
0
        public void InvalidClusterHealthWaitTime_Validate_ReturnsError(int waitTime)
        {
            var manifest = TestManifestBuilder
                           .From("http://localhost:19080")
                           .WithClusterHealthWaitTime(waitTime)
                           .Build();

            var result = _validator.Validate(manifest);

            var error = result.Errors.FirstOrDefault(
                e => e.Property == "CheckClusterHealthWaitTime" &&
                e.Error == "The cluster health wait time is out of range: 10 to 300 seconds.");

            error.ShouldNotBeNull();
        }
예제 #26
0
        public async Task WithUnknownOutputDir_RunAsync_LogsFailure()
        {
            var outputDir = $"TMP{DateTime.Now:HHmmssFFF}";
            var manifest  = TestManifestBuilder
                            .From("http://localhost:19080")
                            .WithTempDir(outputDir)
                            .Build();
            var command = new CleanLocalPackagesCommand(
                new CommandContext {
                Manifest = manifest, Logger = Logger.Object
            });

            await command.RunAsync();

            ShouldContainsLogMessage("Local folder has failed with error:");
        }
예제 #27
0
        public async Task WithOutputDir_RunAsync_LogsSuccess()
        {
            var outputDir = await CreateDirectoryAsync();

            var manifest = TestManifestBuilder
                           .From("http://localhost:19080")
                           .WithTempDir(outputDir)
                           .Build();
            var command = new CleanLocalPackagesCommand(
                new CommandContext {
                Manifest = manifest, Logger = Logger.Object
            });

            await command.RunAsync();

            ShouldContainsLogMessage("Local folder has been cleaned");
        }
예제 #28
0
        public void InvalidPackagePathVersion_Validate_ReturnsError()
        {
            var manifest = TestManifestBuilder
                           .From("http://localhost:19080")
                           .WithGroup(new DeploymentItem {
                PackagePath = null
            })
                           .Build();

            var result = _validator.Validate(manifest);

            var error = result.Errors.FirstOrDefault(
                e => e.Property == "ApplicationVersion" &&
                e.Error == "Unable to find the application version in the application manifest file.");

            error.ShouldNotBeNull();
        }
예제 #29
0
        public void ValidParameterFile_Handle_UpdatesParameters()
        {
            var packagePath   = Path.Combine(TestInfo.OutputDir, "Support", "Packages", "App1");
            var parameterFile = Path.Combine(packagePath, "Parameters", "Cloud.xml");
            var manifest      = TestManifestBuilder
                                .From("http://localhost:19080")
                                .WithGroup(new DeploymentItem {
                PackagePath = packagePath, ParameterFile = parameterFile
            })
                                .Build();

            Subject.Handle(manifest);

            var parameters = manifest.Groups.First().Items.First().Parameters;

            parameters.ContainsKey("ConnectionString").ShouldBeTrue();
        }
예제 #30
0
        public void ValidPackagePath_Handle_UpdatesApplicationTypeName()
        {
            var packagePath   = Path.Combine(TestInfo.OutputDir, "Support", "Packages", "App1");
            var parameterFile = Path.Combine(packagePath, "Parameters", "Cloud.xml");
            var manifest      = TestManifestBuilder
                                .From("http://localhost:19080")
                                .WithGroup(new DeploymentItem {
                PackagePath = packagePath, ParameterFile = parameterFile
            })
                                .Build();

            Subject.Handle(manifest);

            var applicationType = manifest.Groups.First().Items.First().ApplicationTypeName;

            applicationType.ShouldBe("App1Type");
        }