Skip to content

Commit

Permalink
Watchdog check
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Nov 22, 2023
1 parent 62dbaae commit 05f7d30
Show file tree
Hide file tree
Showing 7 changed files with 448 additions and 2 deletions.
33 changes: 33 additions & 0 deletions tests/test/check/data/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,36 @@
sudo bash -c "passwd --help &> /root/passwd.log; \
ls -alZ /root/passwd.log; \
rm -f /root/passwd.log" || /bin/true

/watchdog/ping:
test: |
set -x

export

# Collect a couple of successful reponse
sysctl net.ipv4.icmp_echo_ignore_all
# sysctl net.ipv4.icmp_echo_ignore_all=0
echo "test starts, will sleep for a while"
sleep 10

# Disable ICMP response
# sysctl net.ipv4.icmp_echo_ignore_all=1

# Now wait to be rebooted
sleep 60

echo "bye!"

duration: 30m

check:
- name: watchdog
interval: 5

ping: true
ping-packets: 1
ping-threshold: 3

ssh-ping: true
ssh-ping-threshold: 3
12 changes: 12 additions & 0 deletions tests/test/check/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@ tier: 2
environment:
PROVISION_METHODS: local virtual
tag+: [additional_coverage]

/watchdog:
test: ./test-watchdog.sh

environment:
PROVISION_METHODS: local virtual

adjust:
- when: how == full
environment:
PROVISION_METHODS: virtual
tag+: [additional_coverage]
42 changes: 42 additions & 0 deletions tests/test/check/test-watchdog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

. /usr/share/beakerlib/beakerlib.sh || exit 1

function assert_check_result () {
rlAssertEquals "$1" "watchdog:$2" "$(yq -r ".[] | .check | .[] | select(.event == \"$3\") | \"\\(.name):\\(.result)\"" $results)"
}


rlJournalStart
rlPhaseStartSetup
rlRun "run=\$(mktemp -d)" 0 "Create run directory"

rlRun "results=$run/plan/execute/results.yaml"

rlRun "pushd data"
rlRun "set -o pipefail"
rlPhaseEnd

for method in ${PROVISION_METHODS:-local}; do
rlPhaseStartTest "Test guest watchdog ping with $method provisioning"
rlRun "watchdog_log=$run/plan/execute/data/guest/default-0/watchdog/ping-1/tmt-watchdog.txt"

rlRun "tmt run --id $run --scratch -a -vv provision -h $method test -n /watchdog"

rlRun "cat $results"
rlRun "cat $watchdog_log"

rlAssertExists "$watchdog_log"

assert_check_result "watchdog as an after-test should pass" "pass" "after-test"

# rlAssertGrep "<no matches>" "$avc_log"
rlPhaseEnd
done

rlPhaseStartCleanup
rlRun "popd"

# rlRun "rm -rf $run"
rlPhaseEnd
rlJournalEnd
2 changes: 1 addition & 1 deletion tmt/checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
SpecBasedContainer,
cached_property,
field,
)
)

if TYPE_CHECKING:
import tmt.base
Expand Down
Loading

0 comments on commit 05f7d30

Please sign in to comment.