Skip to content

Commit

Permalink
automation: Use podman by default
Browse files Browse the repository at this point in the history
Docker is not supported anymore in Fedora and RHEL 8,
hence change the run-tests.sh to use podman by default, to use docker:

    sudo env CONTAINER_CMD=docker ./automation/run-tests.sh

Removed unneeded workaround script for enabling systemd.

And add back the test in travis using
'networkmanager/NetworkManager-master' and
'networkmanager/NetworkManager-1.22-git' copr repos.

The travis does not support podman [yet][1], hence still using docker.

[1]: containers/podman#3679

Signed-off-by: Gris Ge <[email protected]>
  • Loading branch information
cathay4t committed Feb 20, 2020
1 parent 202337e commit 6a6fff6
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 120 deletions.
18 changes: 13 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ env:
use_coveralls=false
- CONTAINER_IMAGE=nmstate/centos8-nmstate-dev
testflags="--test-type integ_slow --pytest-args='-x'"
- CONTAINER_IMAGE=nmstate/centos8-nmstate-dev-nm-1.22-git
testflags="--test-type integ --pytest-args='-x'"
- CONTAINER_IMAGE=nmstate/centos8-nmstate-dev
testflags="--test-type integ --pytest-args='-x'
--copr networkmanager/NetworkManager-1.22-git"
- CONTAINER_IMAGE=nmstate/centos8-nmstate-dev
testflags="--test-type integ --pytest-args='-x'
--copr networkmanager/NetworkManager-master"
- CONTAINER_IMAGE=nmstate/centos8-nmstate-dev
testflags="--test-type format"
- CONTAINER_IMAGE=nmstate/centos8-nmstate-dev
Expand All @@ -23,8 +27,12 @@ env:
matrix:
fast_finish: true
allow_failures:
- env: CONTAINER_IMAGE=nmstate/centos8-nmstate-dev-nm-1.22-git
testflags="--test-type integ --pytest-args='-x'"
- env: CONTAINER_IMAGE=nmstate/centos8-nmstate-dev
testflags="--test-type integ --pytest-args='-x'
--copr networkmanager/NetworkManager-1.22-git"
- env: CONTAINER_IMAGE=nmstate/centos8-nmstate-dev
testflags="--test-type integ --pytest-args='-x'
--copr networkmanager/NetworkManager-master"

addons:
apt:
Expand All @@ -43,7 +51,7 @@ before_install:

script:
- sudo modprobe openvswitch
- ./automation/run-tests.sh $testflags
- CONTAINER_CMD="docker" ./automation/run-tests.sh $testflags

after_success:
- sudo pip install coveralls codecov
Expand Down
30 changes: 17 additions & 13 deletions automation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ It may be used both locally and through CI.
https://hub.docker.com/r/nmstate/

- run-tests.sh: Execute the tests in a container using
'nmstate/fedora-nmstate-dev' docker image.
'nmstate/fedora-nmstate-dev' container image.

The following steps are executed:
- Run the container (defined in the Dockerfile) as a daemon.
Expand All @@ -20,23 +20,24 @@ It may be used both locally and through CI.
It also handles the cleanup of the container and nets (stop,rm).

## Running the Tests
Assuming *docker* is installed on the host, just run:
Assuming *podman* is installed on the host, just run:
`./automation/run-tests.sh`

By default, `./automation/run-tests.sh` will run all tests in the container
using 'nmstate/fedora-nmstate-dev' docker image.
using 'nmstate/fedora-nmstate-dev' container image.
You may change the test type by specifying the `--test-type` flag, for example:

* `./automation/run-tests.sh --test-type integ --el8`:
Integration tests (without slow test cases) using
'nmstate/centos8-nmstate-dev' docker image.
'nmstate/centos8-nmstate-dev' container image.

* `./automation/run-tests.sh --test-type integ`:
Integration tests (without slow test cases) using
'nmstate/fedora-nmstate-dev' docker image.
'nmstate/fedora-nmstate-dev' container image.

