Skip to content

Commit

Permalink
Test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
w1am committed Jan 7, 2025
1 parent a0dd296 commit 740872b
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 72 deletions.
1 change: 1 addition & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
9.0.x
- name: Run Tests
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -133,36 +133,36 @@ async Task<T> InitClient<T>(Func<T, Task> 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<char> 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<char> ReadVersion(string s) {
// foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
// yield return c;
// }
// }
// }
}

public async Task DisposeAsync() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -135,36 +135,36 @@ async Task<T> InitClient<T>(Func<T, Task> 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<char> 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<char> ReadVersion(string s) {
// foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
// yield return c;
// }
// }
// }
}

public async Task DisposeAsync() {
Expand Down

0 comments on commit 740872b

Please sign in to comment.