diff --git a/xCAT-test/bats/genesis_bmcsetup_users.bats b/xCAT-test/bats/genesis_bmcsetup_users.bats index 2b750a570..870646c87 100644 --- a/xCAT-test/bats/genesis_bmcsetup_users.bats +++ b/xCAT-test/bats/genesis_bmcsetup_users.bats @@ -51,12 +51,33 @@ case "$1 $2" in 'channel getaccess') echo 'Fixed Name : No' ;; 'user list') cat /run/fixture/users ;; 'user disable') printf '%s\n' "$3" >>/run/fixture/disabled ;; + 'raw 0xc') + [ "$3 $4 $5" != '2 1 0xc0' ] || echo '00 01' + ;; + 'raw 0x3a') + case "$3" in + 0x50) echo '59 55 4f 4f' ;; + 0xb) echo 0 ;; + esac + ;; + 'raw 0x32') + [ "$3" != 0x72 ] || echo ' 01' + ;; esac exit 0 SH cat >"$fixture/bin/getipmi" <<'SH' #!/bin/sh -cp /run/fixture/ipmicfg.xml /tmp/ipmicfg.xml +counter=/run/fixture/retrievals +count=0 +[ ! -f "$counter" ] || count=$(cat "$counter") +count=$((count + 1)) +echo "$count" >"$counter" +if [ -f "/run/fixture/ipmicfg.$count.xml" ]; then + cp "/run/fixture/ipmicfg.$count.xml" /tmp/ipmicfg.xml +else + cp /run/fixture/ipmicfg.xml /tmp/ipmicfg.xml +fi SH local utility for utility in modprobe updateflag.awk remoteimmsetup allowcred.awk; do @@ -241,3 +262,68 @@ XML -d 0 lan print 1 -d 0 lan print 1' ] } + +@test 'bmcsetup retains defaults for absent optional configuration fields' { + sed -i '/taggedvlan\|gateway\|ipcfgmethod/d' "$fixture/ipmicfg.xml" + : >"$fixture/lan.0" + run_genesis 0 + run lan_calls + [ "$output" = '-d 0 lan print 1 +-d 0 lan set 1 ipsrc static +-d 0 lan print 1 +-d 0 lan set 1 ipaddr 192.0.2.2 +-d 0 lan print 1 +-d 0 lan set 1 netmask 255.255.255.0' ] + grep -Fx 'raw 0xc 1 1 0x14 0 0' "$fixture/calls" + grep -Fx -- '-d 0 user set password 2 test-password' "$fixture/calls" + [ ! -e "$fixture/tmp/ipmicfg.xml" ] +} + +@test 'bmcsetup retries configuration retrieval before reading the complete reply' { + sed '/bmcip/d' "$fixture/ipmicfg.xml" >"$fixture/ipmicfg.1.xml" + run_genesis 0 + [ "$(cat "$fixture/retrievals")" = 2 ] + run cat "$fixture/sleeps" + [ "$output" = '5 +15 +1' ] + grep -F 'FAILED TO RETRIEVE SETTINGS, RETRYING in 15 seconds' "$fixture/messages" + grep -Fx -- '-d 0 user enable 2' "$fixture/calls" + [ ! -e "$fixture/tmp/ipmicfg.xml" ] +} + +@test 'bmcsetup uses configured user and long password values' { + sed -i 's/USERID/operator/; s/test-password/01234567890123456789/; s/^/ /' "$fixture/ipmicfg.xml" + sed -i 's/USERID/operator/' "$fixture/users" + run_genesis 0 + grep -Fx -- '-d 0 user enable 2' "$fixture/calls" + grep -Fx -- '-d 0 user set password 2 01234567890123456789 20' "$fixture/calls" + run cat "$fixture/disabled" + [ "$output" = 4 ] + [ ! -e "$fixture/tmp/ipmicfg.xml" ] +} + +@test 'bmcsetup reads the configured port in each vendor branch' { + local manufacturer product port expected + while IFS='|' read -r manufacturer product port expected; do + printf 'Vendor %s product %s port %s\n' "$manufacturer" "$product" "$port" + printf '%s\n' 'IPMI Version : 1.5' "Manufacturer ID : $manufacturer" \ + "Product ID : $product" >"$fixture/mcinfo" + sed -i '/bmcport/d' "$fixture/ipmicfg.xml" + printf '%s\n' "$port" >>"$fixture/ipmicfg.xml" + rm -f "$fixture/calls" + run_genesis 0 + grep -Fx -- "$expected" "$fixture/calls" + [ ! -e "$fixture/tmp/ipmicfg.xml" ] + done <<'CASES' +2|220|1|-d 0 raw 0xc 1 1 0xc0 1 +2|100|1|-d 0 raw 0xc 1 1 0xc0 1 +19046|1287|0|raw 0x32 0x71 0 1 0 +19046|100|1|-d 0 raw 0xc 1 1 0xc0 1 +674|100|1|raw 0x30 0x28 0x01 0x00 +674|100|0 2 3|raw 0x30 0x28 0x03 0x04 +10876|2437|0|raw 0x30 0x70 0x0c 1 1 +10876|2437|1|raw 0x30 0x70 0x0c 1 0 +343|149|1|-d 0 lan print 3 +CASES +}