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
4 changes: 2 additions & 2 deletions Shared.IntegrationTesting.Tests/GenericSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", "");
NlogLogger logger = new();
logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName);
LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly);

Check warning on line 39 in Shared.IntegrationTesting.Tests/GenericSteps.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

'LogManager.AddHiddenAssembly(Assembly)' is obsolete: 'Replaced by LogManager.Setup().SetupLogFactory(setup => setup.AddCallSiteHiddenAssembly(assembly)). Marked obsolete on NLog 5.3'

Check warning on line 39 in Shared.IntegrationTesting.Tests/GenericSteps.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

'LogManager.AddHiddenAssembly(Assembly)' is obsolete: 'Replaced by LogManager.Setup().SetupLogFactory(setup => setup.AddCallSiteHiddenAssembly(assembly)). Marked obsolete on NLog 5.3'

this.TestingContext.DockerHelper = new TestDockerHelper();
this.TestingContext.DockerHelper.Logger = logger;
Expand All @@ -44,8 +44,8 @@
DockerServices services = DockerServices.SqlServer | DockerServices.EventStore | DockerServices.MessagingService | DockerServices.SecurityService |
DockerServices.CallbackHandler | DockerServices.FileProcessor |
DockerServices.TestHost | DockerServices.TransactionProcessor |
DockerServices.TransactionProcessorAcl | DockerServices.ConfigurationHost
| DockerServices.EstateManagementUI;
DockerServices.TransactionProcessorAcl | DockerServices.ConfigurationHost |
DockerServices.EstateManagementUI | DockerServices.EstateReporting;

this.TestingContext.Logger = logger;
this.TestingContext.Logger.LogInformation("About to Start Containers for Scenario Run");
Expand Down
4 changes: 3 additions & 1 deletion Shared.IntegrationTesting/ContainerType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public enum ContainerType
FileProcessor,
TransactionProcessorAcl,
ConfigurationHost,
EstateManangementUI,
EstateManagementUI,
EstateReporting,
NotSet
}

Expand All @@ -33,6 +34,7 @@ public enum DockerServices
TransactionProcessorAcl = 256,
ConfigurationHost = 512,
EstateManagementUI = 1024,
EstateReporting = 2048
}

public enum DockerEnginePlatform
Expand Down
1 change: 1 addition & 0 deletions Shared.IntegrationTesting/DockerPorts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public static class DockerPorts
public static readonly Int32 ConfigHostDockerPort = 9200;

public static readonly Int32 EstateManagementUIDockerPort = 5004;
public static readonly Int32 EstateReportingDockerPort = 5011;
public static readonly Int32 SqlServerDockerPort = 1433;
}
47 changes: 41 additions & 6 deletions Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
public String ScenarioName;

protected String CallbackHandlerContainerName;
protected String EstateReportingContainerName;

protected Int32 CallbackHandlerPort;
protected Int32 EstateReportingPort;

protected (String clientId, String clientSecret) ClientDetails;

Expand Down Expand Up @@ -149,7 +151,8 @@
this.ImageDetails.Add(ContainerType.FileProcessor, ("stuartferguson/fileprocessor:master", true));
this.ImageDetails.Add(ContainerType.TransactionProcessorAcl, ("stuartferguson/transactionprocessoracl:master", true));
this.ImageDetails.Add(ContainerType.ConfigurationHost, ("stuartferguson/mobileconfiguration:master", true));
this.ImageDetails.Add(ContainerType.EstateManangementUI, ("stuartferguson/estatemanagementui:latest", true));
this.ImageDetails.Add(ContainerType.EstateManagementUI, ("stuartferguson/estatemanagementui:latest", true));
this.ImageDetails.Add(ContainerType.EstateReporting, ("stuartferguson/estatereportingapi:latest", true));
}

this.HostPorts = new Dictionary<ContainerType, Int32>();
Expand All @@ -168,7 +171,7 @@
public virtual Dictionary<String,String> GetAdditionalVariables(ContainerType containerType){
Dictionary<String, String> result = new();

Dictionary<String, String>? additional = this.AdditionalVariables.SingleOrDefault(a => a.Key == containerType).Value;

Check warning on line 174 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 174 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
if (additional != null){
foreach (KeyValuePair<String, String> item in additional) {
result.Add(item.Key, item.Value);
Expand Down Expand Up @@ -209,7 +212,7 @@
Docker.DotNet.DockerClientBuilder b = new DockerClientBuilder();
DockerClient docker = b.Build();

SystemInfoResponse? info = await docker.System.GetSystemInfoAsync();

Check warning on line 215 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 215 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

return info.OSType switch {
"linux" => Result.Success(DockerEnginePlatform.Linux),
Expand Down Expand Up @@ -241,7 +244,8 @@
ContainerType.TransactionProcessor => this.TransactionProcessorPort,
ContainerType.TransactionProcessorAcl => this.TransactionProcessorAclPort,
ContainerType.SqlServer => this.SqlServerPort,
ContainerType.EstateManangementUI => this.EstateManagementUiPort,
ContainerType.EstateManagementUI => this.EstateManagementUiPort,
ContainerType.EstateReporting => this.EstateReportingPort,
_ when key == ContainerType.EventStore && this.IsSecureEventStore => this.EventStoreSecureHttpPort,
_ when key == ContainerType.EventStore && this.IsSecureEventStore == false => this.EventStoreHttpPort,
_ => null
Expand Down Expand Up @@ -292,7 +296,7 @@

(String imageName, Boolean useLatest) imageDetails = this.GetImageDetails(ContainerType.CallbackHandler).Data;

ContainerBuilder callbackHandlerContainer = new ContainerBuilder()

Check warning on line 299 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'

Check warning on line 299 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'
.WithName(this.CallbackHandlerContainerName) // similar to WithName()
.WithImage(imageDetails.imageName)
.WithEnvironment(environmentVariables)
Expand All @@ -315,6 +319,7 @@
this.TransactionProcessorAclContainerName = $"transactionacl{this.TestId:N}";
this.ConfigHostContainerName = $"mobileconfighost{this.TestId:N}";
this.EstateManagementUiContainerName = $"estateadministrationui{this.TestId:N}";
this.EstateReportingContainerName = $"estatereporting{this.TestId:N}";
}

protected Int32 EstateManagementUiPort;
Expand All @@ -331,7 +336,7 @@
{"EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP","true"},
{"EVENTSTORE_PROJECTION_EXECUTION_TIMEOUT","5000"}
};
ContainerBuilder eventStoreContainer = new ContainerBuilder();

Check warning on line 339 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'

Check warning on line 339 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'

if (!this.IsSecureEventStore){
environmentVariables.Add("EVENTSTORE_INSECURE","true");
Expand Down Expand Up @@ -427,7 +432,7 @@

(String imageName, Boolean useLatest) imageDetails = this.GetImageDetails(ContainerType.FileProcessor).Data;

ContainerBuilder fileProcessorContainer = new ContainerBuilder()

Check warning on line 435 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'

Check warning on line 435 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'
.WithName(this.FileProcessorContainerName) // similar to WithName()
.WithImage(imageDetails.imageName)
.WithEnvironment(environmentVariables)
Expand Down Expand Up @@ -475,9 +480,9 @@
environmentVariables.Add($"DataReloadConfig:DefaultInSeconds", "1");
environmentVariables.Add("ConnectionStrings:TransactionProcessorReadModel", this.SetConnectionString("TransactionProcessorReadModel", this.UseSecureSqlServerDatabase));

(String imageName, Boolean useLatest) imageDetails = this.GetImageDetails(ContainerType.EstateManangementUI).Data;
(String imageName, Boolean useLatest) imageDetails = this.GetImageDetails(ContainerType.EstateManagementUI).Data;

ContainerBuilder containerBuilder = new ContainerBuilder()

Check warning on line 485 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'

Check warning on line 485 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'
.WithName(this.EstateManagementUiContainerName)
.WithImage(imageDetails.imageName)
.WithEnvironment(environmentVariables)
Expand All @@ -495,7 +500,7 @@

(String imageName, Boolean useLatest) imageDetails = this.GetImageDetails(ContainerType.ConfigurationHost).Data;

ContainerBuilder configHostContainer = new ContainerBuilder().WithName(this.ConfigHostContainerName)

Check warning on line 503 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'

Check warning on line 503 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'
.WithImage(imageDetails.imageName)
.WithEnvironment(environmentVariables)
.MountHostFolder(this.DockerPlatform, this.HostTraceFolder)
Expand All @@ -522,7 +527,7 @@

(String imageName, Boolean useLatest) imageDetails = this.GetImageDetails(ContainerType.MessagingService).Data;

ContainerBuilder messagingServiceContainer = new ContainerBuilder().WithName(this.MessagingServiceContainerName) // similar to WithName()

Check warning on line 530 in Shared.IntegrationTesting/TestContainers/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

'ContainerBuilder.ContainerBuilder()' is obsolete: 'This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.'
.WithImage(imageDetails.imageName).WithEnvironment(environmentVariables).MountHostFolder(this.DockerPlatform, this.HostTraceFolder).WithPortBinding(DockerPorts.MessagingServiceDockerPort, true);
//.WithWaitStrategy(Wait.ForUnixContainer().UntilInternalTcpPortIsAvailable(DockerPorts.MessagingServiceDockerPort));

Expand Down Expand Up @@ -623,6 +628,31 @@
return testHostContainer;
}

public virtual ContainerBuilder SetupEstateReportingContainer()
{
this.Trace("About to Start Estate Reporting Container");

Dictionary<String, String> environmentVariables = this.GetCommonEnvironmentVariables();

Dictionary<String, String> additionalEnvironmentVariables = this.GetAdditionalVariables(ContainerType.EstateReporting);

foreach (KeyValuePair<String, String> additionalEnvironmentVariable in additionalEnvironmentVariables)
{
environmentVariables.Add(additionalEnvironmentVariable.Key, additionalEnvironmentVariable.Value);
}

(String imageName, Boolean useLatest) imageDetails = this.GetImageDetails(ContainerType.EstateReporting).Data;

ContainerBuilder estateReportingContainer = new ContainerBuilder()
.WithName(this.EstateReportingContainerName) // similar to WithName()
.WithImage(imageDetails.imageName)
.WithEnvironment(environmentVariables)
.MountHostFolder(this.DockerPlatform, this.HostTraceFolder)
.WithPortBinding(DockerPorts.EstateReportingDockerPort, true);

return estateReportingContainer;
}

public virtual async Task<INetwork> SetupTestNetwork(String networkName = null,
Boolean reuseIfExists = false){
networkName = String.IsNullOrEmpty(networkName) ? $"testnw{this.TestId:N}" : networkName;
Expand Down Expand Up @@ -844,7 +874,8 @@
ContainerType.SecurityService => ("https", this.SecurityServicePort),
ContainerType.TransactionProcessorAcl => ("http", this.TransactionProcessorAclPort),
//ContainerType.ConfigurationHost => ("http", this.ConfigHostPort),
//ContainerType.EstateManangementUI => ("https", this.EstateManagementUiPort),
//ContainerType.EstateManagementUI => ("https", this.EstateManagementUiPort),
ContainerType.EstateReporting => ("http", this.EstateReportingPort),
_ => (null, 0)
};

Expand Down Expand Up @@ -998,7 +1029,8 @@
DockerServices.EventStore=> ContainerType.EventStore,
DockerServices.SqlServer => ContainerType.SqlServer,
DockerServices.ConfigurationHost => ContainerType.ConfigurationHost,
DockerServices.EstateManagementUI => ContainerType.EstateManangementUI,
DockerServices.EstateManagementUI => ContainerType.EstateManagementUI,
DockerServices.EstateReporting => ContainerType.EstateReporting,
_ => ContainerType.NotSet
};

Expand Down Expand Up @@ -1078,12 +1110,15 @@
case ContainerType.ConfigurationHost:
ConfigHostPort = GetPort(DockerPorts.ConfigHostDockerPort);
break;
case ContainerType.EstateManangementUI:
case ContainerType.EstateManagementUI:
EstateManagementUiPort = GetPort(DockerPorts.EstateManagementUIDockerPort);
break;
case ContainerType.SqlServer:
SqlServerPort = GetPort(DockerPorts.SqlServerDockerPort);
break;
case ContainerType.EstateReporting:
EstateReportingPort = GetPort(DockerPorts.EstateReportingDockerPort);
break;

}
}
Expand Down
4 changes: 3 additions & 1 deletion Shared.IntegrationTesting/TestContainers/DockerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? OSPlatform.OSX :
OSPlatform.Windows;

this.HostTraceFolder = (isCI, platform) switch

Check warning on line 35 in Shared.IntegrationTesting/TestContainers/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '(true, _)' is not covered. However, a pattern with a 'when' clause might successfully match this value.

Check warning on line 35 in Shared.IntegrationTesting/TestContainers/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '(true, _)' is not covered. However, a pattern with a 'when' clause might successfully match this value.
{
(true, var p) when p == OSPlatform.Linux => $"/home/runner/trace/{scenarioName}",
(true, var p) when p == OSPlatform.OSX => $"/Users/runner/trace/{scenarioName}",
Expand Down Expand Up @@ -97,8 +97,10 @@
await StartContainer2(this.SetupFileProcessorContainer, networks, DockerServices.FileProcessor);
await StartContainer2(this.SetupTransactionProcessorAclContainer, networks, DockerServices.TransactionProcessorAcl);
await StartContainer2(this.SetupConfigHostContainer, networks, DockerServices.ConfigurationHost);
if (this.DockerPlatform == DockerEnginePlatform.Linux)
if (this.DockerPlatform == DockerEnginePlatform.Linux) {
await StartContainer2(this.SetupEstateManagementUiContainer, networks, DockerServices.EstateManagementUI);
await StartContainer2(this.SetupEstateReportingContainer, networks, DockerServices.EstateReporting);
}

await this.LoadEventStoreProjections();

Expand Down Expand Up @@ -132,7 +134,7 @@
continue;
}

String? name = containerService.Item2.Name;

Check warning on line 137 in Shared.IntegrationTesting/TestContainers/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 137 in Shared.IntegrationTesting/TestContainers/DockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
this.Trace($"Stopping container [{name}]");
//if (name.Contains("eventstore"))
//{
Expand Down
Loading