De-flake TelemetryTest (#7445)

This commit is contained in:
Basil Crow authored and GitHub committed 2022-11-26 07:25:07 -08:00
1 parent 88cabe5999
commit d3d1c88d29
1 file changed
+12 -4
@@ -64,13 +64,21 @@ public class TelemetryTest {
j.jenkins.setNoUsageStatistics(false); // tests usually don't submit this, but we need this
assertEquals("no requests received", 0, counter);
ExtensionList.lookupSingleton(Telemetry.TelemetryReporter.class).doRun();
await().pollInterval(250, TimeUnit.MILLISECONDS)
.atMost(10, TimeUnit.SECONDS)
.until(logger::getMessages, hasItem("Telemetry submission received response 200 for: test-data"));
await().pollInterval(250, TimeUnit.MILLISECONDS)
.atMost(10, TimeUnit.SECONDS)
.until(logger::getMessages, hasItem("Skipping telemetry for 'future' as it is configured to start later"));
await().pollInterval(250, TimeUnit.MILLISECONDS)
.atMost(10, TimeUnit.SECONDS)
.until(logger::getMessages, hasItem("Skipping telemetry for 'past' as it is configured to end in the past"));
await().pollInterval(250, TimeUnit.MILLISECONDS)
.atMost(10, TimeUnit.SECONDS)
.until(logger::getMessages, hasItem("Skipping telemetry for 'empty' as it has no data"));
await().pollInterval(250, TimeUnit.MILLISECONDS)
.atMost(10, TimeUnit.SECONDS)
.until(() -> types, hasItem("test-data"));
assertThat(logger.getMessages(), hasItem("Telemetry submission received response 200 for: test-data"));
assertThat(logger.getMessages(), hasItem("Skipping telemetry for 'future' as it is configured to start later"));
assertThat(logger.getMessages(), hasItem("Skipping telemetry for 'past' as it is configured to end in the past"));
assertThat(logger.getMessages(), hasItem("Skipping telemetry for 'empty' as it has no data"));
assertThat(types, not(hasItem("future")));
assertThat(types, not(hasItem("past")));
assertThat(correlators.size(), is(counter));