Skip to content

tests: More shared code based on the patterns we have#35021

Closed
def- wants to merge 28 commits intoMaterializeInc:mainfrom
def-:pr-test-unification
Closed

tests: More shared code based on the patterns we have#35021
def- wants to merge 28 commits intoMaterializeInc:mainfrom
def-:pr-test-unification

Conversation

@def-
Copy link
Copy Markdown
Contributor

@def- def- commented Feb 15, 2026

No description provided.

@github-actions
Copy link
Copy Markdown
Contributor

Pre-merge checklist

  • The PR title is descriptive and will make sense in the git log.
  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).

@def- def- force-pushed the pr-test-unification branch from 25b7c96 to 0704e0f Compare February 18, 2026 08:07
def- and others added 28 commits February 18, 2026 08:09
…l_workflows()

8 mzcompose.py files had an identical ~8-line workflow_default body that
iterates all workflows as test parts. Extract this into a single method
on Composition and replace the boilerplate with a one-liner call.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ws()

Extend run_all_workflows() to support skipping additional workflows
(beyond 'default') and optionally sharding via Buildkite parallelism.
This deduplicates workflow_default boilerplate in 4 more test files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ters

Add internally_sharded, args, and between_workflows parameters to
Composition.run_all_workflows() and use them to replace the repeated
"internal sharding + buildkite sharding" boilerplate in 5 CDC test files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…files()

Add `shard_test_files()` and `glob_test_files()` methods to Composition
that encapsulate the repeated pattern of parsing a filter argument,
globbing for .td files in the test directory, sharding via Buildkite
parallelism, and printing the result. Replace 8 occurrences of this
~10-15 line boilerplate across 6 CDC test files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…run_scenarios()

Deduplicate the repeated buildkite shard + scenario loop pattern across
5 CDC resumption test files (10 occurrences) into a single reusable
method on Composition.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move duplicated helper functions (create_mysql, create_mysql_replica,
get_targeted_mysql_version, PostgresRecvlogical, create_postgres,
get_targeted_pg_version) from test/mysql-cdc and test/pg-cdc pairs
into shared utility modules, following the existing mysql_util.py
pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…orkflows()

Replace the 29-line workflow_default boilerplate in both mysql-cdc-resumption
and mysql-cdc-resumption-old-syntax with calls to c.run_all_workflows(),
using the exclude, internally_sharded, and between_workflows parameters
added in earlier sessions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…estdrive_size_args()

Replace repeated two-line f-string pairs for default replica/storage size
testdrive vars with a single static method call, improving readability
across 6 CDC and kafka-matrix test files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ows()

Replace manual workflow_default boilerplate in 3 CDC resumption test
files with c.run_all_workflows(between_workflows=...). Also extract a
run_testdrive_files helper in sql-server-resumption-old-syntax to
eliminate 13 repeated SQL Server credential var pairs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…l_cdc_resumption.py

The two mysql-cdc-resumption mzcompose.py files (675 lines each) differed
by only 1 import line. Extract all 24 shared helper and scenario functions
into a new misc/python/materialize/mysql_cdc_resumption.py module, reducing
each file from 675 to 313 lines (-324 lines net).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…resumption.py

Extract 14 shared functions (helpers + scenarios) from pg-cdc-resumption and
pg-cdc-resumption-old-syntax into a new shared module, eliminating ~280 lines
of duplicated code. The new-syntax file retains its 3 extra scenarios and
pg8000 helpers; the old-syntax file is reduced from 281 to 95 lines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The SSH setup boilerplate (run setup.td, query public key, authorize on
bastion host) was repeated in 10 workflows. Extract three helpers:
_get_ssh_public_key, _authorize_ssh_key, _setup_and_authorize_ssh.

Net -139 lines (42 added, 181 removed).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `MySql.default_testdrive_args()` and `SqlServer.default_testdrive_args()`
static methods that return the standard testdrive --var args for MySQL root
password and SQL Server credentials. Replace all 24 inline occurrences across
19 files with calls to these methods, consistent with the existing
`Materialized.default_testdrive_size_args()` pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…s_util.py

Move 5 identical replication slot helper functions from both
pg-cdc/mzcompose.py and pg-cdc-old-syntax/mzcompose.py into the shared
postgres_util.py module. The helpers use the common cursor/execute/fetchall
DB interface and work with both psycopg and pg8000 connection objects.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move 4 identical functions (workflow_cdc, workflow_replica_connection,
workflow_schema_change_restart, _make_inserts) from both mysql-cdc and
mysql-cdc-old-syntax mzcompose.py files into a shared mysql_cdc.py module.
The mzcompose framework discovers imported workflow_* functions via
getmembers(module, isfunction), so no wrapper functions are needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rive_ssl_args to postgres_util.py

