From 6a6fff65a416766fcb60dce58fa2ea82d08b6e87 Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Thu, 20 Feb 2020 20:35:33 +0800 Subject: [PATCH] automation: Use podman by default 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]: https://github.com/containers/libpod/issues/3679 Signed-off-by: Gris Ge --- .travis.yml | 18 +++++-- automation/README.md | 30 +++++++----- automation/open_container_shell.sh | 13 +++-- automation/run-tests.sh | 2 +- packaging/Dockerfile.centos8-nmstate-dev | 16 +++---- ...Dockerfile.centos8-nmstate-dev-nm-1.22-git | 48 ------------------- packaging/Dockerfile.fedora-nmstate-dev | 22 ++++----- packaging/build-container.sh | 5 +- packaging/docker_enable_systemd.sh | 11 ----- packaging/docker_sys_config.sh | 14 ------ packaging/network_manager_enable_trace.conf | 3 ++ 11 files changed, 62 insertions(+), 120 deletions(-) delete mode 100644 packaging/Dockerfile.centos8-nmstate-dev-nm-1.22-git delete mode 100644 packaging/docker_enable_systemd.sh delete mode 100644 packaging/docker_sys_config.sh create mode 100644 packaging/network_manager_enable_trace.conf diff --git a/.travis.yml b/.travis.yml index a0b6dce471..d76e187740 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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: @@ -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 diff --git a/automation/README.md b/automation/README.md index c026a506e7..50d982a2b8 100644 --- a/automation/README.md +++ b/automation/README.md @@ -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. @@ -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`. @@ -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 @@ -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. diff --git a/automation/open_container_shell.sh b/automation/open_container_shell.sh index 5e97eab547..21a27b641f 100755 --- a/automation/open_container_shell.sh +++ b/automation/open_container_shell.sh @@ -18,11 +18,14 @@ # along with this program. If not, see . # -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 @@ -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 diff --git a/automation/run-tests.sh b/automation/run-tests.sh index 154c53cf0f..3a79133bff 100755 --- a/automation/run-tests.sh +++ b/automation/run-tests.sh @@ -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" diff --git a/packaging/Dockerfile.centos8-nmstate-dev b/packaging/Dockerfile.centos8-nmstate-dev index a985f8f5dd..458fc9a5b6 100644 --- a/packaging/Dockerfile.centos8-nmstate-dev +++ b/packaging/Dockerfile.centos8-nmstate-dev @@ -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 && \ @@ -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" ] diff --git a/packaging/Dockerfile.centos8-nmstate-dev-nm-1.22-git b/packaging/Dockerfile.centos8-nmstate-dev-nm-1.22-git deleted file mode 100644 index fdfe4c0bd6..0000000000 --- a/packaging/Dockerfile.centos8-nmstate-dev-nm-1.22-git +++ /dev/null @@ -1,48 +0,0 @@ -# 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 - -RUN dnf copr enable nmstate/ovs-el8 -y && \ - dnf copr enable networkmanager/NetworkManager-1.22-git -y - -RUN dnf -y install --setopt=install_weak_deps=False \ - NetworkManager \ - NetworkManager-ovs \ - NetworkManager-team \ - NetworkManager-config-server \ - openvswitch2.11 \ - systemd-udev \ - python3-devel \ - python3-dbus \ - python3-gobject-base \ - python3-jsonschema \ - python3-pyyaml \ - python3-setuptools \ - python36 \ - dnsmasq \ - git \ - iproute \ - rpm-build \ - python3-pytest \ - python3-pytest-cov \ - python3-virtualenv \ - && \ - pip3 install python-coveralls tox==3.5.3 --user && \ - alternatives --set python /usr/bin/python3 && \ - 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 - -VOLUME [ "/sys/fs/cgroup" ] - -CMD ["/usr/sbin/init"] diff --git a/packaging/Dockerfile.fedora-nmstate-dev b/packaging/Dockerfile.fedora-nmstate-dev index b216217345..da434e0c0a 100644 --- a/packaging/Dockerfile.fedora-nmstate-dev +++ b/packaging/Dockerfile.fedora-nmstate-dev @@ -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 \ @@ -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 @@ -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" ] diff --git a/packaging/build-container.sh b/packaging/build-container.sh index c39fbd2b8f..5a997b2502 100755 --- a/packaging/build-container.sh +++ b/packaging/build-container.sh @@ -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: \ -- "${@}") @@ -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" } diff --git a/packaging/docker_enable_systemd.sh b/packaging/docker_enable_systemd.sh deleted file mode 100644 index 860da6076f..0000000000 --- a/packaging/docker_enable_systemd.sh +++ /dev/null @@ -1,11 +0,0 @@ -cd /lib/systemd/system/sysinit.target.wants/; -for i in *; do - [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; -done; -rm -f /lib/systemd/system/multi-user.target.wants/*; -rm -f /etc/systemd/system/*.wants/*; -rm -f /lib/systemd/system/local-fs.target.wants/*; -rm -f /lib/systemd/system/sockets.target.wants/*udev*; -rm -f /lib/systemd/system/sockets.target.wants/*initctl*; -rm -f /lib/systemd/system/basic.target.wants/*; -rm -f /lib/systemd/system/anaconda.target.wants/*; diff --git a/packaging/docker_sys_config.sh b/packaging/docker_sys_config.sh deleted file mode 100644 index 529e360d5f..0000000000 --- a/packaging/docker_sys_config.sh +++ /dev/null @@ -1,14 +0,0 @@ -install -o root -g root -d /etc/sysconfig/network-scripts - -cat > /etc/NetworkManager/conf.d/97-trace-logging.conf <