Skip to content

Add retries to tlsv1_3 tests - #51434

Merged
nikitamikhaylov merged 2 commits into
masterfrom
50679-test_tlsv1_3-is-flaky-test_https_wrong_cert-test_https_non_ssl_auth
Jun 27, 2023
Merged

nikitamikhaylov merged 2 commits into
masterfrom
50679-test_tlsv1_3-is-flaky-test_https_wrong_cert-test_https_non_ssl_auth

Conversation

@antaljanosbenjamin

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

I spent quite some time to investigate and reproduce the flaky failures, but I was unable to do it, so we decided to add some retries to reduce the flakyness of our tests. More info in this comment.

@antaljanosbenjamin antaljanosbenjamin added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 26, 2023
@antaljanosbenjamin
antaljanosbenjamin marked this pull request as ready for review June 26, 2023 15:15
@robot-clickhouse-ci-1

robot-clickhouse-ci-1 commented Jun 26, 2023 •

Copy link
Copy Markdown
Contributor

This is an automated comment for commit 5de8c4a with description of existing statuses. It's updated for the latest CI running
The full report is available here
The overall status of the commit is 🔴 failure

Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help🟢 success
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR🟢 success
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process🟢 success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help🟢 success
Docker image for serversThe check to build and optionally push the mentioned image to docker hub🟢 success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here🟢 success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integrational tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc🟢 success
Install packagesChecks that the built packages are installable in a clear environment🟢 success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests🔴 failure
Mergeable CheckChecks if all other necessary checks are successful🔴 failure
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests🟢 success
Push to DockerhubThe check for building and pushing the CI related docker images to docker hub🟢 success
SQLancerFuzzing tests that detect logical bugs with SQLancer tool🟢 success
SqllogicRun clickhouse on the sqllogic test set against sqlite and checks that all statements are passed🟢 success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc🟢 success
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc🔴 failure
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors🟢 success
Style CheckRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report🟢 success
Unit testsRuns the unit tests for different release types🟢 success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts🟢 success

assert "unknown ca" in str(err.value)
while count <= MAX_RETRY:
with pytest.raises(Exception) as err:
execute_query_https("SELECT currentUser()", user="john", cert_name="wrong")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is probably better to add retries to the execute_query_https itself instead of each time it is called.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because this error only an issue for requests that are using an invalid cert, I would like to keep the scope of the retries as strict as possible, especially considering that we are not fixing anything, we just allowing the requests fail in a particular way a few times. E.g.: maybe we can have a race condition in our networking layer that would cause the broken pipe error to show up in other test cases time to time. If we include the retry logic to the execute_query_https method, we might not notice those errors.

However if you think that is way to go, I am happy to make the changes.

@evillique evillique self-assigned this Jun 26, 2023
@evillique

evillique commented Jun 26, 2023 •

Copy link
Copy Markdown
Member

The last time the retries were added it did not seem to solve the issue: #49632, #49982 and in the end, it is still failing even today: link (the test is different but the issue is the same)

I think that we should add more debug information to the exception about the connectivity (try to execute a query with standard node.query()) and maybe some other that will help with understanding what is wrong with our CI.

@alexey-milovidov alexey-milovidov changed the title Add retries to flaky tests Add retries to tlsv1_3 tests Jun 26, 2023
@antaljanosbenjamin

Copy link
Copy Markdown
Member Author

I think the retries didn't work previously because the wrong type of exception was used: instead of BrokenPipeError I think the correct one would be URLError based on this part of the log:

>       assert "unknown ca" in str(err.value)
E       AssertionError: assert 'unknown ca' in '<urlopen error [Errno 32] Broken pipe>'
E        +  where '<urlopen error [Errno 32] Broken pipe>' = str(URLError(BrokenPipeError(32, 'Broken pipe')))
E        +    where URLError(BrokenPipeError(32, 'Broken pipe')) = <ExceptionInfo URLError(BrokenPipeError(32, 'Broken pipe')) tblen=8>.value

The str(URLError(BrokenPipeError suggests me that the raised exception is an URLError`. Quick reproduction:

>>> str(URLError(BrokenPipeError(32, 'Broken pipe')))
'<urlopen error [Errno 32] Broken pipe>'

As you can see this matches the string printed by the failed test. So in my opinion the retry logic didn't do any retries at all, therefore it didn't fixed the issue. Do I miss something?

@nikitamikhaylov
nikitamikhaylov merged commit a601e9c into master Jun 27, 2023
@nikitamikhaylov
nikitamikhaylov deleted the 50679-test_tlsv1_3-is-flaky-test_https_wrong_cert-test_https_non_ssl_auth branch June 27, 2023 11:57
@qoega

qoega commented Jun 28, 2023

Copy link
Copy Markdown
Member

@antaljanosbenjamin now it is

____________________________ test_https_wrong_cert _____________________________
[gw1] linux -- Python 3.8.10 /usr/bin/python3

    def test_https_wrong_cert():
        # Wrong certificate: different user's certificate
        with pytest.raises(Exception) as err:
            execute_query_https("SELECT currentUser()", user="john", cert_name="client2")
        assert "403" in str(err.value)
    
        # Wrong certificate: self-signed certificate.
        with pytest.raises(Exception) as err:
            execute_query_https("SELECT currentUser()", user="john", cert_name="wrong")
>       assert "unknown ca" in str(err.value)
E       assert 'unknown ca' in "HTTPSConnectionPool(host='172.16.1.2', port=8443): Max retries exceeded with url: /?query=SELECT%20currentUser() (Caused by ProtocolError('Connection aborted.', BrokenPipeError(32, 'Broken pipe')))"
E        +  where "HTTPSConnectionPool(host='172.16.1.2', port=8443): Max retries exceeded with url: /?query=SELECT%20currentUser() (Caused by ProtocolError('Connection aborted.', BrokenPipeError(32, 'Broken pipe')))" = str(MaxRetryError("HTTPSConnectionPool(host='172.16.1.2', port=8443): Max retries exceeded with url: /?query=SELECT%20currentUser() (Caused by ProtocolError('Connection aborted.', BrokenPipeError(32, 'Broken pipe')))"))
E        +    where MaxRetryError("HTTPSConnectionPool(host='172.16.1.2', port=8443): Max retries exceeded with url: /?query=SELECT%20currentUser() (Caused by ProtocolError('Connection aborted.', BrokenPipeError(32, 'Broken pipe')))") = <ExceptionInfo MaxRetryError("HTTPSConnectionPool(host='172.16.1.2', port=8443): Max retries exceeded with url: /?query=SELECT%20currentUser() (Caused by ProtocolError('Connection aborted.', BrokenPipeError(32, 'Broken pipe')))") tblen=10>.value

https://s3.amazonaws.com/clickhouse-test-reports/51494/1ed104417a2cb49fc3c677d9193e2b676de95d77/integration_tests__release__[4_4].html

@qoega qoega mentioned this pull request Jun 28, 2023
@antaljanosbenjamin

Copy link
Copy Markdown
Member Author

I only changed the test_tlsv1_3/test.py file, not the test_ssl_cert_authentication/test.py, however I can have a look as the two tests are very similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_tlsv1_3 is flaky (test_https_wrong_cert, test_https_non_ssl_auth)

6 participants