コード例 #1
0
 public DeploymentController(DeploymentService DeploymentService, ProjectService ProjectService, DatabaseService DatabaseService, Userservice Userservice)
 {
     _DeploymentService = DeploymentService;
     _ProjectService    = ProjectService;
     _DatabaseService   = DatabaseService;
     _Userservice       = Userservice;
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: hypersolutions/hyperfabric
        public static async Task <int> Main(string[] args)
        {
            var options = CommandLineHelper <DeploymentOptions>
                          .FromArgs(args, "HyperFabric", "Commandline parallel deployment tool for service fabric.")
                          .For(o => o.Json).IsRequired("Json string or file path for the manifest.", "-j", "--json")
                          .For(o => o.Loggers).IsOptional(
                "Comma-separated list of loggers to use e.g. Console, File.", "-l", "--loggers")
                          .WithOptionHandler(new JsonOptionHandler())
                          .WithOptionHandler(new LoggersOptionHandler())
                          .Parse();

            var exitCode = -1;

            if (options != null)
            {
                var manifestBuilder = new ManifestBuilder();
                var manifest        = string.IsNullOrWhiteSpace(options.JsonString)
                    ? manifestBuilder.FromFile(options.JsonPath)
                    : manifestBuilder.FromString(options.JsonString);

                var success = await DeploymentService.RunAsync(manifest, options.LoggerList);

                exitCode = success ? 0 : -1;
            }

            return(exitCode);
        }
コード例 #5
0
        public async Task CreateAsync_OK()
        {
            // Arrange
            DeploymentModel deploymentModel = new DeploymentModel
            {
                TagName = "1",
            };

            deploymentModel.Environment = new EnvironmentModel
            {
                Name     = "at23",
                Hostname = "hostname"
            };

            _releaseRepository.Setup(r => r.GetSucceededReleaseFromDb(
                                         It.IsAny <string>(),
                                         It.IsAny <string>(),
                                         It.IsAny <string>())).ReturnsAsync(GetReleases("updatedRelease.json").First());

            _applicationInformationService.Setup(ais => ais.UpdateApplicationInformationAsync(
                                                     It.IsAny <string>(),
                                                     It.IsAny <string>(),
                                                     It.IsAny <string>(),
                                                     It.IsAny <EnvironmentModel>())).Returns(Task.CompletedTask);

            Mock <IAzureDevOpsBuildClient> azureDevOpsBuildClient = new Mock <IAzureDevOpsBuildClient>();

            azureDevOpsBuildClient.Setup(b => b.QueueAsync(
                                             It.IsAny <QueueBuildParameters>(),
                                             It.IsAny <int>())).ReturnsAsync(GetBuild());

            _deploymentRepository.Setup(r => r.Create(
                                            It.IsAny <DeploymentEntity>())).ReturnsAsync(GetDeployments("createdDeployment.json").First());

            DeploymentService deploymentService = new DeploymentService(
                new TestOptionsMonitor <AzureDevOpsSettings>(GetAzureDevOpsSettings()),
                azureDevOpsBuildClient.Object,
                _httpContextAccessor.Object,
                _deploymentRepository.Object,
                _releaseRepository.Object,
                _applicationInformationService.Object);

            // Act
            DeploymentEntity deploymentEntity = await deploymentService.CreateAsync(deploymentModel);

            // Assert
            Assert.NotNull(deploymentEntity);
            _releaseRepository.Verify(
                r => r.GetSucceededReleaseFromDb(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            _applicationInformationService.Verify(
                ais => ais.UpdateApplicationInformationAsync(
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <EnvironmentModel>()),
                Times.Once);
            azureDevOpsBuildClient.Verify(
                b => b.QueueAsync(It.IsAny <QueueBuildParameters>(), It.IsAny <int>()), Times.Once);
            _deploymentRepository.Verify(r => r.Create(It.IsAny <DeploymentEntity>()), Times.Once);
        }
コード例 #6
0
        public async Task UpdateAsync()
        {
            // Arrange
            _deploymentRepository.Setup(r => r.Get(
                                            It.IsAny <string>(),
                                            It.IsAny <string>())).ReturnsAsync(GetDeployments("createdDeployment.json").First());

            _deploymentRepository.Setup(r => r.Update(
                                            It.IsAny <DeploymentEntity>())).Returns(Task.CompletedTask);

            DeploymentService deploymentService = new DeploymentService(
                new TestOptionsMonitor <AzureDevOpsSettings>(GetAzureDevOpsSettings()),
                new Mock <IAzureDevOpsBuildClient>().Object,
                _httpContextAccessor.Object,
                _deploymentRepository.Object,
                _releaseRepository.Object,
                _applicationInformationService.Object);

            // Act
            await deploymentService.UpdateAsync(GetDeployments("createdDeployment.json").First(), "ttd");

            // Assert
            _deploymentRepository.Verify(r => r.Get(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            _deploymentRepository.Verify(r => r.Update(It.IsAny <DeploymentEntity>()), Times.Once);
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        static void Main(string[] args)
        {
            UpdateOrganizationSettingApp app = new UpdateOrganizationSettingApp();
            Logger   logger   = app.Logger;
            ExitCode exitCode = ExitCode.None;

            try
            {
                logger.Info("Application started.");

                CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");

                Options options = new Options();

                Parser.Default.ParseArgumentsStrict(args, options, CommandLineOptions.ArgumentParsingFailed);

                Connection connection = null;

                if (string.IsNullOrWhiteSpace(options.ConnectionString))
                {
                    connection = new Connection(options.AuthorityUrl, options.OrganizationUrl, options.OrganizationUrlSuffix,
                                                options.TenantId, options.ServicePrincipalId, options.ServicePrincipalSecret, options.ConnectionRetries, options.ConnectionTimeout);
                }
                else
                {
                    connection = new Connection(options.ConnectionString, options.ConnectionRetries, options.ConnectionTimeout);
                }

                //TO-DO: this is in experimental mode
                //Console.ReadLine();

                using (CrmServiceContext organizationServiceContext = new CrmServiceContext(connection.OrganizationService))
                    using (CrmService crmService = new CrmService(organizationServiceContext, connection))
                        using (DeploymentService deploymentService = new DeploymentService(organizationServiceContext, crmService))
                        {
                            var organizationSettings = new Organization
                            {
                                BlockAttachments = options.BlockAttachments,
                                EnableAccessToLegacyWebClientUI = options.EnableAccessToLegacyWebClientUI,
                                LegacyFormRendering             = options.LegacyFormRendering,
                                OrganizationName                = options.OrganizationName,
                                SessionTimeoutEnabled           = options.SessionTimeoutEnabled,
                                SessionTimeoutInMinutes         = options.SessionTimeoutInMinutes,
                                SessionTimeoutReminderInMinutes = options.SessionTimeoutReminderInMinutes,
                                SLAPauseStates = options.SLAPauseStates
                            };
                            deploymentService.UpdateOrganizationSettings(organizationSettings);
                            exitCode = ExitCode.Success;
                        }
            }
            catch (Exception ex)
            {
                exitCode = new ExceptionHandlingService(ex).GetExitCode();
            }
            finally
            {
                logger.Info(CultureInfo.InvariantCulture, "Application exited with code: {0}", (int)exitCode);
                Environment.Exit((int)exitCode);
            }
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        public void ThatNoScriptsDoesntFail()
        {
            var databaseServiceMock        = new Mock <IDatabaseService>(MockBehavior.Strict);
            var configurationServiceMock   = new Mock <IConfigurationService>(MockBehavior.Strict);
            var scriptServiceMock          = new Mock <IScriptService>(MockBehavior.Strict);
            var fileServiceMock            = new Mock <IFileService>(MockBehavior.Strict);
            var scriptMessageFormatterMock = new Mock <IScriptMessageFormatter>(MockBehavior.Strict);

            IDictionary <int, IScriptFile> availableScripts = new Dictionary <int, IScriptFile>();
            IDictionary <int, IChangeLog>  changeLogs       = new Dictionary <int, IChangeLog>();

            string changeScript = "Change Script";

            // FileService Setup
            fileServiceMock.Setup(file => file.CleanupPastRuns()).Verifiable();
            fileServiceMock.Setup(file => file.GetScriptFiles()).Returns(availableScripts).Verifiable();
            fileServiceMock.Setup(file => file.WriteChangeScript(It.Is <string>(s => s == changeScript))).Verifiable();
            fileServiceMock.Setup(file => file.WriteScriptList(It.IsAny <Dictionary <int, IScriptFile> >())).Verifiable();

            // Database Service Setup
            databaseServiceMock.Setup(db => db.GetAppliedChanges()).Returns(changeLogs).Verifiable();

            // Configuration Service Setup
            configurationServiceMock.Setup(config => config.LastChangeToApply).Returns(1000).Verifiable();
            configurationServiceMock.Setup(config => config.OutputFile).Returns("File Location").Verifiable();
            configurationServiceMock.Setup(config => config.ScriptListFile).Returns("ScriptListFileLocation").Verifiable();
            configurationServiceMock.Setup(config => config.RootDirectory).Returns("Root Directory").Verifiable();

            // Script Formatter setup
            scriptMessageFormatterMock.Setup(fm => fm.FormatCollection(It.IsAny <ICollection <int> >())).Returns("String Formatted.").Verifiable();

            // Script Service Setup
            scriptServiceMock.Setup(script => script.BuildChangeScript(It.IsAny <IDictionary <int, IScriptFile> >())).Returns(changeScript).Verifiable();

            DeploymentService deploymentService = new DeploymentService(databaseServiceMock.Object, configurationServiceMock.Object, scriptServiceMock.Object, fileServiceMock.Object, scriptMessageFormatterMock.Object);

            deploymentService.BuildDeploymentScript();

            // File Verifies
            fileServiceMock.Verify(file => file.CleanupPastRuns(), Times.Exactly(1));
            fileServiceMock.Verify(file => file.GetScriptFiles(), Times.Exactly(1));
            fileServiceMock.Verify(file => file.WriteChangeScript(It.Is <string>(s => s == changeScript)), Times.Never());
            fileServiceMock.Verify(file => file.WriteScriptList(It.IsAny <Dictionary <int, IScriptFile> >()), Times.Never());

            // Database Verifies
            databaseServiceMock.Verify(db => db.GetAppliedChanges(), Times.Exactly(0));

            // Configuration Service Verifies
            configurationServiceMock.Verify(config => config.LastChangeToApply, Times.Never());
            configurationServiceMock.Verify(config => config.OutputFile, Times.Never());
            configurationServiceMock.Verify(config => config.ScriptListFile, Times.Never());
            configurationServiceMock.Verify(config => config.RootDirectory, Times.AtLeastOnce());

            // Script Formamter Verifies.
            scriptMessageFormatterMock.Verify(fm => fm.FormatCollection(It.IsAny <ICollection <int> >()), Times.Never());

            // Script Service Verifies
            scriptServiceMock.Verify(script => script.BuildChangeScript(It.IsAny <IDictionary <int, IScriptFile> >()), Times.Never());
        }
コード例 #11
0
 public DeploymentCommand(AmazonAppConfigClient client)
 {
     _client                      = client;
     _deploymentService           = new DeploymentService(client);
     _applicationService          = new AwsAppConfigApplicationService(client);
     _environmentService          = new AwsAppConfigEnvironmentService(client);
     _configurationProfileService = new AwsAppConfigConfigurationProfileService(client);
 }
コード例 #12
0
        public void Deploy_NullEnvironment_ThrowsException()
        {
            IProductManifestRepository manifestRepository = Substitute.For <IProductManifestRepository>();
            IServiceDeploymentHandler  deploymentHandler  = Substitute.For <IServiceDeploymentHandler>();

            this.sut = new DeploymentService(manifestRepository, deploymentHandler);

            Assert.Throws <ArgumentException>(() => this.sut.Deploy("someproduct", null, "someVersion"));
        }
コード例 #13
0
 public HookService(
     IDeploymentTargetReadService targetSource,
     DeploymentService deploymentService,
     ILogger logger,
     MonitoringService monitoringService)
 {
     _targetSource      = targetSource;
     _deploymentService = deploymentService;
     _logger            = logger;
     _monitoringService = monitoringService;
 }
コード例 #14
0
 public void SetUp()
 {
     _mockJobConfigurationParser = new Mock <IJobConfigurationParser>();
     _mockSqlExecutionService    = new Mock <ISqlExecutionService>();
     _mockFileService            = new Mock <IFileService>();
     _mockSqlScriptProvider      = new Mock <ISqlScriptProvider>();
     _deploymentService          = new DeploymentService(_mockJobConfigurationParser.Object,
                                                         _mockSqlScriptProvider.Object,
                                                         _mockFileService.Object,
                                                         _mockSqlExecutionService.Object);
 }
コード例 #15
0
ファイル: EPRuntimeImpl.cs プロジェクト: lanicon/nesper
 public void TraverseStatements(BiConsumer<EPDeployment, EPStatement> consumer)
 {
     foreach (var deploymentId in DeploymentService.Deployments) {
         var deployment = DeploymentService.GetDeployment(deploymentId);
         if (deployment != null) {
             foreach (var stmt in deployment.Statements) {
                 consumer.Invoke(deployment, stmt);
             }
         }
     }
 }
コード例 #16
0
        public void Deploy_GetsManifest_DeploysServices()
        {
            IProductManifestRepository manifestRepository = Substitute.For <IProductManifestRepository>();
            IServiceDeploymentHandler  deploymentHandler  = Substitute.For <IServiceDeploymentHandler>();

            manifestRepository.GetManifest(Arg.Any <string>(), Arg.Any <string>())
            .Returns(GetTestManifest(2));

            this.sut = new DeploymentService(manifestRepository, deploymentHandler);
            this.sut.Deploy("someProduct", "someEnvironment", "someVersion");

            deploymentHandler.ReceivedWithAnyArgs()
            .Deploy(Arg.Any <ProductManifest>(), Arg.Any <string>(), Arg.Any <string>());
        }
コード例 #17
0
        public void Deploy_NoManifest_DoesNothing()
        {
            IProductManifestRepository manifestRepository = Substitute.For <IProductManifestRepository>();
            IServiceDeploymentHandler  deploymentHandler  = Substitute.For <IServiceDeploymentHandler>();

            manifestRepository.GetManifest(Arg.Any <string>(), Arg.Any <string>())
            .Returns((ProductManifest)null);

            this.sut = new DeploymentService(manifestRepository, deploymentHandler);
            this.sut.Deploy("someProduct", "someEnvironment", "someVersion");

            deploymentHandler.DidNotReceiveWithAnyArgs()
            .Deploy(Arg.Any <ProductManifest>(), Arg.Any <string>(), Arg.Any <string>());
        }
コード例 #18
0
 public UserController(
     Userservice Userservice,
     DatabaseService DatabaseService,
     DeploymentService DeploymentService,
     ProjectService ProjectService,
     UserManager <UserWithIdentity> userManager,
     SignInManager <UserWithIdentity> signInManager)
 {
     _Userservice       = Userservice;
     _ProjectService    = ProjectService;
     _DatabaseService   = DatabaseService;
     _DeploymentService = DeploymentService;
     _userManager       = userManager;
     _signInManager     = signInManager;
 }
コード例 #19
0
 public DeployerApp(
     [NotNull] ILogger logger,
     [NotNull] DeploymentService deploymentService,
     [NotNull] IKeyValueConfiguration appSettings,
     [NotNull] LoggingLevelSwitch levelSwitch,
     [NotNull] CancellationTokenSource cancellationTokenSource)
 {
     LevelSwitch              = levelSwitch ?? throw new ArgumentNullException(nameof(levelSwitch));
     Logger                   = logger ?? throw new ArgumentNullException(nameof(logger));
     _deploymentService       = deploymentService ?? throw new ArgumentNullException(nameof(deploymentService));
     _appSettings             = appSettings ?? throw new ArgumentNullException(nameof(appSettings));
     _cancellationTokenSource = cancellationTokenSource ??
                                throw new ArgumentNullException(nameof(cancellationTokenSource));
     _appExit = new AppExit(Logger);
 }
コード例 #20
0
        public void Deploy_HasBranch_UsesBranch()
        {
            IProductManifestRepository manifestRepository = Substitute.For <IProductManifestRepository>();
            IServiceDeploymentHandler  deploymentHandler  = Substitute.For <IServiceDeploymentHandler>();

            ProductManifest testManifest = GetTestManifest(2);

            manifestRepository.GetManifest(Arg.Any <string>(), Arg.Any <string>())
            .Returns(testManifest);
            this.sut = new DeploymentService(manifestRepository, deploymentHandler);
            this.sut.Deploy("someProduct", "someEnvironment", "someVersion", "someBranch");

            deploymentHandler.Received()
            .Deploy(testManifest, "someEnvironment", "someVersion", "someBranch");
        }
コード例 #21
0
ファイル: Mutation.cs プロジェクト: jkelin/supercompose
 public Mutation(
     NodeService nodeService,
     ComposeService composeService,
     DeploymentService deploymentService,
     IDbContextFactory <SuperComposeContext> ctxFactiry,
     ConnectionService conn,
     IAuthorizationService authorizationService
     )
 {
     this.nodeService       = nodeService;
     this.composeService    = composeService;
     this.deploymentService = deploymentService;
     this.ctxFactiry        = ctxFactiry;
     this.conn = conn;
     this.authorizationService = authorizationService;
 }
コード例 #22
0
        private static IDeploymentService BuildService()
        {
            VstsConfig  vstsConfig = GetVstsConfig();
            IFileSystem fileSystem = new FileSystem();
            IHttpClient httpClient = new HttpClient();
            IProductManifestRepository manifestRepository = new JsonFileProductManifestRepository(fileSystem);
            ITokenRepository           tokenRepository    = new JsonFileTokenRepository(fileSystem);
            IVstsReleaseClient         releaseClient      = new VstsSyncReleaseClient(vstsConfig);
            IAuthenticator             authenticator      = new VstsOAuthAuthenticator(httpClient, tokenRepository, vstsConfig);
            IReleaseRepository         releaseRepository  = new VstsReleaseRepository(releaseClient, authenticator, vstsConfig);
            IServiceDeploymentExecutor deploymentExecutor = new VstsDeploymentExecutor(releaseRepository, vstsConfig);
            IServiceDeploymentHandler  deploymentHandler  = new SequentialDeploymentHandler(deploymentExecutor, 10);
            IDeploymentService         service            = new DeploymentService(manifestRepository, deploymentHandler);

            return(service);
        }
コード例 #23
0
        static void Main(string[] args)
        {
            UpdateServiceEndpointApp app = new UpdateServiceEndpointApp();
            Logger   logger   = app.Logger;
            ExitCode exitCode = ExitCode.None;

            try
            {
                logger.Info("Application started.");

                CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");

                Options options = new Options();

                Parser.Default.ParseArgumentsStrict(args, options, CommandLineOptions.ArgumentParsingFailed);

                Connection connection = null;

                if (string.IsNullOrWhiteSpace(options.ConnectionString))
                {
                    connection = new Connection(options.AuthorityUrl, options.OrganizationUrl, options.OrganizationUrlSuffix,
                                                options.TenantId, options.ServicePrincipalId, options.ServicePrincipalSecret, options.ConnectionRetries, options.ConnectionTimeout);
                }
                else
                {
                    connection = new Connection(options.ConnectionString, options.ConnectionRetries, options.ConnectionTimeout);
                }

                using (CrmServiceContext organizationServiceContext = new CrmServiceContext(connection.OrganizationService))
                    using (CrmService crmService = new CrmService(organizationServiceContext, connection))
                        using (IDeploymentService deploymentService = new DeploymentService(organizationServiceContext, crmService))
                        {
                            deploymentService.UpdateServiceEndpoint(options.PrimaryKey, options.NamespaceAddress, options.SharedAccessKey, options.ServiceNamespace);
                            exitCode = ExitCode.Success;
                        }
            }
            catch (Exception ex)
            {
                exitCode = new ExceptionHandlingService(ex).GetExitCode();
            }
            finally
            {
                logger.Info(CultureInfo.InvariantCulture, "Application exited with code: {0}", (int)exitCode);
                Environment.Exit((int)exitCode);
            }
        }
コード例 #24
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IDeploymentRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <Deployment>(null));
            var service = new DeploymentService(mock.LoggerMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.DeploymentModelValidatorMock.Object,
                                                mock.BOLMapperMockFactory.BOLDeploymentMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentMapperMock,
                                                mock.BOLMapperMockFactory.BOLDeploymentRelatedMachineMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentRelatedMachineMapperMock);

            ApiDeploymentResponseModel response = await service.Get(default(string));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>()));
        }
コード例 #25
0
        public async void DeploymentRelatedMachines_Not_Exists()
        {
            var mock = new ServiceMockFacade <IDeploymentRepository>();

            mock.RepositoryMock.Setup(x => x.DeploymentRelatedMachines(default(string), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult <List <DeploymentRelatedMachine> >(new List <DeploymentRelatedMachine>()));
            var service = new DeploymentService(mock.LoggerMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.DeploymentModelValidatorMock.Object,
                                                mock.BOLMapperMockFactory.BOLDeploymentMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentMapperMock,
                                                mock.BOLMapperMockFactory.BOLDeploymentRelatedMachineMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentRelatedMachineMapperMock);

            List <ApiDeploymentRelatedMachineResponseModel> response = await service.DeploymentRelatedMachines(default(string));

            response.Should().BeEmpty();
            mock.RepositoryMock.Verify(x => x.DeploymentRelatedMachines(default(string), It.IsAny <int>(), It.IsAny <int>()));
        }
コード例 #26
0
        public async void ByIdProjectIdProjectGroupIdNameCreatedReleaseIdTaskIdEnvironmentId_Not_Exists()
        {
            var mock = new ServiceMockFacade <IDeploymentRepository>();

            mock.RepositoryMock.Setup(x => x.ByIdProjectIdProjectGroupIdNameCreatedReleaseIdTaskIdEnvironmentId(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTimeOffset>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult <List <Deployment> >(new List <Deployment>()));
            var service = new DeploymentService(mock.LoggerMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.DeploymentModelValidatorMock.Object,
                                                mock.BOLMapperMockFactory.BOLDeploymentMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentMapperMock,
                                                mock.BOLMapperMockFactory.BOLDeploymentRelatedMachineMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentRelatedMachineMapperMock);

            List <ApiDeploymentResponseModel> response = await service.ByIdProjectIdProjectGroupIdNameCreatedReleaseIdTaskIdEnvironmentId(default(string), default(string), default(string), default(string), default(DateTimeOffset), default(string), default(string), default(string));

            response.Should().BeEmpty();
            mock.RepositoryMock.Verify(x => x.ByIdProjectIdProjectGroupIdNameCreatedReleaseIdTaskIdEnvironmentId(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTimeOffset>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()));
        }
コード例 #27
0
        public async Task PackageAlreadyExists_RunAsync_LogContainsDeploymentErrorMessage()
        {
            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
                })
                               .Build();

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

                succeeded.ShouldBeTrue();

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

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

                succeeded.ShouldBeFalse();

                var log = OutputParser.Parse(_outputPath);
                ShouldContainDeploymentMessage(
                    log, "Failed to create application type App1Type: Application type and version already exists");
            }
            finally
            {
                await TearDownAsync(packages);
            }
        }
コード例 #28
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IDeploymentRepository>();
            var model = new ApiDeploymentRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Deployment>())).Returns(Task.FromResult(new Deployment()));
            var service = new DeploymentService(mock.LoggerMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.DeploymentModelValidatorMock.Object,
                                                mock.BOLMapperMockFactory.BOLDeploymentMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentMapperMock,
                                                mock.BOLMapperMockFactory.BOLDeploymentRelatedMachineMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentRelatedMachineMapperMock);

            CreateResponse <ApiDeploymentResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.DeploymentModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiDeploymentRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Deployment>()));
        }
コード例 #29
0
        public async void ByTenantId_Exists()
        {
            var mock    = new ServiceMockFacade <IDeploymentRepository>();
            var records = new List <Deployment>();

            records.Add(new Deployment());
            mock.RepositoryMock.Setup(x => x.ByTenantId(It.IsAny <string>())).Returns(Task.FromResult(records));
            var service = new DeploymentService(mock.LoggerMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.DeploymentModelValidatorMock.Object,
                                                mock.BOLMapperMockFactory.BOLDeploymentMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentMapperMock,
                                                mock.BOLMapperMockFactory.BOLDeploymentRelatedMachineMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentRelatedMachineMapperMock);

            List <ApiDeploymentResponseModel> response = await service.ByTenantId(default(string));

            response.Should().NotBeEmpty();
            mock.RepositoryMock.Verify(x => x.ByTenantId(It.IsAny <string>()));
        }
コード例 #30
0
        public async void All()
        {
            var mock    = new ServiceMockFacade <IDeploymentRepository>();
            var records = new List <Deployment>();

            records.Add(new Deployment());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new DeploymentService(mock.LoggerMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.DeploymentModelValidatorMock.Object,
                                                mock.BOLMapperMockFactory.BOLDeploymentMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentMapperMock,
                                                mock.BOLMapperMockFactory.BOLDeploymentRelatedMachineMapperMock,
                                                mock.DALMapperMockFactory.DALDeploymentRelatedMachineMapperMock);

            List <ApiDeploymentResponseModel> response = await service.All();

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
コード例 #31
0
 public IDeploymentService GetDeploymentService()
 {
     CrmConnection connection = null;
     try
     {
         connection = _CrmConnectionProvider.GetDeploymentServiceConnection();
         connection.UserTokenExpiryWindow = new TimeSpan(0, 3, 0);
         if (connection.Timeout == null)
         {
             // Set a sensible timeout - 6 minutes.
             connection.Timeout = new TimeSpan(0, 6, 0);
         }
         // var service = new OrganizationService(connection);
         var service = new DeploymentService(connection);
         return service;
     }
     catch (Exception ex)
     {
         throw new FailedToConnectToCrmException(connection, ex);
     }
 }
コード例 #32
0
 private ListViewItem CreateListViewItem(DeploymentService.ProductDescription productDescription) {
   ListViewItem item = new ListViewItem(new string[] { productDescription.Name, productDescription.Version.ToString() });
   item.Tag = productDescription;
   item.ImageIndex = 0;
   return item;
 }