From Fedora Project Wiki

Revision as of 05:31, 29 September 2023 by Coremodule (talk | contribs) (Modified existing podman testcase to include new sections on checkpointing, stopping, and removing a container as well as container logs.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

A validation test case for Podman on Fedora IoT Edition that tests creating, running, checkpointing, stopping, and removing a container as well as container logs.

Setup

This testcase can be run on either an image or installation, on hardware or in virtualization.

Run as root
Several of the commands in this test case must be run as root as container checkpointing is not supported in rootless podman.

How to test

Boot image or Installation and log in locally or SSH into booted image.

Check if podman is installed

 rpm -q podman

Check to see if you can pull an image from the registry

podman pull registry.fedoraproject.org/fedora:latest

Run hello-world to test.

podman run -it registry.fedoraproject.org/fedora:latest echo Hello-World

Create and Run a Container

Use the following Containerfile to set this container up:

cat << EOF >> Containerfile
FROM registry.fedoraproject.org/fedora:latest
RUN /usr/bin/dnf install -y httpd
EXPOSE 80
CMD ["-D", "FOREGROUND"]
ENTRYPOINT ["/usr/sbin/httpd"]
EOF

Build an image:

sudo podman build -t fedora-httpd $(pwd)

Verify the image:

sudo podman images

Run the container:

sudo podman run -d -p 1080:80 localhost/fedora-httpd

List the running container and take note of the CONTAINER ID:

sudo podman ps

Test that apache is working, this should display the httpd default test page html:

curl http://localhost:1080

Open the firewall to accept connections on port 80 and forward to port 1080:

 sudo firewall-cmd --add-forward-port=port=80:proto=tcp:toport=1080 --permanent
 sudo firewall-cmd --reload

Open a web browser on another computer and enter the IP address to test the page is visible.

Checkpointing/Restoring

Container Checkpointing
Container checkpointing stops a container while writing the state of all processes in the container to disk. With this a container can later be restored and continue running at exactly the same point in time as when it was originally checkpointed.

Checkpoint the container using the CONTAINER ID from the previous sudo podman ps command:

 sudo podman container checkpoint <container_id>

Check that the httpd server is no longer running now that the container has been checkpointed:

 curl http://localhost:1080

Restore the checkpointed container to it's running state:

 sudo podman container restore <container_id>

Now that the container has been restored, check that the httpd server is running again:

 curl http://localhost:1080

Container Inspection/Logs

Inspect the container to ensure it's running:

 sudo podman inspect <container_id> | grep Status

Check that a log message about the "server's fully qualified domain name" is shown:

Ignore the contents, ensure the log
For this test, we don't care about the contents of the log, just that the log message itself shows.
 sudo podman logs <container_id>

Stopping/Removing

Using the CONTAINER ID, stop the container:

 sudo podman stop <container_id>

Ensure the container shows STATUS: Exited:

 sudo podman ps -a

Remove the container:

 sudo podman rm <container_id>

The container should no longer show in the list:

 sudo podman ps -a


Results

  1. Latest image pulled successfully from the Registry
  2. podman is installed
  3. Hello World is displayed
  4. Custom container created, httpd test page visible on a browser or using curl.
  5. Container is checkpointed and restored
  6. Log message is shown
  7. Container stops and is removed