From: David Petera Date: Wed, 7 May 2025 14:02:09 +0000 (+0200) Subject: CI: Add package install tests. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cbf796e6d6a0393119e70cf211db5e3c449dacc3;p=thirdparty%2Fbird.git CI: Add package install tests. We are checking that generated BIRD packages can be installed and run. Communication between bird and birdc is also tested. This fixes #202 --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df06e0608..dc252d36b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,7 @@ stages: - image - build - pkg + - install - test ## Common rules @@ -618,7 +619,6 @@ build-release: - if python3 -m venv venv; then . venv/bin/activate; fi - pip3 install apkg - apkg build -a bird-$(cat VERSION)*.tar.gz - #- apkg install -y pkg/pkgs/*/*/*.deb artifacts: paths: - pkg/pkgs/* @@ -636,7 +636,6 @@ build-release: - pip3 install beautifulsoup4==4.11.2 - pip3 install apkg - apkg build -a bird-$(cat VERSION)*.tar.gz - #- apkg install -y pkg/pkgs/*/*/*.deb artifacts: paths: - pkg/pkgs/* @@ -648,7 +647,6 @@ build-release: script: - pip3 install apkg - apkg build -a bird-$(cat VERSION)*.tar.gz - #- apkg install -y pkg/pkgs/*/*/*.rpm artifacts: paths: - pkg/pkgs/* @@ -663,7 +661,6 @@ build-release: - pip3 install beautifulsoup4==4.11.2 - pip3 install apkg - apkg build -a bird-$(cat VERSION)*.tar.gz - #- apkg install -y pkg/pkgs/*/*/*.rpm artifacts: paths: - pkg/pkgs/* @@ -931,6 +928,232 @@ pkg-ubuntu-24.10-amd64: image: registry.nic.cz/labs/bird:ubuntu-24.10-amd64 +## Package installability checks + +.install-deb: &install-deb + <<: *test-job + stage: install + script: + # check that bird is _not_ installed now + - | + if bird --version >/dev/null 2>&1; then + echo "Error: bird unexpectedly installed" + exit 1 + fi + # install packages + - find pkg/pkgs/ -type f -name '*.deb' '(' -ls -exec dpkg -i '{}' ';' ')' + # test that install is correct + - ./tools/test-install "$CI_COMMIT_MESSAGE" + +.install-rpm: &install-rpm + <<: *test-job + stage: install + script: + # check that bird is _not_ installed now + - | + if bird --version >/dev/null 2>&1; then + echo "Error: bird unexpectedly installed" + exit 1 + fi + # install packages + - find pkg/pkgs/ -type f -name '*.rpm' '(' -ls -exec rpm -i '{}' ';' ')' + # test that install is correct + - ./tools/test-install "$CI_COMMIT_MESSAGE" + + +install-centos-7-amd64: + <<: *install-rpm + needs: + - job: pkg-centos-7-amd64 + image: registry.nic.cz/labs/bird:centos-7-amd64 + +install-centos-8-amd64: + <<: *install-rpm + needs: + - job: pkg-centos-8-amd64 + image: registry.nic.cz/labs/bird:centos-8-amd64 + +install-fedora-32-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-32-amd64 + image: registry.nic.cz/labs/bird:fedora-32-amd64 + +install-fedora-33-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-33-amd64 + image: registry.nic.cz/labs/bird:fedora-33-amd64 + +install-opensuse-15.0-amd64: + <<: *install-rpm + needs: + - job: pkg-opensuse-15.0-amd64 + image: registry.nic.cz/labs/bird:opensuse-15.0-amd64 + +install-opensuse-15.1-amd64: + <<: *install-rpm + needs: + - job: pkg-opensuse-15.1-amd64 + image: registry.nic.cz/labs/bird:opensuse-15.1-amd64 + +install-opensuse-15.2-amd64: + <<: *install-rpm + needs: + - job: pkg-opensuse-15.2-amd64 + image: registry.nic.cz/labs/bird:opensuse-15.2-amd64 + +install-opensuse-15.3-amd64: + <<: *install-rpm + needs: + - job: pkg-opensuse-15.3-amd64 + image: registry.nic.cz/labs/bird:opensuse-15.3-amd64 + +install-opensuse-15.4-amd64: + <<: *install-rpm + needs: + - job: pkg-opensuse-15.4-amd64 + image: registry.nic.cz/labs/bird:opensuse-15.4-amd64 + +install-opensuse-15.5-amd64: + <<: *install-rpm + needs: + - job: pkg-opensuse-15.5-amd64 + image: registry.nic.cz/labs/bird:opensuse-15.5-amd64 + +install-fedora-34-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-34-amd64 + image: registry.nic.cz/labs/bird:fedora-34-amd64 + +install-fedora-35-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-35-amd64 + image: registry.nic.cz/labs/bird:fedora-35-amd64 + +install-fedora-36-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-36-amd64 + image: registry.nic.cz/labs/bird:fedora-36-amd64 + +install-fedora-37-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-37-amd64 + image: registry.nic.cz/labs/bird:fedora-37-amd64 + +install-fedora-38-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-38-amd64 + image: registry.nic.cz/labs/bird:fedora-38-amd64 + +install-fedora-39-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-39-amd64 + image: registry.nic.cz/labs/bird:fedora-39-amd64 + +install-fedora-40-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-40-amd64 + image: registry.nic.cz/labs/bird:fedora-40-amd64 + +install-fedora-41-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-41-amd64 + image: registry.nic.cz/labs/bird:fedora-41-amd64 + +install-fedora-42-amd64: + <<: *install-rpm + needs: + - job: pkg-fedora-42-amd64 + image: registry.nic.cz/labs/bird:fedora-42-amd64 + +install-ubuntu-18.04-amd64: + <<: *install-deb + needs: + - job: pkg-ubuntu-18.04-amd64 + image: registry.nic.cz/labs/bird:ubuntu-18.04-amd64 + +install-debian-10-amd64: + <<: *install-deb + needs: + - job: pkg-debian-10-amd64 + image: registry.nic.cz/labs/bird:debian-10-amd64 + +install-debian-10-i386: + <<: *install-deb + needs: + - job: pkg-debian-10-i386 + image: registry.nic.cz/labs/bird:debian-10-i386 + +install-debian-11-amd64: + <<: *install-deb + needs: + - job: pkg-debian-11-amd64 + image: registry.nic.cz/labs/bird:debian-11-amd64 + +install-debian-11-i386: + <<: *install-deb + needs: + - job: pkg-debian-11-i386 + image: registry.nic.cz/labs/bird:debian-11-i386 + +install-debian-12-amd64: + <<: *install-deb + needs: + - job: pkg-debian-12-amd64 + image: registry.nic.cz/labs/bird:debian-12-amd64 + +install-debian-12-i386: + <<: *install-deb + needs: + - job: pkg-debian-12-i386 + image: registry.nic.cz/labs/bird:debian-12-i386 + +install-debian-testing-amd64: + <<: *install-deb + needs: + - job: pkg-debian-testing-amd64 + image: registry.nic.cz/labs/bird:debian-testing-amd64 + +install-debian-testing-i386: + <<: *install-deb + needs: + - job: pkg-debian-testing-i386 + image: registry.nic.cz/labs/bird:debian-testing-i386 + +install-ubuntu-20.04-amd64: + <<: *install-deb + needs: + - job: pkg-ubuntu-20.04-amd64 + image: registry.nic.cz/labs/bird:ubuntu-20.04-amd64 + +install-ubuntu-22.04-amd64: + <<: *install-deb + needs: + - job: pkg-ubuntu-22.04-amd64 + image: registry.nic.cz/labs/bird:ubuntu-22.04-amd64 + +install-ubuntu-24.04-amd64: + <<: *install-deb + needs: + - job: pkg-ubuntu-24.04-amd64 + image: registry.nic.cz/labs/bird:ubuntu-24.04-amd64 + +install-ubuntu-24.10-amd64: + <<: *install-deb + needs: + - job: pkg-ubuntu-24.10-amd64 + image: registry.nic.cz/labs/bird:ubuntu-24.10-amd64 + + ################################### ## Non-linux build tests in QEMU ## ################################### diff --git a/misc/gitlab/template.yml.j2 b/misc/gitlab/template.yml.j2 index 046be964f..e5619696b 100644 --- a/misc/gitlab/template.yml.j2 +++ b/misc/gitlab/template.yml.j2 @@ -23,6 +23,7 @@ stages: - image - build - pkg + - install - test ## Common rules @@ -242,7 +243,6 @@ build-release: - if python3 -m venv venv; then . venv/bin/activate; fi - pip3 install apkg - apkg build -a bird-$(cat VERSION)*.tar.gz - #- apkg install -y pkg/pkgs/*/*/*.deb artifacts: paths: - pkg/pkgs/* @@ -260,7 +260,6 @@ build-release: - pip3 install beautifulsoup4==4.11.2 - pip3 install apkg - apkg build -a bird-$(cat VERSION)*.tar.gz - #- apkg install -y pkg/pkgs/*/*/*.deb artifacts: paths: - pkg/pkgs/* @@ -272,7 +271,6 @@ build-release: script: - pip3 install apkg - apkg build -a bird-$(cat VERSION)*.tar.gz - #- apkg install -y pkg/pkgs/*/*/*.rpm artifacts: paths: - pkg/pkgs/* @@ -287,7 +285,6 @@ build-release: - pip3 install beautifulsoup4==4.11.2 - pip3 install apkg - apkg build -a bird-$(cat VERSION)*.tar.gz - #- apkg install -y pkg/pkgs/*/*/*.rpm artifacts: paths: - pkg/pkgs/* @@ -308,6 +305,51 @@ pkg-{{ dist["name"] }}: {%- endif %} {% endfor %} +## Package installability checks + +.install-deb: &install-deb + <<: *test-job + stage: install + script: + # check that bird is _not_ installed now + - | + if bird --version >/dev/null 2>&1; then + echo "Error: bird unexpectedly installed" + exit 1 + fi + # install packages + - find pkg/pkgs/ -type f -name '*.deb' '(' -ls -exec dpkg -i '{}' ';' ')' + # test that install is correct + - ./tools/test-install "$CI_COMMIT_MESSAGE" + +.install-rpm: &install-rpm + <<: *test-job + stage: install + script: + # check that bird is _not_ installed now + - | + if bird --version >/dev/null 2>&1; then + echo "Error: bird unexpectedly installed" + exit 1 + fi + # install packages + - find pkg/pkgs/ -type f -name '*.rpm' '(' -ls -exec rpm -i '{}' ';' ')' + # test that install is correct + - ./tools/test-install "$CI_COMMIT_MESSAGE" + +{% for dist in distros %} +install-{{ dist["name"] }}: + <<: *{{ { + "pkg-rpm": "install-rpm", + "pkg-rpm-wa": "install-rpm", + "pkg-deb": "install-deb", + "pkg-deb-legacy": "install-deb", + }[dist["type"]] }} + needs: + - job: pkg-{{ dist["name"] }} + image: registry.nic.cz/labs/bird:{{ dist["name"] }} +{% endfor %} + ################################### ## Non-linux build tests in QEMU ## ################################### diff --git a/tools/test-install b/tools/test-install new file mode 100755 index 000000000..628c4a39c --- /dev/null +++ b/tools/test-install @@ -0,0 +1,61 @@ +#!/bin/sh + +STABLE_VERSION=$(cat VERSION) +CI_COMMIT_MESSAGE=$(echo "$1" | sed '$s/\r\{0,1\}$//') # trimming new line + +bird --version 2>&1 | grep -F "$STABLE_VERSION" +bird --version 2>version-reported + +if [ "$CI_COMMIT_MESSAGE" = "NEWS and version update" ]; then + echo "Processing a release commit" + + echo "BIRD version ${STABLE_VERSION}" > version-expected + diff version-reported version-expected +else + echo "Processing a non-release commit" + + if ! grep -qF "BIRD version ${STABLE_VERSION}+branch" version-reported; then + echo "Error: Version mismatch!" + ( echo "Reported: "; cat version-reported ) + ( echo "Expected: "; echo "BIRD version ${STABLE_VERSION}+branch.." ) + exit 1 + fi +fi + +# Run BIRD with minimal config and test with simple birdc commands +mkdir -p /run/bird +echo "protocol device {}" > minimal.conf +bird -c minimal.conf + +birdcl show proto > show-proto-out 2>&1 +birdcl down > down-out 2>&1 +birdcl show proto > show-proto-after-down-out 2>&1 + +if ! grep -qE "BIRD .* ready\." show-proto-out || ! grep -qE "BIRD .* ready\." down-out; then + echo "Error: BIRD did not start correctly" + echo "Output:" + cat show-proto-out down-out + exit 1 +fi + +if ! grep -qE "device1\s*Device\s*---\s*up" show-proto-out; then + echo "Error: BIRD did not show protocols correcly" + echo "Output:" + cat show-proto-out + exit 1 +fi + +if ! grep -qF "Shutdown requested" down-out; then + echo "Error: BIRD did not shutdown correctly after DOWN command." + echo "Output:" + cat down-out + exit 1 +fi + +if ! grep -qF "Unable to connect to server control socket" show-proto-after-down-out; then + echo "Error: BIRD did not shutdown correctly after DOWN command." + echo "Output:" + cat show-proto-after-down-out + exit 1 +fi +