Skip to content

Port xbstream_fifo_test.sh to pytest (xbstream_fifo_tests.py) - #12

Draft
saikumar-vs wants to merge 5 commits into
mainfrom
pxb-xbstream-fifo-pytest-port
Draft

saikumar-vs wants to merge 5 commits into
mainfrom
pxb-xbstream-fifo-pytest-port

Conversation

@saikumar-vs

@saikumar-vs saikumar-vs commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ports xbstream_fifo_test.sh (the bash FIFO-streamed backup test, updated to use SeaweedFS in #11, now merged) to the Python/pytest framework, following the conventions of innodb_myrocks_backup_tests.py and inc_backup_load_tests.py.

  • test_helper.py — FIFO_STREAM/FIFO_DIR constants and new BackupTestHelper methods: take_backup_fifo (runs xtrabackup --backup in the background + xbcloud put in the foreground, both reading/writing the same named pipes), take_full_backup_fifo/take_incremental_backup_fifo (full and full+N-incremental orchestration, mirroring the bash script's full_backup_and_restore()/incremental_backup_and_restore()), and cleanup_fifo_state. These stream xtrabackup/xbstream and xbcloud through named pipes as two concurrent processes — distinct from take_backup()'s existing "cloud" backup_type, which is a single shell pipe.
    Two existing methods were extended (not just added-to): xbcloud_get gained a use_fifo keyword (default False, so existing callers are unaffected) that switches it from the single-pipe xbcloud get | xbstream -x to the two-process FIFO form; and take_backup()'s inline stop/move-datadir/copy-back/restart restore logic was factored out into a new shared restore_datadir_from() method (also used by the FIFO path), removing the duplication between the two.
  • seaweedfs_helper.py (new) — SeaweedFSHelper class managing the local SeaweedFS S3-gateway docker container, ported from the xbstream_fifo_test.sh start_seaweedfs()/cleanup_exit() shell logic merged in Replace MinIO with SeaweedFS in xbstream_fifo_test.sh, fix keyring_file bugs #11.
  • xbstream_fifo_tests.py (new) — the test file itself: a session-scoped seaweedfs fixture (starts the container once, stops it at session end) and 7 tests mirroring the bash script's scenarios (full, incremental, compressed, partition-table, keyring_file, keyring_kmip, xbcrypt-encrypted backup).
  • README.md — new section documenting env vars, how to run, and the test reference table, matching the existing per-file structure.
  • kmip_helper.py / test_helper.py / hashicorp_kmip_setup.py — enabled the hashicorp KMIP vault type (was commented out of KMIP_CONFIGS/DEFAULT_KMIP_CONFIGS, and even if enabled, setup_hashicorp() was invoking the downloaded setup script via bash instead of python3, which would have failed immediately). Added a HASHICORP_VAULT_LICENSE env-var skip-guard everywhere the shared KMIP_CONFIGS now surfaces a hashicorp variant (this file's test_fifo_kmip_backup, plus the existing test_kmip_component_backup and test_crash_backup_encrypted_kmip in inc_backup_load_tests.py), matching the existing FORTANIX_EMAIL/FORTANIX_PASSWORD guard pattern.
  • Improved error surfacing in kmip_helper.py (setup_hashicorp now records self.last_error for empty-download/exec failures) and seaweedfs_helper.py (start() now checks and reports docker start's exit code instead of ignoring it); also fixed an or FIFO_STREAM/or FIFO_DIR pattern in test_helper.py that would have silently overridden an explicit fifo_streams=0/fifo_dir="" with the default (should only fall back on None).
  • Branch has been rebased onto main (post-Replace MinIO with SeaweedFS in xbstream_fifo_test.sh, fix keyring_file bugs #11) so this PR's diff no longer shows against a stale base.

Test plan

Verified end-to-end against real PXB 8.4.0-7 / PS 8.4.10-10 builds and a live SeaweedFS container:

  • test_fifo_full_backup_and_restore
  • test_fifo_incremental_backup
  • test_fifo_compressed_backup (confirmed real zstd compression in the backup log)
  • test_fifo_partition_tables
  • test_fifo_keyring_file_backup
  • test_fifo_encrypted_backup
  • test_fifo_kmip_backup[pykmip] — run 3 times: passed, then hit a genuine xtrabackup --prepare SIGSEGV crash (__printf_buffer/__vsnprintf_internal), then passed again. Non-deterministic and reproducible independently of this port's code — a product-level PXB 8.4.0-7 stability issue during prepare of an encrypted (keyring_kmip) backup, in the same general class as the separately-noted keyring_file InnoDB-assertion crash. Worth its own PXB bug report; not something this PR can fix.
  • test_fifo_kmip_backup[fortanix] / [hashicorp] — confirmed both skip cleanly without FORTANIX_EMAIL/FORTANIX_PASSWORD / HASHICORP_VAULT_LICENSE set (neither available in this environment; the credential/license-driven setup paths themselves are unverified end-to-end)
  • Re-verified take_full_backup_fifo/take_incremental_backup_fifo/take_backup_fifo after the method renaming and the xbcloud_get/restore_datadir_from consolidation (full + incremental FIFO backups still pass)

Regression-checked: innodb_myrocks_backup_tests.py and inc_backup_load_tests.py still collect cleanly (72 tests total across all three files).

🤖 Generated with Claude Code

@saikumar-vs
saikumar-vs marked this pull request as draft September 22, 2026 10:01
saikumar-vs and others added 5 commits September 22, 2026 20:24
Adds FIFO-streamed cloud backup coverage to the Python test framework,
following the conventions of innodb_myrocks_backup_tests.py and
inc_backup_load_tests.py:

- test_helper.py: additive FIFO_STREAM/FIFO_DIR constants and six new
  BackupTestHelper methods (take_fifo_backup_step, restore_fifo_backup_step,
  take_fifo_full_backup_and_restore, take_fifo_incremental_backup_and_restore,
  restore_datadir_from, cleanup_fifo_state). These stream xtrabackup/xbstream
  and xbcloud through named pipes as two concurrent processes (background +
  foreground), mirroring the bash script's xbcloud_put()/xbcloud_get(),
  rather than take_backup()'s "cloud" backup_type (a single shell pipe).
  No existing method was modified.
- seaweedfs_helper.py: new SeaweedFSHelper class managing the local
  SeaweedFS S3-gateway docker container, ported from the already-fixed
  xbstream_fifo_test.sh start_seaweedfs()/cleanup_exit() shell logic
  (percona-qa/server-qa PR #11).
- xbstream_fifo_tests.py: the actual test file, with a session-scoped
  seaweedfs fixture and 7 tests mirroring the bash script's scenarios
  (full, incremental, compressed, partition-table, keyring_file, keyring_kmip,
  xbcrypt-encrypted backup).
- README.md: new section documenting env vars, how to run, and the test
  reference table, matching the existing per-file structure.

Verified end-to-end against real PXB 8.4.0-7 / PS 8.4.10-10 builds and a
live SeaweedFS container: all 7 tests pass (test_fifo_kmip_backup requires
KMIP vault/license resources not available in this environment, so it
wasn't run, matching the same gap noted in the bash-script PR). One
transient SeaweedFS-readiness timeout and one missing --xtrabackup-plugin-dir
in two tests' prepare_params were found and fixed during that verification.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
hashicorp was commented out of KMIP_CONFIGS/DEFAULT_KMIP_CONFIGS and, even
if enabled, KMIPHelper.setup_hashicorp() executed the downloaded
hashicorp_kmip_setup.py (a real Python script, #!/usr/bin/env python3,
argparse-based) via `bash -s`, which would have failed immediately with a
syntax error. Fixed to invoke it via `python3 -`, matching how the retired
bash kmip_helper.sh ran it.

Enabling hashicorp in the shared KMIP_CONFIGS adds a `[hashicorp]`
parametrized variant to every vault_type-parametrized test that reads from
it (test_fifo_kmip_backup here, plus the existing test_kmip_component_backup
and test_crash_backup_encrypted_kmip in inc_backup_load_tests.py). Added a
VAULT_LICENSE environment-variable guard (pytest.skip when unset) at each
of those three call sites, matching the existing FORTANIX_EMAIL/PASSWORD
guard pattern, since hashicorp_kmip_setup.py requires a real HashiCorp
Vault Enterprise license.

Verified: xbstream_fifo_tests.py::test_fifo_kmip_backup[hashicorp] skips
cleanly (no VAULT_LICENSE in this environment) instead of failing; full
license-driven setup path still needs a real Vault Enterprise license to
verify end-to-end, same limitation noted for the bash script in PR #11.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Unifies the license env var name to HASHICORP_VAULT_LICENSE across
hashicorp_kmip_setup.py's check_license() and the three pytest skip-guard
sites (test_helper.py's run_kmip_component_backup/
run_crash_tests_pstress_encrypted, xbstream_fifo_tests.py's
test_fifo_kmip_backup). Fortanix's env vars (FORTANIX_EMAIL/PASSWORD) are
left as-is.

Left untouched: the `-e VAULT_LICENSE=...` passed into the Vault Enterprise
docker container itself (hashicorp_kmip_setup.py:142) -- that's HashiCorp
Vault's own required container env var name, not something under our
control, and renaming it would break Vault's license detection.

Also documents HASHICORP_VAULT_LICENSE in README.md alongside the existing
FORTANIX_EMAIL/PASSWORD guidance for all three affected tests.

Verified: xbstream_fifo_tests.py::test_fifo_kmip_backup[hashicorp] still
skips cleanly under the new env var name.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Updated KMIPHelper to store error messages in `self.last_error` for empty script downloads and execution failures, improving error reporting.
- Modified SeaweedFSHelper to capture and report errors when starting the SeaweedFS container, providing clearer feedback on failures.

These changes improve the robustness and clarity of error handling in the respective helper classes.
- xbcloud_put_fifo -> take_backup_fifo: it drives xtrabackup --backup
  itself (not just an upload like xbcloud_put), so it belongs with the
  existing take_full_backup/take_incremental_backup naming instead of
  being named after the xbcloud subcommand it happens to also call.
- take_fifo_full_backup_and_restore -> take_full_backup_fifo
- take_fifo_incremental_backup_and_restore -> take_incremental_backup_fifo
  Both drop the "_and_restore" suffix to match take_full_backup/
  take_incremental_backup, which already restore internally without
  saying so in the name, and move "fifo" to a consistent suffix
  position shared with take_backup_fifo/xbcloud_get(use_fifo=...).

xbcloud_get's use_fifo flag is left as-is: unlike the backup/put side,
FIFO vs single-pipe on the get side is genuinely just a transport detail
of the same "get a backup from cloud" operation, not a different one.

Verified test_fifo_full_backup_and_restore and test_fifo_incremental_backup
still pass end-to-end against real PXB 8.4.0-7/PS 8.4.10-10 builds and a
live SeaweedFS container after the rename.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@saikumar-vs
saikumar-vs force-pushed the pxb-xbstream-fifo-pytest-port branch from 0eea4f4 to e230815 Compare September 22, 2026 15:12
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