Skip to content

[TASK] Move the container-structure-test checks into the image tests and remove container-structure-test - #661

Merged
Kanti merged 3 commits into
masterfrom
task/structure-tests-to-phpunit
Nov 23, 2026
Merged

Kanti merged 3 commits into
masterfrom
task/structure-tests-to-phpunit

Conversation

@Kanti

@Kanti Kanti commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The CI tested bootstrap, base, base-app, php, php-dev and php-nginx twice: with the PHPUnit image tests in ci/image-tests and with the container-structure-test suites in tests/structure-test. Most checks of the suites were covered by the image tests already, often more strictly (a service that runs instead of a line in its configuration, a request through Nginx instead of nginx -T). The rest is moved into the image tests here, so they are the only tests of the images: one place to add a test, one runner, one result per image job, and no binary downloaded from storage.googleapis.com/.../latest into the build environment.

What

Based on master (stack: this → #662). It needs none of the other open pull requests: it was first stacked on #660, #658 and #657, where the checks below were made, and was rebased onto master without conflicts; make generate changes nothing, and the PHPUnit tests (351) and PHPStan of ci/ pass.

  • Image tests (ci/image-tests): every check of the suites is in the image tests now, see the mapping under Tests. New tests go at the end of the trait that the images with that property use, so the images that inherit it get them too (for example php-nginx-dev, php-apache and php-apache-dev, which had no suite).
    • Docker/ImageConfiguration.php (new) reads what the image sets for its containers with docker image inspect: environment variables, entrypoint, command and exposed ports. The suites' metadataTest checked the same.
    • Docker/FileInfo::permissions() (new) gives type and mode as ls -l shows them, e.g. -rwxr-xr-x, including the setuid, setgid and sticky bits. assertRootScript() and assertRootFile() only check the r, w and x bits, so the exact modes of the suites (permissions: '-rwxr-xr-x') are checked with it.
    • PhpModules lists readline, which the suite's php -m list had and the image tests did not; the CLI and PHP-FPM load it in all PHP images.
  • Removed:
    • tests/structure-test (the six suites and run.sh), and with it tests/.
    • The step "run structure-test" of the image jobs: GithubJobBuilder::structuredTests() and its call; .github/workflows/build.yaml regenerated (33 steps fewer).
    • make structure-test.
    • container-structure-test in webdevops/dockerfile-build-env (downloaded unpinned as latest), and its check in BuildEnvChecks.
    • The fixture ci/tests/Fixtures/repository/tests/structure-test and GithubJobBuilderTest::testStructureTestUsesTheSuiteOfTheTagToo; the expected step lists no longer have the step.
  • Docs: AGENTS.md (repository map, the paragraph on make structure-test), CONTRIBUTING.md (Building in CI, Building and testing locally; the image tests also read the configuration of the image). docs/ did not mention it.

Changes for existing users

  • webdevops/dockerfile-build-env no longer contains container-structure-test. The CI of this repository was its only user here; install it yourself if you need it.
  • make structure-test is gone; make test-image IMAGE=webdevops/<image>:<tag> runs the tests of an image.

Tests

Mapping of the checks of the suites

"Covered" means an image test that already existed checks it; "new" means this pull request adds the test. Traits in ci/image-tests/Checks/.

bootstrap (bootstrap:ubuntu-22.04)

Check of the suite Image test
LC_ALL=C.UTF-8, LANG=C.UTF-8, TERM=xterm, PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin BootstrapChecks::testLocaleTerminalAndPathOfTheImage new
apk-install, apk-upgrade, apt-install, apt-upgrade -rwxr-xr-x BootstrapChecks::testBootstrapScript (program of root, r/w/x bits) and testBootstrapCommandPermissions (exact mode) covered, exact mode new
apt-add-repository, apt-update, docker-image-cleanup, docker-image-info, generate-locales, generate-dockerimage-info, docker-run-bootstrap, go-replace -rwxr-xr-x BootstrapChecks::testBootstrapCommandPermissions new (PhpChecks::testPhpScript had six of them, only for the PHP images)
/sbin/gosu -rwxr-xr-x BootstrapChecks::testGosuPermissions new

base (base:ubuntu-22.04)

Check of the suite Image test
entrypoint ["/entrypoint"], cmd ["supervisord"] EntrypointChecks::testEntrypointCommandAndLogVariablesOfTheImage new
DOCKER_CONF_HOME=/opt/docker/, LOG_STDOUT="", LOG_STDERR="" the same test new
bootstrap.sh, config.sh, control.sh, entrypoint.sh, service.d/supervisor.sh in /opt/docker/bin -rwxr-xr-x BaseChecks::testBaseScript and testBasePermissions (exact mode) covered, exact mode new
supervisor.conf, supervisor.d/{cron,dnsmasq,postfix,ssh,syslog}.conf, logrotate.d/syslog-ng, syslog-ng/syslog-ng.conf in /opt/docker/etc -rw-r--r-- BaseChecks::testBaseFile and testBasePermissions covered, exact mode new
/opt/docker/provision/service.d/{cron,dnsmasq,postfix,ssh,syslog}.sh -rw-r--r-- ServiceChecks::testInstallerIsKeptOnlyForTheServicesTheImageDoesNotRun new
which supervisord, wget, curl (/usr/bin), zic (/usr/sbin), netstat, sed (/usr/bin or /bin) BaseChecks::testBaseCommandIsOnThePath new

base-app (base-app:ubuntu-22.04)

Check of the suite Image test
APPLICATION_USER=application, APPLICATION_GROUP=application, APPLICATION_PATH=/app, APPLICATION_UID=1000, APPLICATION_GID=1000 BaseAppChecks::testApplicationVariablesOfTheImage new
bootstrap.d/10-user-application.sh and 20-app.sh deleted BaseAppChecks::testBuildScriptsWereRunAndDeleted (no *.sh left in /opt/docker/provision/bootstrap.d) new
/app drwxr-xr-x, UID and GID 1000 BaseAppChecks::testApplicationPathBelongsToTheApplicationUser (directory of application) and testApplicationPathPermissions (mode, 1000:1000) covered, mode new
id application: uid=1000(application) gid=1000(application) groups=1000(application) BaseAppChecks::testApplicationUser (UID, GID, group) and testIdOfTheApplicationUser (the line) covered, the line new
which zip, unzip, nslookup, ssh, rsync, git, patch, bzip2: /usr/bin/<tool> BaseAppChecks::testApplicationToolIsOnThePath new

php (all ten tags)

Check of the suite Image test
entrypoint, cmd EntrypointChecks::testEntrypointCommandAndLogVariablesOfTheImage new
exposed port 9000 PhpFpmPublicChecks::testImageExposesPhpFpm new
LC_ALL, LANG, TERM BootstrapChecks::testLocaleTerminalAndPathOfTheImage new
DOCKER_CONF_HOME, LOG_STDOUT, LOG_STDERR EntrypointChecks::testEntrypointCommandAndLogVariablesOfTheImage new
APPLICATION_* BaseAppChecks::testApplicationVariablesOfTheImage new
/usr/local/bin/pie and /tmp/pie do not exist PhpChecks::testPieIsOnlyThereDuringTheBuild new
bootstrap.d/10-php-init.sh, 11-php-conf.sh, 10-user-application.sh, 20-app.sh deleted BaseAppChecks::testBuildScriptsWereRunAndDeleted new
service.d/cron.sh and syslog.sh deleted; dnsmasq.sh, postfix.sh, ssh.sh kept, -rw-r--r-- ServiceChecks::testInstallerIsKeptOnlyForTheServicesTheImageDoesNotRun new
fpm/php-fpm.conf, fpm/pool.d/application.conf exist PhpFpmChecks::testPhpFpmLayout covered
entrypoint.d/20-php-fpm.sh, 20-php.sh exist PhpChecks::testEntrypointScriptsOfPhp new
supervisor.d/php-fpm.conf exists; syslog.conf and cron.conf have autostart = true ServiceChecks::testServiceStartsAutomaticallyOnlyIfTheImageRunsIt (that they run: ServiceChecks::testSupervisordStartsTheServicesOfTheImage) new
/app as for base-app
php.session.upload_progress.enabled=On: enabled in the CLI, session.upload_progress.enabled => On => On in php-fpm -i PhpEnvironmentChecks::testSessionUploadProgressFromTheEnvironment new
which zip … patch BaseAppChecks::testApplicationToolIsOnThePath new
php -v: PHP 8.2 or newer PhpChecks::testPhpVersion: the PHP version of the tag (8.2 to 8.6) and at least its security release covered
php-fpm -t: test is successful PhpFpmServiceChecks::testPhpFpmRuns: PHP-FPM runs under supervisord, which it does not with a configuration that fails -t covered
SOME_VAR=someval in php-fpm -i PhpFpmEnvironmentChecks::testPhpFpmPoolDirectivesOfDockerConfFromTheEnvironment: a PHP-FPM worker sees APPLICATION_PATH of the container covered
which convert, gm, gs (/usr/bin), composer (/usr/local/bin) PhpChecks::testPhpCommandIsOnThePath (testImageMagick, testGraphicsMagick, testGhostscript, testComposer ran them by their absolute path) new
php -m: 66 modules PhpChecks::testPhpModules covered, readline added to PhpModules
php-fpm -m: the same modules PhpFpmChecks::testPhpFpmCommandListsTheModules new (PhpWebChecks::testPhpFpmModules checked a worker, only in the images with a web server)
vips and xmlrpc up to PHP 8.5 PhpChecks::testPhpModules (PhpModules adds them up to 8.5) covered

php-dev (all ten tags)

Check of the suite Image test
/usr/bin/blackfire exists PhpDevelopmentChecks::testBlackfireCli new
syslog.conf, postfix.conf, ssh.conf have autostart = true ServiceChecks::testServiceStartsAutomaticallyOnlyIfTheImageRunsIt new
php -m lists Xdebug and not Blackfire PhpDevelopmentChecks::testXdebugIsLoaded covered
PHP_DEBUGGER=blackfire: Blackfire, not Xdebug PhpDevelopmentEnvironmentChecks::testPhpDebuggerSelectsTheExtension (blackfire) covered

php-nginx (all ten tags)

Check of the suite Image test
WEB_DOCUMENT_ROOT=/app, WEB_DOCUMENT_INDEX=index.php, WEB_ALIAS_DOMAIN=*.vm, WEB_PHP_TIMEOUT=600, WEB_PHP_SOCKET=127.0.0.1:9000 WebEnvironmentChecks::testWebServerVariablesOfTheImage new
exposed ports 80, 443 PiPageChecks::testImageExposesHttpAndHttps new
/opt/docker/bin/service.d/nginx.sh exists NginxChecks::testNginxScript covered
/opt/docker/etc/nginx/vhost.conf exists NginxChecks::testNginxFile covered
nginx.conf has autostart = true ServiceChecks::testServiceStartsAutomaticallyOnlyIfTheImageRunsIt new
nginx -t: syntax is ok, test is successful NginxChecks::testNginxRuns and PiPageChecks::testWebServerAnswers: Nginx runs with the configuration of the entrypoint and answers over http and https covered
WEB_DOCUMENT_ROOT=/some/test/dir: root "/some/test/dir"; in nginx -T WebEnvironmentChecks::testDocumentRootAndIndexFromTheEnvironment: a request gets the start page of WEB_DOCUMENT_ROOT covered
WEB_DOCUMENT_INDEX=somefile.php: index somefile.php; the same test, with WEB_DOCUMENT_INDEX=start.html covered

Results

The PHPUnit tests of ci/: DockerTest covers FileInfo::permissions() (program, file, directory, setuid and setgid, setgid without x, sticky directory, link, character device, missing path) and ImageConfiguration::parse(); GithubJobBuilderTest no longer expects the step.

The image tests of this branch and of master, against the published images (amd64):

Image master's tests this branch Failures only on this branch
bootstrap:ubuntu-22.04 17 tests, 0 failures 31 tests, 0 failures –
base:ubuntu-22.04 87, 5 131, 5 –
base-app:ubuntu-22.04 41, 5 78, 5 –
php:8.5 154, 10 220, 10 –
php:8.5-alpine 154, 13 220, 14 testBaseCommandIsOnThePath@zic
php-dev:8.5 173, 10 240, 10 –
php-dev:8.5-alpine 173, 13 240, 14 testBaseCommandIsOnThePath@zic
php-nginx:8.5 202, 8 270, 8 –
php-nginx:8.5-alpine 202, 11 270, 12 testBaseCommandIsOnThePath@zic

Every other failure is the same with master's tests: the published images are older than master, e.g. PHP 8.5.12 and no docker-healthcheck (#645). The published Alpine images have no /usr/sbin/zic, and master's PhpChecks::testZicIsInstalled fails on them too: master installs tzdata-utils since #638, so the image of this pull request's CI has it.

With the changes of #657, #658 and #660 (the published images with their files copied over), the tests of this branch and of #660:

Image tests of #660 this branch Failures only on this branch
php:8.5 173 tests, 2 failures 239, 2 –
php:8.5-alpine 173, 4 239, 5 testBaseCommandIsOnThePath@zic, as above
php-nginx:8.5-alpine 222, 3 290, 4 testBaseCommandIsOnThePath@zic, as above

The new tests fail without the property

local/port-st-mutant is php-nginx:8.5 without the properties, everything else unchanged (ENV LC_ALL=C DOCKER_CONF_HOME=/opt/docker APPLICATION_GID=1001 WEB_PHP_TIMEOUT=60, ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"], chmod u+s of go-replace, chmod 0775 of gosu and /app, chmod g+s of config.sh, wget and patch moved to /usr/local/bin, gm copied there, autostart=true without spaces in cron.conf, ssh.sh removed from service.d, a script left in bootstrap.d, /tmp/pie, 20-php.sh renamed). PhpNginxTest against it fails these tests, besides the failures of the published image:

testLocaleTerminalAndPathOfTheImage, testBootstrapCommandPermissions@go-replace, testGosuPermissions, testBasePermissions@config.sh, testBaseCommandIsOnThePath@wget, testServiceStartsAutomaticallyOnlyIfTheImageRunsIt@cron, testInstallerIsKeptOnlyForTheServicesTheImageDoesNotRun@ssh, testEntrypointCommandAndLogVariablesOfTheImage, testApplicationVariablesOfTheImage, testApplicationPathPermissions, testApplicationToolIsOnThePath@patch, testBuildScriptsWereRunAndDeleted, testPieIsOnlyThereDuringTheBuild, testEntrypointScriptsOfPhp, testPhpCommandIsOnThePath@gm, testWebServerVariablesOfTheImage, and the existing testPhpScript@/sbin/gosu. The existing testBaseScript@config.sh passes on it: it checks the r, w and x bits only.

php-dev:8.5 with ENV PHP_DISMOD=redis and /usr/bin/blackfire moved to /usr/local/bin: testBlackfireCli, testPhpFpmCommandListsTheModules (php-fpm -m should list redis) and the existing testPhpModules fail, nothing else.

Where no such image could be built:

  • testImageExposesHttpAndHttps and testImageExposesPhpFpm: a derived image cannot drop an EXPOSE. docker image inspect shows {"9000/tcp":{}} for php:8.5 (no 80 and 443) and null for base-app:ubuntu-22.04 (no 9000).
  • testIdOfTheApplicationUser: id application fails in base:ubuntu-22.04 (no such user).
  • testSessionUploadProgressFromTheEnvironment: without the variable, the same commands print disabled and session.upload_progress.enabled => Off => Off (the defaults that testPhpSettings and testPhpFpmDisablesUploadProgress check); with it enabled and On => On.

How it was verified

  • ci/console generate leaves no change; it removed the 33 steps "run structure-test" from .github/workflows/build.yaml.
  • The PHPUnit tests of ci/ (351) pass, PHPStan (level 8) and Rector with the configuration of ci/ find nothing.
  • The values of the new tests in the published images before writing them: docker image inspect of 11 images (the three base images; php, php-dev and php-nginx with 8.5 and 8.5-alpine; php-nginx-dev:8.5, php-apache:8.5), and stat, which and the autostart lines of the configuration in containers of 14 images (the three base images and the PHP images with 8.5 and 8.5-alpine, except php-apache-dev:8.5-alpine).
  • Not verified: arm64, PHP 8.2 to 8.4 and 8.6, php-apache and the -dev images with a web server in full runs; this pull request's CI runs the tests on all of them. webdevops/dockerfile-build-env was not built here (a build cannot reach HTTPS in this environment); only three lines of a RUN are removed.

…and remove container-structure-test

The CI tested bootstrap, base, base-app, php, php-dev and php-nginx twice: with
the PHPUnit image tests and with the container-structure-test suites in
tests/structure-test. Most checks of the suites were covered by the image tests
already; the others now are, in the traits of the images with that property, so
that the images that build on them (php-nginx-dev, php-apache, ...) get them
too: the environment, entrypoint, command and exposed ports of the image (read
with docker image inspect), the exact modes of the bootstrap commands and of the
files of base, the installers of the services that an image does not run, the
build scripts that docker-run-bootstrap deleted, the paths of the tools,
php-fpm -m, the Blackfire CLI and php.session.upload_progress.enabled from the
environment.

The image tests are now the only tests of the images. The suites, run.sh, the
"run structure-test" step of the image jobs, make structure-test and the
container-structure-test binary in webdevops/dockerfile-build-env are removed.
@Kanti
Kanti removed this pull request from stack #659 November 23, 2026 08:17
@Kanti
Kanti changed the base branch from task/production-defaults to master November 23, 2026 08:18
@Kanti
Kanti force-pushed the task/structure-tests-to-phpunit branch from 220f259 to 3ce7c11 Compare November 23, 2026 08:18
@Kanti
Kanti added this pull request to stack #669 November 23, 2026 08:18
…ogress, allow spaces around = in autostart

php-fpm -i shows the setting before a pool applies its own: with
php_admin_flag[session.upload_progress.enabled] = off in a pool, php-fpm -i
still shows On while the worker has it off. The test now asks a worker over
FastCGI. The check of autostart in supervisor.d accepts autostart=true too.
@sonarqubecloud

Copy link
Copy Markdown

@Kanti
Kanti marked this pull request as ready for review November 23, 2026 08:54
@Kanti
Kanti merged commit a87c79a into master Nov 23, 2026
199 of 200 checks passed
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