Skip to content

update test-support clients and servers to be natively async#580

Merged
olix0r merged 31 commits intomainfrom
eliza/deflake-reconnect
Jun 29, 2020
Merged

update test-support clients and servers to be natively async#580
olix0r merged 31 commits intomainfrom
eliza/deflake-reconnect

Conversation

@hawkw
Copy link
Contributor

@hawkw hawkw commented Jun 23, 2020

Currently, the test clients and servers in linkerd2-app-integration
each run their own separate Tokio runtime on a background thread. This
was done in order to allow writing the test code in a synchronous
fashion, rather than using futures. Now, however, a majority of the
tests already use async-await syntax, so we can run all this stuff on
the same test runtime. This should reduce the number of threads in the
tests significantly, which may decrease flakiness and possibly improve
test performance a bit.

This branch updates the test support servers and clients to run as tasks
spawned on the main test runtime. It does not touch the test control
plane (Destination and Identity services) as they still need to be
updated to use Tonic and std::future.

This does introduce one potential footgun that is worth noting: if a
test server that makes assertions is spawned in the background, the
JoinHandle for its task must be awaited. Otherwise, panics will not be
propagated to the main test task, and the test can spuriously pass if
the assertion fails.

Signed-off-by: Eliza Weisman [email protected]

@hawkw hawkw requested review from a team, kleimkuhler and olix0r June 23, 2020 23:09
Copy link
Member

@olix0r olix0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm when CI is happy

hawkw added 26 commits June 23, 2020 17:18
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Because the test server is now running on the same runtime as everything
else, any tasks it spawns are no longer cancelled when the server is
dropped (which used to shut down the server's runtime). Moving it to the
same runtime meant that if the server is shut down, the spawned task
that owns the `TcpListener` is _not_ cancelled, and the connection from
the proxy remains open. Some tests relied on servers closing their
socket when dropped, and this behavior broke those tests.

This commit reuses the existing graceful shutdown code to ensure the
test server cancels all tasks it spawns when shutdown is triggered.

Signed-off-by: <Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
it's more trustwrthy

Signed-off-by: Eliza Weisman <[email protected]>
@hawkw hawkw force-pushed the eliza/deflake-reconnect branch from 42dc7f8 to ad5e2f9 Compare June 24, 2020 00:39
Copy link
Contributor

@kleimkuhler kleimkuhler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@olix0r olix0r merged commit 13b5fd6 into main Jun 29, 2020
@olix0r olix0r deleted the eliza/deflake-reconnect branch June 29, 2020 17:48
olix0r pushed a commit that referenced this pull request Jun 30, 2020
This branch updates the test support mock control plane components in
`linkerd2-app-integration` to use `std::future`, Tonic, and Tokio 0.2.
Rather than spawning a separate thread for each control plane componwnr
as we did previously, they are now spawned as tasks on the main test
thread's runtime. As discussed in #580, this _may_ make the tests
slightly less flaky and/or slightly faster on CI.

Closes linkerd/linkerd2#3963

Signed-off-by: Eliza Weisman <[email protected]>
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Jul 2, 2020
This release increases the default buffer size to match the proxy's
in-flight request limit. This reduces contention in overload--especially
high-concurrency--situations, substantially reducing tail latency.

---

* update test-support clients and servers to be natively async (linkerd/linkerd2-proxy#580)
* Print build diagnostics in docker (linkerd/linkerd2-proxy#583)
* update test controllers to std::future/Tonic; remove threads (linkerd/linkerd2-proxy#585)
* buffer: Box the inner service's reponse future (linkerd/linkerd2-proxy#586)
* Eliminate Bind & Listen traits (linkerd/linkerd2-proxy#584)
* cache: replace Lock with Buffer (linkerd/linkerd2-proxy#587)
cpretzer pushed a commit to linkerd/linkerd2 that referenced this pull request Jul 2, 2020
This release increases the default buffer size to match the proxy's
in-flight request limit. This reduces contention in overload--especially
high-concurrency--situations, substantially reducing tail latency.

---

* update test-support clients and servers to be natively async (linkerd/linkerd2-proxy#580)
* Print build diagnostics in docker (linkerd/linkerd2-proxy#583)
* update test controllers to std::future/Tonic; remove threads (linkerd/linkerd2-proxy#585)
* buffer: Box the inner service's reponse future (linkerd/linkerd2-proxy#586)
* Eliminate Bind & Listen traits (linkerd/linkerd2-proxy#584)
* cache: replace Lock with Buffer (linkerd/linkerd2-proxy#587)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants