Skip to content

Commit 21abca3

Browse files
author
mgajda
committed
Rewrite V3DiscoveryServerAdsDeltaResourcesIT to have a 2 second poll delay to account for potential delays in writing to the wire (we don't want that to happen)
1 parent d4c528a commit 21abca3

File tree

1 file changed

+14
-39
lines changed

1 file changed

+14
-39
lines changed

server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsDeltaResourcesIT.java

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public void validateTestRequestToEchoServerViaEnvoy() throws InterruptedExceptio
142142
snapshot
143143
);
144144

145-
await().atMost(3, TimeUnit.SECONDS).untilAsserted(
145+
await().atMost(5, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).untilAsserted(
146146
() -> {
147147
assertThat(nonce.toString()).isEqualTo("01234");
148148
assertThat(errorDetails.toString()).isEqualTo("");
@@ -152,59 +152,34 @@ public void validateTestRequestToEchoServerViaEnvoy() throws InterruptedExceptio
152152
assertThat(resourceToNonceMap.get(V3.LISTENER_TYPE_URL).toString()).contains("4");
153153
}
154154
);
155-
}
156-
157-
@Test
158-
public void validateNewSnapshotVersionButSameUnderlyingResourcesDoesNotTriggerUpdate()
159-
throws InterruptedException {
160-
assertThat(onStreamOpenLatch.await(15, TimeUnit.SECONDS)).isTrue()
161-
.overridingErrorMessage("failed to open ADS stream");
162-
163-
assertThat(onStreamRequestLatch.await(15, TimeUnit.SECONDS)).isTrue()
164-
.overridingErrorMessage("failed to receive ADS request");
165-
166-
// there is no onStreamResponseLatch because V3DiscoveryServer doesn't call the callbacks
167-
// when responding to a delta request
168-
169-
String baseUri = String
170-
.format("http://%s:%d", ENVOY.getContainerIpAddress(), ENVOY.getMappedPort(LISTENER_PORT));
171-
172-
await().atMost(5, TimeUnit.SECONDS).ignoreExceptions().untilAsserted(
173-
() -> given().baseUri(baseUri).contentType(ContentType.TEXT)
174-
.when().get("/")
175-
.then().statusCode(200)
176-
.and().body(containsString(UPSTREAM.response)));
177-
178-
// basically the nonces will count up from 0 to 3 as envoy receives more resources
179-
// and check that no messages have been sent to errorDetails
180-
assertThat(nonce.toString()).isEqualTo("0123");
181-
assertThat(resourceToNonceMap.containsKey(V3.CLUSTER_TYPE_URL)).isTrue();
182-
assertThat(resourceToNonceMap.containsKey(V3.LISTENER_TYPE_URL)).isTrue();
183-
assertThat(resourceToNonceMap.containsKey(V3.ROUTE_TYPE_URL)).isTrue();
184-
assertThat(errorDetails.toString()).isEqualTo("");
185155

186-
// now write a new snapshot, with the only change being an update
187-
// to the version, wait for a few seconds for envoy to pick it up, and
188-
// check that the nonce doesn't change
189-
Snapshot snapshot = V3TestSnapshots.createSnapshot(true,
156+
// now increment the version but keep all the underlying resources the same. This should not
157+
// trigger any updates, so the nonces should remain constant to above.
158+
snapshot = V3TestSnapshots.createSnapshot(true,
190159
true,
191160
"upstream",
192161
UPSTREAM.ipAddress(),
193162
EchoContainer.PORT,
194-
"listener0",
163+
"listener1",
195164
LISTENER_PORT,
196165
"route0",
197-
"2");
166+
"3");
198167
LOGGER.info("snapshot={}", snapshot);
199168
cache.setSnapshot(
200169
GROUP,
201170
snapshot
202171
);
203172

204-
await().atMost(3, TimeUnit.SECONDS).untilAsserted(
173+
await().atMost(5, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).untilAsserted(
205174
() -> {
206-
assertThat(nonce.toString()).isEqualTo("0123");
175+
176+
LOGGER.info("lastWatchRequestTime={}", cache.statusInfo(GROUP));
177+
assertThat(nonce.toString()).isEqualTo("01234");
207178
assertThat(errorDetails.toString()).isEqualTo("");
179+
assertThat(resourceToNonceMap.containsKey(V3.LISTENER_TYPE_URL)).isTrue();
180+
// we know that the most recent update was to the listener, so check
181+
// that it received the most recent nonce
182+
assertThat(resourceToNonceMap.get(V3.LISTENER_TYPE_URL).toString()).contains("4");
208183
}
209184
);
210185
}

0 commit comments

Comments
 (0)