Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoox committed Oct 14, 2024
1 parent 481ad0c commit e8ea4a2
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,18 @@ public void onCompleted() {}
requestStreamObserver.onNext(DiscoveryRequest.newBuilder()
.setTypeUrl(Resources.V3.CLUSTER_TYPE_URL)
.build());

int expectedNonce = 0;
DiscoveryResponse discoveryResponse = queue.take();
while (discoveryResponse.getResourcesList().isEmpty()) {
// The commited cluster is not yet available. Send ack and receive the next discovery response.
sendAck(requestStreamObserver, discoveryResponse);
discoveryResponse = queue.take();
expectedNonce++;
}
final String versionInfo1 = discoveryResponse.getVersionInfo();
assertDiscoveryResponse(versionInfo1, discoveryResponse, fooCluster, queue, "0");
assertDiscoveryResponse(versionInfo1, discoveryResponse, fooCluster,
queue, Integer.toString(expectedNonce));
// Send ack
sendAck(requestStreamObserver, discoveryResponse);
// No discovery response because there's no change.
Expand All @@ -96,15 +100,16 @@ public void onCompleted() {}
// Change the configuration.
fooCluster = cluster(fooClusterName, 2);
updateCluster(fooGroupName, fooClusterId, fooCluster, webClient);
expectedNonce++;
discoveryResponse = queue.take();
final String versionInfo2 = discoveryResponse.getVersionInfo();
assertThat(versionInfo2).isNotEqualTo(versionInfo1);
assertDiscoveryResponse(versionInfo2, discoveryResponse, fooCluster, queue, "1");
assertDiscoveryResponse(versionInfo2, discoveryResponse, fooCluster,
queue, Integer.toString(expectedNonce));
// Send ack
sendAck(requestStreamObserver, discoveryResponse);
// No discovery response because there's no change.
assertThat(queue.poll(300, TimeUnit.MILLISECONDS)).isNull();

// Add another cluster
final String barGroupName = "groups/bar";
createGroup("bar", webClient);
Expand All @@ -113,6 +118,7 @@ public void onCompleted() {}
final Cluster barCluster = cluster(barClusterName, 1);
createCluster(barGroupName, barClusterId, barCluster, webClient);

expectedNonce++;
discoveryResponse = queue.take();
final String versionInfo3 = discoveryResponse.getVersionInfo();
assertThat(versionInfo3.length()).isEqualTo(64);
Expand All @@ -134,9 +140,11 @@ public void onCompleted() {}

// Remove bar group.
deleteGroup(barGroupName, webClient);
expectedNonce++;
discoveryResponse = queue.take();
final String versionInfo4 = discoveryResponse.getVersionInfo();
assertDiscoveryResponse(versionInfo4, discoveryResponse, fooCluster, queue, "3");
assertDiscoveryResponse(versionInfo4, discoveryResponse, fooCluster,
queue, Integer.toString(expectedNonce));
assertThat(versionInfo4).isEqualTo(versionInfo2);
// Send ack
sendAck(requestStreamObserver, discoveryResponse);
Expand Down

0 comments on commit e8ea4a2

Please sign in to comment.