Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Adjust behave-test-steps so it can be used with Podman #62

Draft
wants to merge 1 commit into
base: v1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 37 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@
# Cekit Behave steps
# Cekit Behave steps -- Podman edition

This repository contains test steps for the [Behave library](https://github.com/behave/behave) used in the [Cekit tool](https://github.com/cekit/cekit/).
This branch is intended to be a home for work to get behave-test-steps to work
with Podman.

## Why external repository?
Ideally we will continue to work with Docker as well, but the initial priority
is Podman support even at the expense of Docker.

Because the test steps are rapidly changing by adding new steps or adjusting existing ones
it does not make sense to combine it together with Cekit releases. These do have different lifecycle. We decided to separate these and so far it's working well.
## Preparation

## Dependencies (Cekit 3.0+)
Podman v2.x+ features a REST API which is docker-compatible but also extends it
with more stuff from the libpod API.

Because test steps have different requirements and these can change over time, Cekit introduced a weak dependency mechanism (see https://github.com/cekit/cekit/pull/357 for more information). In this steps library it is implemented in the `loader.py` file which defines what dependencies are required.
See <https://docs.podman.io/en/latest/_static/api.html>

This information will let Cekit check **at runtime** if requirements are met and if not, user will be notified. If you are running on a known platform, in case a depenency is missing, you will be provided with a hint what to install to satisfy the requirement.
Starting the API endpoint as a user

podman system service -t 5000 # lifetime in seconds. -t 0 = forever

socket is `/run/user/$(id -u)/podman/podman.sock`

Note: there are packages to set this up as a replacement for the docker daemon
socket (`podman-docker` RPM). We don't rely on this because we want to support
concurrent use of podman and docker.

You *might* have systemd sockets and services defined to start the daemon

systemctl --user enable podman.service
systemctl --user start podman.service


## Testing

Set the environment variable `CTF_API_SOCK` to a URI corresponding to the Podman
socket, e.g.

export CTF_API_SOCK=unix:///run/user/1000/podman/podman.sock

Run a test using cekit, e.g.

cekit --descriptor ubi8-openjdk-11.yaml test behave --wip \
--steps-url https://github.com/jmtd/behave-test-steps \
--steps-ref podman
3 changes: 2 additions & 1 deletion steps/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
# A future version of Cekit will expose this to us, for now we hard-code
DOCKER_API_VERSION = "1.35"

d = docker.APIClient(version=DOCKER_API_VERSION)
base_url = os.environ.get("CTF_API_SOCK", 'unix://var/run/docker.sock')
d = docker.APIClient(version=DOCKER_API_VERSION, base_url=base_url)


class ExecException(Exception):
Expand Down
4 changes: 3 additions & 1 deletion steps/image_steps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import docker


Expand All @@ -6,7 +7,8 @@
# A future version of Cekit will expose this to us, for now we hard-code
DOCKER_API_VERSION = "1.35"

DOCKER_CLIENT = docker.APIClient(version=DOCKER_API_VERSION)
base_url = os.environ.get("CTF_API_SOCK", 'unix://var/run/docker.sock')
DOCKER_CLIENT = docker.APIClient(version=DOCKER_API_VERSION, base_url=base_url)

@then(u'the image should contain label {label}')
@then(u'the image should contain label {label} {check} value {value}')
Expand Down
Loading