]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
CI: Add test of user and groups before and after package installation dp-ci-debian-trixie 49/head
authorDavid Petera <david.petera@nic.cz>
Wed, 20 Aug 2025 14:45:06 +0000 (16:45 +0200)
committerroot <root@fai-m-02.office.nic.cz>
Wed, 27 Aug 2025 09:43:50 +0000 (11:43 +0200)
Also fix typo and add more descriptive logging to installation test

.gitlab-ci.yml
misc/gitlab/template.yml.j2
tools/test-install

index 35ed808c9cc2f2e956252eec94693ef67496aeac..9866b5a2c4d58d1c29a8fabd53bfdbd3b2837472 100644 (file)
@@ -1015,30 +1015,46 @@ pkg-ubuntu-24.10-amd64:
   <<: *test-job
   stage: install
   script:
-    # check that bird is _not_ installed now
+    # check that bird is _not_ installed now and no user or group bird exists
     - |
       if bird --version >/dev/null 2>&1; then
-        echo "Error: bird unexpectedly installed"
+        echo "Error: BIRD unexpectedly installed"
+        exit 1
+      fi
+      if id -g bird >/dev/null 2>&1; then
+        echo "Error: User group 'bird' unexpectedly exist before installation"
+        exit 1
+      fi
+      if id -u bird >/dev/null 2>&1; then
+        echo "Error: User 'bird' unexpectedly exist before installation"
         exit 1
       fi
     # install packages
     - find pkg/pkgs/ -type f -name '*.deb' '(' -ls -exec dpkg -i '{}' ';' ')'
-    # test that install is correct
+    # test that installation is successful
     - ./tools/test-install "$CI_COMMIT_MESSAGE"
 
 .install-rpm: &install-rpm
   <<: *test-job
   stage: install
   script:
-    # check that bird is _not_ installed now
+    # check that bird is _not_ installed now and no user or group bird exists
     - |
       if bird --version >/dev/null 2>&1; then
-        echo "Error: bird unexpectedly installed"
+        echo "Error: BIRD unexpectedly installed"
+        exit 1
+      fi
+      if id -g bird >/dev/null 2>&1; then
+        echo "Error: User group 'bird' exist before installation"
+        exit 1
+      fi
+      if id -u bird >/dev/null 2>&1; then
+        echo "Error: User 'bird' exist before installation"
         exit 1
       fi
     # install packages
     - find pkg/pkgs/ -type f -name '*.rpm' '(' -ls -exec rpm -i '{}' ';' ')'
-    # test that install is correct
+    # test that installation is successful
     - ./tools/test-install "$CI_COMMIT_MESSAGE"
 
 
index 9b7f90c72ca306e177d1334de62abb588635a19d..ef42ca8818c7e9668216b30649cf5cbfc1b6124b 100644 (file)
@@ -312,30 +312,46 @@ pkg-{{ dist["name"] }}:
   <<: *test-job
   stage: install
   script:
-    # check that bird is _not_ installed now
+    # check that bird is _not_ installed now and no user or group bird exists
     - |
       if bird --version >/dev/null 2>&1; then
-        echo "Error: bird unexpectedly installed"
+        echo "Error: BIRD unexpectedly installed"
+        exit 1
+      fi
+      if id -g bird >/dev/null 2>&1; then
+        echo "Error: User group 'bird' unexpectedly exist before installation"
+        exit 1
+      fi
+      if id -u bird >/dev/null 2>&1; then
+        echo "Error: User 'bird' unexpectedly exist before installation"
         exit 1
       fi
     # install packages
     - find pkg/pkgs/ -type f -name '*.deb' '(' -ls -exec dpkg -i '{}' ';' ')'
-    # test that install is correct
+    # test that installation is successful
     - ./tools/test-install "$CI_COMMIT_MESSAGE"
 
 .install-rpm: &install-rpm
   <<: *test-job
   stage: install
   script:
-    # check that bird is _not_ installed now
+    # check that bird is _not_ installed now and no user or group bird exists
     - |
       if bird --version >/dev/null 2>&1; then
-        echo "Error: bird unexpectedly installed"
+        echo "Error: BIRD unexpectedly installed"
+        exit 1
+      fi
+      if id -g bird >/dev/null 2>&1; then
+        echo "Error: User group 'bird' exist before installation"
+        exit 1
+      fi
+      if id -u bird >/dev/null 2>&1; then
+        echo "Error: User 'bird' exist before installation"
         exit 1
       fi
     # install packages
     - find pkg/pkgs/ -type f -name '*.rpm' '(' -ls -exec rpm -i '{}' ';' ')'
-    # test that install is correct
+    # test that installation is successful
     - ./tools/test-install "$CI_COMMIT_MESSAGE"
 
 {% for dist in distros %}
index 628c4a39cfa0b0c2f9148bedd7feb607ec446a83..4711783afabc4af72f6297bd0f7a7e4d35d6c4a8 100755 (executable)
@@ -1,19 +1,29 @@
 #!/bin/sh
 
+# Test that user and user group bird exist
+echo "Testing that user and group 'bird' exists..."
+if ! id bird >/dev/null 2>&1; then
+  echo "Error: User or group 'bird' does not exist after installation"
+  exit 1
+fi
+echo "Success"
+
+
 STABLE_VERSION=$(cat VERSION)
 CI_COMMIT_MESSAGE=$(echo "$1" | sed '$s/\r\{0,1\}$//') # trimming new line  
 
+echo "Testing version..."
+
 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"
 
+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"
-
+  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 )
@@ -21,6 +31,8 @@ else
     exit 1
   fi
 fi
+echo "Success"
+
 
 # Run BIRD with minimal config and test with simple birdc commands
 mkdir -p /run/bird
@@ -31,15 +43,18 @@ birdcl show proto > show-proto-out 2>&1
 birdcl down > down-out 2>&1
 birdcl show proto > show-proto-after-down-out 2>&1
 
+echo "Testing that BIRD can be started..."
 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
+echo "Success"
 
+echo "Testing that BIRD responds to command-line commands..."
 if ! grep -qE "device1\s*Device\s*---\s*up" show-proto-out; then
-  echo "Error: BIRD did not show protocols correcly"
+  echo "Error: BIRD did not show protocols correctly"
   echo "Output:"
   cat show-proto-out
   exit 1
@@ -58,4 +73,7 @@ if ! grep -qF "Unable to connect to server control socket" show-proto-after-down
   cat show-proto-after-down-out
   exit 1
 fi
+echo "Success"
+
+echo "All install tests passed! (ノ◕ヮ◕)ノ*:・゚✧"