diff --git a/xds/src/test/java/com/linecorp/centraldogma/xds/internal/CdsStreamingTest.java b/xds/src/test/java/com/linecorp/centraldogma/xds/internal/CdsStreamingTest.java index 453d9ab442..07e35ad0a7 100644 --- a/xds/src/test/java/com/linecorp/centraldogma/xds/internal/CdsStreamingTest.java +++ b/xds/src/test/java/com/linecorp/centraldogma/xds/internal/CdsStreamingTest.java @@ -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. @@ -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); @@ -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); @@ -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);