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

Fix flaky tests 2 (stateless, integration) #61869

Merged
merged 6 commits into from Mar 28, 2024

Conversation

fm4v
Copy link
Member

@fm4v fm4v commented Mar 25, 2024

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changes:

  1. ClickHouseCluster.get_docker_handle() wait docker frequently and less time
  2. integration tests: persist pdb history between test runs.
    Run pytest --pdb. On failure or breakpoint, it will fall back to PDB. Commands written here will be saved to a local file and loaded at the start of the next test run.
  3. (attempt to) Fix some flaky integration and stateless tests

List of tests:

  • tests/integration/test_backup_restore_on_cluster/test.py::test_different_tables_on_nodes
  • tests/integration/test_global_overcommit_tracker/test.py::test_global_overcommit
  • tests/integration/test_merges_memory_limit/test.py::test_memory_limit_success
  • tests/integration/test_runtime_configurable_cache_size/test.py::test_query_cache_size_is_runtime_configurable
  • tests/integration/test_dictionaries_update_and_reload/test.py::test_reload_after_fail_by_timer
  • 0_stateless/01287_max_execution_speed.sql
  • 01676_clickhouse_client_autocomplete.sh
  • 03002_filter_skip_virtual_columns_with_non_deterministic_functions.sql

Failed reports is here

@@ -101,9 +101,11 @@ def test_query_cache_size_is_runtime_configurable(start_cluster):
node.query("SELECT 2 SETTINGS use_query_cache = 1, query_cache_ttl = 1")
node.query("SELECT 3 SETTINGS use_query_cache = 1, query_cache_ttl = 1")

time.sleep(2)
Copy link
Member

Choose a reason for hiding this comment

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

This is unreliable, it will remain flaky

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually break this test here in the last assert, sleep is required as i understand

        res = node.query_with_retry(
            "SELECT value FROM system.asynchronous_metrics WHERE metric = 'QueryCacheEntries'",
            check_callback=lambda result: result == "1\n",
        )
>       assert res == "1\n"
E       AssertionError: assert '2\n' == '1\n'
E         - 1
E         + 2

Copy link
Member

Choose a reason for hiding this comment

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

I wrote this test originally and found this open PR by luck.

There were three recorded test failures in the past 6 months or so:

which is super sporadic given how many CI tests run per day.

In all cases, we ran three queries with query cache TTL = 1 sec, then wait 2 sec, and find that the query cache contains only 1 entry whereas 2 entries are expected. I can honestly not think of a scenario where this can happen except one: the asynchronous metrics are updated in a weird time interval that they report only 1 entry. Instead of adding retries (l. 105, please revert all retries from this file which only hide problems), please add SYSTEM RELOAD ASYNCHRONOUS METRICS before l. 106, see #53710. When I am back from vacation, I can add some documentation for SYSTEM RELOAD ASYNCHRONOUS METRICS.

Copy link
Member Author

@fm4v fm4v Mar 26, 2024

Choose a reason for hiding this comment

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

Retries are removed and SYSTEM RELOAD ASYNCHRONOUS METRICS after each wait. Lets pray it will be fixed

@tavplubix tavplubix self-assigned this Mar 25, 2024
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added pr-ci pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-cloud labels Mar 25, 2024
@robot-clickhouse-ci-2
Copy link
Contributor

robot-clickhouse-ci-2 commented Mar 25, 2024

This is an automated comment for commit 0afd2e8 with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Check nameDescriptionStatus
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⏳ pending
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⏳ pending
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❌ 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❌ failure
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors❌ failure
Successful checks
Check nameDescriptionStatus
A SyncThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
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
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ 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
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✅ success
PR CheckThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ 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✅ 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

@tavplubix tavplubix added the can be tested Allows running workflows for external contributors label Mar 25, 2024
@fm4v fm4v force-pushed the fix-flaky-tests2 branch 2 times, most recently from baf53fb to ef001b1 Compare March 25, 2024 17:45
@fm4v
Copy link
Member Author

fm4v commented Mar 25, 2024

@tavplubix addition to original commits:

  1. Add a test that compares parts after a database restore.
    tests/integration/test_backup_restore_on_cluster/test.py::test_replicated_database_compare_parts
  2. Add fixture that persist pdb history to file
  3. (attempt to) Fix tests/integration/test_dictionaries_update_and_reload/test.py::test_reload_after_fail_by_timer

@fm4v fm4v force-pushed the fix-flaky-tests2 branch 6 times, most recently from 02f486a to fb4bf33 Compare March 26, 2024 15:22
@@ -101,9 +101,11 @@ def test_query_cache_size_is_runtime_configurable(start_cluster):
node.query("SELECT 2 SETTINGS use_query_cache = 1, query_cache_ttl = 1")
node.query("SELECT 3 SETTINGS use_query_cache = 1, query_cache_ttl = 1")

time.sleep(2)
Copy link
Member

Choose a reason for hiding this comment

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

I wrote this test originally and found this open PR by luck.

There were three recorded test failures in the past 6 months or so:

which is super sporadic given how many CI tests run per day.

In all cases, we ran three queries with query cache TTL = 1 sec, then wait 2 sec, and find that the query cache contains only 1 entry whereas 2 entries are expected. I can honestly not think of a scenario where this can happen except one: the asynchronous metrics are updated in a weird time interval that they report only 1 entry. Instead of adding retries (l. 105, please revert all retries from this file which only hide problems), please add SYSTEM RELOAD ASYNCHRONOUS METRICS before l. 106, see #53710. When I am back from vacation, I can add some documentation for SYSTEM RELOAD ASYNCHRONOUS METRICS.

robot-ch-test-poll2 added a commit that referenced this pull request Mar 28, 2024
…8b78e919e53c0a813dbc73dde9716

Cherry pick #61869 to 24.3: Fix flaky tests 2 (stateless, integration)
fm4v added a commit that referenced this pull request Mar 28, 2024
Backport #61869 to 24.3: Fix flaky tests 2 (stateless, integration)
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 28, 2024
robot-ch-test-poll added a commit that referenced this pull request Apr 2, 2024
…8b78e919e53c0a813dbc73dde9716

Cherry pick #61869 to 23.8: Fix flaky tests 2 (stateless, integration)
robot-ch-test-poll added a commit that referenced this pull request Apr 2, 2024
…8b78e919e53c0a813dbc73dde9716

Cherry pick #61869 to 24.1: Fix flaky tests 2 (stateless, integration)
robot-ch-test-poll added a commit that referenced this pull request Apr 2, 2024
…8b78e919e53c0a813dbc73dde9716

Cherry pick #61869 to 24.2: Fix flaky tests 2 (stateless, integration)
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can be tested Allows running workflows for external contributors pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backports-created-cloud pr-ci pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-cloud pr-synced-to-cloud The PR is synced to the cloud repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants