Skip to content

Derive MySQL host and port from {DB_HOST} in tests - #407

Closed
swissspidy wants to merge 1 commit into
mainfrom
claude/great-meitner-9btwir
Closed

swissspidy wants to merge 1 commit into
mainfrom
claude/great-meitner-9btwir

Conversation

@swissspidy

@swissspidy swissspidy commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Fixes the failing install-wp-tests.feature scenarios (e.g. https://github.com/wp-cli/scaffold-command/actions/runs/44215297421/job/134503641818).

Cause

The parallel Docker workers in wp-cli-tests only pass WP_CLI_TEST_DBHOST (127.0.0.1:3306) to the container. They don't pass MYSQL_HOST or MYSQL_TCP_PORT, so {MYSQL_HOST} and {MYSQL_PORT} were empty:

  • mysql ... -h -P --protocol=tcp -e "DROP DATABASE IF EXISTS wp_cli_test_scaffold" failed quietly (it's an I try step). The database was left over from an earlier scenario, so install-wp-tests.sh stopped at its "Reinstalling will delete the existing test database" prompt and exited with 1.
  • The SHOW DATABASES checks failed with Unknown server host '-P'.

Fix

A small mysql-client.sh helper splits {DB_HOST} into a host and a port, or a host and a socket. If the mariadb client is available, it uses that instead of mysql, the same way install-wp-tests.sh does. It replaces every {MYSQL_HOST}/{MYSQL_PORT} usage in install-wp-tests.feature and scaffold-theme-tests.feature.


Generated by Claude Code

Summary by CodeRabbit

  • Chores
    • Improved database test setup compatibility with MySQL and MariaDB clients.
    • Test database connections now support host-only, host-and-port, and socket configurations, with credentials and commands passed through consistently.

The parallel Docker workers of wp-cli-tests only receive
`WP_CLI_TEST_DBHOST`, not `MYSQL_HOST` and `MYSQL_TCP_PORT`, so
`{MYSQL_HOST}` and `{MYSQL_PORT}` stayed empty. The `DROP DATABASE`
step then failed silently and `install-wp-tests.sh` stopped at its
"reinstall?" prompt, and the `SHOW DATABASES` check failed with
"Unknown server host '-P'".

Use a small helper script that splits `{DB_HOST}` into host and port
(or socket) instead, and prefers the `mariadb` client when available.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UWTd5pQ8Dw6arxXZ4GdZrc
@swissspidy
swissspidy requested a review from a team as a code owner November 18, 2026 06:29
Copilot AI balanced review requested due to automatic review settings November 18, 2026 06:29

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The install and scaffold test features now create and use mysql-client.sh for database commands. The wrapper selects mariadb or mysql and parses DB_HOST as a host, host and port, or host and socket path.

Changes: Test Database Client Configuration

Layer / File(s) Summary
Create and use the database client wrapper
features/install-wp-tests.feature, features/scaffold-theme-tests.feature
The scenarios create a wrapper that selects mariadb when available and otherwise uses mysql. It configures the connection from DB_HOST and replaces direct database-drop and database-listing commands with wrapper calls.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: schlessera, wojsmol

Merge Risk: Minimal · up to ef753

This change makes the install and scaffold test scenarios derive the database host and port from the configured DB_HOST, and use mariadb when it is available. It affects only test fixtures, and no merge-blocking risk was found.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added automated-pr bug command:scaffold-theme-tests Related to 'scaffold theme-tests' command scope:testing Related to testing labels Nov 18, 2026
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy closed this Nov 18, 2026
@swissspidy
swissspidy deleted the claude/great-meitner-9btwir branch November 18, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-pr bug command:scaffold-theme-tests Related to 'scaffold theme-tests' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants