diff --git a/t/Makefile.am b/t/Makefile.am index 792fb906..79247d21 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -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@ diff --git a/t/etc/redfishpower-plugsub-blades.dev b/t/etc/redfishpower-plugsub-blades.dev new file mode 100644 index 00000000..6187a192 --- /dev/null +++ b/t/etc/redfishpower-plugsub-blades.dev @@ -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-{{plug}}/Stat\n" + expect "redfishpower> " + send "setonpath redfish/Default-{{plug}}/Reset {\"ResetType\":\"On\"}\n" + expect "redfishpower> " + send "setoffpath redfish/Default-{{plug}}/Reset {\"ResetType\":\"ForceOff\"}\n" + expect "redfishpower> " + send "setcyclepath redfish/Default-{{plug}}/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> " + } +} diff --git a/t/etc/redfishpower-plugsub.dev b/t/etc/redfishpower-plugsub.dev new file mode 100644 index 00000000..bedae413 --- /dev/null +++ b/t/etc/redfishpower-plugsub.dev @@ -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-{{plug}}/Reset {\"ResetType\":\"On\"}\n" + expect "redfishpower> " + send "setpath Node[0-7] off redfish/Group0-{{plug}}/Reset {\"ResetType\":\"ForceOff\"}\n" + expect "redfishpower> " + send "setpath Node[0-7] cycle redfish/Group0-{{plug}}/Reset {\"ResetType\":\"ForceRestart\"}\n" + expect "redfishpower> " + send "setstatpath redfish/Default\n" + expect "redfishpower> " + send "setonpath redfish/Default-{{plug}}/Reset {\"ResetType\":\"On\"}\n" + expect "redfishpower> " + send "setoffpath redfish/Default-{{plug}}/Reset {\"ResetType\":\"ForceOff\"}\n" + expect "redfishpower> " + send "setcyclepath redfish/Default-{{plug}}/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> " + } +} diff --git a/t/t0034-redfishpower.t b/t/t0034-redfishpower.t index 9d4107c9..b68bde66 100755 --- a/t/t0034-redfishpower.t +++ b/t/t0034-redfishpower.t @@ -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