Exemple #1
0
        protected static void GlobalSetup()
        {
            ShouldlyConfiguration.DefaultTaskTimeout = TimeSpan.FromMinutes(1);

            (String, String, String)dockerCredentials = ("https://www.docker.com", "stuartferguson", "Sc0tland");

            // Setup a network for the DB Server
            Setup.DatabaseServerNetwork = DockerHelper.SetupTestNetwork("sharednetwork");

            NlogLogger logger = new NlogLogger();

            logger.Initialise(LogManager.GetLogger("Specflow"), "Specflow");
            LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly);

            String sqlServerImageName           = "mcr.microsoft.com/mssql/server:2019-latest";
            DockerEnginePlatform enginePlatform = DockerHelper.GetDockerEnginePlatform();

            if (enginePlatform == DockerEnginePlatform.Windows)
            {
                sqlServerImageName = "tobiasfenster/mssql-server-dev-unsupported:2019-cu13";
            }

            // Start the Database Server here
            Setup.DatabaseServerContainer = Setup.StartSqlContainerWithOpenConnection(Setup.SqlServerContainerName,
                                                                                      logger,
                                                                                      sqlServerImageName,
                                                                                      Setup.DatabaseServerNetwork,
                                                                                      dockerCredentials,
                                                                                      Setup.SqlUserName,
                                                                                      Setup.SqlPassword);
        }
Exemple #2
0
        /// <summary>
        /// Starts the containers for scenario run.
        /// </summary>
        /// <param name="scenarioName">Name of the scenario.</param>
        public override async Task StartContainersForScenarioRun(String scenarioName)
        {
            this.HostTraceFolder = null;
            if (DockerHelper.GetDockerEnginePlatform() == DockerEnginePlatform.Linux)
            {
                this.HostTraceFolder = FdOs.IsWindows() ? $"F:\\home\\txnproc\\trace\\{scenarioName}" : $"//home//txnproc//trace//{scenarioName}";
            }

            Logging.Enabled();

            Guid testGuid = Guid.NewGuid();

            this.TestId = testGuid;

            this.Logger.LogInformation($"Test Id is {testGuid}");

            // Setup the container names
            this.SecurityServiceContainerName    = $"sferguson.ddns.net";
            this.EstateManagementContainerName   = $"estate{testGuid:N}";
            this.EstateReportingContainerName    = $"estatereporting{testGuid:N}";
            this.EstateManagementUiContainerName = $"estateadministrationui{testGuid:N}";
            this.EventStoreContainerName         = $"eventstore{testGuid:N}";

            String eventStoreAddress = $"http://{this.EventStoreContainerName}";

            this.ClientDetails     = ("serviceClient", "Secret1");
            this.SqlServerDetails  = (Setup.SqlServerContainerName, Setup.SqlUserName, Setup.SqlPassword);
            this.DockerCredentials = ("https://www.docker.com", "stuartferguson", "Sc0tland");

            INetworkService testNetwork = DockerHelper.SetupTestNetwork($"testnetwork{this.TestId:N}");

            this.TestNetworks.Add(testNetwork);

            // Setup the docker image names
            String eventStoreImageName      = "eventstore/eventstore:21.2.0-buster-slim";
            String estateMangementImageName = "stuartferguson/estatemanagement";
            String estateReportingImageName = "stuartferguson/estatereporting";

            DockerEnginePlatform enginePlatform = DockerHelper.GetDockerEnginePlatform();

            if (enginePlatform == DockerEnginePlatform.Windows)
            {
                estateMangementImageName = "stuartferguson/estatemanagementwindows";
                estateReportingImageName = "stuartferguson/estatereportingwindows";
                eventStoreImageName      = "stuartferguson/eventstore";
            }

            IContainerService eventStoreContainer = this.SetupEventStoreContainer(eventStoreImageName, testNetwork);

            this.EventStoreHttpPort = eventStoreContainer.ToHostExposedEndpoint($"{DockerHelper.EventStoreHttpDockerPort}/tcp").Port;

            String insecureEventStoreEnvironmentVariable    = "EventStoreSettings:Insecure=true";
            String persistentSubscriptionPollingInSeconds   = "AppSettings:PersistentSubscriptionPollingInSeconds=10";
            String internalSubscriptionServiceCacheDuration = "AppSettings:InternalSubscriptionServiceCacheDuration=0";

            List <String> estateManagementVariables = new List <String>();

            estateManagementVariables.Add($"SecurityConfiguration:ApiName=estateManagement{this.TestId.ToString("N")}");
            estateManagementVariables.Add($"EstateRoleName=Estate{this.TestId.ToString("N")}");
            estateManagementVariables.Add($"MerchantRoleName=Merchant{this.TestId.ToString("N")}");
            estateManagementVariables.AddRange(new List <String> {
                insecureEventStoreEnvironmentVariable,
                persistentSubscriptionPollingInSeconds,
                internalSubscriptionServiceCacheDuration
            });


            IContainerService estateManagementContainer = this.SetupEstateManagementContainer(estateMangementImageName,
                                                                                              new List <INetworkService>
            {
                testNetwork,
                Setup.DatabaseServerNetwork
            },
                                                                                              securityServicePort: 55001,
                                                                                              additionalEnvironmentVariables: estateManagementVariables,
                                                                                              forceLatestImage: true);

            IContainerService estateReportingContainer = this.SetupEstateReportingContainer(estateReportingImageName,
                                                                                            new List <INetworkService>
            {
                testNetwork,
                Setup.DatabaseServerNetwork
            },
                                                                                            true,
                                                                                            additionalEnvironmentVariables: new List <String>
            {
                insecureEventStoreEnvironmentVariable,
                persistentSubscriptionPollingInSeconds,
                internalSubscriptionServiceCacheDuration
            });

            IContainerService estateManagementUiContainer = SetupEstateManagementUIContainer(this.EstateManagementUiContainerName,
                                                                                             this.Logger,
                                                                                             "estateadministrationui",
                                                                                             new List <INetworkService>
            {
                testNetwork
            },
                                                                                             this.EstateManagementContainerName,
                                                                                             this.EstateReportingContainerName,
                                                                                             this.HostTraceFolder,
                                                                                             this.DockerCredentials,
                                                                                             ($"estateUIClient{this.TestId.ToString("N")}", "Secret1"));

            this.Containers.AddRange(new List <IContainerService>
            {
                eventStoreContainer,
                estateManagementContainer,
                estateReportingContainer,
                estateManagementUiContainer
            });

            // Cache the ports
            this.EstateManagementApiPort = estateManagementContainer.ToHostExposedEndpoint("5000/tcp").Port;
            this.EventStoreHttpPort      = eventStoreContainer.ToHostExposedEndpoint("2113/tcp").Port;
            this.EstateManagementUIPort  = estateManagementUiContainer.ToHostExposedEndpoint("5004/tcp").Port;

            // Setup the base address resolvers
            String EstateManagementBaseAddressResolver(String api) => $"http://127.0.0.1:{this.EstateManagementApiPort}";

            HttpClientHandler clientHandler = new HttpClientHandler
            {
                ServerCertificateCustomValidationCallback = (message,
                                                             certificate2,
                                                             arg3,
                                                             arg4) =>
                {
                    return(true);
                }
            };
            HttpClient httpClient = new HttpClient(clientHandler);

            this.EstateClient = new EstateClient(EstateManagementBaseAddressResolver, httpClient);
            Func <String, String> securityServiceBaseAddressResolver = api => $"https://sferguson.ddns.net:55001";

            this.SecurityServiceClient = new SecurityServiceClient(securityServiceBaseAddressResolver, httpClient);

            await LoadEventStoreProjections().ConfigureAwait(false);
        }