* `./automation/run-tests.sh --test-type integ_slow`:
Integration slow test cases using `nmstate/fedora-nmstate-dev` docker image.
Integration slow test cases using `nmstate/fedora-nmstate-dev` container
image.

For a full list of command-line flags, run `./automation/run-tests.sh --help`.

Expand Down Expand Up @@ -78,8 +79,8 @@ sudo ../packaging/build-container.sh local/fedora-nmstate-dev
To test the image, either specify it manually as described above or tag it locally:

```
sudo docker tag local/centos8-nmstate-dev nmstate/centos8-nmstate-dev:latest
sudo docker tag local/fedora-nmstate-dev nmstate/fedora-nmstate-dev:latest
sudo podman tag local/centos8-nmstate-dev nmstate/centos8-nmstate-dev:latest
sudo podman tag local/fedora-nmstate-dev nmstate/fedora-nmstate-dev:latest
```

### Push local image to the docker hub
Expand All @@ -90,11 +91,14 @@ persistent. If this is not feasible, a new build could be pushed as follow to
the Docker Hub:

```shell
sudo docker tag local/centos8-nmstate-dev nmstate/centos8-nmstate-dev:latest
sudo docker push nmstate/centos8-nmstate-dev:latest

sudo docker tag local/fedora-nmstate-dev nmstate/fedora-nmstate-dev:latest
sudo docker push nmstate/fedora-nmstate-dev:latest
sudo podman login docker.io
sudo podman tag local/centos8-nmstate-dev nmstate/centos8-nmstate-dev:latest
sudo podman push nmstate/centos8-nmstate-dev:latest \
docker://docker.io/nmstate/centos8-nmstate-dev:latest

sudo podman tag local/fedora-nmstate-dev nmstate/fedora-nmstate-dev:latest
sudo podman push nmstate/fedora-nmstate-dev:latest \
docker://docker.io/nmstate/fedora-nmstate-dev:latest
```

It will be overwritten after the next commit to master, though.
13 changes: 8 additions & 5 deletions automation/open_container_shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

docker_ps() {
docker ps --format '{{.ID}} {{.Image}}' | grep nmstate-dev
: ${CONTAINER_CMD:=podman}


container_ps() {
$CONTAINER_CMD ps --format '{{.ID}} {{.Image}}' | grep nmstate-dev
}

number_of_containers="$(docker_ps | wc -l)"
number_of_containers="$(container_ps | wc -l)"

if [[ "${number_of_containers}" == "0" ]]
then
Expand All @@ -36,6 +39,6 @@ then
"WARNING: ${number_of_containers} of containers found, using first"
fi

container_id="$(docker_ps \
container_id="$(container_ps \
| head -n 1 | cut -d " " -f 1)"
docker exec -it "${container_id}" /bin/bash
$CONTAINER_CMD exec -it "${container_id}" /bin/bash
2 changes: 1 addition & 1 deletion automation/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ PYTEST_OPTIONS="--verbose --verbose \
--cov /usr/lib/python*/site-packages/nmstatectl \
--cov-report=term"

: ${CONTAINER_CMD:=docker}
: ${CONTAINER_CMD:=podman}

test -t 1 && USE_TTY="-t"

Expand Down
16 changes: 7 additions & 9 deletions packaging/Dockerfile.centos8-nmstate-dev
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# This Dockerfile is based on the recommendations provided in the
# Fedora official repository
# (https://hub.docker.com/r/fedora/systemd-systemd/).
# It enables systemd to be operational.
FROM docker.io/library/centos:8
ENV container docker
COPY docker_enable_systemd.sh docker_sys_config.sh ./

RUN bash ./docker_enable_systemd.sh && rm ./docker_enable_systemd.sh

RUN dnf -y install dnf-plugins-core epel-release && \
dnf config-manager --set-enabled PowerTools && \
Expand Down Expand Up @@ -39,7 +31,13 @@ RUN dnf -y install dnf-plugins-core epel-release && \
ln -s /root/.local/bin/tox /usr/bin/tox && \
ln -s /usr/bin/pytest-3 /usr/bin/pytest && \
dnf clean all && \
bash ./docker_sys_config.sh && rm ./docker_sys_config.sh
systemctl enable openvswitch && \
sed -i -e 's/^#RateLimitInterval=.*/RateLimitInterval=0/' \
-e 's/^#RateLimitBurst=.*/RateLimitBurst=0/' \
/etc/systemd/journald.conf

COPY network_manager_enable_trace.conf \
/etc/NetworkManager/conf.d/97-trace-logging.conf

VOLUME [ "/sys/fs/cgroup" ]

Expand Down
48 changes: 0 additions & 48 deletions packaging/Dockerfile.centos8-nmstate-dev-nm-1.22-git

This file was deleted.

22 changes: 9 additions & 13 deletions packaging/Dockerfile.fedora-nmstate-dev
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# This Dockerfile is based on the recommendations provided in the
# Fedora official repository
# (https://hub.docker.com/r/fedora/systemd-systemd/).
# It enables systemd to be operational.
FROM docker.io/library/fedora:32
ENV container docker
COPY docker_enable_systemd.sh docker_sys_config.sh ./

RUN bash ./docker_enable_systemd.sh && rm ./docker_enable_systemd.sh

RUN dnf -y install --setopt=install_weak_deps=False \
NetworkManager \
Expand All @@ -32,6 +24,8 @@ RUN dnf -y install --setopt=install_weak_deps=False \
iproute \
python3-coveralls \
python3-tox \
python3-pytest \
python3-pytest-cov \
rpm-build \
\
# Below packages for pip (used by tox) to build
Expand All @@ -46,11 +40,13 @@ RUN dnf -y install --setopt=install_weak_deps=False \
make \
dbus-devel && \
dnf clean all && \
pip install pytest==4.6.6 pytest-cov==2.8.1 --user && \
# Below line is workaround for
# https://src.fedoraproject.org/rpms/rootfiles/pull-request/1
ln -s /root/.local/bin/pytest /usr/bin/pytest && \
bash ./docker_sys_config.sh && rm ./docker_sys_config.sh
systemctl enable openvswitch && \
sed -i -e 's/^#RateLimitInterval=.*/RateLimitInterval=0/' \
-e 's/^#RateLimitBurst=.*/RateLimitBurst=0/' \
/etc/systemd/journald.conf

COPY network_manager_enable_trace.conf \
/etc/NetworkManager/conf.d/97-trace-logging.conf

VOLUME [ "/sys/fs/cgroup" ]

Expand Down
5 changes: 4 additions & 1 deletion packaging/build-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ PROJECT_PATH="$(dirname $EXEC_PATH)"
DEFAULT_BUILD_FLAGS="--no-cache --rm"
DEFAULT_TAG_PREFIX="nmstate"

: ${CONTAINER_CMD:=podman}

options=$(getopt --options "" \
--longoptions extra-args: \
-- "${@}")
Expand Down Expand Up @@ -66,7 +68,8 @@ rebuild_container() {

echo >/dev/stderr "Building '${container_spec}' into tag '${build_tag}'..."

docker build ${DEFAULT_BUILD_FLAGS} ${extra_args} -t "${build_tag}" \
$CONTAINER_CMD build ${DEFAULT_BUILD_FLAGS} ${extra_args} \
-t "${build_tag}" \
-f "${container_spec}" "$PROJECT_PATH/packaging"
}

Expand Down
11 changes: 0 additions & 11 deletions packaging/docker_enable_systemd.sh

This file was deleted.

14 changes: 0 additions & 14 deletions packaging/docker_sys_config.sh

This file was deleted.

3 changes: 3 additions & 0 deletions packaging/network_manager_enable_trace.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[logging]
level=TRACE
domains=ALL

0 comments on commit 6a6fff6

Please sign in to comment.