From 2d700ad327151f861a1f68cd4f7f2da2f88b84c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bragan=C3=A7a?= <495495+thefringeninja@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:29:30 -0800 Subject: [PATCH] read semantic versions when reading server version (#287) --- .../Fixtures/Base/EventStoreTestServer.cs | 12 ++++++++++-- .../Fixtures/EventStoreFixture.cs | 14 +++++++++++--- .../GlobalEnvironment.cs | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/test/EventStore.Client.Tests.Common/Fixtures/Base/EventStoreTestServer.cs b/test/EventStore.Client.Tests.Common/Fixtures/Base/EventStoreTestServer.cs index fb7e5f601..c1edde5a3 100644 --- a/test/EventStore.Client.Tests.Common/Fixtures/Base/EventStoreTestServer.cs +++ b/test/EventStore.Client.Tests.Common/Fixtures/Base/EventStoreTestServer.cs @@ -110,12 +110,20 @@ static Version GetVersion() { .Start(); using var log = eventstore.Logs(true, cts.Token); - foreach (var line in log.ReadToEnd()) + foreach (var line in log.ReadToEnd()) { if (line.StartsWith(versionPrefix) && - Version.TryParse(line[(versionPrefix.Length + 1)..].Split(' ')[0], out var version)) + 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; + } + } } void VerifyCertificatesExist() { diff --git a/test/EventStore.Client.Tests.Common/Fixtures/EventStoreFixture.cs b/test/EventStore.Client.Tests.Common/Fixtures/EventStoreFixture.cs index e59e7149d..1744ceda6 100644 --- a/test/EventStore.Client.Tests.Common/Fixtures/EventStoreFixture.cs +++ b/test/EventStore.Client.Tests.Common/Fixtures/EventStoreFixture.cs @@ -164,12 +164,20 @@ static Version GetEventStoreVersion() { .Start(); using var log = eventstore.Logs(true, cancellator.Token); - foreach (var line in log.ReadToEnd()) + foreach (var line in log.ReadToEnd()) { if (line.StartsWith(versionPrefix) && - Version.TryParse(line[(versionPrefix.Length + 1)..].Split(' ')[0], out var version)) + 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; + } + } } } @@ -205,4 +213,4 @@ public abstract class EventStoreTests : IClassFixture where [Collection(nameof(EventStoreSharedDatabaseFixture))] public abstract class EventStoreSharedDatabaseTests(ITestOutputHelper output, TFixture fixture) : EventStoreTests(output, fixture) - where TFixture : EventStoreFixture; \ No newline at end of file + where TFixture : EventStoreFixture; diff --git a/test/EventStore.Client.Tests.Common/GlobalEnvironment.cs b/test/EventStore.Client.Tests.Common/GlobalEnvironment.cs index 74f8838da..57c632154 100644 --- a/test/EventStore.Client.Tests.Common/GlobalEnvironment.cs +++ b/test/EventStore.Client.Tests.Common/GlobalEnvironment.cs @@ -23,7 +23,7 @@ static void EnsureDefaults(IConfiguration configuration) { configuration.EnsureValue("ES_USE_EXTERNAL_SERVER", "false"); configuration.EnsureValue("ES_DOCKER_REGISTRY", "ghcr.io/eventstore/eventstore"); - configuration.EnsureValue("ES_DOCKER_TAG", "latest"); + configuration.EnsureValue("ES_DOCKER_TAG", "ci"); configuration.EnsureValue("ES_DOCKER_IMAGE", $"{configuration["ES_DOCKER_REGISTRY"]}:{configuration["ES_DOCKER_TAG"]}"); configuration.EnsureValue("EVENTSTORE_MEM_DB", "false");