Skip to content

test: make the Postgres fixture match config/sync - #30

Open
rfay wants to merge 1 commit into
mainfrom
20261122_rfay_postgres_config_sync
Open

rfay wants to merge 1 commit into
mainfrom
20261122_rfay_postgres_config_sync

Conversation

@rfay

@rfay rfay commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

The Postgres test DB dump now matches the shared config/sync, so the deploy hook's drush config-import passes on ddev restart of a Postgres test project.

The Issue

tests/per_test.sh imports db-postgres.sql.gz for Postgres variants. The dump didn't match config/sync. On ddev restart, the deploy hook runs drush config-import, which failed with these errors:

  • Site UUID in source storage does not match the target storage.
  • Unable to uninstall the PostgreSQL module, because it provides the pgsql database driver.
  • Entities exist of type ... need to be deleted before importing.

The first ddev start doesn't hit this, because the DB is imported after it. A restart of test-drupal11-postgres-flex failed its post-start hook.

How This PR Solves The Issue

  • settings.php sets $settings['config_exclude_modules'] = ['mysql', 'pgsql']. The MySQL/MariaDB and Postgres variants share one config/sync, so config import and export now leave the database driver modules alone.
  • db-postgres.sql.gz is regenerated on Postgres 17:
    1. A demo_umami install, plus the other modules in core.extension.yml.
    2. The site UUID and every config entity UUID set to the values in config/sync.
    3. drush config-import, after which a second import reports no changes.
    4. Cache, session and watchdog tables emptied before the dump.

Manual Testing Instructions

git clone https://github.com/ddev/ddev-upsun && cd ddev-upsun
gh pr checkout 30
bats tests/drupal11-unified.bats -f 'test-drupal11-postgres-flex$'
# Expect: ok 1 test-drupal11-postgres-flex

To check the restart by hand, run these from the ddev-upsun checkout:

REPO=$PWD && mkdir -p ~/tmp/pgtest && cd ~/tmp/pgtest
cp -r $REPO/tests/testdata/drupal11-base/. . && cp -r $REPO/tests/testdata/platform-configs/postgres-flex/. .
ddev config --project-type=drupal11 --docroot=web --fail-on-hook-fail --web-environment-add=PLATFORM_PROJECT=test,PLATFORM_ENVIRONMENT=test
ddev add-on get $REPO
ddev start -y
ddev composer install --no-dev --no-interaction
ddev import-db --file=db-postgres.sql.gz
ddev restart
# Expect the deploy hook to run config-import without errors

Automated Testing Overview

Claude Code ran these on Linux, each passing:

  • bats tests/drupal11-unified.bats -f 'test-drupal11-postgres-flex$'
  • The postgres, mariadb and mysql flex tests with a ddev restart check that runs the deploy hook under --fail-on-hook-fail.

Nobody ran the fixed-format variants or macOS.

Release/Deployment Notes

This PR changes only test fixtures. #29 can drop --skip-hooks from its restart check after this merges.

https://claude.ai/code/session_01UrTUMwxMkiE5j9dzeKy8rR


Generated by Claude Code

## Short Summary (TL;DR)

The Postgres test DB dump now matches the shared `config/sync`, so the deploy hook's `drush config-import` passes on `ddev restart` of a Postgres test project.

## The Issue

`tests/per_test.sh` imports `db-postgres.sql.gz` for Postgres variants. The dump didn't match `config/sync`. On `ddev restart`, the deploy hook runs `drush config-import`, which failed with these errors:

- Site UUID in source storage does not match the target storage.
- Unable to uninstall the PostgreSQL module, because it provides the `pgsql` database driver.
- Entities exist of type ... need to be deleted before importing.

The first `ddev start` doesn't hit this, because the DB is imported after it. A restart of `test-drupal11-postgres-flex` failed its post-start hook.

## How This PR Solves The Issue

- `settings.php` sets `$settings['config_exclude_modules'] = ['mysql', 'pgsql']`. The MySQL/MariaDB and Postgres variants share one `config/sync`, so config import and export now leave the database driver modules alone.
- `db-postgres.sql.gz` is regenerated on Postgres 17:
  1. A `demo_umami` install, plus the other modules in `core.extension.yml`.
  2. The site UUID and every config entity UUID set to the values in `config/sync`.
  3. `drush config-import`, after which a second import reports no changes.
  4. Cache, session and watchdog tables emptied before the dump.

## Manual Testing Instructions

```bash
git clone https://github.com/ddev/ddev-upsun && cd ddev-upsun
gh pr checkout 30
bats tests/drupal11-unified.bats -f 'test-drupal11-postgres-flex$'
# Expect: ok 1 test-drupal11-postgres-flex
```

To check the restart by hand, run these from the `ddev-upsun` checkout:

```bash
REPO=$PWD && mkdir -p ~/tmp/pgtest && cd ~/tmp/pgtest
cp -r $REPO/tests/testdata/drupal11-base/. . && cp -r $REPO/tests/testdata/platform-configs/postgres-flex/. .
ddev config --project-type=drupal11 --docroot=web --fail-on-hook-fail --web-environment-add=PLATFORM_PROJECT=test,PLATFORM_ENVIRONMENT=test
ddev add-on get $REPO
ddev start -y
ddev composer install --no-dev --no-interaction
ddev import-db --file=db-postgres.sql.gz
ddev restart
# Expect the deploy hook to run config-import without errors
```

## Automated Testing Overview

Claude Code ran these on Linux, each passing:

- `bats tests/drupal11-unified.bats -f 'test-drupal11-postgres-flex$'`
- The postgres, mariadb and mysql flex tests with a `ddev restart` check that runs the deploy hook under `--fail-on-hook-fail`.

Nobody ran the fixed-format variants or macOS.

## Release/Deployment Notes

This PR changes only test fixtures. #29 can drop `--skip-hooks` from its restart check after this merges.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01UrTUMwxMkiE5j9dzeKy8rR

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UrTUMwxMkiE5j9dzeKy8rR
@rfay
rfay force-pushed the 20261122_rfay_postgres_config_sync branch from 65c9aa4 to fad1f9d Compare November 22, 2026 03:48
@rfay
rfay changed the base branch from 20261122_rfay_platform_cache_volume to main November 22, 2026 03:48
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.

2 participants