From 740872b0d00de2ca3bd419589856a8df3e684276 Mon Sep 17 00:00:00 2001 From: William Chong Date: Tue, 7 Jan 2025 12:51:25 +0400 Subject: [PATCH] Test workflow --- .github/workflows/base.yml | 1 + .../Fixtures/KurrentPermanentFixture.cs | 72 +++++++++---------- .../Fixtures/KurrentTemporaryFixture.cs | 72 +++++++++---------- 3 files changed, 73 insertions(+), 72 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index c57a9ce3d..43d5ce4c5 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -53,6 +53,7 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: | + 8.0.x 9.0.x - name: Run Tests shell: bash diff --git a/test/Kurrent.Client.Tests.Common/Fixtures/KurrentPermanentFixture.cs b/test/Kurrent.Client.Tests.Common/Fixtures/KurrentPermanentFixture.cs index 2530126e0..ddf9e8c93 100644 --- a/test/Kurrent.Client.Tests.Common/Fixtures/KurrentPermanentFixture.cs +++ b/test/Kurrent.Client.Tests.Common/Fixtures/KurrentPermanentFixture.cs @@ -37,11 +37,11 @@ protected KurrentPermanentFixture(ConfigureFixture configure) { public ILogger Log => Logger; - public ITestService Service { get; } + public ITestService Service { get; } public KurrentFixtureOptions Options { get; } - public Faker Faker { get; } = new Faker(); + public Faker Faker { get; } = new Faker(); - public Version EventStoreVersion { get; private set; } = null!; + // public Version EventStoreVersion { get; private set; } = null!; public bool EventStoreHasLastStreamPosition { get; private set; } public KurrentClient Streams { get; private set; } = null!; @@ -87,13 +87,13 @@ public async Task InitializeAsync() { await ContainerSemaphore.WaitAsync(); try { await Service.Start(); + // EventStoreVersion = GetEventStoreVersion(); + // EventStoreHasLastStreamPosition = (EventStoreVersion?.Major ?? int.MaxValue) >= 21; + EventStoreHasLastStreamPosition = true; } finally { ContainerSemaphore.Release(); } - EventStoreVersion = GetEventStoreVersion(); - EventStoreHasLastStreamPosition = (EventStoreVersion?.Major ?? int.MaxValue) >= 21; - await WarmUpGatekeeper.WaitAsync(); try { @@ -133,36 +133,36 @@ async Task InitClient(Func action, bool execute = true) where T : return client; } - static Version GetEventStoreVersion() { - const string versionPrefix = "EventStoreDB version"; - - using var cancellator = new CancellationTokenSource(FromSeconds(30)); - using var eventstore = new Builder() - .UseContainer() - .UseImage(GlobalEnvironment.DockerImage) - .Command("--version") - .Build() - .Start(); - - using var log = eventstore.Logs(true, cancellator.Token); - foreach (var line in log.ReadToEnd()) { - if (line.StartsWith(versionPrefix) && - Version.TryParse( - new string(ReadVersion(line[(versionPrefix.Length + 1)..]).ToArray()), - out var version - )) { - return version; - } - } - - throw new InvalidOperationException("Could not determine server version."); - - IEnumerable ReadVersion(string s) { - foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) { - yield return c; - } - } - } + // static Version GetEventStoreVersion() { + // const string versionPrefix = "EventStoreDB version"; + // + // using var cancellator = new CancellationTokenSource(FromSeconds(30)); + // using var eventstore = new Builder() + // .UseContainer() + // .UseImage(GlobalEnvironment.DockerImage) + // .Command("--version") + // .Build() + // .Start(); + // + // using var log = eventstore.Logs(true, cancellator.Token); + // foreach (var line in log.ReadToEnd()) { + // if (line.StartsWith(versionPrefix) && + // Version.TryParse( + // new string(ReadVersion(line[(versionPrefix.Length + 1)..]).ToArray()), + // out var version + // )) { + // return version; + // } + // } + // + // throw new InvalidOperationException("Could not determine server version."); + // + // IEnumerable ReadVersion(string s) { + // foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) { + // yield return c; + // } + // } + // } } public async Task DisposeAsync() { diff --git a/test/Kurrent.Client.Tests.Common/Fixtures/KurrentTemporaryFixture.cs b/test/Kurrent.Client.Tests.Common/Fixtures/KurrentTemporaryFixture.cs index c0c054e1c..7b5ccd6bb 100644 --- a/test/Kurrent.Client.Tests.Common/Fixtures/KurrentTemporaryFixture.cs +++ b/test/Kurrent.Client.Tests.Common/Fixtures/KurrentTemporaryFixture.cs @@ -40,11 +40,11 @@ protected KurrentTemporaryFixture(ConfigureFixture configure) { public ILogger Log => Logger; - public ITestService Service { get; } + public ITestService Service { get; } public KurrentFixtureOptions Options { get; } - public Faker Faker { get; } = new Faker(); + public Faker Faker { get; } = new Faker(); - public Version EventStoreVersion { get; private set; } = null!; + // public Version EventStoreVersion { get; private set; } = null!; public bool EventStoreHasLastStreamPosition { get; private set; } public KurrentClient Streams { get; private set; } = null!; @@ -89,13 +89,13 @@ public async Task InitializeAsync() { await ContainerSemaphore.WaitAsync(); try { await Service.Start(); + // EventStoreVersion = GetEventStoreVersion(); + // EventStoreHasLastStreamPosition = (EventStoreVersion?.Major ?? int.MaxValue) >= 21; + EventStoreHasLastStreamPosition = true; } finally { ContainerSemaphore.Release(); } - EventStoreVersion = GetEventStoreVersion(); - EventStoreHasLastStreamPosition = (EventStoreVersion?.Major ?? int.MaxValue) >= 21; - await WarmUpGatekeeper.WaitAsync(); try { @@ -135,36 +135,36 @@ async Task InitClient(Func action, bool execute = true) where T : return client; } - static Version GetEventStoreVersion() { - const string versionPrefix = "EventStoreDB version"; - - using var cancellator = new CancellationTokenSource(FromSeconds(30)); - using var eventstore = new Builder() - .UseContainer() - .UseImage(GlobalEnvironment.DockerImage) - .Command("--version") - .Build() - .Start(); - - using var log = eventstore.Logs(true, cancellator.Token); - foreach (var line in log.ReadToEnd()) { - if (line.StartsWith(versionPrefix) && - Version.TryParse( - new string(ReadVersion(line[(versionPrefix.Length + 1)..]).ToArray()), - out var version - )) { - return version; - } - } - - throw new InvalidOperationException("Could not determine server version."); - - IEnumerable ReadVersion(string s) { - foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) { - yield return c; - } - } - } + // static Version GetEventStoreVersion() { + // const string versionPrefix = "EventStoreDB version"; + // + // using var cancellator = new CancellationTokenSource(FromSeconds(30)); + // using var eventstore = new Builder() + // .UseContainer() + // .UseImage(GlobalEnvironment.DockerImage) + // .Command("--version") + // .Build() + // .Start(); + // + // using var log = eventstore.Logs(true, cancellator.Token); + // foreach (var line in log.ReadToEnd()) { + // if (line.StartsWith(versionPrefix) && + // Version.TryParse( + // new string(ReadVersion(line[(versionPrefix.Length + 1)..]).ToArray()), + // out var version + // )) { + // return version; + // } + // } + // + // throw new InvalidOperationException("Could not determine server version."); + // + // IEnumerable ReadVersion(string s) { + // foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) { + // yield return c; + // } + // } + // } } public async Task DisposeAsync() {