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
68 changes: 34 additions & 34 deletions .github/workflows/nightlybuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,49 +76,49 @@ jobs:
name: tracelogslinux
path: /home/txnproc/trace/

buildwindows:
name: "Nightly Build - Windows"
env:
ASPNETCORE_ENVIRONMENT: "Production"
# buildwindows:
# name: "Nightly Build - Windows"
# env:
# ASPNETCORE_ENVIRONMENT: "Production"

runs-on: windows-latest
# runs-on: windows-latest

steps:
- uses: actions/checkout@v1
# steps:
# - uses: actions/checkout@v1

- name: Install NET 9
uses: actions/setup-dotnet@v4.0.1
with:
dotnet-version: '9.0.x'
# - name: Install NET 9
# uses: actions/setup-dotnet@v4.0.1
# with:
# dotnet-version: '9.0.x'

- name: Build Windows SQL Server
run: |
cd SQLDocker
docker build -t mssqlserver:2022-ltsc2022 --build-arg SQL_VERSION=2022 --build-arg WIN_VERSION=ltsc2022 .
# - name: Build Windows SQL Server
# run: |
# cd SQLDocker
# docker build -t mssqlserver:2022-ltsc2022 --build-arg SQL_VERSION=2022 --build-arg WIN_VERSION=ltsc2022 .

- name: Restore Nuget Packages
run: dotnet restore Shared.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}
# - name: Restore Nuget Packages
# run: dotnet restore Shared.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}

- name: Build Code
run: dotnet build Shared.sln --configuration Release
# - name: Build Code
# run: dotnet build Shared.sln --configuration Release

- name: Run Event Store Tests
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "Shared.EventStoreContext.Tests\Shared.EventStoreContext.Tests.csproj"
# - name: Run Event Store Tests
# run: |
# echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
# dotnet test "Shared.EventStoreContext.Tests\Shared.EventStoreContext.Tests.csproj"

- name: Run Integration Tests
env:
IsCI: true
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "Shared.IntegrationTesting.Tests\Shared.IntegrationTesting.Tests.csproj"
# - name: Run Integration Tests
# env:
# IsCI: true
# run: |
# echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
# dotnet test "Shared.IntegrationTesting.Tests\Shared.IntegrationTesting.Tests.csproj"

- uses: actions/upload-artifact@v4.4.3
if: ${{ failure() }}
with:
name: tracelogswindows
path: C:\\Users\\runneradmin\\txnproc
# - uses: actions/upload-artifact@v4.4.3
# if: ${{ failure() }}
# with:
# name: tracelogswindows
# path: C:\\Users\\runneradmin\\txnproc

# buildmacos:
# name: "Nightly Build - Mac"
Expand Down
96 changes: 48 additions & 48 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,55 +54,55 @@ jobs:
name: tracelogslinux
path: /home/txnproc/trace/

buildwindows:
name: "Build and Test Pull Requests - Windows"
env:
ASPNETCORE_ENVIRONMENT: "Production"

runs-on: windows-latest

steps:
- uses: actions/checkout@v1

- name: Install NET 9
uses: actions/setup-dotnet@v4.0.1
with:
dotnet-version: '9.0.x'

- name: Build Windows SQL Server
run: |
cd SQLDocker
docker build -t mssqlserver:2022-ltsc2022 --build-arg SQL_VERSION=2022 --build-arg WIN_VERSION=ltsc2022 .

- name: Restore Nuget Packages
run: dotnet restore Shared.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}

- name: Build Code
run: dotnet build Shared.sln --configuration Release

- name: Run Unit Tests
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "Shared.Tests\Shared.Tests.csproj"

- name: Run Event Store Tests
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "Shared.EventStore.Tests\Shared.EventStore.Tests.csproj"
dotnet test "Shared.EventStoreContext.Tests\Shared.EventStoreContext.Tests.csproj"

- name: Run Integration Tests
env:
IsCI: true
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "Shared.IntegrationTesting.Tests\Shared.IntegrationTesting.Tests.csproj"
# buildwindows:
# name: "Build and Test Pull Requests - Windows"
# env:
# ASPNETCORE_ENVIRONMENT: "Production"

- uses: actions/upload-artifact@v4.4.3
#if: ${{ failure() }}
with:
name: tracelogswindows
path: C:\\Users\\runneradmin\\txnproc
# runs-on: windows-latest

# steps:
# - uses: actions/checkout@v1

# - name: Install NET 9
# uses: actions/setup-dotnet@v4.0.1
# with:
# dotnet-version: '9.0.x'

# - name: Build Windows SQL Server
# run: |
# cd SQLDocker
# docker build -t mssqlserver:2022-ltsc2022 --build-arg SQL_VERSION=2022 --build-arg WIN_VERSION=ltsc2022 .

# - name: Restore Nuget Packages
# run: dotnet restore Shared.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}

# - name: Build Code
# run: dotnet build Shared.sln --configuration Release

# - name: Run Unit Tests
# run: |
# echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
# dotnet test "Shared.Tests\Shared.Tests.csproj"

# - name: Run Event Store Tests
# run: |
# echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
# dotnet test "Shared.EventStore.Tests\Shared.EventStore.Tests.csproj"
# dotnet test "Shared.EventStoreContext.Tests\Shared.EventStoreContext.Tests.csproj"

# - name: Run Integration Tests
# env:
# IsCI: true
# run: |
# echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
# dotnet test "Shared.IntegrationTesting.Tests\Shared.IntegrationTesting.Tests.csproj"

# - uses: actions/upload-artifact@v4.4.3
# #if: ${{ failure() }}
# with:
# name: tracelogswindows
# path: C:\\Users\\runneradmin\\txnproc

# buildmacos:
# name: "Build and Test Pull Requests - Mac"
Expand Down
43 changes: 35 additions & 8 deletions ClientProxyBase/ClientProxyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
{

HttpRequestMessage requestMessage = new(HttpMethod.Get, uri);
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(AuthenticationSchemes.Bearer, accessToken);
if (String.IsNullOrEmpty(accessToken) == false)
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(AuthenticationSchemes.Bearer, accessToken);

// Make the Http Call here
HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken);
Expand All @@ -129,8 +130,15 @@
{

HttpRequestMessage requestMessage = new(HttpMethod.Post, uri);
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(AuthenticationSchemes.Bearer, accessToken);
requestMessage.Content = new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, "application/json");
if (String.IsNullOrEmpty(accessToken) == false)
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(AuthenticationSchemes.Bearer, accessToken);
if (content.GetType() == typeof(FormUrlEncodedContent)) {
// Treat this specially
requestMessage.Content = content as FormUrlEncodedContent;
}
else {
requestMessage.Content = new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, "application/json");
}

// Make the Http Call here
HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken);
Expand All @@ -150,8 +158,17 @@
{

HttpRequestMessage requestMessage = new(HttpMethod.Put, uri);
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(AuthenticationSchemes.Bearer, accessToken);
requestMessage.Content = new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, "application/json");
if (String.IsNullOrEmpty(accessToken) == false)
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(AuthenticationSchemes.Bearer, accessToken);
if (content.GetType() == typeof(FormUrlEncodedContent))
{
// Treat this specially
requestMessage.Content = content as FormUrlEncodedContent;
}
else
{
requestMessage.Content = new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, "application/json");
}

// Make the Http Call here
HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken);
Expand All @@ -171,8 +188,17 @@
{

HttpRequestMessage requestMessage = new(HttpMethod.Patch, uri);
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(AuthenticationSchemes.Bearer, accessToken);
requestMessage.Content = new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, "application/json");
if (String.IsNullOrEmpty(accessToken) == false)
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(AuthenticationSchemes.Bearer, accessToken);
if (content.GetType() == typeof(FormUrlEncodedContent))
{
// Treat this specially
requestMessage.Content = content as FormUrlEncodedContent;
}
else
{
requestMessage.Content = new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, "application/json");
}

// Make the Http Call here
HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken);
Expand All @@ -192,7 +218,8 @@
{

HttpRequestMessage requestMessage = new(HttpMethod.Delete, uri);
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(AuthenticationSchemes.Bearer, accessToken);
if (String.IsNullOrEmpty(accessToken) == false)
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(AuthenticationSchemes.Bearer, accessToken);

// Make the Http Call here
HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken);
Expand All @@ -213,7 +240,7 @@
}

public class ClientHttpException : Exception {
public ClientHttpException(string? message,

Check warning on line 243 in ClientProxyBase/ClientProxyBase.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.

Check warning on line 243 in ClientProxyBase/ClientProxyBase.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.
Exception? innerException = null) : base(message, innerException) {

}
Expand Down
11 changes: 8 additions & 3 deletions Shared.IntegrationTesting.Tests/GenericSteps.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
namespace Shared.IntegrationTesting.Tests;
using ClientProxyBase;

namespace Shared.IntegrationTesting.Tests;

using Logger;
using Microsoft.AspNetCore.Http;
using NLog;
using Reqnroll;

public class TestDockerHelper : DockerHelper{
public override async Task CreateSubscriptions(){

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

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
// Nothing here
}
}
Expand All @@ -30,7 +33,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 36 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 @@ -43,15 +46,17 @@
DockerServices services = DockerServices.EventStore | DockerServices.MessagingService | DockerServices.SecurityService |
DockerServices.CallbackHandler | DockerServices.FileProcessor |
DockerServices.TestHost | DockerServices.TransactionProcessor |
DockerServices.TransactionProcessorAcl;

DockerServices.TransactionProcessorAcl | DockerServices.KeyCloak;
this.TestingContext.Logger = logger;
this.TestingContext.Logger.LogInformation("About to Start Containers for Scenario Run");
this.TestingContext.DockerHelper.ScenarioName = scenarioName;
await this.TestingContext.DockerHelper.StartContainersForScenarioRun(scenarioName, services).ConfigureAwait(false);
this.TestingContext.Logger.LogInformation("Containers for Scenario Run Started");
}



