Skip to content

Commit

Permalink
fix: flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
mvarendorff2 committed Oct 7, 2024
1 parent 92c1e71 commit 4adfb2c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Fluss.PostgreSQL.IntegrationTest/PostgreSQLTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ public async Task TestDatabaseNotificationForwarding()
}
};

// Short delay to allow database trigger to register
await Task.Delay(1000);

// Publish an event using the first repository
await repository1.Publish([
new EventEnvelope
Expand All @@ -410,13 +413,13 @@ await repository1.Publish([
]);

// Wait for both event handlers to be triggered or timeout after 5 seconds
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(5));
var allTasks = await Task.WhenAny(
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(10));
var fasterTask = await Task.WhenAny(
Task.WhenAll(eventRaised1.Task, eventRaised2.Task),
timeoutTask
);

Assert.NotEqual(timeoutTask, allTasks);
Assert.True(timeoutTask != fasterTask, "Ran into timeout");
Assert.True(await eventRaised1.Task, "NewEvents event was not raised on the first repository");
Assert.True(await eventRaised2.Task, "NewEvents event was not raised on the second repository");
}
Expand Down

0 comments on commit 4adfb2c

Please sign in to comment.