-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
30 changed files
with
814 additions
and
820 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 78 additions & 74 deletions
152
test/EventStore.Client.Tests.Common/Extensions/EventStoreClientWarmupExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,89 @@ | ||
namespace EventStore.Client.Tests; | ||
|
||
public static class EventStoreClientWarmupExtensions { | ||
public static Task WarmUp(this EventStoreClient client) => | ||
DatabaseWarmup<EventStoreClient>.TryExecuteOnce(client, async ct => { | ||
// if we can read from $users then we know that | ||
// 1. the users exist | ||
// 2. we are connected to leader if we require it | ||
var users = await client | ||
.ReadStreamAsync( | ||
direction: Direction.Forwards, | ||
streamName: "$users", | ||
revision: StreamPosition.Start, | ||
maxCount: 1, | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct) | ||
.ToArrayAsync(ct); | ||
public static Task WarmUp(this EventStoreClient client) => | ||
DatabaseWarmup<EventStoreClient>.TryExecuteOnce( | ||
client, | ||
async ct => { | ||
// if we can read from $users then we know that | ||
// 1. the users exist | ||
// 2. we are connected to leader if we require it | ||
var users = await client | ||
.ReadStreamAsync( | ||
direction: Direction.Forwards, | ||
streamName: "$users", | ||
revision: StreamPosition.Start, | ||
maxCount: 1, | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
) | ||
.ToArrayAsync(ct); | ||
|
||
if (users.Length == 0) | ||
throw new ("System is not ready yet..."); | ||
if (users.Length == 0) | ||
throw new("System is not ready yet..."); | ||
|
||
// the read from leader above is not enough to guarantee the next write goes to leader | ||
_ = await client.AppendToStreamAsync( | ||
streamName: "warmup", | ||
expectedState: StreamState.Any, | ||
eventData: Enumerable.Empty<EventData>(), | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
); | ||
}); | ||
// the read from leader above is not enough to guarantee the next write goes to leader | ||
_ = await client.AppendToStreamAsync( | ||
streamName: "warmup", | ||
expectedState: StreamState.Any, | ||
eventData: Enumerable.Empty<EventData>(), | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
); | ||
} | ||
); | ||
|
||
public static Task WarmUp(this EventStoreOperationsClient client) => | ||
DatabaseWarmup<EventStoreOperationsClient>.TryExecuteOnce( | ||
client, | ||
async ct => { | ||
await client.RestartPersistentSubscriptions( | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
); | ||
} | ||
); | ||
public static Task WarmUp(this EventStoreOperationsClient client) => | ||
DatabaseWarmup<EventStoreOperationsClient>.TryExecuteOnce( | ||
client, | ||
async ct => { | ||
await client.RestartPersistentSubscriptions( | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
); | ||
} | ||
); | ||
|
||
public static Task WarmUp(this EventStorePersistentSubscriptionsClient client) => | ||
DatabaseWarmup<EventStorePersistentSubscriptionsClient>.TryExecuteOnce( | ||
client, | ||
async ct => { | ||
var id = Guid.NewGuid(); | ||
await client.CreateToStreamAsync( | ||
streamName: $"warmup-stream-{id}", | ||
groupName: $"warmup-group-{id}", | ||
settings: new(), | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
); | ||
} | ||
); | ||
public static Task WarmUp(this EventStorePersistentSubscriptionsClient client) => | ||
DatabaseWarmup<EventStorePersistentSubscriptionsClient>.TryExecuteOnce( | ||
client, | ||
async ct => { | ||
var id = Guid.NewGuid(); | ||
await client.CreateToStreamAsync( | ||
streamName: $"warmup-stream-{id}", | ||
groupName: $"warmup-group-{id}", | ||
settings: new(), | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
); | ||
} | ||
); | ||
|
||
public static Task WarmUp(this EventStoreProjectionManagementClient client) => | ||
DatabaseWarmup<EventStoreProjectionManagementClient>.TryExecuteOnce( | ||
client, | ||
async ct => { | ||
_ = await client | ||
.ListAllAsync( | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
) | ||
.Take(1) | ||
.ToArrayAsync(ct); | ||
public static Task WarmUp(this EventStoreProjectionManagementClient client) => | ||
DatabaseWarmup<EventStoreProjectionManagementClient>.TryExecuteOnce( | ||
client, | ||
async ct => { | ||
_ = await client | ||
.ListAllAsync( | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
) | ||
.Take(1) | ||
.ToArrayAsync(ct); | ||
|
||
// await client.RestartSubsystemAsync(userCredentials: TestCredentials.Root, cancellationToken: ct); | ||
} | ||
); | ||
// await client.RestartSubsystemAsync(userCredentials: TestCredentials.Root, cancellationToken: ct); | ||
} | ||
); | ||
|
||
public static Task WarmUp(this EventStoreUserManagementClient client) => | ||
DatabaseWarmup<EventStoreUserManagementClient>.TryExecuteOnce( | ||
client, | ||
async ct => _ = await client | ||
.ListAllAsync( | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
) | ||
.Take(1) | ||
.ToArrayAsync(ct) | ||
); | ||
public static Task WarmUp(this EventStoreUserManagementClient client) => | ||
DatabaseWarmup<EventStoreUserManagementClient>.TryExecuteOnce( | ||
client, | ||
async ct => _ = await client | ||
.ListAllAsync( | ||
userCredentials: TestCredentials.Root, | ||
cancellationToken: ct | ||
) | ||
.Take(1) | ||
.ToArrayAsync(ct) | ||
); | ||
} |
6 changes: 3 additions & 3 deletions
6
test/EventStore.Client.Tests.Common/Extensions/OperatingSystemExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
namespace EventStore.Client; | ||
|
||
public static class OperatingSystemExtensions { | ||
public static bool IsWindows(this OperatingSystem operatingSystem) => | ||
operatingSystem.Platform != PlatformID.Unix | ||
&& operatingSystem.Platform != PlatformID.MacOSX; | ||
public static bool IsWindows(this OperatingSystem operatingSystem) => | ||
operatingSystem.Platform != PlatformID.Unix | ||
&& operatingSystem.Platform != PlatformID.MacOSX; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.