Skip to content

Commit

Permalink
read semantic versions when reading server version (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
thefringeninja authored Feb 14, 2024
1 parent 9ae7e8b commit 2d700ad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<char> ReadVersion(string s) {
foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
yield return c;
}
}
}

void VerifyCertificatesExist() {
Expand Down
14 changes: 11 additions & 3 deletions test/EventStore.Client.Tests.Common/Fixtures/EventStoreFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<char> ReadVersion(string s) {
foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
yield return c;
}
}
}
}

Expand Down Expand Up @@ -205,4 +213,4 @@ public abstract class EventStoreTests<TFixture> : IClassFixture<TFixture> where

[Collection(nameof(EventStoreSharedDatabaseFixture))]
public abstract class EventStoreSharedDatabaseTests<TFixture>(ITestOutputHelper output, TFixture fixture) : EventStoreTests<TFixture>(output, fixture)
where TFixture : EventStoreFixture;
where TFixture : EventStoreFixture;
2 changes: 1 addition & 1 deletion test/EventStore.Client.Tests.Common/GlobalEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 2d700ad

Please sign in to comment.