Move workflow_wal_level, workflow_replication_disabled, and kill_pg_and_mz
into a new shared pg_cdc.py module. Move get_testdrive_ssl_args() from
pg-cdc-old-syntax's local definition to postgres_util.py and use it in
both pg-cdc files, replacing inline SSL cert extraction in pg-cdc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… in checks

Add a pre-dedented `KAFKA_SCHEMA` constant and a shared
`remove_target_cluster_from_explain()` function to `checks/common.py`,
replacing 12 identical `schemas()`/`schema()` wrapper functions and 5
identical `remove_target_cluster_from_explain()` definitions across 20
check files. Also replaces 3 inline `dedent(KAFKA_SCHEMA_WITH_SINGLE_STRING_FIELD)`
usages with the constant.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nt_connection_drop into pg_cdc.py

Move 3 shared workflow functions from pg-cdc and pg-cdc-old-syntax
mzcompose.py files into the shared pg_cdc.py module. Each function
is parameterized to handle the minor differences between the two
test suites (exclude list, max_replication_slots, DB connection
library).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace 27 occurrences of the 4-line ALTER SYSTEM SET boilerplate across
9 test files with a single method call on Composition. This makes each
call site clearly express intent rather than exposing port/user details.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…boilerplate

Replace 48 occurrences of the 4-line `c.sql("ALTER SYSTEM SET ...",
port=6877, user="mz_system")` pattern across 16 files with a 1-line
`c.alter_system_set(name, value)` call. The method handles the internal
port and system user automatically and forwards extra kwargs like
`print_statement` and `service`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ver schema()

Extract the 33-line quickstart cluster recreation boilerplate into a
reusable Composition method. This replaces 3 identical occurrences in
testdrive and testdrive-old-kafka-src-syntax with 4-line calls.

Also replace the leftover schema() wrapper in source-sink-errors with the
KAFKA_SCHEMA constant from common.py (missed in Session 17).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace 49 occurrences of `c.kill("materialized"); c.up("materialized")`
across 15 files with `c.restart_mz()`. Remove 4 standalone `restart_mz()`
helper functions from shared modules and test files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…_system boilerplate

Replace 60+ occurrences of `c.sql(..., port=6877, user="mz_system")` and
`c.sql_query(..., port=6877, user="mz_system")` with dedicated
`sql_as_mz_system()` and `sql_query_as_mz_system()` methods across 15 files.
Also converts 3 leftover raw ALTER SYSTEM SET calls to `alter_system_set()`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract two helpers to deduplicate repeated patterns:
- `_run_kafka_ssh_test()`: encapsulates the full kafka SSH test setup
  (down, override bastion, start deps, authorize, failure/recovery cycle),
  replacing 3 near-identical 25-line workflows with 6-line calls each.
- `_test_ssh_bastion_failure_recovery()`: encapsulates the kill/up/verify
  bastion failure sequence, replacing inline code in pg, mysql, and
  sql_server workflows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…erplate

50 occurrences of the 4-5 line STORAGECTL/STORAGE/COMPUTECTL/COMPUTE
address block across 8 test files are replaced with a single call to
Clusterd.replica_addresses(). Net -164 lines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the 93-line workflow_many_inserts function (testing concurrent
inserts during source creation) from both mysql-cdc and
mysql-cdc-old-syntax mzcompose.py files into the shared mysql_cdc.py
module. The only difference was the CREATE SOURCE SQL (new vs old
syntax), now passed as a parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The 0dt test file had 6 identical 20-line Materialized+Testdrive override
blocks, 4 identical 10-line Testdrive-only override blocks, and 5 identical
12-line rehydrate+promote timing blocks. Extract these into _mz_new_services(),
_testdrive_mz_new(), and _promote_mz_new() helpers to reduce duplication.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both backup-restore and backup-restore-postgres test files had nearly
identical workflow_default functions (~60 lines each) with an explicit
TODO comment asking for extraction. The only differences were the
metadata store backend (CockroachDB vs Postgres).

Extract the shared logic into misc/python/materialize/backup_restore.py,
using Composition.backup()/restore() (which auto-detect the store) and
a new Composition.exec_metadata_store_sql() method that dispatches to
the correct CLI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@def- def- force-pushed the pr-test-unification branch from 0704e0f to 9698b6f Compare February 18, 2026 08:11
@def- def- changed the title Pr test unification tests: More shared code based on the patterns we have Feb 18, 2026
@def- def- closed this Feb 18, 2026
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.

1 participant