From 1fe94b81f6f071abf51b997f40e8bbe2d1e38fc5 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 16 Nov 2022 14:10:29 +0000 Subject: [PATCH 1/5] Upgrade shared libraries to NET 7 --- .github/workflows/createrelease.yml | 5 ++ .github/workflows/pullrequest.yml | 9 ++- ClientProxyBase/ClientProxyBase.csproj | 2 +- Driver/Driver.csproj | 2 +- .../Shared.DomainDrivenDesign.csproj | 2 +- .../EventStoreContextTests.cs | 72 ++++++++----------- .../Shared.EventStore.Tests.csproj | 14 ++-- Shared.EventStore/Shared.EventStore.csproj | 12 ++-- ...EventStorePersistentSubscriptionsClient.cs | 3 +- .../Shared.IntegrationTesting.Tests.csproj | 10 +-- Shared.IntegrationTesting/DockerHelper.cs | 20 ++---- .../Shared.IntegrationTesting.csproj | 8 +-- .../ConfigurationRootExtensionsTests.cs | 4 +- Shared.Tests/Shared.Tests.csproj | 12 ++-- Shared.sln | 8 ++- Shared/Shared.csproj | 10 +-- 16 files changed, 94 insertions(+), 99 deletions(-) diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml index 4ad45ea1..7bacebf6 100644 --- a/.github/workflows/createrelease.yml +++ b/.github/workflows/createrelease.yml @@ -15,6 +15,11 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Install NET 7 + uses: actions/setup-dotnet@v2 + with: + dotnet-version: '7.0.x' + - name: Get the version id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index f1689245..8852bc81 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -16,6 +16,11 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Install NET 7 + uses: actions/setup-dotnet@v2 + with: + dotnet-version: '7.0.x' + - name: Restore Nuget Packages run: dotnet restore Shared.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json @@ -44,10 +49,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Install NET 6 + - name: Install NET 7 uses: actions/setup-dotnet@v2 with: - dotnet-version: '6.0.x' + dotnet-version: '7.0.x' - name: Restore Nuget Packages run: dotnet restore Shared.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json diff --git a/ClientProxyBase/ClientProxyBase.csproj b/ClientProxyBase/ClientProxyBase.csproj index 6d856688..1d0f1e7b 100644 --- a/ClientProxyBase/ClientProxyBase.csproj +++ b/ClientProxyBase/ClientProxyBase.csproj @@ -1,7 +1,7 @@  - net6.0;netstandard2.0 + net7.0;netstandard2.0 diff --git a/Driver/Driver.csproj b/Driver/Driver.csproj index ec8df561..29000e56 100644 --- a/Driver/Driver.csproj +++ b/Driver/Driver.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 diff --git a/Shared.DomainDrivenDesign/Shared.DomainDrivenDesign.csproj b/Shared.DomainDrivenDesign/Shared.DomainDrivenDesign.csproj index be3ba9ee..aa51cae5 100644 --- a/Shared.DomainDrivenDesign/Shared.DomainDrivenDesign.csproj +++ b/Shared.DomainDrivenDesign/Shared.DomainDrivenDesign.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 diff --git a/Shared.EventStore.Tests/EventStoreContextTests.cs b/Shared.EventStore.Tests/EventStoreContextTests.cs index 3aaf6a92..5a96f881 100644 --- a/Shared.EventStore.Tests/EventStoreContextTests.cs +++ b/Shared.EventStore.Tests/EventStoreContextTests.cs @@ -44,26 +44,7 @@ public async Task EventStoreContext_InsertEvents_EventsAreWritten(Boolean secure await Task.Delay(TimeSpan.FromSeconds(30)); - EventStoreClientSettings settings = new EventStoreClientSettings(); - settings.ConnectivitySettings = EventStoreClientConnectivitySettings.Default; - - if (secureEventStore) { - settings.ConnectivitySettings.Address = new Uri($"esdb://admin:changeit@127.0.0.1:{this.EventStoreHttpPort}?tls=true&tlsVerifyCert=false"); - } - else { - settings.CreateHttpMessageHandler = () => new SocketsHttpHandler { - SslOptions = { - RemoteCertificateValidationCallback = (sender, - certificate, - chain, - errors) => true, - } - }; - - settings.ConnectivitySettings.Insecure = true; - settings.ConnectivitySettings.Address = new Uri($"esdb://admin:changeit@127.0.0.1:{this.EventStoreHttpPort}?tls=false"); - settings.DefaultCredentials = new UserCredentials("admin", "changeit"); - } + EventStoreClientSettings settings = this.CreateEventStoreClientSettings(secureEventStore); EventStoreClient client = new(settings); EventStoreProjectionManagementClient projectionManagementClient = new(settings); @@ -89,27 +70,8 @@ public async Task EventStoreContext_ReadEvents_EventsAreRead(Boolean secureEvent await Task.Delay(TimeSpan.FromSeconds(30)); - EventStoreClientSettings settings = new EventStoreClientSettings(); - settings.ConnectivitySettings = EventStoreClientConnectivitySettings.Default; - - if (secureEventStore) { - settings.ConnectivitySettings.Address = new Uri($"esdb://admin:changeit@127.0.0.1:{this.EventStoreHttpPort}?tls=true&tlsVerifyCert=false"); - } - else { - settings.CreateHttpMessageHandler = () => new SocketsHttpHandler { - SslOptions = { - RemoteCertificateValidationCallback = (sender, - certificate, - chain, - errors) => true, - } - }; - - settings.ConnectivitySettings.Insecure = true; - settings.ConnectivitySettings.Address = new Uri($"esdb://admin:changeit@127.0.0.1:{this.EventStoreHttpPort}?tls=false"); - settings.DefaultCredentials = new UserCredentials("admin", "changeit"); - } - + EventStoreClientSettings settings = this.CreateEventStoreClientSettings(secureEventStore); + EventStoreClient client = new(settings); EventStoreProjectionManagementClient projectionManagementClient = new(settings); IEventStoreContext context = new EventStoreContext(client, projectionManagementClient); @@ -134,6 +96,32 @@ public async Task EventStoreContext_ReadEvents_EventsAreRead(Boolean secureEvent }); } + private EventStoreClientSettings CreateEventStoreClientSettings(Boolean secureEventStore) { + String connectionString = secureEventStore switch { + true => $"esdb://admin:changeit@127.0.0.1:{this.EventStoreHttpPort}?tls=true&tlsVerifyCert=false", + _ => $"esdb://admin:changeit@127.0.0.1:{this.EventStoreHttpPort}?tls=false" + }; + + EventStoreClientSettings settings = EventStoreClientSettings.Create(connectionString); + settings.ConnectivitySettings.Insecure = secureEventStore switch { + true => false, + _ => true + }; + + if (secureEventStore == false) { + settings.CreateHttpMessageHandler = () => new SocketsHttpHandler { + SslOptions = { + RemoteCertificateValidationCallback = (sender, + certificate, + chain, + errors) => true, + } + }; + } + + return settings; + } + private INetworkService SetupTestNetwork(String networkName = null, Boolean reuseIfExists = false) { networkName = String.IsNullOrEmpty(networkName) ? $"testnetwork{Guid.NewGuid()}" : networkName; @@ -152,7 +140,7 @@ private void StartContainers(Boolean isSecureEventStore) { INetworkService networkService = this.SetupTestNetwork($"testNetwork-{Guid.NewGuid():N}", true); this.TestNetworks.Add(networkService); - IContainerService containerService = this.StartEventStoreContainer("eventstore/eventstore:21.10.5-bionic", + IContainerService containerService = this.StartEventStoreContainer("eventstore/eventstore:22.6.0-bionic", $"eventStore-{Guid.NewGuid():N}", isSecureEventStore, networkService); diff --git a/Shared.EventStore.Tests/Shared.EventStore.Tests.csproj b/Shared.EventStore.Tests/Shared.EventStore.Tests.csproj index 1deab52f..adcd13be 100644 --- a/Shared.EventStore.Tests/Shared.EventStore.Tests.csproj +++ b/Shared.EventStore.Tests/Shared.EventStore.Tests.csproj @@ -1,22 +1,22 @@ - net6.0 + net7.0 Full false - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Shared.EventStore/Shared.EventStore.csproj b/Shared.EventStore/Shared.EventStore.csproj index 1cdf13b3..690bbd2b 100644 --- a/Shared.EventStore/Shared.EventStore.csproj +++ b/Shared.EventStore/Shared.EventStore.csproj @@ -1,17 +1,17 @@  - net6.0 + net7.0 - - - + + + - + - + diff --git a/Shared.EventStore/SubscriptionWorker/EventStorePersistentSubscriptionsClient.cs b/Shared.EventStore/SubscriptionWorker/EventStorePersistentSubscriptionsClient.cs index 8fa505ab..89b373a6 100644 --- a/Shared.EventStore/SubscriptionWorker/EventStorePersistentSubscriptionsClient.cs +++ b/Shared.EventStore/SubscriptionWorker/EventStorePersistentSubscriptionsClient.cs @@ -32,7 +32,8 @@ public EventStorePersistentSubscriptionsClient(global::EventStore.Client.EventSt UserCredentials? userCredentials, Int32 bufferSize, CancellationToken cancellationToken) { - return this.SubscriptionsClient.SubscribeAsync(stream, group, eventAppeared, subscriptionDropped, userCredentials, bufferSize, false, cancellationToken); + //return this.SubscriptionsClient.SubscribeAsync(stream, group, eventAppeared, subscriptionDropped, userCredentials, bufferSize, false, cancellationToken); + return this.SubscriptionsClient.SubscribeToStreamAsync(stream, group, eventAppeared, subscriptionDropped, userCredentials, bufferSize, cancellationToken); } #endregion diff --git a/Shared.IntegrationTesting.Tests/Shared.IntegrationTesting.Tests.csproj b/Shared.IntegrationTesting.Tests/Shared.IntegrationTesting.Tests.csproj index 0f19f985..83a3017a 100644 --- a/Shared.IntegrationTesting.Tests/Shared.IntegrationTesting.Tests.csproj +++ b/Shared.IntegrationTesting.Tests/Shared.IntegrationTesting.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable @@ -13,16 +13,16 @@ - - + + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Shared.IntegrationTesting/DockerHelper.cs b/Shared.IntegrationTesting/DockerHelper.cs index 7cd75f4d..70732b6a 100644 --- a/Shared.IntegrationTesting/DockerHelper.cs +++ b/Shared.IntegrationTesting/DockerHelper.cs @@ -101,17 +101,7 @@ await this.SetupEstateManagementContainer(new List { testNetwork, this.SqlServerNetwork }); - - //await this.SetupEstateReportingContainer(new List { - // testNetwork, - // this.SqlServerNetwork - // }); - - //await this.SetupVoucherManagementContainer(new List { - // testNetwork, - // this.SqlServerNetwork - // }); - + await this.SetupTransactionProcessorContainer(new List { testNetwork, this.SqlServerNetwork @@ -122,9 +112,9 @@ await this.SetupFileProcessorContainer(new List { this.SqlServerNetwork }); - //await this.SetupVoucherManagementAclContainer(new List { - // testNetwork, - // }); + await this.SetupVoucherManagementAclContainer(new List { + testNetwork, + }); await this.SetupTransactionProcessorAclContainer(testNetwork); @@ -171,7 +161,7 @@ public virtual async Task CreateGenericSubscriptions() { public virtual async Task CreateEstateSubscriptions(String estateName) { List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new List<(String streamName, String groupName, Int32 maxRetries)> { - (estateName.Replace(" ", ""), "Reporting", 2), + (estateName.Replace(" ", ""), "Estate Management", 2), ($"EstateManagementSubscriptionStream_{estateName.Replace(" ", "")}", "Estate Management", 0), ($"TransactionProcessorSubscriptionStream_{estateName.Replace(" ", "")}", "Transaction Processor", 0), ($"FileProcessorSubscriptionStream_{estateName.Replace(" ", "")}", "File Processor", 0) diff --git a/Shared.IntegrationTesting/Shared.IntegrationTesting.csproj b/Shared.IntegrationTesting/Shared.IntegrationTesting.csproj index 69202f98..0bb745d3 100644 --- a/Shared.IntegrationTesting/Shared.IntegrationTesting.csproj +++ b/Shared.IntegrationTesting/Shared.IntegrationTesting.csproj @@ -1,15 +1,15 @@  - net6.0 + net7.0 - + - - + + diff --git a/Shared.Tests/ConfigurationRootExtensionsTests.cs b/Shared.Tests/ConfigurationRootExtensionsTests.cs index d0622578..6cc08bac 100644 --- a/Shared.Tests/ConfigurationRootExtensionsTests.cs +++ b/Shared.Tests/ConfigurationRootExtensionsTests.cs @@ -50,7 +50,7 @@ public class ConfigurationRootExtensionsTests [Fact] public void ConfigurationRootExtensions_LogConfiguration_ConfigurationIsLogged() { - IConfigurationBuilder builder = new ConfigurationBuilder().AddInMemoryCollection(ConfigurationRootExtensionsTests.DefaultAppSettings).AddEnvironmentVariables(); + IConfigurationBuilder builder = new ConfigurationBuilder().AddInMemoryCollection(ConfigurationRootExtensionsTests.DefaultAppSettings).AddEnvironmentVariables(); IConfigurationRoot configuration = builder.Build(); @@ -60,7 +60,7 @@ public void ConfigurationRootExtensions_LogConfiguration_ConfigurationIsLogged() configuration.LogConfiguration(loggerAction); String[] loggedEntries = testLogger.GetLogEntries(); - Int32 expectedCount = ConfigurationRootExtensionsTests.DefaultAppSettings.Count + 7; // 3 blank lines & 4 headers + Int32 expectedCount = ConfigurationRootExtensionsTests.DefaultAppSettings.Count + 10; // 3 blank lines & 4 headers and PS Setting loggedEntries.Length.ShouldBe(expectedCount); loggedEntries.Where(l => l.Contains("No Value")).Count().ShouldBe(1); } diff --git a/Shared.Tests/Shared.Tests.csproj b/Shared.Tests/Shared.Tests.csproj index 5e556c48..4a870764 100644 --- a/Shared.Tests/Shared.Tests.csproj +++ b/Shared.Tests/Shared.Tests.csproj @@ -1,25 +1,25 @@  - net6.0 + net7.0 None false - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/Shared.sln b/Shared.sln index e19aacf4..c15064b7 100644 --- a/Shared.sln +++ b/Shared.sln @@ -23,7 +23,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Driver", "Driver\Driver.csp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared.EventStore.Tests", "Shared.EventStore.Tests\Shared.EventStore.Tests.csproj", "{81AF1FCA-837F-4CEA-9E8E-AD38F510930A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.IntegrationTesting.Tests", "Shared.IntegrationTesting.Tests\Shared.IntegrationTesting.Tests.csproj", "{77D4A6AC-1DEF-4F6D-88C8-35763A1FD9B5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared.IntegrationTesting.Tests", "Shared.IntegrationTesting.Tests\Shared.IntegrationTesting.Tests.csproj", "{77D4A6AC-1DEF-4F6D-88C8-35763A1FD9B5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2F43E6CC-A4C5-4C18-8674-FF5E2E6C1604}" + ProjectSection(SolutionItems) = preProject + .github\workflows\createrelease.yml = .github\workflows\createrelease.yml + .github\workflows\pullrequest.yml = .github\workflows\pullrequest.yml + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index 3cdbe0ed..2adccc73 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 @@ -10,13 +10,13 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + From ad6625f095b8e021392ba7931545dee112245f6d Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 16 Nov 2022 15:05:32 +0000 Subject: [PATCH 2/5] :| --- Shared.IntegrationTesting/DockerHelper.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Shared.IntegrationTesting/DockerHelper.cs b/Shared.IntegrationTesting/DockerHelper.cs index 70732b6a..be38e108 100644 --- a/Shared.IntegrationTesting/DockerHelper.cs +++ b/Shared.IntegrationTesting/DockerHelper.cs @@ -14,7 +14,6 @@ public class DockerHelper : BaseDockerHelper { public DockerHelper() :base(){ - } protected virtual void SetHostTraceFolder(String scenarioName) { From 1d13ea101e7b9763ed13a0f43c49666dd147b75e Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 16 Nov 2022 15:13:41 +0000 Subject: [PATCH 3/5] Fix logging unit test --- Shared.Tests/ConfigurationRootExtensionsTests.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Shared.Tests/ConfigurationRootExtensionsTests.cs b/Shared.Tests/ConfigurationRootExtensionsTests.cs index 6cc08bac..de4b8efa 100644 --- a/Shared.Tests/ConfigurationRootExtensionsTests.cs +++ b/Shared.Tests/ConfigurationRootExtensionsTests.cs @@ -59,8 +59,9 @@ public void ConfigurationRootExtensions_LogConfiguration_ConfigurationIsLogged() configuration.LogConfiguration(loggerAction); - String[] loggedEntries = testLogger.GetLogEntries(); - Int32 expectedCount = ConfigurationRootExtensionsTests.DefaultAppSettings.Count + 10; // 3 blank lines & 4 headers and PS Setting + String[] loggedEntries = testLogger.GetLogEntries().Where(l => l.Contains("PSLockDownPolicy") == false && + String.IsNullOrEmpty(l) == false).ToArray(); + Int32 expectedCount = ConfigurationRootExtensionsTests.DefaultAppSettings.Count + 5; // 5 headers loggedEntries.Length.ShouldBe(expectedCount); loggedEntries.Where(l => l.Contains("No Value")).Count().ShouldBe(1); } @@ -80,7 +81,8 @@ public void ConfigurationRootExtensions_LogConfiguration_NoConfiguration_NoConfi configuration.LogConfiguration(loggerAction); - String[] loggedEntries = testLogger.GetLogEntries(); + String[] loggedEntries = testLogger.GetLogEntries().Where(l => l.Contains("PSLockDownPolicy") == false && + String.IsNullOrEmpty(l) == false).ToArray(); loggedEntries.Length.ShouldBe(0); } From bb8fcebbcd7afe78e579fc4303762b9b0f5bd0fa Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 16 Nov 2022 15:19:22 +0000 Subject: [PATCH 4/5] More fixes --- Shared.Tests/ConfigurationRootExtensionsTests.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Shared.Tests/ConfigurationRootExtensionsTests.cs b/Shared.Tests/ConfigurationRootExtensionsTests.cs index de4b8efa..326ed73e 100644 --- a/Shared.Tests/ConfigurationRootExtensionsTests.cs +++ b/Shared.Tests/ConfigurationRootExtensionsTests.cs @@ -59,13 +59,17 @@ public void ConfigurationRootExtensions_LogConfiguration_ConfigurationIsLogged() configuration.LogConfiguration(loggerAction); - String[] loggedEntries = testLogger.GetLogEntries().Where(l => l.Contains("PSLockDownPolicy") == false && - String.IsNullOrEmpty(l) == false).ToArray(); - Int32 expectedCount = ConfigurationRootExtensionsTests.DefaultAppSettings.Count + 5; // 5 headers + String[] loggedEntries = this.FilterLogEntries(testLogger); + Int32 expectedCount = ConfigurationRootExtensionsTests.DefaultAppSettings.Count; // 5 headers loggedEntries.Length.ShouldBe(expectedCount); loggedEntries.Where(l => l.Contains("No Value")).Count().ShouldBe(1); } + private string[] FilterLogEntries(TestLogger testLogger) { + return testLogger.GetLogEntries().Where(l => l.Contains("PSLockDownPolicy") == false && String.IsNullOrEmpty(l) == false) + .Where(l => l.Contains("Configuration Section") == false).ToArray(); + } + /// /// Configurations the root extensions log configuration no configuration no configuration is logged. /// @@ -81,8 +85,7 @@ public void ConfigurationRootExtensions_LogConfiguration_NoConfiguration_NoConfi configuration.LogConfiguration(loggerAction); - String[] loggedEntries = testLogger.GetLogEntries().Where(l => l.Contains("PSLockDownPolicy") == false && - String.IsNullOrEmpty(l) == false).ToArray(); + String[] loggedEntries = this.FilterLogEntries(testLogger); loggedEntries.Length.ShouldBe(0); } From 2d9adc1fb5478e4fa5e90b6fa5f0c9cba71ebf84 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 16 Nov 2022 15:33:35 +0000 Subject: [PATCH 5/5] :| --- Shared.Tests/Shared.Tests.csproj | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Shared.Tests/Shared.Tests.csproj b/Shared.Tests/Shared.Tests.csproj index 4a870764..39d37b03 100644 --- a/Shared.Tests/Shared.Tests.csproj +++ b/Shared.Tests/Shared.Tests.csproj @@ -1,29 +1,29 @@  - - net7.0 - None - false - + + net7.0 + None + false + - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + - - - + + + - + \ No newline at end of file