forked from spark404/cs-functional-test
-
Notifications
You must be signed in to change notification settings - Fork 1
/
runtest.sh
executable file
·193 lines (166 loc) · 5.61 KB
/
runtest.sh
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
# --------------------------------------------------------------------------------- #
# Stuff you may well have to change
# --------------------------------------------------------------------------------- #
export CLOUDSTACK=/Users/isoutham/repo/cloudstack
export INSTALL_VM=cloud-install-sys-tmplt
export SCRIPT=${CLOUDSTACK}/scripts/storage/secondary
#export XENTEMPLATE=systemvmtemplate-master-4.6.0-xen.vhd.bz2
export XENTEMPLATE=systemvm64template-systemvm-persistent-config-4.6.0.88-xen.vhd.bz2
#export XENTEMPLATE=systemvm64template-systemvm-persistent-config-4.5.0.71-xen.vhd.bz2
#export XENTEMPLATE=systemvm64template-systemvm-persistent-config-4.5.0.69-xen.vhd.bz2
#export XENTEMPLATE=systemvm64template-4.4-2014-12-02-xen.vhd.bz2
#export XENTEMPLATE=systemvmtemplate-master-4.6.0-xen.vhd.bz2
# --------------------------------------------------------------------------------- #
# The rest
# --------------------------------------------------------------------------------- #
#export MAVEN_OPTS="-Xmx2048m -XX:MaxPermSize=512m"
MAVEN_OPTS='-Xmx2048m -XX:MaxPermSize=1024m -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n'
export LINUX_TMPL=ttylinux_pv.vhd
export DEVCLOUD=192.168.56.5
export DEVCLOUD_VBOX=management
export HYPERVISOR=192.168.56.10
export HYPERVISOR_VBOX=xenserver
export SECSTORE=/exports/secondary
args=`getopt npbit $*`
if [ $? != 0 ]
then
echo $0 [-p] [-b]
echo specify -p to stop after preparing the test environment
echo specify -b to build cloudstack before starting the test cycle
echo specify -n to activate the noredist profile
echo specify -i to install a new systemvm
exit
fi
SCRIPT_LOCATION=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
set -- $args
for i do
case $i in
-p)
PREPARE=1
;;
-b)
BUILD=1
;;
-n)
NOREDIST=" -Dnoredist "
;;
-i)
INSTALLSVM="1"
;;
-t)
INSTALLTINY="1"
;;
esac
done
systemvm() {
TF=/tmp/$$
vagrant ssh-config management > ${TF}
PORT=$(cat ${TF} | grep Port | awk '{print $2;}')
USER=$(cat ${TF} | grep "User " | awk '{print $2;}')
HN=$(cat ${TF} | grep HostName | awk '{print $2;}')
ID=$(cat ${TF} | grep IdentityFile | awk '{print $2;}')
rm ${TF}
if [ ! -d ${SCRIPT} ]
then
echo "Could not locate ${SCRIPT}"
exit 2
fi
scp -P ${PORT} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${ID} ${SCRIPT}/* ${SCRIPT_LOCATION}/systemvm/${XENTEMPLATE} ${USER}@${HN}:
CMD="sudo sh ./${INSTALL_VM} -m ${SECSTORE} -f ${XENTEMPLATE} -h xenserver -o 127.0.0.1 -r cloud -d cloud -t 1 -F"
vagrant ssh management -c "$CMD"
}
linuxImage() {
TF=/tmp/$$
vagrant ssh-config management > ${TF}
PORT=$(cat ${TF} | grep Port | awk '{print $2;}')
USER=$(cat ${TF} | grep "User " | awk '{print $2;}')
HN=$(cat ${TF} | grep HostName | awk '{print $2;}')
ID=$(cat ${TF} | grep IdentityFile | awk '{print $2;}')
rm ${TF}
echo Install Tiny Linux
if [ -f ${SCRIPT_LOCATION}/systemvm/${LINUX_TMPL} ]
then
echo Installing linux image template 5
scp -P ${PORT} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${ID} ${SCRIPT_LOCATION}/systemvm/${LINUX_TMPL} ${SCRIPT_LOCATION}/systemvm/template.properties ${USER}@${HN}:
vagrant ssh management -c "sudo mkdir -p /exports/secondary/template/tmpl/1/5"
vagrant ssh management -c "sudo cp ${LINUX_TMPL} /exports/secondary/template/tmpl/1/5/ce5b212e-215a-3461-94fb-814a635b2215.vhd"
vagrant ssh management -c "sudo cp template.properties /exports/secondary/template/tmpl/1/5"
fi
}
vagrant up ${DEVCLOUD_VBOX}
if [ $? -ne 0 ]
then
echo Failed to start ${DEVCLOUD_VBOX}
exit 1
fi
vagrant up ${HYPERVISOR_VBOX}
if [ $? -ne 0 ]
then
echo Failed to start ${HYPERVISOR_VBOX}
exit 1
fi
if [ -n "${INSTALLSVM}" ]
then
systemvm
exit
fi
if [ -n "${INSTALLTINY}" ]
then
linuxImage
exit
fi
sudo touch /tmp/a
# Kill any old cloudstack instances
ps -ef | grep java|grep systemvm| awk '{print $2;}' | xargs kill -9
echo Drop old cloud database
sed -i "" -e 's/^DBHOST=.*/DBHOST='${DEVCLOUD}'/' build/replace.properties
echo Update the database
sudo touch /tmp/a
vagrant ssh management -c "mysql -u cloud --password=cloud -e 'drop database cloud;'"
cd ${CLOUDSTACK}
echo Copy developer-prefill.sql
cp ${SCRIPT_LOCATION}/developer-prefill.sql ${CLOUDSTACK}/developer/developer-prefill.sql.override
mvn -P developer ${NOREDIST} -Ddeploydb -pl developer
sudo touch /tmp/a
cd ${CLOUDSTACK}
rm -f vmops.log
rm -f jetty-console.out
if [ ! -z "${BUILD}" ]
then
echo Building CloudStack
mvn -T 2C -Psystemvm ${NOREDIST} clean install
fi
echo Start CloudStack
cd ${CLOUDSTACK}
mvn -P systemvm ${NOREDIST} -pl :cloud-client-ui jetty:run > jetty-console.out 2>&1 &
SERVER_PID=$!
echo Clean the xenserver
sudo touch /tmp/a
python "${SCRIPT_LOCATION}"/xapi_cleanup_xenservers.py http://${HYPERVISOR} root password
# Check for initialization of the management server
COUNTER=0
while [ "$COUNTER" -lt 34 ] ; do
if grep -q 'Management server node 127.0.0.1 is up' jetty-console.out ; then
break
fi
sleep 5
COUNTER=$(($COUNTER+1))
done
sudo touch /tmp/a
if grep -q 'Management server node 127.0.0.1 is up' jetty-console.out ; then
echo Started OK
sleep 20
echo Provisioning CloudStack with devcloud zone
python ${CLOUDSTACK}/tools/marvin/marvin/deployDataCenter.py -i ${SCRIPT_LOCATION}/config/devcloud-advanced.cfg
python "${SCRIPT_LOCATION}"/cloudstack_checkssvmalive.py
if [ ! -z "${PREPARE}" ] ; then
echo "CloudStack running with PID $SERVER_PID"
exit
fi
sleep 30
python "${SCRIPT_LOCATION}"/cloudstack_test_basic_instance.py
fi
mvn -P systemvm -pl :cloud-client-ui jetty:stop
#sleep 30
#kill -KILL $SERVER_PID