1212using ClusterTest . Messages ;
1313using FluentAssertions ;
1414using Proto . Cluster . Gossip ;
15+ using Proto . TestKit ;
1516using Xunit ;
1617using Xunit . Abstractions ;
1718
@@ -34,8 +35,7 @@ public GossipTests(ITestOutputHelper testOutputHelper)
3435 [ Fact ]
3536 public async Task CanGetConsensus ( )
3637 {
37- var clusterFixture = new InMemoryClusterFixture ( ) ;
38- await using var _ = clusterFixture ;
38+ await using var clusterFixture = new InMemoryClusterFixture ( ) ;
3939 await clusterFixture . InitializeAsync ( ) ;
4040
4141 const string initialValue = "hello consensus" ;
@@ -50,17 +50,14 @@ public async Task CanGetConsensus()
5050
5151 }
5252
53- [ Fact ( Skip = "Flaky" ) ]
53+ [ Fact ]
5454 public async Task CompositeConsensusWorks ( )
5555 {
5656 var timeout = CancellationTokens . FromSeconds ( 20 ) ;
57- var clusterFixture = new InMemoryClusterFixture ( ) ;
58- await using var _ = clusterFixture ;
57+ await using var clusterFixture = new InMemoryClusterFixture ( ) ;
5958 await clusterFixture . InitializeAsync ( ) ;
6059
61- // Allow cluster to settle before verifying consensus
62- await Task . Delay ( 1000 ) ;
63-
60+ // Wait for the cluster to reach topology consensus before performing checks
6461 var ( consensus , initialTopologyHash ) =
6562 await clusterFixture . Members . First ( ) . MemberList . TopologyConsensus ( timeout ) ;
6663
@@ -83,8 +80,11 @@ public async Task CompositeConsensusWorks()
8380
8481 afterSettingMatchingState . value . Should ( ) . Be ( initialTopologyHash ) ;
8582
83+ var updatedTopology = clusterFixture . Members . First ( ) . ExpectUpdatedTopologyConsensus ( ) ;
84+
8685 await clusterFixture . SpawnMember ( ) ;
87- await Task . Delay ( 2000 ) ; // Allow topology state to propagate
86+
87+ await updatedTopology ;
8888
8989 var afterChangingTopology =
9090 await firstNodeCheck . TryGetConsensus ( TimeSpan . FromMilliseconds ( 500 ) , timeout ) ;
@@ -96,8 +96,7 @@ public async Task CompositeConsensusWorks()
9696 [ Fact ]
9797 public async Task CanFallOutOfConsensus ( )
9898 {
99- var clusterFixture = new InMemoryClusterFixture ( ) ;
100- await using var _ = clusterFixture ;
99+ await using var clusterFixture = new InMemoryClusterFixture ( ) ;
101100 await clusterFixture . InitializeAsync ( ) ;
102101
103102 const string initialValue = "hello consensus" ;
@@ -146,8 +145,7 @@ public async Task Gossip_should_replicate_large_state_with_small_batches()
146145 const int maxSend = 2 ;
147146 const int keysPerMember = 5 ;
148147
149- var clusterFixture = new GossipClusterFixture ( memberCount , fanout , maxSend ) ;
150- await using var _ = clusterFixture ;
148+ await using var clusterFixture = new GossipClusterFixture ( memberCount , fanout , maxSend ) ;
151149 await clusterFixture . InitializeAsync ( ) ;
152150
153151 var expected = clusterFixture . Members . ToDictionary (
0 commit comments