Skip to content

python3.10-http-server: Add test scripts - #90

Open
elisaarghir wants to merge 2 commits into
unikraft:testfrom
elisaarghir:test-python3.10
Open

python3.10-http-server: Add test scripts#90
elisaarghir wants to merge 2 commits into
unikraft:testfrom
elisaarghir:test-python3.10

Conversation

@elisaarghir

Copy link
Copy Markdown

Add scripts/test/ directory with scripts used for testing:

  • .gitignore: files to be ignored by GIT
  • all.sh: script that tests all available configurations
  • wrapper.sh: wrapper script over test.sh that starts the instance beforehand
  • common.sh: script with common variables and functions, included by other scripts
  • single.sh: basic script to test started instance
  • README.md: instructions to run the tests

- build/: scripts for building the image using defconfigs.
- defconfig/: minimal Unikraft configuration files.
- run/: scripts for running images and rootfs generation.
- README.md: instructions for the automation scripts.

Signed-off-by: Arghir Elisa-Elena <arghirelisaelena@gmail.com>
Add scripts/test/ for python3.10-http-server/:
- README.md: instructions to run the tests
- common.sh: common functions and variables for test scripts
- single.sh: test an instance started beforehand
- wrapper.sh: wrapper over single.sh that also starts an instance
- all.sh: test all configurations

Signed-off-by: Arghir Elisa-Elena <arghirelisaelena@gmail.com>
@razvand
razvand requested a review from george17c March 1, 2026 07:09
@razvand razvand self-assigned this Mar 1, 2026
@razvand razvand added the enhancement New feature or request label Mar 1, 2026

@george17c george17c left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from these suggestions, also implement the changes I suggested on your other PR. I have not included them here.

test -d ./scripts/test/log || mkdir ./scripts/test/log

test_build_run qemu.x86_64 127.0.0.1 8080
test_build_run qemu.arm64 127.0.0.1 18080

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the port number from 18080 to 8080, I think it's a typo.

test_build_run fc.x86_64 172.44.0.2 8080
test_build fc.arm64
test_build xen.x86_64
test_build xen.arm64

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 lines should all be test_build_run <plat>.<arch> <host> <port>, so

test_build_run fc.arm64 172.44.0.2 8080
test_build_run xen.x86_64 127.0.0.1 8080
test_build_run xen.arm64 127.0.0.1 8080

echo "Using as remote $host:$port" 1>&2

test_curl_connect "$host" "$port"
test_curl_check_reply "$host" "$port" "Directory listing"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check will always fail, because the check string is wrong.
Instead of "Directory listing" it should be "Hello, World!", because that's what the server returns after a GET request.

test_curl_connect "$host" "$port"
test_curl_check_reply "$host" "$port" "Directory listing"

end_with_success

@george17c george17c Mar 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This end_with_success is redundant, it makes the output include an extra PASSED message. The first one is printed by wrapper.sh, so there is no need for this one.


clean_up
start_instance
sleep 10

@george17c george17c Mar 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I tested, sleep 10 is not enough for the server to properly initialize, so the curl check will almost always fail. Increase it to 15 or higher.

And then query it with the `single.sh` script:

```console
./single.sh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include the path from the application directory:

./scripts/test/single.sh

Running single.sh from the test drectory will fail because it will not find the auxiliary script common.sh, it uses a relative path.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a scripts-based build/run/test harness for the python3.10-http-server Unikraft app, including end-to-end smoke tests that can be run across multiple platform/arch configurations.

Changes:

  • Adds scripts/test/ with common helpers plus single.sh, wrapper.sh, and all.sh for automated test runs and log capture.
  • Introduces scripts/build/*, scripts/run/*, and scripts/defconfig/* to build and boot the app across QEMU/Firecracker/Xen targets.
  • Adds README documentation for using the new scripts.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
python3.10-http-server/scripts/test/wrapper.sh Wrapper to start an instance then run the single-instance HTTP checks.
python3.10-http-server/scripts/test/single.sh Runs basic HTTP connectivity and response-content checks against a running instance.
python3.10-http-server/scripts/test/README.md Documents how to run the test scripts.
python3.10-http-server/scripts/test/common.sh Shared test helpers: cleanup, start, and connectivity checks.
python3.10-http-server/scripts/test/all.sh Orchestrates building and running tests across supported configurations and logs output.
python3.10-http-server/scripts/test/.gitignore Ignores generated test logs.
python3.10-http-server/scripts/run/xen.x86_64 Xen x86_64 run script: rootfs generation, initrd packaging, and xl launch.
python3.10-http-server/scripts/run/xen.arm64 Xen arm64 run script: rootfs generation, initrd packaging, and xl launch.
python3.10-http-server/scripts/run/qemu.x86_64 QEMU x86_64 run script with host port forward and kernel/initrd boot args.
python3.10-http-server/scripts/run/qemu.arm64 QEMU arm64 run script with host port forward and kernel/initrd boot args.
python3.10-http-server/scripts/run/fc.x86_64 Firecracker x86_64 run script using a config JSON and socket cleanup.
python3.10-http-server/scripts/run/fc.arm64 Firecracker arm64 run script using a config JSON and socket cleanup.
python3.10-http-server/scripts/README.md Documents the build/run script entrypoints and usage.
python3.10-http-server/scripts/defconfig/xen.x86_64 Xen x86_64 Unikraft defconfig for this app.
python3.10-http-server/scripts/defconfig/xen.arm64 Xen arm64 Unikraft defconfig for this app.
python3.10-http-server/scripts/defconfig/qemu.x86_64 QEMU x86_64 Unikraft defconfig for this app.
python3.10-http-server/scripts/defconfig/qemu.arm64 QEMU arm64 Unikraft defconfig for this app.
python3.10-http-server/scripts/defconfig/fc.x86_64 Firecracker x86_64 Unikraft defconfig for this app.
python3.10-http-server/scripts/defconfig/fc.arm64 Firecracker arm64 Unikraft defconfig for this app.
python3.10-http-server/scripts/build/xen.x86_64 Xen x86_64 build script that applies defconfig and builds.
python3.10-http-server/scripts/build/xen.arm64 Xen arm64 build script that applies defconfig and builds.
python3.10-http-server/scripts/build/qemu.x86_64 QEMU x86_64 build script that applies defconfig and builds.
python3.10-http-server/scripts/build/qemu.arm64 QEMU arm64 build script that applies defconfig and builds.
python3.10-http-server/scripts/build/fc.x86_64 Firecracker x86_64 build script that applies defconfig and builds.
python3.10-http-server/scripts/build/fc.arm64 Firecracker arm64 build script that applies defconfig and builds.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +26 to +35
start_instance()
{
# Start instance.
setsid --fork "$start_command" 1>&2 &
if test $? -ne 0; then
echo "Cannot start instance" 1>&2
echo "FAILED"
clean_up
exit 1
fi
Comment on lines +1 to +4
CONFIG_ARCH_X86_64=y
CONFIG_PLAT_XEN=y
CONFIG_APP_PYHTON3_HTTP_SERVER=y
CONFIG_LIBPYTHON3=y
Comment on lines +1 to +4
CONFIG_ARCH_ARM64=y
CONFIG_PLAT_XEN=y
CONFIG_APP_PYHTON3_HTTP_SERVER=y
CONFIG_LIBPYTHON3=y
@@ -0,0 +1,13 @@
CONFIG_ARCH_ARM64=y
CONFIG_PLAT_FC=y
CONFIG_APPPYHTON3_HTTP_SERVER=y
And then query it with the `single.sh` script:

```console
./single.sh
@@ -0,0 +1,56 @@
# Scripts for Python3.10-http-server on Unikraft

These are companions instruction to the main instructions in the [`README`](README.md).
Comment on lines +1 to +8
# Scripts for Python3.10-http-server on Unikraft

These are companions instruction to the main instructions in the [`README`](README.md).

Use scripts as quick actions for building and running Python3.10-http-server on Unikraft.

**Note**: Run scripts from the application directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants