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 @@ -8,8 +8,8 @@
<PackageReference Include="EstateManagement.Client" Version="1.0.15-build74" />
<PackageReference Include="MessagingService.Client" Version="1.0.10.2" />
<PackageReference Include="SecurityService.Client" Version="1.0.6.2" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="1.0.14" />
<PackageReference Include="Shared.EventStore" Version="1.0.14" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="1.0.18" />
<PackageReference Include="Shared.EventStore" Version="1.0.18" />
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="System.IO.Abstractions" Version="13.2.9" />
<PackageReference Include="VoucherManagement.Client" Version="1.0.4.1" />
Expand Down
70 changes: 45 additions & 25 deletions TransactionProcessor.IntegrationTests/Common/DockerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ private async Task LoadEventStoreProjections()
Logger.LogInformation("Loaded projections");
}

protected String EventStoreConnectionString;

#region Methods

/// <summary>
Expand Down Expand Up @@ -188,21 +190,21 @@ public override async Task StartContainersForScenarioRun(String scenarioName)
this.TestHostContainerName = $"testhosts{testGuid:N}";
this.VoucherManagementContainerName = $"vouchermanagement{testGuid:N}";
this.MessagingServiceContainerName = $"messaging{testGuid:N}";

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


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

INetworkService testNetwork = DockerHelper.SetupTestNetwork();
this.TestNetworks.Add(testNetwork);
IContainerService eventStoreContainer = DockerHelper.SetupEventStoreContainer(this.EventStoreContainerName, this.Logger, "eventstore/eventstore:20.10.0-buster-slim", testNetwork, traceFolder);
this.EventStoreHttpPort = eventStoreContainer.ToHostExposedEndpoint($"{DockerHelper.EventStoreHttpDockerPort}/tcp").Port;

await Retry.For(async () =>
{
await this.PopulateSubscriptionServiceConfiguration().ConfigureAwait(false);
}, retryFor: TimeSpan.FromMinutes(2), retryInterval: TimeSpan.FromSeconds(30));

this.EventStoreConnectionString =
$"esdb://admin:changeit@{this.EventStoreContainerName}:{DockerHelper.EventStoreHttpDockerPort}?tls=false";

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

IContainerService voucherManagementContainer = SetupVoucherManagementContainer(this.VoucherManagementContainerName,
this.Logger,
"stuartferguson/vouchermanagement",
Expand All @@ -214,12 +216,16 @@ await Retry.For(async () =>
dockerCredentials,
this.SecurityServiceContainerName,
this.EstateManagementContainerName,
eventStoreAddress,
this.EventStoreConnectionString,
(Setup.SqlServerContainerName,
"sa",
"thisisalongpassword123!"),
("serviceClient", "Secret1"),
true);
true,
additionalEnvironmentVariables: new List<String>
{
insecureEventStoreEnvironmentVariable,
});

IContainerService estateManagementContainer = DockerHelper.SetupEstateManagementContainer(this.EstateManagementContainerName, this.Logger,
"stuartferguson/estatemanagement", new List<INetworkService>
Expand All @@ -228,20 +234,26 @@ await Retry.For(async () =>
Setup.DatabaseServerNetwork
}, traceFolder, dockerCredentials,
this.SecurityServiceContainerName,
eventStoreAddress,
this.EventStoreConnectionString,
(Setup.SqlServerContainerName,
"sa",
"thisisalongpassword123!"),
("serviceClient", "Secret1"),
true);
true,
additionalEnvironmentVariables: new List<String>
{
insecureEventStoreEnvironmentVariable,
persistentSubscriptionPollingInSeconds,
internalSubscriptionServiceCacheDuration
});

IContainerService messagingServiceContainer = DockerHelper.SetupMessagingServiceContainer(this.MessagingServiceContainerName, this.Logger,
"stuartferguson/messagingservice", new List<INetworkService>
{
testNetwork
}, traceFolder, dockerCredentials,
this.SecurityServiceContainerName,
eventStoreAddress,
this.EventStoreConnectionString,
("serviceClient", "Secret1"),
true);

Expand Down Expand Up @@ -269,10 +281,16 @@ await Retry.For(async () =>
dockerCredentials,
this.SecurityServiceContainerName,
this.EstateManagementContainerName,
eventStoreAddress,
this.EventStoreConnectionString,
("serviceClient", "Secret1"),
this.TestHostContainerName,
this.VoucherManagementContainerName);
this.VoucherManagementContainerName,
additionalEnvironmentVariables: new List<String>
{
insecureEventStoreEnvironmentVariable,
persistentSubscriptionPollingInSeconds,
internalSubscriptionServiceCacheDuration
});

IContainerService estateReportingContainer = DockerHelper.SetupEstateReportingContainer(this.EstateReportingContainerName,
this.Logger,
Expand All @@ -285,12 +303,18 @@ await Retry.For(async () =>
traceFolder,
dockerCredentials,
this.SecurityServiceContainerName,
eventStoreAddress,
this.EventStoreConnectionString,
(Setup.SqlServerContainerName,
"sa",
"thisisalongpassword123!"),
("serviceClient", "Secret1"),
true);
true,
additionalEnvironmentVariables: new List<String>
{
insecureEventStoreEnvironmentVariable,
persistentSubscriptionPollingInSeconds,
internalSubscriptionServiceCacheDuration
});

IContainerService testhostContainer = SetupTestHostContainer(this.TestHostContainerName,
this.Logger,
Expand Down Expand Up @@ -348,17 +372,13 @@ await Retry.For(async () =>
await this.LoadEventStoreProjections().ConfigureAwait(false);
}

protected async Task PopulateSubscriptionServiceConfiguration()
public async Task PopulateSubscriptionServiceConfiguration(String estateName)
{
EventStorePersistentSubscriptionsClient client = new EventStorePersistentSubscriptionsClient(ConfigureEventStoreSettings(this.EventStoreHttpPort));

PersistentSubscriptionSettings settings = new PersistentSubscriptionSettings(resolveLinkTos: true);
await client.CreateAsync("$ce-EstateAggregate", "Reporting", settings);
await client.CreateAsync("$ce-MerchantAggregate", "Reporting", settings);
await client.CreateAsync("$ce-ContractAggregate", "Reporting", settings);
await client.CreateAsync("$ce-TransactionAggregate", "Reporting", settings);
await client.CreateAsync("$et-TransactionHasBeenCompletedEvent", "TransactionProcessor", settings);
await client.CreateAsync("$et-MerchantFeeAddedToTransactionEvent", "TransactionProcessor", settings);
PersistentSubscriptionSettings settings = new PersistentSubscriptionSettings(resolveLinkTos: true, StreamPosition.Start);
await client.CreateAsync(estateName.Replace(" ", ""), "Reporting", settings);
await client.CreateAsync($"EstateManagementSubscriptionStream_{estateName.Replace(" ", "")}", "Estate Management", settings);
}

private static EventStoreClientSettings ConfigureEventStoreSettings(Int32 eventStoreHttpPort)
Expand Down
27 changes: 18 additions & 9 deletions TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@ public SharedSteps(ScenarioContext scenarioContext,
[When(@"I create the following estates")]
public async Task WhenICreateTheFollowingEstates(Table table)
{
foreach (TableRow tableRow in table.Rows)
{
String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName");
// Setup the subscriptions for the estate
await Retry.For(async () => { await this.TestingContext.DockerHelper.PopulateSubscriptionServiceConfiguration(estateName).ConfigureAwait(false); },
retryFor: TimeSpan.FromMinutes(2),
retryInterval: TimeSpan.FromSeconds(30));
}

foreach (TableRow tableRow in table.Rows)
{
String estateName = SpecflowTableHelper.GetStringRowValue(tableRow, "EstateName");

CreateEstateRequest createEstateRequest = new CreateEstateRequest
{
EstateId = Guid.NewGuid(),
EstateName = estateName
};
{
EstateId = Guid.NewGuid(),
EstateName = estateName
};

CreateEstateResponse response = await this.TestingContext.DockerHelper.EstateClient.CreateEstate(this.TestingContext.AccessToken, createEstateRequest, CancellationToken.None).ConfigureAwait(false);

Expand All @@ -73,11 +82,11 @@ public async Task WhenICreateTheFollowingEstates(Table table)

EstateResponse estate = null;
await Retry.For(async () =>
{
estate = await this.TestingContext.DockerHelper.EstateClient
.GetEstate(this.TestingContext.AccessToken, estateDetails.EstateId, CancellationToken.None).ConfigureAwait(false);
estate.ShouldNotBeNull();
}).ConfigureAwait(false);
{
estate = await this.TestingContext.DockerHelper.EstateClient
.GetEstate(this.TestingContext.AccessToken, estateDetails.EstateId, CancellationToken.None).ConfigureAwait(false);
estate.ShouldNotBeNull();
}, retryFor: TimeSpan.FromSeconds(90)).ConfigureAwait(false);

estate.EstateName.ShouldBe(estateDetails.EstateName);
}
Expand Down
Loading