Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
w1am committed Feb 15, 2024
2 parents 5b02572 + 2d700ad commit bd043f8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using Ductus.FluentDocker.Builders;
using Ductus.FluentDocker.Extensions;
using Ductus.FluentDocker.Model.Builders;
Expand Down Expand Up @@ -102,7 +101,6 @@ public ValueTask DisposeAsync() {

static Version GetVersion() {
const string versionPrefix = "EventStoreDB version";
var versionRegex = new Regex(@"\d+(\.\d+)*", RegexOptions.Compiled);

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
using var eventstore = new Builder().UseContainer()
Expand All @@ -112,14 +110,20 @@ static Version GetVersion() {
.Start();

using var log = eventstore.Logs(true, cts.Token);
foreach (var line in log.ReadToEnd())
if (line.StartsWith(versionPrefix)) {
var versionMatch = versionRegex.Match(line);
if (versionMatch.Success && Version.TryParse(versionMatch.Value, out var version))
return version;
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<char> ReadVersion(string s) {
foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
yield return c;
}
}
}

void VerifyCertificatesExist() {
Expand Down
18 changes: 11 additions & 7 deletions test/EventStore.Client.Tests.Common/Fixtures/EventStoreFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Net;
using System.Text.RegularExpressions;
using Ductus.FluentDocker.Builders;
using Ductus.FluentDocker.Extensions;
using Ductus.FluentDocker.Services.Extensions;
Expand Down Expand Up @@ -155,7 +154,6 @@ async Task<T> InitClient<T>(Func<T, Task> action, bool execute = true) where T :

static Version GetEventStoreVersion() {
const string versionPrefix = "EventStoreDB version";
var versionRegex = new Regex(@"\d+(\.\d+)*", RegexOptions.Compiled);

using var cancellator = new CancellationTokenSource(FromSeconds(30));
using var eventstore = new Builder()
Expand All @@ -166,14 +164,20 @@ static Version GetEventStoreVersion() {
.Start();

using var log = eventstore.Logs(true, cancellator.Token);
foreach (var line in log.ReadToEnd())
if (line.StartsWith(versionPrefix)) {
var versionMatch = versionRegex.Match(line);
if (versionMatch.Success && Version.TryParse(versionMatch.Value, out var version))
return version;
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<char> ReadVersion(string s) {
foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
yield return c;
}
}
}
}

Expand Down
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 bd043f8

Please sign in to comment.