PS-11185 - Group replication test with docker containers#4
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
GroupReplicationlifecycle 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.
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>
… runs 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>
saikumar-vs
reviewed
Jun 22, 2026
saikumar-vs
reviewed
Jun 22, 2026
saikumar-vs
requested changes
Jun 22, 2026
saikumar-vs
left a comment
Contributor
There was a problem hiding this comment.
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.
saikumar-vs
reviewed
Jun 22, 2026
ParveezBaig
reviewed
Jun 24, 2026
saikumar-vs
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_IMAGEandSYSBENCH_IMAGE.The test run with both haproxy and mysql router.
It has helpers for following objects:
Initial tests cover: