Skip to content

Commit

Permalink
Fix flaky ServerMetrics tests (#5812)
Browse files Browse the repository at this point in the history
Motivation:

-
https://ge.armeria.dev/s/4nbxggtjahu5w/tests/task/:core:shadedTest/details/com.linecorp.armeria.server.ServerMetricsTest/checkWhenOk(SessionProtocol%2C%20long%2C%20long)%5B1%5D?top-execution=1
-
https://ge.armeria.dev/s/ymlrbcecdkwz4/tests/task/:core:shadedTest/details/com.linecorp.armeria.server.ServerMetricsTest/checkWhenRequestTimeout(SessionProtocol%2C%20long%2C%20long)%5B1%5D?top-execution=1

The above flaky tests are failing relatively often:
https://ge.armeria.dev/scans/tests?search.timeZoneId=Asia%2FSeoul&tests.container=com.linecorp.armeria.server.ServerMetricsTest#

Cancelling the request doesn't guarantee that the server-side request is
closed immediately.

Modifications:

- Added an `await` condition which waits until the active request in
server-side has indeed been closed

Result:

- Less flaky tests regarding `ServerMetrics`

<!--
Visit this URL to learn more about how to write a pull request
description:

https://armeria.dev/community/developer-guide#how-to-write-pull-request-description
-->
  • Loading branch information
jrhee17 authored Jul 19, 2024
1 parent c208353 commit 74f6e3c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void checkWhenOk(SessionProtocol sessionProtocol, long expectedPendingHttp1Reque

assertThat(result.status()).isSameAs(HttpStatus.OK);
assertThat(serverMetrics.pendingRequests()).isZero();
assertThat(serverMetrics.activeRequests()).isZero();
await().untilAsserted(() -> assertThat(serverMetrics.activeRequests()).isZero());
await().until(() -> serverMetrics.activeConnections() == 0);
}
}
Expand Down Expand Up @@ -273,7 +273,7 @@ void checkWhenRequestTimeout(SessionProtocol sessionProtocol, long expectedPendi

assertThat(result.status()).isSameAs(HttpStatus.SERVICE_UNAVAILABLE);
assertThat(serverMetrics.pendingRequests()).isZero();
assertThat(serverMetrics.activeRequests()).isZero();
await().untilAsserted(() -> assertThat(serverMetrics.activeRequests()).isZero());
await().until(() -> serverMetrics.activeConnections() == 0);
}
}
Expand Down

0 comments on commit 74f6e3c

Please sign in to comment.