Skip to content

Commit

Permalink
t: cover redfishpower plug substitution
Browse files Browse the repository at this point in the history
Problem: There is no coverage for the new redfishpower plug
substitution in paths.

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


AM_CFLAGS = @WARNING_CFLAGS@
Expand Down
54 changes: 54 additions & 0 deletions t/etc/redfishpower-plugsub-blades.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Variant of redfishpower-cray-r272z30.dev that covers use of plug
# substitution and the assumption of blades.
#
# Notes:
# - hypothetical blades go through Node0
# - for easier grepping in tests, simplify paths
specification "redfishpower-plugsub-blades" {
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 "setplugs Blade[0-3] 0\n"
expect "redfishpower> "
send "setstatpath redfish/Default-%%p/Stat\n"
expect "redfishpower> "
send "setonpath redfish/Default-%%p/Reset {\"ResetType\":\"On\"}\n"
expect "redfishpower> "
send "setoffpath redfish/Default-%%p/Reset {\"ResetType\":\"ForceOff\"}\n"
expect "redfishpower> "
send "setcyclepath redfish/Default-%%p/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> "
}
}
62 changes: 62 additions & 0 deletions t/etc/redfishpower-plugsub.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Variant of redfishpower-cray-r272z30.dev that covers use of plug
# substitution.
#
# Notes:
# - for easier grepping in tests, simplify paths
# - different paths for different chunks of nodes/plugs
# - no plug specific paths set for Node[8-15], will use defaults
# set via setstatpath, setonpath, etc.
specification "redfishpower-plugsub" {
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-7] stat redfish/Group0\n"
expect "redfishpower> "
send "setpath Node[0-7] on redfish/Group0-%%p/Reset {\"ResetType\":\"On\"}\n"
expect "redfishpower> "
send "setpath Node[0-7] off redfish/Group0-%%p/Reset {\"ResetType\":\"ForceOff\"}\n"
expect "redfishpower> "
send "setpath Node[0-7] cycle redfish/Group0-%%p/Reset {\"ResetType\":\"ForceRestart\"}\n"
expect "redfishpower> "
send "setstatpath redfish/Default\n"
expect "redfishpower> "
send "setonpath redfish/Default-%%p/Reset {\"ResetType\":\"On\"}\n"
expect "redfishpower> "
send "setoffpath redfish/Default-%%p/Reset {\"ResetType\":\"ForceOff\"}\n"
expect "redfishpower> "
send "setcyclepath redfish/Default-%%p/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> "
}
}
136 changes: 136 additions & 0 deletions t/t0034-redfishpower.t
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,142 @@ test_expect_success 'stop powerman daemon (setpath2)' '
wait
'

#
# redfishpower plug substitution coverage
#

test_expect_success 'create powerman.conf for 16 cray redfish nodes (plugsub)' '
cat >powerman_plugsub.conf <<-EOT
listen "$testaddr"
include "$testdevicesdir/redfishpower-plugsub.dev"
device "d0" "redfishpower-plugsub" "$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 (plugsub)' '
$powermand -Y -c powerman_plugsub.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_plugsub_query.out &&
makeoutput "" "t[0-15]" "" >test_plugsub_query.exp &&
test_cmp test_plugsub_query.exp test_plugsub_query.out
'
test_expect_success 'powerman -1 t[0-15] works' '
$powerman -h $testaddr -1 t[0-15] >test_plugsub_on.out &&
echo Command completed successfully >test_plugsub_on.exp &&
test_cmp test_plugsub_on.exp test_plugsub_on.out
'
test_expect_success 'powerman -q shows all on' '
$powerman -h $testaddr -q >test_plugsub_query2.out &&
makeoutput "t[0-15]" "" "" >test_plugsub_query2.exp &&
test_cmp test_plugsub_query2.exp test_plugsub_query2.out
'
test_expect_success 'stop powerman daemon (plugsub)' '
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 (plugsub2)' '
cat >powerman_plugsub2.conf <<-EOT
listen "$testaddr"
include "$testdevicesdir/redfishpower-plugsub.dev"
device "d0" "redfishpower-plugsub" "$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 (plugsub2)' '
$powermand -Y -c powerman_plugsub2.conf &
echo $! >powermand.pid &&
$powerman --retry-connect=100 --server-host=$testaddr -d
'
# Note: redfishpower-plugsub.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_plugsub2_on_T1.out &&
grep "plugname=Node0" test_plugsub2_on_T1.out | grep "path=" | grep Group0-Node0
'
test_expect_success 'powerman -T -1 shows correct path being used (t8)' '
$powerman -h $testaddr -T -1 t8 > test_plugsub2_on_T2.out &&
grep "plugname=Node8" test_plugsub2_on_T2.out | grep "path=" | grep Default-Node8
'
test_expect_success 'stop powerman daemon (plugsub2)' '
kill -15 $(cat powermand.pid) &&
wait
'

