diff --git a/TransactionProcessorACL.BusinessLogic/TransactionProcessorACL.BusinessLogic.csproj b/TransactionProcessorACL.BusinessLogic/TransactionProcessorACL.BusinessLogic.csproj
index 09fac28..4462bae 100644
--- a/TransactionProcessorACL.BusinessLogic/TransactionProcessorACL.BusinessLogic.csproj
+++ b/TransactionProcessorACL.BusinessLogic/TransactionProcessorACL.BusinessLogic.csproj
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs b/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs
index e5d10ca..dd4c0e0 100644
--- a/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs
+++ b/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs
@@ -45,52 +45,12 @@ public class DockerHelper : global::Shared.IntegrationTesting.DockerHelper
///
public ISecurityServiceClient SecurityServiceClient;
- ///
- /// The test identifier
- ///
- public Guid TestId;
-
///
/// The transaction processor client
///
public ITransactionProcessorClient TransactionProcessorClient;
- ///
- /// The containers
- ///
- protected List Containers;
-
- ///
- /// The estate management API port
- ///
- protected Int32 EstateManagementApiPort;
-
- ///
- /// The event store HTTP port
- ///
- protected Int32 EventStoreHttpPort;
-
- ///
- /// The security service port
- ///
- protected Int32 SecurityServicePort;
-
- ///
- /// The test networks
- ///
- protected List TestNetworks;
-
- ///
- /// The transaction processor acl port
- ///
- protected Int32 TransactionProcessorACLPort;
-
private const String MinimumSupportedApplicationVersion = "1.0.5";
-
- ///
- /// The transaction processor port
- ///
- protected Int32 TransactionProcessorPort;
private readonly TestingContext TestingContext;
@@ -102,199 +62,29 @@ public class DockerHelper : global::Shared.IntegrationTesting.DockerHelper
/// Initializes a new instance of the class.
///
/// The logger.
- public DockerHelper(NlogLogger logger, TestingContext testingContext)
+ public DockerHelper()
{
- this.Logger = logger;
- this.TestingContext = testingContext;
- this.Containers = new List();
- this.TestNetworks = new List();
+ this.TestingContext = new TestingContext();
}
#endregion
#region Methods
- protected override String GenerateEventStoreConnectionString()
- {
- // TODO: this could move to shared
- String eventStoreAddress = $"esdb://admin:changeit@{this.EventStoreContainerName}:{DockerHelper.EventStoreHttpDockerPort}";
- if (this.IsSecureEventStore)
- {
- eventStoreAddress = $"{eventStoreAddress}?tls=true&tlsVerifyCert=false";
- }
- else
- {
- eventStoreAddress = $"{eventStoreAddress}?tls=false&tlsVerifyCert=false";
- }
-
- return eventStoreAddress;
- }
-
- public Boolean IsSecureEventStore { get; private set; }
-
///
/// Starts the containers for scenario run.
///
/// Name of the scenario.
public override async Task StartContainersForScenarioRun(String scenarioName)
{
- String IsSecureEventStoreEnvVar = Environment.GetEnvironmentVariable("IsSecureEventStore");
+ await base.StartContainersForScenarioRun(scenarioName);
- if (IsSecureEventStoreEnvVar == null)
- {
- // No env var set so default to insecure
- this.IsSecureEventStore = false;
- }
- else
- {
- // We have the env var so we set the secure flag based on the value in the env var
- Boolean.TryParse(IsSecureEventStoreEnvVar, out Boolean isSecure);
- this.IsSecureEventStore = isSecure;
- }
-
- this.HostTraceFolder = FdOs.IsWindows() ? $"D:\\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 = $"securityservice{testGuid:N}";
- this.EstateManagementContainerName = $"estate{testGuid:N}";
- this.EventStoreContainerName = $"eventstore{testGuid:N}";
- this.EstateReportingContainerName = $"estatereporting{testGuid:N}";
- this.TransactionProcessorContainerName = $"txnprocessor{testGuid:N}";
- this.TransactionProcessorACLContainerName = $"txnprocessoracl{testGuid:N}";
- this.TestHostContainerName = $"testhosts{testGuid:N}";
- this.VoucherManagementContainerName = $"vouchermanagement{testGuid:N}";
- this.DockerCredentials = ("https://www.docker.com", "stuartferguson", "Sc0tland");
- this.ClientDetails = ("serviceClient", "Secret1");
- this.SqlServerDetails = (Setup.SqlServerContainerName, Setup.SqlUserName, Setup.SqlPassword);
-
- INetworkService testNetwork = DockerHelper.SetupTestNetwork();
- this.TestNetworks.Add(testNetwork);
-
- IContainerService eventStoreContainer =
- this.SetupEventStoreContainer("eventstore/eventstore:21.10.0-buster-slim", testNetwork, isSecure: this.IsSecureEventStore);
- this.EventStoreHttpPort = eventStoreContainer.ToHostExposedEndpoint($"{DockerHelper.EventStoreHttpDockerPort}/tcp").Port;
-
- String insecureEventStoreEnvironmentVariable = "EventStoreSettings:Insecure=True";
- if (this.IsSecureEventStore)
- {
- insecureEventStoreEnvironmentVariable = "EventStoreSettings:Insecure=False";
- }
-
- String persistentSubscriptionPollingInSeconds = "AppSettings:PersistentSubscriptionPollingInSeconds=10";
- String internalSubscriptionServiceCacheDuration = "AppSettings:InternalSubscriptionServiceCacheDuration=0";
-
- IContainerService estateManagementContainer = this.SetupEstateManagementContainer("stuartferguson/estatemanagement",
- new List
- {
- testNetwork,
- Setup.DatabaseServerNetwork
- },
- true,
- additionalEnvironmentVariables:new List
- {
- insecureEventStoreEnvironmentVariable,
- persistentSubscriptionPollingInSeconds,
- internalSubscriptionServiceCacheDuration
- });
-
- IContainerService securityServiceContainer = this.SetupSecurityServiceContainer("stuartferguson/securityservice",
- testNetwork,
- true);
-
- IContainerService voucherManagementContainer = this.SetupVoucherManagementContainer("stuartferguson/vouchermanagement",
- new List
- {
- testNetwork
- },
- true,
- additionalEnvironmentVariables:new List
- {
- insecureEventStoreEnvironmentVariable,
- });
-
- String pataPawaUrlEnvironmentVariable = "OperatorConfiguration:PataPawaPostPay:Url=http://" + this.TestHostContainerName + ":9000/PataPawaPostPayService/basichttp";
- String pataPawaApiLogonRequiredEnvironmentVariable = "OperatorConfiguration:PataPawaPostPay:ApiLogonRequired=false";
- String transactionProcessorReadModelConnectionString = $"ConnectionStrings:TransactionProcessorReadModel=\"server={this.SqlServerDetails.sqlServerContainerName};user id=sa;password={this.SqlServerDetails.sqlServerPassword};database=TransactionProcessorReadModel\"";
-
- IContainerService transactionProcessorContainer = this.SetupTransactionProcessorContainer("stuartferguson/transactionprocessor",
- new List
- {
- testNetwork,
- Setup.DatabaseServerNetwork
- },
- true,
- additionalEnvironmentVariables:new List
- {
- transactionProcessorReadModelConnectionString,
- pataPawaUrlEnvironmentVariable,
- pataPawaApiLogonRequiredEnvironmentVariable,
- insecureEventStoreEnvironmentVariable,
- persistentSubscriptionPollingInSeconds,
- internalSubscriptionServiceCacheDuration,
- $"AppSettings:VoucherManagementApi=http://{this.VoucherManagementContainerName}:{DockerHelper.VoucherManagementDockerPort}"
- });
-
- IContainerService estateReportingContainer = this.SetupEstateReportingContainer("stuartferguson/estatereporting",
- new List
- {
- testNetwork,
- Setup.DatabaseServerNetwork
- },
- true,
- additionalEnvironmentVariables:new List
- {
- insecureEventStoreEnvironmentVariable,
- persistentSubscriptionPollingInSeconds,
- internalSubscriptionServiceCacheDuration
- });
-
- List additionalVariables = new List()
- {
- $"AppSettings:MinimumSupportedApplicationVersion={DockerHelper.MinimumSupportedApplicationVersion}"
- };
-
- IContainerService transactionProcessorACLContainer = this.SetupTransactionProcessorACLContainer("transactionprocessoracl", testNetwork,
- additionalEnvironmentVariables:additionalVariables);
-
- IContainerService testhostContainer = this.SetupTestHostContainer("stuartferguson/testhosts",
- new List
- {
- testNetwork,
- Setup.DatabaseServerNetwork
- },
- true);
-
- this.Containers.AddRange(new List
- {
- eventStoreContainer,
- estateManagementContainer,
- securityServiceContainer,
- transactionProcessorContainer,
- transactionProcessorACLContainer,
- estateReportingContainer,
- testhostContainer,
- voucherManagementContainer
- });
-
- // Cache the ports
- this.EstateManagementApiPort = estateManagementContainer.ToHostExposedEndpoint("5000/tcp").Port;
- this.SecurityServicePort = securityServiceContainer.ToHostExposedEndpoint("5001/tcp").Port;
- this.TransactionProcessorPort = transactionProcessorContainer.ToHostExposedEndpoint("5002/tcp").Port;
- this.TransactionProcessorACLPort = transactionProcessorACLContainer.ToHostExposedEndpoint("5003/tcp").Port;
-
// Setup the base address resolvers
- String EstateManagementBaseAddressResolver(String api) => $"http://127.0.0.1:{this.EstateManagementApiPort}";
+ String EstateManagementBaseAddressResolver(String api) => $"http://127.0.0.1:{this.EstateManagementPort}";
String SecurityServiceBaseAddressResolver(String api) => $"https://127.0.0.1:{this.SecurityServicePort}";
String TransactionProcessorBaseAddressResolver(String api) => $"http://127.0.0.1:{this.TransactionProcessorPort}";
- String TransactionProcessorAclBaseAddressResolver(String api) => $"http://127.0.0.1:{this.TransactionProcessorACLPort}";
+ String TransactionProcessorAclBaseAddressResolver(String api) => $"http://127.0.0.1:{this.TransactionProcessorAclPort}";
HttpClientHandler clientHandler = new HttpClientHandler
{
@@ -315,27 +105,9 @@ public override async Task StartContainersForScenarioRun(String scenarioName)
this.HttpClient = new HttpClient();
this.HttpClient.BaseAddress = new Uri(TransactionProcessorAclBaseAddressResolver(string.Empty));
- await this.LoadEventStoreProjections(this.EventStoreHttpPort, this.IsSecureEventStore).ConfigureAwait(false);
- await this.PopulateSubscriptionServiceConfigurationGeneric(this.IsSecureEventStore).ConfigureAwait(false);
}
- public async Task PopulateSubscriptionServiceConfigurationForEstate(String estateName, Boolean isSecureEventStore)
- {
- List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new List<(String streamName, String groupName, Int32 maxRetries)>();
- subscriptions.Add((estateName.Replace(" ", ""), "Reporting", 2));
- subscriptions.Add(($"EstateManagementSubscriptionStream_{estateName.Replace(" ", "")}", "Estate Management", 0));
- subscriptions.Add(($"TransactionProcessorSubscriptionStream_{estateName.Replace(" ", "")}", "Transaction Processor", 0));
- await this.PopulateSubscriptionServiceConfiguration(this.EventStoreHttpPort, subscriptions, isSecureEventStore);
- }
- public async Task PopulateSubscriptionServiceConfigurationGeneric(Boolean isSecureEventStore)
- {
- List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new List<(String streamName, String groupName, Int32 maxRetries)>();
- subscriptions.Add(($"$ce-MerchantBalanceArchive", "Transaction Processor - Ordered", 0));
- subscriptions.Add(($"$et-EstateCreatedEvent", "Transaction Processor - Ordered", 2));
- await this.PopulateSubscriptionServiceConfiguration(this.EventStoreHttpPort, subscriptions, isSecureEventStore);
- }
-
- private async Task RemoveEstateReadModel()
+ private async Task RemoveEstateReadModel()
{
List estateIdList = this.TestingContext.GetAllEstateIds();
@@ -360,24 +132,7 @@ public override async Task StopContainersForScenarioRun()
{
await RemoveEstateReadModel().ConfigureAwait(false);
- if (this.Containers.Any())
- {
- foreach (IContainerService containerService in this.Containers)
- {
- containerService.StopOnDispose = true;
- containerService.RemoveOnDispose = true;
- containerService.Dispose();
- }
- }
-
- if (this.TestNetworks.Any())
- {
- foreach (INetworkService networkService in this.TestNetworks)
- {
- networkService.Stop();
- networkService.Remove(true);
- }
- }
+ base.StopContainersForScenarioRun();
}
#endregion
diff --git a/TransactionProcessorACL.IntegrationTests/Common/GenericSteps.cs b/TransactionProcessorACL.IntegrationTests/Common/GenericSteps.cs
index b59a1d2..b35720d 100644
--- a/TransactionProcessorACL.IntegrationTests/Common/GenericSteps.cs
+++ b/TransactionProcessorACL.IntegrationTests/Common/GenericSteps.cs
@@ -6,6 +6,7 @@ namespace TransactionProcessor.IntegrationTests.Common
{
using System.Threading;
using System.Threading.Tasks;
+ using global::Shared.IntegrationTesting;
using global::Shared.Logger;
using NLog;
using TechTalk.SpecFlow;
@@ -34,46 +35,28 @@ public async Task StartSystem()
logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName);
LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly);
- this.TestingContext.DockerHelper = new DockerHelper(logger, this.TestingContext);
+ this.TestingContext.DockerHelper = new DockerHelper();
+ this.TestingContext.DockerHelper.Logger = logger;
+ this.TestingContext.DockerHelper.SqlServerContainer = Setup.DatabaseServerContainer;
+ this.TestingContext.DockerHelper.SqlServerNetwork = Setup.DatabaseServerNetwork;
+ this.TestingContext.DockerHelper.DockerCredentials = Setup.DockerCredentials;
+ this.TestingContext.DockerHelper.SqlCredentials = Setup.SqlCredentials;
+ this.TestingContext.DockerHelper.SqlServerContainerName = "sharedsqlserver";
+
+ this.TestingContext.DockerHelper.SetImageDetails(ContainerType.TransactionProcessorAcl, ("transactionprocessoracl", false));
+
this.TestingContext.Logger = logger;
this.TestingContext.Logger.LogInformation("About to Start Containers for Scenario Run");
await this.TestingContext.DockerHelper.StartContainersForScenarioRun(scenarioName).ConfigureAwait(false);
this.TestingContext.Logger.LogInformation("Containers for Scenario Run Started");
-
- Thread.Sleep(20000);
}
[AfterScenario]
public async Task StopSystem()
{
- if (this.ScenarioContext.TestError != null)
- {
- //Exception currentEx = this.ScenarioContext.TestError;
- //Console.Out.WriteLine(currentEx.Message);
- //while (currentEx.InnerException != null)
- //{
- // currentEx = currentEx.InnerException;
- // Console.Out.WriteLine(currentEx.Message);
- //}
-
- //// The test has failed, grab the logs from all the containers
- //List containers = new List();
- //containers.Add(this.TestingContext.DockerHelper.EstateManagementContainer);
- //containers.Add(this.TestingContext.DockerHelper.TransactionProcessorContainer);
-
- //foreach (IContainerService containerService in containers)
- //{
- // ConsoleStream logStream = containerService.Logs();
- // IList logData = logStream.ReadToEnd();
-
- // foreach (String s in logData)
- // {
- // Console.Out.WriteLine(s);
- // }
- //}
- }
-
+ this.TestingContext.Logger.LogInformation("About to Stop Containers for Scenario Run");
await this.TestingContext.DockerHelper.StopContainersForScenarioRun().ConfigureAwait(false);
+ this.TestingContext.Logger.LogInformation("Containers for Scenario Run Stopped");
}
}
}
diff --git a/TransactionProcessorACL.IntegrationTests/Common/Setup.cs b/TransactionProcessorACL.IntegrationTests/Common/Setup.cs
index a2912ea..d1baf0d 100644
--- a/TransactionProcessorACL.IntegrationTests/Common/Setup.cs
+++ b/TransactionProcessorACL.IntegrationTests/Common/Setup.cs
@@ -21,49 +21,38 @@ namespace TransactionProcessor.IntegrationTests.Common
public class Setup
{
public static IContainerService DatabaseServerContainer;
- private static String DbConnectionStringWithNoDatabase;
public static INetworkService DatabaseServerNetwork;
-
- public static String SqlServerContainerName = "shareddatabasesqlserver";
-
- public const String SqlUserName = "sa";
-
- public const String SqlPassword = "thisisalongpassword123!";
+ public static (String usename, String password) SqlCredentials = ("sa", "thisisalongpassword123!");
+ public static (String url, String username, String password) DockerCredentials = ("https://www.docker.com", "stuartferguson", "Sc0tland");
[BeforeTestRun]
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
- DatabaseServerNetwork = global::Shared.IntegrationTesting.DockerHelper.SetupTestNetwork("sharednetwork", true);
+ DockerHelper dockerHelper = new DockerHelper();
NlogLogger logger = new NlogLogger();
logger.Initialise(LogManager.GetLogger("Specflow"), "Specflow");
LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly);
+ dockerHelper.Logger = logger;
+ dockerHelper.SqlCredentials = Setup.SqlCredentials;
+ dockerHelper.DockerCredentials = Setup.DockerCredentials;
+ dockerHelper.SqlServerContainerName = "sharedsqlserver";
- // Start the Database Server here
- DatabaseServerContainer = global::Shared.IntegrationTesting.DockerHelper.StartSqlContainerWithOpenConnection(Setup.SqlServerContainerName,
- logger,
- "mcr.microsoft.com/mssql/server:2019-latest",
- Setup.DatabaseServerNetwork,
- "",
- dockerCredentials,
- Setup.SqlUserName,
- Setup.SqlPassword);
+ Setup.DatabaseServerNetwork = dockerHelper.SetupTestNetwork("sharednetwork", true);
+ Setup.DatabaseServerContainer = dockerHelper.SetupSqlServerContainer(Setup.DatabaseServerNetwork);
}
public static String GetConnectionString(String databaseName)
{
- return $"server={Setup.DatabaseServerContainer.Name};database={databaseName};user id={Setup.SqlUserName};password={Setup.SqlPassword}";
+ return $"server={Setup.DatabaseServerContainer.Name};database={databaseName};user id={Setup.SqlCredentials.usename};password={Setup.SqlCredentials.password}";
}
public static String GetLocalConnectionString(String databaseName)
{
Int32 databaseHostPort = Setup.DatabaseServerContainer.ToHostExposedEndpoint("1433/tcp").Port;
- return $"server=localhost,{databaseHostPort};database={databaseName};user id={Setup.SqlUserName};password={Setup.SqlPassword}";
+ return $"server=localhost,{databaseHostPort};database={databaseName};user id={Setup.SqlCredentials.usename};password={Setup.SqlCredentials.password}";
}
}
diff --git a/TransactionProcessorACL.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessorACL.IntegrationTests/Shared/SharedSteps.cs
index 083b778..3b2ad23 100644
--- a/TransactionProcessorACL.IntegrationTests/Shared/SharedSteps.cs
+++ b/TransactionProcessorACL.IntegrationTests/Shared/SharedSteps.cs
@@ -575,7 +575,7 @@ public async Task WhenICreateTheFollowingEstates(Table table)
// Setup the subscriptions for the estate
await Retry.For(async () =>
{
- await this.TestingContext.DockerHelper.PopulateSubscriptionServiceConfigurationForEstate(estateName,this.TestingContext.DockerHelper.IsSecureEventStore).ConfigureAwait(false);
+ await this.TestingContext.DockerHelper.CreateEstateSubscriptions(estateName).ConfigureAwait(false);
}, retryFor: TimeSpan.FromMinutes(2), retryInterval: TimeSpan.FromSeconds(30));
EstateResponse estate = null;
diff --git a/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj b/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj
index c899162..079a94f 100644
--- a/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj
+++ b/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj
@@ -7,7 +7,7 @@
-
+
@@ -16,12 +16,12 @@
-
+
-
+
all
diff --git a/TransactionProcessorACL.Testing/TransactionProcessorACL.Testing.csproj b/TransactionProcessorACL.Testing/TransactionProcessorACL.Testing.csproj
index aa8bc9f..1f9d224 100644
--- a/TransactionProcessorACL.Testing/TransactionProcessorACL.Testing.csproj
+++ b/TransactionProcessorACL.Testing/TransactionProcessorACL.Testing.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/TransactionProcessorACL/Startup.cs b/TransactionProcessorACL/Startup.cs
index 9a7b8a1..9f42773 100644
--- a/TransactionProcessorACL/Startup.cs
+++ b/TransactionProcessorACL/Startup.cs
@@ -120,7 +120,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
endpoints.MapHealthChecks("health", new HealthCheckOptions()
{
Predicate = _ => true,
- ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
+ ResponseWriter = Shared.HealthChecks.HealthCheckMiddleware.WriteResponse
});
});
diff --git a/TransactionProcessorACL/TransactionProcessorACL.csproj b/TransactionProcessorACL/TransactionProcessorACL.csproj
index d5dba4d..bd3c8cd 100644
--- a/TransactionProcessorACL/TransactionProcessorACL.csproj
+++ b/TransactionProcessorACL/TransactionProcessorACL.csproj
@@ -23,7 +23,7 @@
-
+