test: Language Runtime Container tests#17881
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds runtime container-validation tests for four language runtimes (Python, Ruby, PHP, Node.js) to the Azure Linux image test suite. Each test lives under base/images/tests/cases/runtime/container-base/test_<lang>/ and faithfully mirrors the existing test_nginx example: a Dockerfile layers the runtime onto the image-under-test (ARG BASE_IMAGE/FROM ${BASE_IMAGE}), a small app/server file is COPY'd in, and pytest uses the @pytest.mark.dockerfile() marker plus the container_exec_shell fixture to start a server and assert on an HTTP response. This extends smoke coverage of the container-base image's language runtimes.
Changes:
- Adds version + HTTP-server tests for Python, Ruby, and Node.js (each:
--versioncheck and a stdlib HTTP server round-trip). - Adds PHP tests covering
php --version, thezipextension being loaded, and a zip round-trip via the built-in server +router.php. - Adds per-language
Dockerfiles thatdnf installthe runtime and supporting tools, consistent with the documented Dockerfile-based runtime-test pattern.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
test_python/test_python.py |
Python version + stdlib http.server response test. |
test_python/app.py |
Minimal http.server returning the expected string. |
test_python/Dockerfile |
Installs python3, curl; copies app.py. |
test_ruby/test_ruby.py |
Ruby version + stdlib socket HTTP server test. |
test_ruby/app.rb |
Minimal TCPServer returning the expected string. |
test_ruby/Dockerfile |
Installs ruby, curl; copies app.rb. |
test_php/test_php.py |
PHP version, zip extension, and zip round-trip test. |
test_php/router.php |
Built-in-server router exercising ZipArchive. |
test_php/Dockerfile |
Installs php-cli, php-pecl-zip, unzip, curl; copies router.php. |
test_nodejs/test_nodejs.py |
Node.js version + stdlib http server test. |
test_nodejs/server.js |
Minimal http server returning the expected string. |
test_nodejs/Dockerfile |
Installs nodejs, curl; copies server.js. |
I verified: the @pytest.mark.dockerfile()/container_exec_shell framework supports these tests; each EXPECTED_RESPONSE matches its app's output; the referenced packages (python3, ruby, nodejs, php-cli, php-pecl-zip, unzip, curl) all exist as specs in the repo; and the Dockerfile and wait_for_http conventions match the established test_nginx precedent and the tests README.md. I found no substantive issues.
| if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"])) { | ||
| return false; // serve the requested resource as-is. | ||
| } else { | ||
| $zip = new ZipArchive(); |
There was a problem hiding this comment.
question(non-blocking): I'm wondering what motivated the more extensive testing (zip/unzip) for php and why you didn't do something similar for the other languages.
There was a problem hiding this comment.
Thank you @tobias for the review.
test_php_zip_extension_loaded is intentionally PHP-specific. This is a direct port of the existing golden-container smoke tests, and my current goal is to bring them to the Azure Linux 4.0 base container with minimal changes. Once the golden containers are available, I plan to run the same test suite against them as well. For that reason, I have kept the tests as close to the original implementation as possible. But I am open to the option of adding this test later when golden container is availble.
The ZIP validation originates from the upstream PHP golden-container test. The php-pecl-zip package is an optional extension, so the presence of PHP alone does not guarantee that the ZIP extension is available. That's why the test explicitly verifies it through both a php -m check and a functional round-trip validation.
The other runtimes do not have an equivalent optional, headless-relevant extension.
883c209 to
181dd27
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Language runtime tests for container