Skip to content

Commit 947008f

Browse files
Copilottrask
andcommitted
Fix LiveMetrics test timing issue by waiting for dependency metric
Co-authored-by: trask <[email protected]>
1 parent ed49b91 commit 947008f

File tree

1 file changed

+13
-1
lines changed
  • smoke-tests/apps/LiveMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest

1 file changed

+13
-1
lines changed

smoke-tests/apps/LiveMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/LiveMetricsTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ void testTelemetryDataFlow() throws java.lang.Exception {
5050

5151
assertThat(testing.mockedIngestion.isPingReceived()).isTrue();
5252

53+
// Wait for dependency metric to be available in LiveMetrics post bodies
54+
Awaitility.await()
55+
.atMost(Duration.ofSeconds(30))
56+
.until(() -> {
57+
List<String> postBodies = testing.mockedIngestion.getPostBodies();
58+
PostBodyVerifier tempVerifier = new PostBodyVerifier();
59+
for (String postBody : postBodies) {
60+
tempVerifier.searchPostBody(postBody);
61+
}
62+
return tempVerifier.hasDependency();
63+
});
64+
5365
List<String> postBodies = testing.mockedIngestion.getPostBodies();
5466
assertThat(postBodies).hasSizeGreaterThan(0); // should post at least once
5567

@@ -143,7 +155,7 @@ private boolean hasDependency(List<MetricPoint> metrics) {
143155
String name = metric.getName();
144156
double value = metric.getValue();
145157
if (name.equals("\\ApplicationInsights\\Dependency Calls/Sec")) {
146-
return value > 0;
158+
return value == 1;
147159
}
148160
}
149161
return false;

0 commit comments

Comments
 (0)