Skip to content

PS-11185 - Group replication test with docker containers#4

Merged
tplavcic merged 88 commits into
mainfrom
PS-11185-group-replication
Jun 30, 2026
Merged

PS-11185 - Group replication test with docker containers#4
tplavcic merged 88 commits into
mainfrom
PS-11185-group-replication

Conversation

@tplavcic

Copy link
Copy Markdown
Contributor

This creates a pytest framework for running group replication tests with docker images. The purpose is to cover some scenarios which are used in K8S operators.
Docker images which are used can be customized with env variables SERVER_IMAGE, HAPROXY_IMAGE, ROUTER_IMAGE, XTRABACKUP_IMAGE and SYSBENCH_IMAGE.
The test run with both haproxy and mysql router.

It has helpers for following objects:

  • docker
  • group replication
  • xtrabackup
  • sysbench

Initial tests cover:

  • basic group replication sanity
  • failover with load
  • scaling test with load
  • backup/restore test with full and incremental backup

tplavcic and others added 16 commits June 8, 2026 10:39
Add HAProxy as a second proxy in front of the Group Replication cluster
alongside MySQL Router, and run the suite under both.

- Generalize the proxy abstraction in GroupReplication: a `proxy` of
  router/haproxy/None drives rw_endpoint/ro_endpoint/exec_sql, verify
  (check_proxy=), and the renamed public wait_proxy_ready().
- HAProxy uses the Percona operator image (perconalab/percona-server-
  mysql-operator:main-haproxy): write frontend :3307, read frontend :3308.
  Since HAProxy is not SQL-aware and the forking external-check is
  unreliable under amd64-on-arm64 emulation, both backends use mysql-check
  for liveness and the framework pins the write target to the current
  primary via the runtime API (ready/maint), re-pinning on failover.
- conftest: parametrize gr_cluster over both proxies with a @pytest.mark.
  proxies(...) marker for per-test selection; move create() inside the
  fixture try/finally so a failed bring-up tears down instead of leaking.
- docker_helper.create gains a `platform` arg (image is amd64-only); _run
  and exec_mysql gain a `timeout` so a probe to a proxy with no live
  backend can't block forever.

Full suite (test_basic + test_failover, both proxies) passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the implicit conftest parametrization (pytest_generate_tests +
@pytest.mark.proxies marker) with an explicit
@pytest.mark.parametrize("gr_cluster", [...], indirect=True) on each test,
so the proxy set each test runs under is visible at the test itself.

