From fc66489569700e544d7d2a45f751ab992b2756fd Mon Sep 17 00:00:00 2001 From: Nate Anderson Date: Fri, 1 Sep 2023 16:27:54 -0700 Subject: [PATCH] Manually synchronize the test and add more print statements --- tests/Integration/Momento.Sdk.Tests/TopicTest.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/Integration/Momento.Sdk.Tests/TopicTest.cs b/tests/Integration/Momento.Sdk.Tests/TopicTest.cs index fdeeab40..5f196e3e 100644 --- a/tests/Integration/Momento.Sdk.Tests/TopicTest.cs +++ b/tests/Integration/Momento.Sdk.Tests/TopicTest.cs @@ -87,7 +87,7 @@ public TopicTest(CacheClientFixture cacheFixture, TopicClientFixture topicFixtur [Fact(Timeout = 5000)] public async Task PublishAndSubscribe_ByteArray_Succeeds() { - testOutputHelper.WriteLine("starting binary publish and subscribe test"); + await Console.Error.WriteLineAsync("starting binary publish and subscribe test"); const string topicName = "topic_bytes"; var valuesToSend = new List { @@ -106,9 +106,13 @@ public async Task PublishAndSubscribe_ByteArray_Succeeds() $"Unexpected response: {subscribeResponse}"); var subscription = ((TopicSubscribeResponse.Subscription)subscribeResponse).WithCancellation(cts.Token); + await Console.Error.WriteLineAsync("subscription created"); + var taskCompletionSourceBool = new TaskCompletionSource(); var testTask = Task.Run(async () => { var messageCount = 0; + // semaphore. + taskCompletionSourceBool.SetResult(true); await foreach (var message in subscription) { Assert.NotNull(message); @@ -126,7 +130,8 @@ public async Task PublishAndSubscribe_ByteArray_Succeeds() return messageCount; }, cts.Token); - await Task.Delay(1000); + await Console.Error.WriteLineAsync("enumerator task started"); + await taskCompletionSourceBool.Task; foreach (var value in valuesToSend) { @@ -134,6 +139,7 @@ public async Task PublishAndSubscribe_ByteArray_Succeeds() Assert.True(publishResponse is TopicPublishResponse.Success, $"Unexpected response: {publishResponse}"); await Task.Delay(100); } + await Console.Error.WriteLineAsync("messages sent"); Assert.Equal(valuesToSend.Count, await testTask); }