#
# redfishpower plug substitution coverage w/ hypothetical blades
#
# Blades[0-3] assumed to go through t0
#

test_expect_success 'create powerman.conf for 16 cray redfish nodes (plugsubB)' '
cat >powerman_plugsubB.conf <<-EOT
listen "$testaddr"
include "$testdevicesdir/redfishpower-plugsub-blades.dev"
device "d0" "redfishpower-plugsub-blades" "$redfishdir/redfishpower -h t[0-15] --test-mode |&"
node "t[0-15]" "d0" "Node[0-15]"
node "blade[0-3]" "d0" "Blade[0-3]"
EOT
'
test_expect_success 'start powerman daemon and wait for it to start (plugsubB)' '
$powermand -Y -c powerman_plugsubB.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_plugsubB_query.out &&
makeoutput "" "blade[0-3],t[0-15]" "" >test_plugsubB_query.exp &&
test_cmp test_plugsubB_query.exp test_plugsubB_query.out
'
test_expect_success 'powerman -1 blade[0-3],t[0-15] works' '
$powerman -h $testaddr -1 blade[0-3],t[0-15] >test_plugsubB_on.out &&
echo Command completed successfully >test_plugsubB_on.exp &&
test_cmp test_plugsubB_on.exp test_plugsubB_on.out
'
test_expect_success 'powerman -q shows all on' '
$powerman -h $testaddr -q >test_plugsubB_query2.out &&
makeoutput "blade[0-3],t[0-15]" "" "" >test_plugsubB_query2.exp &&
test_cmp test_plugsubB_query2.exp test_plugsubB_query2.out
'
test_expect_success 'stop powerman daemon (plugsubB)' '
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 (plugsubB2)' '
cat >powerman_plugsubB2.conf <<-EOT
listen "$testaddr"
include "$testdevicesdir/redfishpower-plugsub-blades.dev"
device "d0" "redfishpower-plugsub-blades" "$redfishdir/redfishpower -h t[0-15] --test-mode -vv |&"
node "t[0-15]" "d0" "Node[0-15]"
node "blade[0-3]" "d0" "Blade[0-3]"
EOT
'
test_expect_success 'start powerman daemon and wait for it to start (plugsubB2)' '
$powermand -Y -c powerman_plugsubB2.conf &
echo $! >powermand.pid &&
$powerman --retry-connect=100 --server-host=$testaddr -d
'
test_expect_success 'powerman -T -1 shows correct path being used (t0)' '
$powerman -h $testaddr -T -1 t0 > test_plugsubB2_on_T1.out &&
grep "plugname=Node0" test_plugsubB2_on_T1.out | grep "path=" | grep Default-Node0
'
test_expect_success 'powerman -T -1 shows correct path being used (t8)' '
$powerman -h $testaddr -T -1 blade0 > test_plugsubB2_on_T2.out &&
grep "plugname=Blade0" test_plugsubB2_on_T2.out | grep "path=" | grep Default-Blade0
'
test_expect_success 'stop powerman daemon (plugsubB2)' '
kill -15 $(cat powermand.pid) &&
wait
'

test_done

# vi: set ft=sh

0 comments on commit 9cb8eff

Please sign in to comment.