~louis/crashdc/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash

typeset -i error=0
typeset host=crashdcSLES10x

wait_for_server()
{
host=$1

typeset -i nologin=1
typeset -i nonetwork=1

	echo -n "### $(date) Waiting for $host VM to settle"
while (( nologin )) || (( nonetwork ));do
	echo -n "."

	ping -q -c 1 -t 5 ${host} > /dev/null

	error=$?

	if (( error ));then
		nonetwork=1
		nologin=1
	else
		if (( nonetwork ));then
			echo
			echo -n "### $(date) $host VM is there and network is started"
		fi
		nonetwork=0
		ssh -o ConnectTimeout=5 root@${host} uname -a > /dev/null 2>&1
		error=$?
		if ! (( error ));then
			nologin=0
			echo 
			echo "### $(date) $host VM is there and login is enabled"
		else
			sleep 5
		fi
	fi
done
}

cleanup_last_vmcore()
{
	ssh root@${host} "rm -f \'ls -rtd /var/log/dump/*/vmcore | head -1\'"
}

test_service()
{
	echo "### $(date) Testing crashdc init script"
	ssh root@${host} "service crashdc status"
	ssh root@${host} "service crashdc generate"
	sleep 45
	ssh root@${host} "service crashdc generate advanced"
	sleep 45
	ssh root@${host} "service crashdc generate custom /tmp/toto"
}
echo "### $(date) Starting ${host} VM"

vmrun -T ws start /work/VM/${host}/${host}.vmx

wait_for_server ${host}

echo "### $(date) Preparing VM for tests"
scp prepare_test_sles10 root@${host}:
ssh root@${host} /root/prepare_test_sles10
sync
sleep 5
sync

echo "### $(date) Run ${host} test #1 : XEN kernel"
nohup ssh root@${host} "echo c > /proc/sysrq-trigger" > /dev/null 2>&1 &
sleep 10	#Otherwise the other end is still alive

wait_for_server ${host}

test_service

echo "### $(date) Preparing to reboot to SMP kernel"
ssh root@${host} "mv /boot/grub/menu.lst /boot/grub/menu.lst.smp;sed 's/^default 2/default 1/' /boot/grub/menu.lst.smp > /boot/grub/menu.lst"
ssh root@${host} "reboot"
sleep 10	#Otherwise the other end is still alive

wait_for_server ${host}
echo "### $(date) Run ${host} test #2 : SMP kernel"
nohup ssh root@${host} "echo c > /proc/sysrq-trigger" > /dev/null 2>&1 &
sleep 10	#Otherwise the other end is still alive

wait_for_server ${host}

test_service
echo "### $(date) Preparing to reboot to DEFAULT kernel"
ssh root@${host} "mv /boot/grub/menu.lst /boot/grub/menu.lst.default;sed 's/^default 1/default 0/' /boot/grub/menu.lst.default > /boot/grub/menu.lst"
ssh root@${host} "reboot"
sleep 10	#Otherwise the other end is still alive

wait_for_server ${host}
echo "### $(date) Run ${host} test #3 : DEFAULT kernel"
nohup ssh root@${host} "echo c > /proc/sysrq-trigger" > /dev/null 2>&1 &
sleep 10	#Otherwise the other end is still alive

wait_for_server ${host}

test_service
echo "### $(date) Finished running all tests"
echo 
echo "### $(date) Tests Results are :"
ssh root@${host} "grep -e KERNEL: -e DUMPFILE -e \"mode in use\" /var/log/dump/2*/*txt"
exit 0