From f723c4115d3e25a6cbab1e292dead0d6b81a94ed Mon Sep 17 00:00:00 2001 From: Vasek Sraier Date: Tue, 17 May 2022 11:34:46 +0200 Subject: [PATCH] WIP: packaing tests using apkg's new test feature --- ci/pkgtest.yaml | 19 +++++++++++-------- distro/tests/extra/all/control | 2 ++ distro/tests/manager-packaging/control | 15 +++++++++++++++ manager/scripts/make-package.sh | 16 ++++++++++++---- manager/tests/packaging/kresctl.sh | 2 +- manager/tests/packaging/systemd_service.sh | 3 ++- 6 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 distro/tests/extra/all/control create mode 100644 distro/tests/manager-packaging/control mode change 100644 => 100755 manager/tests/packaging/kresctl.sh mode change 100644 => 100755 manager/tests/packaging/systemd_service.sh diff --git a/ci/pkgtest.yaml b/ci/pkgtest.yaml index 955d64c1e..8b55b903d 100644 --- a/ci/pkgtest.yaml +++ b/ci/pkgtest.yaml @@ -20,8 +20,14 @@ stages: paths: - pkg/ -.apkgbuild: &apkgbuild # new jinja2 breaks docs (sphinx/breathe) - - pip3 install -U apkg 'jinja2<3.1' +.apkginstall: &apkginstall # new jinja2 breaks docs (sphinx/breathe) + - git clone https://gitlab.nic.cz/packaging/apkg.git + - cd apkg; git checkout test; pip3 install -U . 'jinja2<3.1' + # - pip3 install -U . 'jinja2<3.1' + + +.apkgbuild: &apkgbuild + - *apkginstall - apkg build-dep -y - apkg build @@ -170,13 +176,10 @@ nixos-unstable:pkgbuild: .debpkgtest: &debpkgtest - *pkgdebrepo - - apt-get install -y knot-dnsutils - apt-get install -y $(find ./pkg/pkgs -name '*.deb' | grep -v module | grep -v debug | grep -v devel) - - systemctl start kresd@1 - - kdig @127.0.0.1 nic.cz | grep -qi NOERROR - - systemctl stop kresd@1 - - systemctl start knot-resolver - - kdig @127.0.0.1 nic.cz | grep -qi NOERROR + - *apkginstall + - apkg test-dep + - apkg test centos-7:pkgtest: <<: *pkgtest diff --git a/distro/tests/extra/all/control b/distro/tests/extra/all/control new file mode 100644 index 000000000..e77964d6e --- /dev/null +++ b/distro/tests/extra/all/control @@ -0,0 +1,2 @@ +{# This adds all tests for manager's packaging #} +{% include 'distro/tests/manager-packaging/control' %} diff --git a/distro/tests/manager-packaging/control b/distro/tests/manager-packaging/control new file mode 100644 index 000000000..a86109e62 --- /dev/null +++ b/distro/tests/manager-packaging/control @@ -0,0 +1,15 @@ +{# Test that kresctl command exists and is in $PATH #} +Test-Command: bash manager/tests/packaging/kresctl.sh + + +{# Tests that manager can be started with default config and it resolves some domains #} +Test-Command: bash manager/tests/packaging/systemd_service.sh +{% if distro.match('fedora') -%} +Depends: knot-utils +{% elif distro.match('debian') -%} +Depends: knot-dnsutils +{% elif distro.match('arch') -%} +Depends: knot +{% else -%} +error this should fail +{%- endif %} diff --git a/manager/scripts/make-package.sh b/manager/scripts/make-package.sh index 60cf2fad7..85549e65f 100644 --- a/manager/scripts/make-package.sh +++ b/manager/scripts/make-package.sh @@ -3,6 +3,16 @@ set -o errexit set -o nounset +function install_pipx { + python3 -m pip install --user pipx + python3 -m pipx ensurepath + export PATH="$PATH:/root/.local/bin" # hack to make binaries installed with pipx work +} + +function pipx { + python3 -m pipx ${@} +} + function init_debian { export DEBIAN_FRONTEND=noninteractive @@ -38,10 +48,8 @@ else fi # install apkg -python3 -m pip install --user pipx -python3 -m pipx ensurepath -PATH="$PATH:/root/.local/bin" # hack to make binaries installed with pipx work -python3 -m pipx install apkg +install_pipx +pipx install apkg # prepare the repo #git clone https://gitlab.nic.cz/knot/knot-resolver diff --git a/manager/tests/packaging/kresctl.sh b/manager/tests/packaging/kresctl.sh old mode 100644 new mode 100755 index 48fca73a5..579f1a10a --- a/manager/tests/packaging/kresctl.sh +++ b/manager/tests/packaging/kresctl.sh @@ -4,4 +4,4 @@ set -e # We expect `kresctl` command to exist in $PATH -command -q -v kresctl \ No newline at end of file +command -v kresctl > /dev/null diff --git a/manager/tests/packaging/systemd_service.sh b/manager/tests/packaging/systemd_service.sh old mode 100644 new mode 100755 index 2afb5f832..3719ff1fe --- a/manager/tests/packaging/systemd_service.sh +++ b/manager/tests/packaging/systemd_service.sh @@ -10,7 +10,8 @@ if test "$(id -u)" -ne 0; then fi +trap "systemctl stop knot-resolver.service" EXIT systemctl start knot-resolver.service # check that the resolvers are actually running -kdig @127.0.0.1 nic.cz \ No newline at end of file +kdig @127.0.0.1 nic.cz -- 2.47.3