Skip to content

Commit

Permalink
Fix flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziomello committed Sep 29, 2024
1 parent 3d56b7e commit 74f18a1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
13 changes: 12 additions & 1 deletion .github/gh_matrix_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,18 @@ def macos_config(overrides):
"coverage": False,
"installcheck_args": f'TESTS="{" ".join(list(tests) * 20)}"',
"name": "Flaky Check Debug",
"pg": PG14_LATEST,
"pg": PG16_LATEST,
"pginstallcheck": False,
}
)
)
m["include"].append(
build_debug_config(
{
"coverage": False,
"installcheck_args": f'TESTS="{" ".join(list(tests) * 20)}"',
"name": "Flaky Check Debug",
"pg": PG17_LATEST,
"pginstallcheck": False,
}
)
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/linux-32bit-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ jobs:
run: |
set -o pipefail
export LANG=C.UTF-8
PG_MAJOR=$(echo "${{ matrix.pg }}" | sed -e 's![.].*!!')
if [ ${PG_MAJOR} -eq 17 ]; then
SKIPS="${SKIPS} constraint_exclusion_prepared ordered_append*"
fi
# PostgreSQL cannot be run as root. So, switch to postgres user.
runuser -u postgres -- \
make -k -C build installcheck IGNORES="${IGNORES}" \
Expand Down
22 changes: 7 additions & 15 deletions tsl/test/shared/expected/constraint_exclusion_prepared.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,22 @@ SELECT
\gset
SELECT format('\! diff -u --label "Uncompressed results" --label "Compressed results" %s %s', :'TEST_RESULTS_UNCOMPRESSED', :'TEST_RESULTS_COMPRESSED') as "DIFF_CMD"
\gset
-- disable memoize node to make EXPLAIN output comparable between PG14 and previous versions
SELECT CASE WHEN current_setting('server_version_num')::int/10000 >= 14 THEN set_config('enable_memoize','off',false) ELSE 'off' END AS enable_memoize;
enable_memoize
off
(1 row)

-- get EXPLAIN output for all variations
\set PREFIX 'EXPLAIN (analyze, costs off, timing off, summary off)'
\set PREFIX_VERBOSE 'EXPLAIN (analyze, costs off, timing off, summary off, verbose)'
set work_mem to '64MB';
-- disable incremental sort here to make plans comparable to PG < 13
SELECT CASE WHEN current_setting('server_version_num')::int/10000 >= 13 THEN set_config('enable_incremental_sort','off',false) ELSE 'off' END;
case
off
(1 row)

SET work_mem TO '64MB';
-- In the following test cases, we test that certain indexes are used. By using the
-- timescaledb.enable_decompression_sorted_merge optimization, we are pushing a sort node
-- below the DecompressChunk node, which operates on the batches. This could lead to flaky
-- tests because the input data is small and PostgreSQL switches from IndexScans to
-- SequentialScans. Disable the optimization for the following tests to ensure we have
-- stable query plans in all CI environments.
SET timescaledb.enable_decompression_sorted_merge = 0;
set max_parallel_workers_per_gather to 0;
SET timescaledb.enable_decompression_sorted_merge TO 'off';
SET max_parallel_workers_per_gather TO '0';
-- disable incremental sort to avoid flaky results
SET enable_incremental_sort TO 'off';
-- disable memoize node to avoid flaky results
SET enable_memoize TO 'off';
\set TEST_TABLE 'metrics'
\ir :TEST_QUERY_NAME
-- This file and its contents are licensed under the Timescale License.
Expand Down
17 changes: 8 additions & 9 deletions tsl/test/shared/sql/constraint_exclusion_prepared.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,26 @@ SELECT
SELECT format('\! diff -u --label "Uncompressed results" --label "Compressed results" %s %s', :'TEST_RESULTS_UNCOMPRESSED', :'TEST_RESULTS_COMPRESSED') as "DIFF_CMD"
\gset

-- disable memoize node to make EXPLAIN output comparable between PG14 and previous versions
SELECT CASE WHEN current_setting('server_version_num')::int/10000 >= 14 THEN set_config('enable_memoize','off',false) ELSE 'off' END AS enable_memoize;

-- get EXPLAIN output for all variations
\set PREFIX 'EXPLAIN (analyze, costs off, timing off, summary off)'
\set PREFIX_VERBOSE 'EXPLAIN (analyze, costs off, timing off, summary off, verbose)'

set work_mem to '64MB';
-- disable incremental sort here to make plans comparable to PG < 13
SELECT CASE WHEN current_setting('server_version_num')::int/10000 >= 13 THEN set_config('enable_incremental_sort','off',false) ELSE 'off' END;

SET work_mem TO '64MB';

-- In the following test cases, we test that certain indexes are used. By using the
-- timescaledb.enable_decompression_sorted_merge optimization, we are pushing a sort node
-- below the DecompressChunk node, which operates on the batches. This could lead to flaky
-- tests because the input data is small and PostgreSQL switches from IndexScans to
-- SequentialScans. Disable the optimization for the following tests to ensure we have
-- stable query plans in all CI environments.
SET timescaledb.enable_decompression_sorted_merge = 0;
SET timescaledb.enable_decompression_sorted_merge TO 'off';
SET max_parallel_workers_per_gather TO '0';

-- disable incremental sort to avoid flaky results
SET enable_incremental_sort TO 'off';
-- disable memoize node to avoid flaky results
SET enable_memoize TO 'off';

set max_parallel_workers_per_gather to 0;
\set TEST_TABLE 'metrics'
\ir :TEST_QUERY_NAME
\set TEST_TABLE 'metrics_space'
Expand Down

0 comments on commit 74f18a1

Please sign in to comment.