Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ItemGroup>
<PackageReference Include="MediatR" Version="10.0.1" />
<PackageReference Include="SecurityService.Client" Version="1.1.1" />
<PackageReference Include="Shared" Version="1.3.8" />
<PackageReference Include="TransactionProcessor.Client" Version="1.1.9" />
<PackageReference Include="Shared" Version="1.4.1" />
<PackageReference Include="TransactionProcessor.Client" Version="1.1.12" />
</ItemGroup>

<ItemGroup>
Expand Down
259 changes: 7 additions & 252 deletions TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs

Large diffs are not rendered by default.

43 changes: 13 additions & 30 deletions TransactionProcessorACL.IntegrationTests/Common/GenericSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<IContainerService> containers = new List<IContainerService>();
//containers.Add(this.TestingContext.DockerHelper.EstateManagementContainer);
//containers.Add(this.TestingContext.DockerHelper.TransactionProcessorContainer);

//foreach (IContainerService containerService in containers)
//{
// ConsoleStream<String> logStream = containerService.Logs();
// IList<String> 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");
}
}
}
33 changes: 11 additions & 22 deletions TransactionProcessorACL.IntegrationTests/Common/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="1.3.9" />
<PackageReference Include="ClientProxyBase" Version="1.4.1" />
<PackageReference Include="Ductus.FluentDocker" Version="2.10.51" />
<PackageReference Include="EstateManagement.Client" Version="1.1.5" />
<PackageReference Include="EstateReporting.Database" Version="1.1.7" />
Expand All @@ -16,12 +16,12 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="SecurityService.Client" Version="1.1.2-build20" />
<PackageReference Include="Shared.IntegrationTesting" Version="1.3.9" />
<PackageReference Include="Shared.IntegrationTesting" Version="1.4.1" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="SpecFlow" Version="3.9.74" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74" />
<PackageReference Include="SpecFlow.xUnit" Version="3.9.74" />
<PackageReference Include="TransactionProcessor.Client" Version="1.1.13-build21" />
<PackageReference Include="TransactionProcessor.Client" Version="1.1.12" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TransactionProcessor.Client" Version="1.1.9" />
<PackageReference Include="TransactionProcessor.Client" Version="1.1.12" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion TransactionProcessorACL/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
});

Expand Down
2 changes: 1 addition & 1 deletion TransactionProcessorACL/TransactionProcessorACL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2-beta1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Shared" Version="1.3.8" />
<PackageReference Include="Shared" Version="1.4.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.3.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.3" />
Expand Down