Skip to content

Commit

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

Add basic coverage in t0034-redfishpower.t and add test device file
t/etc/redfishpower-setplugs.dev.
  • Loading branch information
chu11 committed Mar 19, 2024
1 parent 25fa0af commit f06df25
Show file tree
Hide file tree
Showing 3 changed files with 91 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 @@ -60,7 +60,8 @@ EXTRA_DIST= \
sharness.sh \
etc/sierra_plugs.conf \
etc/mcr_plugs.conf \
etc/vpc.dev
etc/vpc.dev \
etc/redfishpower-setplugs.dev


AM_CFLAGS = @WARNING_CFLAGS@
Expand Down
48 changes: 48 additions & 0 deletions t/etc/redfishpower-setplugs.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Variant of redfishpower-cray-r272z30.dev that covers use of setplugs
# configuration
specification "redfishpower-setplugs" {
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 "setstatpath redfish/v1/Systems/Self\n"
expect "redfishpower> "
send "setonpath redfish/v1/Systems/Self/Actions/ComputerSystem.Reset {\"ResetType\":\"On\"}\n"
expect "redfishpower> "
send "setoffpath redfish/v1/Systems/Self/Actions/ComputerSystem.Reset {\"ResetType\":\"ForceOff\"}\n"
expect "redfishpower> "
send "setcyclepath redfish/v1/Systems/Self/Actions/ComputerSystem.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> "
}
}
41 changes: 41 additions & 0 deletions t/t0034-redfishpower.t
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,47 @@ test_expect_success 'stop powerman daemon (failhosts)' '
wait
'

#
# redfishpower setplugs coverage
#

test_expect_success 'create powerman.conf for 16 cray redfish nodes (setplugs)' '
cat >powerman_setplugs.conf <<-EOT
listen "$testaddr"
include "$testdevicesdir/redfishpower-setplugs.dev"
device "d0" "redfishpower-setplugs" "$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 (setplugs)' '
$powermand -Y -c powerman_setplugs.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_setplugs_query.out &&
makeoutput "" "t[0-15]" "" >test_setplugs_query.exp &&
test_cmp test_setplugs_query.exp test_setplugs_query.out
'
test_expect_success 'powerman -T -q shows plugs are being used' '
$powerman -h $testaddr -T -q > test_setplugs_query_T.out &&
grep "Node15: off" test_setplugs_query_T.out
'
test_expect_success 'powerman -1 t[0-15] works' '
$powerman -h $testaddr -1 t[0-15] >test_setplugs_on.out &&
echo Command completed successfully >test_setplugs_on.exp &&
test_cmp test_setplugs_on.exp test_setplugs_on.out
'
test_expect_success 'powerman -q shows all on' '
$powerman -h $testaddr -q >test_setplugs_query2.out &&
makeoutput "t[0-15]" "" "" >test_setplugs_query2.exp &&
test_cmp test_setplugs_query2.exp test_setplugs_query2.out
'
test_expect_success 'stop powerman daemon (setplugs)' '
kill -15 $(cat powermand.pid) &&
wait
'

test_done

# vi: set ft=sh

0 comments on commit f06df25

Please sign in to comment.