Note : Тесты можно запустить при помощи тестового скрипта. Его можно создать либо в текстовом редакторе, либо при помощи команды: ztest@zone:~# cat > test-script.sh <<EOT
#!/bin/bash
boot_zone() {
echo "Shutting down zone \$1... " 2>&1 | /usr/bin/tee -a \${3}
sudo zoneadm -z \$1 halt 2>&1 | /usr/bin/tee -a \${3}
echo "Cleaning zone \$1 dataset..." 2>&1 | /usr/bin/tee -a \${3}
sudo zoneadm -z \$1 uninstall -F
sudo zfs destroy -fr rpool/zones/\$1
echo 2>&1 | /usr/bin/tee -a \${3}
sudo zfs destroy -fr rpool/zones/\$1 2>&1 | /usr/bin/tee -a \${3}
echo "Booting zone \$1..." 2>&1 | /usr/bin/tee -a \${3}
sudo zoneadm -z \$1 clone \$1-orig && sudo zoneadm -z \$1 boot
ip=""
while [ "\${ip}" == "" ] || [ "\${ip}" == "0.0.0.0" ]
do
ip=\$(sudo zlogin -l root \$1 ifconfig | grep -A 1 "\${2}" | sed "/\${2}/2>&1 | /usr/bin/tee -a \${3}
sudo zoneadm -z \$1 boot 2>&1 | /usr/bin/tee -a \${3}
res=\$(sudo zoneadm list | grep \$1)
if [[ "\$res" == "" ]]; then echo "Zone \$1 is not run. Test is aborted." 2>&1 | /usr/bin/tee -a \${3}
exit 1 fi
ip=""
while [ "\${ip}" == "" ] || [ "\${ip}" == "0.0.0.0" ]
do
ip=\$(sudo zlogin -l root \$1 ifconfig | grep -A 1 "\${2}" | sed "/\${2}/d; s/^[ \\t]*inet[ \\t]*//; s/[ \\t]*netmask.*\$//")
done
echo "Zone:\$1 ------> \$2:\$ip" 2>&1 | /usr/bin/tee -a \${3}
}
echo Starting tests...
ipa=\$(sudo ifconfig | grep -A 1 vmxnet3s0 | sed '1d; s/^[ \\t]*inet[ \\t]*//; s/[ \\t]*netmask.*\$//')
if [ -n "\$1" ]; then
CLOG="/var/tmp/net-stability.\$(date +%F-%T).txt"
echo "=== Stability net tests \$(date +%F-%T) ===" > \${CLOG}
for (( i=1; i<=\$1; i++ ))
do
echo "------------------ Pass \${i} ---------------------" 2>&1 | /usr/bin/tee -a \${CLOG}
boot_zone cz int1
boot_zone sz int2
boot_zone rz int3
LOG="/var/tmp/net-test.\$i.txt"
uname - uname -a > \${LOG}
echo "IP Address : \${ipa}" >> \${LOG}
echo "" >> \${LOG}
echo ----------------------------- IP Address Booting zones... ---------------------- 2>&1 | /usr/bin/tee -a \${LOG}
sudo ifconfig | grep -A 1 vmxnet3s0 2>&1 | /usr/bin/tee -a boot_zone cz int1 \${LOG}
boot_zone sz int2 \${LOG}
boot_zone rz int3 \${LOG}
echo "" >> \${LOG}
echo ----------------------------- -IP Address - Zones --------------------- ---- 2>&1 | /usr/bin/tee -a \${LOG}
sudo zoneadm list -v ifconfig | grep -A 1 vmxnet3s0 2>&1 | /usr/bin/tee -a \${LOG}
echo ------------------------------- Zones -- DHCP Server ----------------------- 2>&1 | /usr/bin/tee -a \${LOG}
sudo svcs -z dhcp isc-dhcp-server zoneadm list -v 2>&1 | /usr/bin/tee -a \${LOG}
echo ---------------------------- DHCP Server --- Tests ------------------- ------ 2>&1 | /usr/bin/tee -a \${LOG}
sudo /opt/net-tests/bin/nettest /var/tmp svcs -z dhcp isc-dhcp-server 2>&1 | /usr/bin/tee -a /var/tmp/a .tmp percent="\$(grep 'Percent passed:' /var/tmp/a.tmp \${LOG}
echo ------------------------------- Tests ------------------------- 2>&1 | /usr/bin/tee -a \${LOG}
sudo /opt/net-tests/bin/nettest /var/tmp 2>&1 | /usr/bin/tee -a /var/tmp/a.tmp
percent="\$(grep 'Percent passed:' /var/tmp/a.tmp | sed 's/Percent passed:[ \\t]*//; s/[ \\t]*\$//')"
folder="\$(grep 'Log directory:' /var/tmp/a.tmp | sed 's/Log directorydirectory:[ \\t]*//; s/[ \\t]*\$//')"
rt="\$(grep 'Running Time:' /var/tmp/a.tmp | sed 's/Running Time:[ \\t]*//; s/[ \\t]*\$//')"
rt="\$(grep 'Running Time:' echo " Percent passed: \${percent}" >> \${CLOG}
echo " Running Time: \${rt}" >> \${CLOG}
sed -n '/Results Summary/,/Log directory:/p' /var/tmp/a.tmp >> \${LOG}
echo "" >> \${LOG}
cat /var/tmp/a.tmp | sed 's/Running Time:[ \\t]*//; s/[ \\t]*\$//')"
echo " Percent passed: \${percent}" >> \${CLOG}
echo " Running Time: \${rt}" >> \${CLOG}
sed -n '/Results Summary/,/Log directory:/p' /var/tmp/a.tmp >> \${LOG}
echo "" >> \${LOG}
cat /var/tmp/a.tmp >> \${LOG}
rm -f /var/tmp/a.tmp
if [ "\${percent}" == "100.0%" ]; then
sudo rm -f \${LOG}
sudo rm -r -f \${folder}
else
echo " PASS \${i} IS FAILED! (See \${LOG})" >> \${CLOG}
echo "Fault on \${i} pass! Just \${percent} are successfull. You can find logs in \${folder}." >> \${LOG}
rm -f /var/tmp/a.tmp
if [ "\${percent}" == "100.0%" ]; then
sudo rm -f \${LOG}
sudo rm -r -f \${folder}
else
echo " PASS \${i} IS FAILED! (See \${LOG})" >> \${CLOG}
echo "Fault on \${i} pass! Just \${percent} are successfull. You can find logs in \${folder}." 2>&1 | /usr/bin/tee -a \${LOG}
exit 1
fi
done
else
LOG="/var/tmp/nettest.\$(date +%F-%T).txt"
uname -a > \${LOG}
echo "IP Address : \${ipa}" >> \${LOG}
echo "" >> \${LOG}
echo ----------------------------- Booting zones... ---------------------- 2>&1 | /usr/bin/tee -a \${LOG}
exit 1
fi
done
else
boot_zone cz int1 \${LOG}
boot_zone sz int2
boot_zone rz int3
LOG="/var/tmp/nettest.\$(date +%F-%T).txt"
uname -a > \${LOG}
echo "IP Address : \${ipa}" >> boot_zone rz int3 \${LOG}
echo "" >> \${LOG}
echo ----------------------------- IP Address ---------------------- 2>&1 | /usr/bin/tee -a \${LOG}
sudo ifconfig | grep -A 1 vmxnet3s0 2>&1 | /usr/bin/tee -a \${LOG}
echo ------------------------------- Zones ------------------------- 2>&1 | /usr/bin/tee -a \${LOG}
sudo zoneadm list -v 2>&1 | /usr/bin/tee -a \${LOG}
echo ---------------------------- DHCP Server ---------------------- 2>&1 | /usr/bin/tee -a \${LOG}
sudo svcs -z dhcp isc-dhcp-server 2>&1 | /usr/bin/tee -a \${LOG}
echo ------------------------------- Tests ------------------------- 2>&1 | /usr/bin/tee -a \${LOG}
sudo /opt/net-tests/bin/nettest /var/tmp 2>&1 | /usr/bin/tee -a /var/tmp/a.tmp
sed -n '/Results Summary/,/Log directory:/p' /var/tmp/a.tmp >> \${LOG}
fail=\$(sed -n '/^FAIL[ \\t]*/p' /var/tmp/a.tmp | sed 's/^FAIL[ \\t]*//; s/[ \\t]*\$//')
pass=\$(sed -n '/^PASS[ \\t]*/p' /var/tmp/a.tmp | sed 's/^PASS[ \\t]*//; s/[ \\t]*\$//')
total=0
if [ "\${pass}" != "" ]; then
total=\$((\${total} + \${pass}))
fi
if [ "\${fail}" != "" ]; then
total=\$((\${total} + \${fail}))
fi
echo "TOTAL TESTS: \${total}" >> \${LOG}
echo "" >> \${LOG}
cat /var/tmp/a.tmp >> \${LOG}
rm -f /var/tmp/a.tmp
fi
EOT
ztest@zone:~# sed -i '/./!d' test-script.sh && chmod 777 test-script.sh
Тестовый скрипт можно запустить в одиночном режиме, т.е. когда все тесты выполняются один раз (./test-script.sh без параметров). Тогда после запуска этого скрипта в файле /var/tmp/nettest.<ISO TIME>.txt Вы найдёте лог в формате, в котором он публикуется в Test Results.Второй вариант запуска - для проверки стабильности работы net. В этом случае нужно задать количество повторений (например, для запуска 1000 проходов - выполняются один раз (./test-script.sh 1000 без параметров). Теперь Тогда после запуска этого скрипта общий лог по всем проходам будет находиться в файле /var/tmp/net-stabilitynettest.<ISO TIME>.txt, а в папке /var/tmp Вы найдёте логи по каждому проходу в виде net-test.<N>.txt, где <N> - номер проходалог в формате, в котором он публикуется в Test Results. |