[AfterScenario()]
public async Task StopSystem(){
DockerServices sharedDockerServices = DockerServices.SqlServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ClientProxyBase\ClientProxyBase.csproj" />
<ProjectReference Include="..\Shared.IntegrationTesting\Shared.IntegrationTesting.csproj" />
</ItemGroup>

Expand Down
28 changes: 27 additions & 1 deletion Shared.IntegrationTesting/BaseDockerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@
protected List<INetworkService> TestNetworks;

protected String TransactionProcessorAclContainerName;

protected Int32 TransactionProcessorAclPort;

protected String KeyCloakContainerName;
protected Int32 KeyCloakPort;

protected String TransactionProcessorContainerName;

protected Int32 TransactionProcessorPort;
Expand Down Expand Up @@ -146,6 +149,7 @@
this.ImageDetails.Add(ContainerType.TransactionProcessor, ("stuartferguson/transactionprocessorwindows:master", true));
this.ImageDetails.Add(ContainerType.FileProcessor, ("stuartferguson/fileprocessorwindows:master", true));
this.ImageDetails.Add(ContainerType.TransactionProcessorAcl, ("stuartferguson/transactionprocessoraclwindows:master", true));
this.ImageDetails.Add(ContainerType.Keycloak, ("quay.io/keycloak/keycloak:26.4.1", true)); // Note: this may not work...
}
else{
if (FdOs.IsLinux()){
Expand All @@ -163,6 +167,7 @@
this.ImageDetails.Add(ContainerType.TransactionProcessor, ("stuartferguson/transactionprocessor:master", true));
this.ImageDetails.Add(ContainerType.FileProcessor, ("stuartferguson/fileprocessor:master", true));
this.ImageDetails.Add(ContainerType.TransactionProcessorAcl, ("stuartferguson/transactionprocessoracl:master", true));
this.ImageDetails.Add(ContainerType.Keycloak, ("quay.io/keycloak/keycloak:26.4.1", true));
}

this.HostPorts = new Dictionary<ContainerType, Int32>();
Expand Down Expand Up @@ -320,6 +325,7 @@
this.MessagingServiceContainerName = $"messaging{this.TestId:N}";
this.TransactionProcessorContainerName = $"transaction{this.TestId:N}";
this.TransactionProcessorAclContainerName = $"transactionacl{this.TestId:N}";
this.KeyCloakContainerName= $"keycloak{this.TestId:N}";
}

public virtual ContainerBuilder SetupEventStoreContainer(){
Expand Down Expand Up @@ -368,6 +374,22 @@
return eventStoreContainerBuilder;
}

public virtual ContainerBuilder SetupKeycloakContainer()
{
this.Trace("About to Start KeyCloak Container");

List<String> environmentVariables = new();
environmentVariables.Add("KC_BOOTSTRAP_ADMIN_USERNAME=admin");
environmentVariables.Add("KC_BOOTSTRAP_ADMIN_PASSWORD=admin");

ContainerBuilder keycloakContainer = new Builder().UseContainer()
.WithName(this.KeyCloakContainerName).WithEnvironment(environmentVariables.ToArray())
.UseImageDetails(this.GetImageDetails(ContainerType.Keycloak).Data).ExposePort(DockerPorts.KeyCloakDockerPort)
.Command("start-dev"); // 👈 equivalent to `docker run ... start-dev`

return keycloakContainer;
}

public virtual ContainerBuilder SetupFileProcessorContainer(){
this.Trace("About to Start File Processor Container");

Expand Down Expand Up @@ -855,7 +877,7 @@
try{
await projectionClient.CreateContinuousAsync(projectionName, projection, trackEmittedStreams:true).ConfigureAwait(false);
}
catch (Exception ex) {

Check warning on line 880 in Shared.IntegrationTesting/BaseDockerHelper.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

The variable 'ex' is declared but never used
// ignored
}

Expand Down Expand Up @@ -934,6 +956,7 @@
DockerServices.TransactionProcessorAcl => ContainerType.TransactionProcessorAcl,
DockerServices.EventStore=> ContainerType.EventStore,
DockerServices.SqlServer => ContainerType.SqlServer,
DockerServices.KeyCloak => ContainerType.Keycloak,
_ => ContainerType.NotSet
};

Expand Down Expand Up @@ -1009,6 +1032,9 @@
case ContainerType.TransactionProcessorAcl:
TransactionProcessorAclPort = GetPort(DockerPorts.TransactionProcessorAclDockerPort);
break;
case ContainerType.Keycloak:
this.KeyCloakPort = GetPort(DockerPorts.KeyCloakDockerPort);
break;
}
}

Expand Down
1 change: 1 addition & 0 deletions Shared.IntegrationTesting/ContainerType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public enum ContainerType
TransactionProcessor,
FileProcessor,
TransactionProcessorAcl,
Keycloak,
NotSet
}
Loading
Loading