From e56084d682880f435fcf109e85a72d02f29d4236 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Tue, 2 Jun 2020 14:48:26 -0400 Subject: [PATCH] Try resetting nsd restart count to avoid errors in mgmt tests --- .travis.yml | 12 ++++++++++++ tests/suites/_mail-functions.sh | 1 + tests/suites/_mgmt-functions.sh | 17 ++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 09154e5d..fe04210d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,15 +13,27 @@ before_install: - echo "==== DUMP ENVIRONMENT ====" - env | sort - echo "UMASK=$(umask)" + # - echo "==== DUMP AppArmor Status ====" - (sudo aa-status; true) + # - echo "==== System update ====" + # Do not run 'upgrade' - sudo apt-get update + # - echo "==== Install QA/test data ====" + # python3-dnspython is used by the python scripts in 'tests' - sudo apt-get -y install python3-dnspython + # avoid the lengthy generation of DH params by copying in a prebuilt file - sudo mkdir -p /home/user-data/ssl - sudo cp ./tests/assets/ssl/dh2048.pem /home/user-data/ssl + # - echo "==== Add the PRIMARY_HOSTNAME to /etc/hosts ====" + # The PRIMARY_HOSTNAME should point to the interface address not + # loopback. That is because of the way MiaB resolves - the local + # resolver is bind9, which requires valid NS records, which would + # point back to the local nsd authoritative name server for the + # domain. We don't have those in QA, so we need the hosts entry. - echo "$(source setup/functions.sh; get_default_privateip 4) $PRIMARY_HOSTNAME" > /tmp/hosts_add.tmp - sudo $SHELL -c 'cat /tmp/hosts_add.tmp >>/etc/hosts' diff --git a/tests/suites/_mail-functions.sh b/tests/suites/_mail-functions.sh index 6a11329f..37c33661 100644 --- a/tests/suites/_mail-functions.sh +++ b/tests/suites/_mail-functions.sh @@ -105,6 +105,7 @@ detect_syslog_error() { !/postfix\/qmgr/ && /warning:/ { exit 1 } /(fatal|reject|error):/ { exit 1 } /Error in / { exit 1 } +/Exception on / { exit 1 } /named\[\d+\]:.* verify failed/ { exit 1 } ' \ >>$TEST_OF 2>&1 <<< "$line" diff --git a/tests/suites/_mgmt-functions.sh b/tests/suites/_mgmt-functions.sh index a5a312b8..88baa1b4 100644 --- a/tests/suites/_mgmt-functions.sh +++ b/tests/suites/_mgmt-functions.sh @@ -80,10 +80,21 @@ mgmt_rest() { return 0 } +systemctl_reset() { + local service="${1:-nsd.service}" + # for travis-ci: reset nsd to avoid "nsd.service: Start request + # repeated too quickly", which occurs inside kick() of the + # management flask app when "system restart nsd" is called on + # detection of a new mail domain + record "[systemctl reset-failed $service]" + systemctl reset-failed $service 2>&1 >>$TEST_OF +} + mgmt_create_user() { local email="$1" local pass="${2:-$email}" local delete_first="${3:-yes}" + local rc=0 # ensure the user is deleted (clean test run) if [ "$delete_first" == "yes" ]; then @@ -91,7 +102,11 @@ mgmt_create_user() { fi record "[create user $email]" mgmt_rest POST /admin/mail/users/add "email=$email" "password=$pass" - return $? + rc=$? + if echo "$REST_OUTPUT" | grep "updated DNS:" >/dev/null; then + systemctl_reset + fi + return $rc } mgmt_assert_create_user() {