Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address flakiness of testSSLHandshakeErrorPropagation #335

Merged
merged 2 commits into from
Jan 25, 2021

Conversation

Lukasa
Copy link
Collaborator

@Lukasa Lukasa commented Jan 22, 2021

Motivation:

Flaky tests are bad.

This test is flaky because the server closes the connection immediately
upon channelActive. In practice this can mean that the handshake never
even gets a chance to start: by the time the SSLHandler ends up
in the pipeline the connection is already dead. Heck, by the time we
attempt to complete the connection the connection might be dead.

Modifications:

  • Change the shutdown to be on first read.
  • Remove the disabled autoRead.
  • Change the expected NIOTS failure mode to connectTimeout,
    which is how this manifests in NIOTS.

Result:

Test is no longer flaky.

@Lukasa Lukasa added the semver/patch For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1) label Jan 22, 2021
@Lukasa Lukasa linked an issue Jan 22, 2021 that may be closed by this pull request
Copy link
Contributor

@weissi weissi left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM

@Lukasa
Copy link
Collaborator Author

Lukasa commented Jan 25, 2021

Oh hey, fun, a new flaky test! Tracking in #290.

@Lukasa
Copy link
Collaborator Author

Lukasa commented Jan 25, 2021

@swift-server-bot test this please

@Lukasa Lukasa requested a review from weissi January 25, 2021 10:42
@Lukasa
Copy link
Collaborator Author

Lukasa commented Jan 25, 2021

@weissi please re-review, I added a new test.

Copy link
Contributor

@weissi weissi left a comment

Choose a reason for hiding this comment

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

thanks @Lukasa , looks mostly good to me, just one question around hardcoding 54 for ECONNRESET

if isTestingNIOTS() {
XCTAssertEqual(error as? ChannelError, .connectTimeout(.milliseconds(100)))
} else {
XCTAssertEqual((error as? IOError).map { $0.errnoCode }, 54)
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason to use 54 over ECONNRESET?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just cribbed it from the test above, happy to swap it.

Motivation:

Flaky tests are bad.

This test is flaky because the server closes the connection immediately
upon channelActive. In practice this can mean that the handshake never
even gets a chance to start: by the time the SSLHandler ends up
in the pipeline the connection is already dead. Heck, by the time we
attempt to complete the connection the connection might be dead.

Modifications:

- Change the shutdown to be on first read.
- Remove the disabled autoRead.
- Change the expected NIOTS failure mode to connectTimeout,
    which is how this manifests in NIOTS.

Result:

Test is no longer flaky.
Copy link
Contributor

@weissi weissi left a comment

Choose a reason for hiding this comment

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

awesome, thank you!

@Lukasa
Copy link
Collaborator Author

Lukasa commented Jan 25, 2021

@swift-server-bot test this please

@Lukasa
Copy link
Collaborator Author

Lukasa commented Jan 25, 2021

One good validation of this having fixed a flaky test is that while we've hit at least two other flaky tests, we've not hit the one this was trying to fix!

@Lukasa Lukasa merged commit 2bacb97 into swift-server:main Jan 25, 2021
@Lukasa Lukasa deleted the cb-flaky-tests branch January 25, 2021 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky test: HTTPClientTests.testSSLHandshakeErrorPropagation
3 participants