summaryrefslogtreecommitdiffstats
path: root/debian/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 06:49:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 06:49:00 +0000
commit93907d0c009d758811b54e7984337477a39f05cf (patch)
treea34881e1b02ccd5281ca58a799877f2d5e80d778 /debian/tests
parentAdding upstream version 4.6.0. (diff)
downloadcrmsh-93907d0c009d758811b54e7984337477a39f05cf.tar.xz
crmsh-93907d0c009d758811b54e7984337477a39f05cf.zip
Adding debian version 4.6.0-1.debian/4.6.0-1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests')
-rw-r--r--debian/tests/control32
-rwxr-xr-xdebian/tests/pacemaker-basic-resource.sh98
-rwxr-xr-xdebian/tests/pacemaker-cluster-init.sh31
-rwxr-xr-xdebian/tests/pacemaker-node-status.sh76
-rwxr-xr-xdebian/tests/testsuite.sh29
-rwxr-xr-xdebian/tests/utils.sh33
6 files changed, 299 insertions, 0 deletions
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..e67a361
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,32 @@
+Test-Command: crm --help
+Depends: crmsh
+Restrictions: needs-root
+
+Test-Command: crm help
+Depends: crmsh
+Restrictions: needs-root
+
+Test-Command: crm --version
+Depends: crmsh
+Restrictions: needs-root
+
+Tests: utils.sh
+Depends: crmsh, fence-virt
+Restrictions: needs-root, allow-stderr
+
+Tests: testsuite.sh
+Depends: crmsh, openssh-server, python3-pytest
+Restrictions: needs-root
+
+Tests: pacemaker-basic-resource.sh
+Depends: crmsh
+Restrictions: needs-root, allow-stderr, isolation-container, skippable
+
+Tests: pacemaker-node-status.sh
+Depends: crmsh
+Restrictions: needs-root, allow-stderr, isolation-container, skippable
+
+# Test disabled because it generates broken corosync config (missing nodelist)
+Tests: pacemaker-cluster-init.sh
+Depends: crmsh, csync2, ntp, ufw, openssh-server, dmidecode [any-amd64 arm64 armhf any-i386], booth, booth-pacemaker
+Restrictions: needs-root, allow-stderr, isolation-machine, skippable
diff --git a/debian/tests/pacemaker-basic-resource.sh b/debian/tests/pacemaker-basic-resource.sh
new file mode 100755
index 0000000..de2a4c4
--- /dev/null
+++ b/debian/tests/pacemaker-basic-resource.sh
@@ -0,0 +1,98 @@
+#!/bin/sh
+
+set -ex
+
+DAEMON_TIMEOUT=60
+CRM_TIMEOUT=5
+RSC_NAME="test"
+rsc_check()
+{
+ if crm status | grep "$RSC_NAME[[:space:]][(]ocf::\?heartbeat:IPv6addr[)]:[[:space:]].*$1" >/dev/null; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+# https://bugs.launchpad.net/bugs/1828228
+ulimit -H -l unlimited 2>/dev/null || {
+ echo "test disabled for unprivileged namespaces"
+ exit 77
+}
+
+#
+# daemons start
+#
+
+service corosync start
+service pacemaker start
+sleep $DAEMON_TIMEOUT
+
+#
+# disable stonith and quorum
+#
+
+crm configure property stonith-enabled="false"
+crm configure property no-quorum-policy="ignore"
+sleep $CRM_TIMEOUT
+
+#
+# creation & start
+#
+
+crm configure primitive $RSC_NAME \
+ ocf:heartbeat:IPv6addr \
+ params ipv6addr="fe00::200" \
+ cidr_netmask="64" \
+ nic="lo"
+sleep $CRM_TIMEOUT
+crm resource start $RSC_NAME
+sleep $CRM_TIMEOUT
+if rsc_check "Started" ; then
+ : INFO resource creation and start OK
+else
+ : ERROR failed to start resource
+ exit 1
+fi
+
+#
+# restart
+#
+
+crm resource restart $RSC_NAME
+sleep $CRM_TIMEOUT
+if rsc_check "Started" ; then
+ : INFO resource restart OK
+else
+ : ERROR failed to restart resource
+ exit 1
+fi
+
+#
+# stop
+#
+
+crm resource stop $RSC_NAME
+sleep $CRM_TIMEOUT
+if rsc_check "Stopped" ; then
+ : INFO resource stop OK
+else
+ : ERROR failed to stop resource
+ exit 1
+fi
+
+#
+# delete
+#
+
+crm configure delete $RSC_NAME
+sleep $CRM_TIMEOUT
+if ! rsc_check "Stopped" ; then
+ : INFO resource delete OK
+else
+ : ERROR failed to delete resource
+ exit 1
+fi
+
+: INFO all tests OK
+exit 0
diff --git a/debian/tests/pacemaker-cluster-init.sh b/debian/tests/pacemaker-cluster-init.sh
new file mode 100755
index 0000000..a3cf349
--- /dev/null
+++ b/debian/tests/pacemaker-cluster-init.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+set -ex
+
+# https://bugs.launchpad.net/bugs/1828228
+ulimit -H -l unlimited 2>/dev/null || {
+ echo "test disabled for unprivileged namespaces"
+ exit 77
+}
+
+# ufw currently broken without /sbin/iptables
+if ! ufw status; then
+ test -e /sbin/iptables || ln -s /usr/sbin/iptables /sbin/iptables
+ test -e /sbin/ip6tables || ln -s /usr/sbin/ip6tables /sbin/ip6tables
+fi
+
+service corosync stop
+
+crm cluster init --yes --name=autopkgtest --unicast
+
+crm cluster geo_init --yes --clusters=autopkgtest=127.2.2.2 --tickets=ticket1
+crm resource start g-booth
+sleep 5
+
+crm status
+
+crm status | grep -q booth-ip.*Started
+crm status | grep -q booth-site.*Started
+
+: INFO all tests OK
+exit 0
diff --git a/debian/tests/pacemaker-node-status.sh b/debian/tests/pacemaker-node-status.sh
new file mode 100755
index 0000000..a0a2fbc
--- /dev/null
+++ b/debian/tests/pacemaker-node-status.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+set -ex
+
+DAEMON_TIMEOUT=60
+CRM_TIMEOUT=5
+
+# https://bugs.launchpad.net/bugs/1828228
+ulimit -H -l unlimited 2>/dev/null || {
+ echo "test disabled for unprivileged namespaces"
+ exit 77
+}
+
+#
+# daemons start
+#
+
+service corosync start
+service pacemaker start
+sleep $DAEMON_TIMEOUT
+
+# Get the node name as sugested in
+# https://lists.clusterlabs.org/pipermail/users/2022-May/030309.html
+NODE="$(crm_node -n)"
+if [ -z "$NODE" ]; then
+ echo "Could not detect node name"
+ exit 1
+fi
+# crmsh will try to ping the node name so make sure it can be resolved
+if ! getent hosts "$NODE" >/dev/null 2>&1; then
+ echo "127.0.0.1 $NODE" >> /etc/hosts
+fi
+
+#
+# online
+#
+
+crm status | grep "Online:.*$NODE"
+
+#
+# standby
+#
+
+crm node standby $NODE
+sleep $CRM_TIMEOUT
+crm status | grep "Node $NODE: standby"
+
+crm node online $NODE
+sleep $CRM_TIMEOUT
+crm status | grep "Online:.*$NODE"
+
+#
+# maintenance
+#
+
+crm node maintenance $NODE
+sleep $CRM_TIMEOUT
+crm status | grep "Node $NODE: maintenance"
+
+crm node ready $NODE
+sleep $CRM_TIMEOUT
+crm status | grep "Online:.*$NODE"
+
+#
+# attributes
+#
+
+crm node attribute $NODE set memory_size 1024
+crm node attribute $NODE show memory_size | grep 1024
+crm node utilization $NODE set memory 2048
+crm node utilization $NODE show memory | grep 2048
+crm node server
+crm node show
+
+: INFO all tests OK
+exit 0
diff --git a/debian/tests/testsuite.sh b/debian/tests/testsuite.sh
new file mode 100755
index 0000000..842551a
--- /dev/null
+++ b/debian/tests/testsuite.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+set -e
+
+# prepare test env
+export PATH=$PATH:/usr/lib/pacemaker
+export PYTHONPATH=/usr/share/crmsh
+# test/unittests/test_report.py::test_ts_to_dt assumes UTC
+export TZ=UTC
+
+mkdir /usr/share/crmsh/doc
+
+# some tests fail if the cluster is running
+service pacemaker stop
+service corosync stop
+
+cd /usr/share/crmsh/tests/unittests
+printf "Running unittests...\n"
+py.test-3 -vv
+
+cp /usr/share/pacemaker/*.rng /usr/share/crmsh/tests/unittests/schemas/
+
+cd /usr/share/crmsh/tests
+printf "\nRunning cibtests...\n"
+./cib-tests.sh
+
+printf "\nRunning regressions...\n"
+./regression.sh -m buildbot || true
+cat crmtestout/regression.out
diff --git a/debian/tests/utils.sh b/debian/tests/utils.sh
new file mode 100755
index 0000000..6ff8480
--- /dev/null
+++ b/debian/tests/utils.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+set -ex
+
+export LC_ALL=C
+PKG=fence-virt
+
+dpkg --purge $PKG
+
+# package not installed
+/usr/share/crmsh/utils/crm_rpmcheck.py $PKG | grep error
+
+# install
+/usr/share/crmsh/utils/crm_pkg.py -n $PKG -s present | grep Unpacking
+/usr/share/crmsh/utils/crm_rpmcheck.py $PKG | grep status
+dpkg --status $PKG
+
+# upgrade
+/usr/share/crmsh/utils/crm_pkg.py -n $PKG -s latest | grep False
+
+# purge
+/usr/share/crmsh/utils/crm_pkg.py -n $PKG -s removed | egrep 'Removing|Purging'
+/usr/share/crmsh/utils/crm_rpmcheck.py $PKG | grep error
+
+# clean
+cd $AUTOPKGTEST_TMP
+mkdir dir
+touch dir/file
+cp /usr/share/crmsh/utils/crm_clean.py .
+$PWD/crm_clean.py $PWD/crm_clean.py $PWD/dir
+if ls | grep .; then
+ exit 1
+fi