Skip to content

Commit

Permalink
t: cover redfishpower setpath config
Browse files Browse the repository at this point in the history
Problem: There is no coverage for the new redfishpower setpath
configuration.

Add basic coverage in t0034-redfishpower.t and add test device file
t/etc/redfishpower-setpath.dev.
  • Loading branch information
chu11 committed Mar 19, 2024
1 parent f337bb6 commit bd73647
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 1 deletion.
3 changes: 2 additions & 1 deletion t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ EXTRA_DIST= \
etc/sierra_plugs.conf \
etc/mcr_plugs.conf \
etc/vpc.dev \
etc/redfishpower-setplugs.dev
etc/redfishpower-setplugs.dev \
etc/redfishpower-setpath.dev


AM_CFLAGS = @WARNING_CFLAGS@
Expand Down
70 changes: 70 additions & 0 deletions t/etc/redfishpower-setpath.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Variant of redfishpower-cray-r272z30.dev that covers use of setplugs
# and setpath configuration
#
# Notes:
# - for easier grepping in tests, simplify paths
# - different paths for different chunks of nodes/plugs
# - no plug specific paths set for Node[10-15], will use defaults
# set via setstatpath, setonpath, etc.
specification "redfishpower-setpath" {
timeout 60

script login {
expect "redfishpower> "
send "auth USER:PASS\n"
expect "redfishpower> "
send "setheader Content-Type:application/json\n"
expect "redfishpower> "
send "setplugs Node[0-15] [0-15]\n"
expect "redfishpower> "
send "setpath Node[0-4] stat redfish/Group0\n"
expect "redfishpower> "
send "setpath Node[0-4] on redfish/Group0/Reset {\"ResetType\":\"On\"}\n"
expect "redfishpower> "
send "setpath Node[0-4] off redfish/Group0/Reset {\"ResetType\":\"ForceOff\"}\n"
expect "redfishpower> "
send "setpath Node[0-4] cycle redfish/Group0/Reset {\"ResetType\":\"ForceRestart\"}\n"
expect "redfishpower> "
send "setpath Node[5-9] stat redfish/Group1\n"
expect "redfishpower> "
send "setpath Node[5-9] on redfish/Group1/Reset {\"ResetType\":\"On\"}\n"
expect "redfishpower> "
send "setpath Node[5-9] off redfish/Group1/Reset {\"ResetType\":\"ForceOff\"}\n"
expect "redfishpower> "
send "setpath Node[5-9] cycle redfish/Group1/Reset {\"ResetType\":\"ForceRestart\"}\n"
expect "redfishpower> "
send "setstatpath redfish/Default\n"
expect "redfishpower> "
send "setonpath redfish/Default/Reset {\"ResetType\":\"On\"}\n"
expect "redfishpower> "
send "setoffpath redfish/Default/Reset {\"ResetType\":\"ForceOff\"}\n"
expect "redfishpower> "
send "setcyclepath redfish/Default/Reset {\"ResetType\":\"ForceRestart\"}\n"
expect "redfishpower> "
send "settimeout 60\n"
expect "redfishpower> "
}
script logout {
send "quit\n"
}
script status_all {
send "stat\n"
foreachnode {
expect "([^\n:]+): ([^\n]+\n)"
setplugstate $1 $2 on="^on\n" off="^off\n"
}
expect "redfishpower> "
}
script on_ranged {
send "on %s\n"
expect "redfishpower> "
}
script off_ranged {
send "off %s\n"
expect "redfishpower> "
}
script cycle_ranged {
send "cycle %s\n"
expect "redfishpower> "
}
}
71 changes: 71 additions & 0 deletions t/t0034-redfishpower.t
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,77 @@ test_expect_success 'stop powerman daemon (setplugs)' '
wait
'

#
# redfishpower setpath coverage
#

test_expect_success 'create powerman.conf for 16 cray redfish nodes (setpath)' '
cat >powerman_setpath.conf <<-EOT
listen "$testaddr"
include "$testdevicesdir/redfishpower-setpath.dev"
device "d0" "redfishpower-setpath" "$redfishdir/redfishpower -h t[0-15] --test-mode |&"
node "t[0-15]" "d0" "Node[0-15]"
EOT
'
test_expect_success 'start powerman daemon and wait for it to start (setpath' '
$powermand -Y -c powerman_setpath.conf &
echo $! >powermand.pid &&
$powerman --retry-connect=100 --server-host=$testaddr -d
'
test_expect_success 'powerman -q shows all off' '
$powerman -h $testaddr -q >test_setpath_query.out &&
makeoutput "" "t[0-15]" "" >test_setpath_query.exp &&
test_cmp test_setpath_query.exp test_setpath_query.out
'
test_expect_success 'powerman -1 t[0-15] works' '
$powerman -h $testaddr -1 t[0-15] >test_setpath_on.out &&
echo Command completed successfully >test_setpath_on.exp &&
test_cmp test_setpath_on.exp test_setpath_on.out
'
test_expect_success 'powerman -q shows all on' '
$powerman -h $testaddr -q >test_setpath_query2.out &&
makeoutput "t[0-15]" "" "" >test_setpath_query2.exp &&
test_cmp test_setpath_query2.exp test_setpath_query2.out
'
test_expect_success 'stop powerman daemon (setpath)' '
kill -15 $(cat powermand.pid) &&
wait
'

# Note, verbose output can mess up the device script's interpretation of power status,
# so restart powermand with verbose mode to run telemetry specific tests.
test_expect_success 'create powerman.conf for 16 cray redfish nodes (setpath2)' '
cat >powerman_setpath2.conf <<-EOT
listen "$testaddr"
include "$testdevicesdir/redfishpower-setpath.dev"
device "d0" "redfishpower-setpath" "$redfishdir/redfishpower -h t[0-15] --test-mode -vv |&"
node "t[0-15]" "d0" "Node[0-15]"
EOT
'
test_expect_success 'start powerman daemon and wait for it to start (setpath2)' '
$powermand -Y -c powerman_setpath2.conf &
echo $! >powermand.pid &&
$powerman --retry-connect=100 --server-host=$testaddr -d
'
# Note: redfishpower-setpath.dev sets different paths for different
# nodes. Following tests check that correct path has been used.
test_expect_success 'powerman -T -1 shows correct path being used (t0)' '
$powerman -h $testaddr -T -1 t0 > test_setpath2_on_T1.out &&
grep "plugname=Node0" test_setpath2_on_T1.out | grep "path=" | grep Group0
'
test_expect_success 'powerman -T -1 shows correct path being used (t5)' '
$powerman -h $testaddr -T -1 t5 > test_setpath2_on_T2.out &&
grep "plugname=Node5" test_setpath2_on_T2.out | grep "path=" | grep Group1
'
test_expect_success 'powerman -T -1 shows correct path being used (t10)' '
$powerman -h $testaddr -T -1 t10 > test_setpath2_on_T3.out &&
grep "plugname=Node10" test_setpath2_on_T3.out | grep "path=" | grep Default
'
test_expect_success 'stop powerman daemon (setpath2)' '
kill -15 $(cat powermand.pid) &&
wait
'

test_done

# vi: set ft=sh

0 comments on commit bd73647

Please sign in to comment.