- conftest: drop pytest_configure (proxies marker) and pytest_generate_tests;
  keep PROXIES and the gr_cluster fixture (reads request.param, now supplied
  by each test's decorator).
- test_basic / test_failover: import pytest and parametrize gr_cluster over
  ["router", "haproxy"]; narrowing to one proxy is just a shorter list.
- README: document the explicit parametrize form (router-only/haproxy-only/both).
- Add a scoped .gitignore for __pycache__/, *.pyc, .pytest_cache/.

Verified: collection shows [router]/[haproxy] ids per test; test_basic passes
under both proxies.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
verify() already reads membership/roles from replication_group_members;
emit a [GR] log line listing the primary and secondary hosts (obeys
GR_VERBOSE), so a run shows who holds which role at each verify — including
the newly elected primary after failover.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a self-contained pytest-based framework under test_scripts/ps/group-replication/ to spin up a Percona Server Group Replication cluster in containers (optionally fronted by MySQL Router or HAProxy) and run end-to-end scenarios similar to operator/K8s workflows.

Changes:

  • Introduces Docker CLI wrappers and a GroupReplication lifecycle helper (bootstrap, verify, failover, scale up/down, checksums).
  • Adds helper containers for workload (Sysbench) and physical backup/restore (XtraBackup).
  • Adds initial pytest suite covering sanity replication, primary failover, scaling under load, and full+incremental backup/restore, plus README/docs and pytest config.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test_scripts/ps/group-replication/docker_helper.py Docker/Podman CLI wrapper for container/network/volume lifecycle and in-container mysql/mysqlsh execution.
test_scripts/ps/group-replication/group_replication_helper.py Core GR cluster orchestration (create/destroy, proxy support, scale/failover helpers, verification and checksums).
test_scripts/ps/group-replication/sysbench_helper.py Sysbench runner helper for load generation via ephemeral containers.
test_scripts/ps/group-replication/xtrabackup_helper.py XtraBackup helper to run full/incremental backups and restore via ephemeral containers.
test_scripts/ps/group-replication/conftest.py Pytest fixtures wiring cluster/proxy selection plus sysbench and xtrabackup setup/teardown.
test_scripts/ps/group-replication/test_basic.py Basic replication sanity test (DDL/DML + checksum verification).
test_scripts/ps/group-replication/test_failover.py Primary failover/recovery scenario under sysbench write workload.
test_scripts/ps/group-replication/test_scaling.py Scale up/down scenario under sysbench workload with checksum validation.
test_scripts/ps/group-replication/test_backup_restore.py Full+incremental backup/restore scenario and point-in-time checksum comparison.
test_scripts/ps/group-replication/pytest.ini Local pytest configuration (discovery + live logging).
test_scripts/ps/group-replication/requirements.txt Python dependencies for running the suite.
test_scripts/ps/group-replication/README.md Usage docs, architecture notes, and how to run/debug scenarios locally.
test_scripts/ps/group-replication/.gitignore Ignores Python/pytest local artifacts for this suite.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test_scripts/ps/group-replication/README.md Outdated
Comment thread test_scripts/ps/group-replication/README.md Outdated
Comment thread test_scripts/ps/group-replication/README.md Outdated
Comment thread test_scripts/ps/group-replication/README.md Outdated
Comment thread test_scripts/ps/group-replication/README.md Outdated
Comment thread test_scripts/ps/group-replication/test_backup_restore.py Outdated
tplavcic and others added 5 commits June 10, 2026 14:01
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Comment thread test_scripts/ps/group-replication/conftest.py
Comment thread test_scripts/ps/group-replication/group_replication_helper.py Outdated
Comment thread test_scripts/ps/group-replication/group_replication_helper.py
… runs

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread test_scripts/ps/group-replication/docker_helper.py
Comment thread test_scripts/ps/group-replication/conftest.py
tplavcic and others added 2 commits June 12, 2026 12:10
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread test_scripts/ps/group-replication/README.md Outdated
Comment thread test_scripts/ps/group-replication/README.md Outdated
tplavcic and others added 2 commits June 12, 2026 12:22
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread test_scripts/ps/group-replication/group_replication_helper.py
Comment thread test_scripts/ps/group-replication/group_replication_helper.py
@tplavcic
tplavcic requested a review from Copilot June 12, 2026 10:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread test_scripts/ps/group-replication/docker_helper.py
Comment thread test_scripts/ps/group-replication/test_backup_restore.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread test_scripts/ps/group-replication/group_replication_helper.py
Comment thread test_scripts/ps/group-replication/sysbench_helper.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread test_scripts/ps/group-replication/sysbench_helper.py
Comment thread test_scripts/ps/group-replication/docker_helper.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread test_scripts/ps/group-replication/sysbench_helper.py
Comment thread test_scripts/ps/group-replication/docker_helper.py
Comment thread test_scripts/ps/group-replication/test_backup_restore.py
Comment thread test_scripts/ps/group-replication/test_failover.py

@saikumar-vs saikumar-vs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks Tomislav, nice framework for testing GR, i have some ideas will gather them and send to you - for now couple of quick suggestions/queries.

Comment thread test_scripts/ps/group-replication/group_replication_helper.py
Comment thread test_scripts/ps/group-replication/test_failover.py

@saikumar-vs saikumar-vs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

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.

4 participants