Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bidirectional tests #607

Merged
merged 6 commits into from May 17, 2024
Merged

Add bidirectional tests #607

merged 6 commits into from May 17, 2024

Conversation

zentron
Copy link
Contributor

@zentron zentron commented May 7, 2024

Simple test confirming once a connection is established the service messaging layer is bi-directional

@zentron zentron requested a review from a team as a code owner May 7, 2024 10:12
@zentron zentron force-pushed the robe/experiment_bidirectional branch from aa9bf68 to 6431b54 Compare May 7, 2024 11:28
await Task.WhenAll(t1, t2);
sw.Stop();

sw.ElapsedMilliseconds.Should().BeLessThan(await t1 + await t2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth replacing the timing to test concurrency by using a "do some action service" and having that action service wait until both requests are in flight before returning.

The tests are run in parallel so the load tends to cause tests with timings to occasionally fail. Sometimes we make those tests run as non parallel but that just means it takes longer to run the tests :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have converted the quick POC hack towards something that is hopefully more reliable

{
await SetupBiDirectionalClients(async (octopusEchoClient, tentacleEchoClient) =>
{
var t1 = Task.Run(async () => await RunEchoTask(octopusEchoClient)).WithTimeout(TimeSpan.FromSeconds(5));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the intent of the timeout? The base class should be providing a timeout on the test if the concern is this will run forever.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I've update the timeout limits for use in the test,

source/Halibut.Tests/BiDirectionalTests.cs Outdated Show resolved Hide resolved
await SetupBiDirectionalPollingClients(async (clientServiceA, clientServiceB) =>
{
MyEchoService.SharedState = 0;
var taskA = clientServiceA.BlockWaitingForSharedStateIncrementAsync().WithCancellation(CancellationToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should prevent random race conditions when we run the tests in parallel thanks!

@zentron zentron merged commit 881b4ca into main May 17, 2024
15 checks passed
@zentron zentron deleted the robe/experiment_bidirectional branch May 17, 2024 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants