-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathjenkins-cs-precise
executable file
·178 lines (143 loc) · 5.94 KB
/
jenkins-cs-precise
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
#!/bin/bash
#
# $1 = test repo number
#
# force a local default so this can be run on command line
DISTRELEASE=${DISTRELEASE-ubuntu-precise}
PACKAGE_REPO=${PACKAGE_REPO-proposed-packages}
[ -e $(dirname $0)/jenkins-deb-common ] || exit 1
. $(dirname $0)/jenkins-deb-common
jenkins_init
jenkins_set_vars
t_kvm_instance_name=${BINARY_BUILD_RELEASE}-essex-allinone
kvm_instance_name="`echo ${t_kvm_instance_name} | tr A-Z a-z`"
chef_env=${kvm_instance_name}
# Cleanup from last run
rm -rf *.log
# this sets IP as a side-effect
get_ip $kvm_instance_name
function err_cleanup_chef() {
echo "*** ENTERING THE TRAP HANDLER"
# $1 - name
if [ "${NOCLEAN-0}" == "1" ]; then
exit 0
fi
echo "capturing stack trace output if it exists. Errors are OK here"
scp root@${IP}:/var/chef/cache/chef-stacktrace.out chef-stacktrace.out.log || :
echo "capturing collectd output"
scp -r root@${IP}:/etc/collectd/ . || :
# Delete node and client from chef-server
/opt/opscode/bin/knife node delete ${kvm_instance_name} -y || :
/opt/opscode/bin/knife client delete ${kvm_instance_name} -y || :
/opt/opscode/bin/knife environment delete -y ${kvm_instance_name} || :
sudo virsh destroy ${1}
sleep 5
sudo lvremove -f ${LVM_ROOT}/${1}
exit 1
}
MEMORY=2048000
maybe_make_kvm_instance $kvm_instance_name
trap "err_cleanup_chef ${kvm_instance_name}" SIGINT SIGTERM ERR
start_kvm_instance $kvm_instance_name ${IP} http://archive.ubuntu.com/ubuntu precise main
if [ ${BINARY_BUILD_VARIANT} = "debian" ]; then
ssh root@${IP} apt-get update -y --force-yes
ssh root@${IP} "DEBIAN_FRONTEND=noninteractive apt-get upgrade -y --force-yes"
ssh root@${IP} apt-get install vlan -y --force-yes
else
ssh root@${IP} rm -f /etc/cron.daily/man-db.cron
ssh root@${IP} yum -y --exclude=kernel* update
ssh root@${IP} yum install -y vconfig perl gcc make yum-fastestmirror redhat-lsb
ssh root@${IP} modprobe nbd
fi
ssh root@${IP} vconfig add eth0 100
ssh root@${IP} vconfig add eth0 101
if [ ${BINARY_BUILD_VARIANT} = "debian" ]; then
# Trying to fix a bug
count=1
while ! ssh root@${IP} "DEBIAN_FRONTEND=noninteractive apt-get install cgroup-lite -y --force-yes"; do
if [ $count -gt 3 ]; then
echo "Unable to install cgroup-lite"
exit 1
fi
if ! ( ssh root@${IP} "/usr/bin/cgroups-mount" ); then
:
fi
sleep 2;
count=$(( count + 1 ));
done
fi
# Install system pre-reqs
if [ ${BINARY_BUILD_VARIANT} = "debian" ]; then
ssh root@${IP} "apt-get install -y wget curl build-essential automake"
else
ssh root@${IP} "yum install -y wget tar"
#ssh root@${IP} "mkdir RPMS; cd RPMS; wget http://184.106.53.105/RPMS/euca2ools-2.0.1-0.1.fc17.noarch.rpm"
#ssh root@${IP} "cd RPMS; wget http://184.106.53.105/RPMS/python-boto-2.1.1-0.2.fc17.noarch.rpm"
#ssh root@${IP} "cd RPMS; yum install -y *.rpm"
fi
# Try to quiet installer
ssh root@${IP} 'echo "alias wget=\"wget -q\"" >> ~/.bashrc '
# Install ruby/chef via opscode's fullstack installer
if ! ( ssh root@${IP} "bash < <(curl -s http://s3.amazonaws.com/opscode-full-stack/install.sh)" ); then
echo "Unable to install Opscode FullStack Installer"
err_cleanup_chef ${kvm_instance_name}
exit 1
fi
# lets create the chef environment
tmp_env=$(mktemp)
cat ~/jenkins-build/files/example-environment.json | sed -e "s/REPLACEWITHNAME/${chef_env}/" > ${tmp_env}.json
if ! ( knife environment from file ${tmp_env}.json ); then
echo "Unable to create environment from ${tmp_env}.json"
exit 1
else
rm ${tmp_env}.json
knife environment show ${chef_env} -Fj
fi
# Setup Hosted Chef
#ssh root@${IP} 'wget -q http://c308412.r12.cf1.rackcdn.com/chef.tar.gz; tar -xvzf chef.tar.gz; knife configure client ./client-config'
# Setup chef to use our jenkins server
ssh root@${IP} 'wget -q http://c308412.r12.cf1.rackcdn.com/chef-server.tgz; tar -xvzf chef-server.tgz; knife configure client ./client-config'
ssh root@${IP} "echo 'environment \"${kvm_instance_name}\"' >> ~/client-config/client.rb"
if ! ( ssh root@${IP} "mkdir /etc/chef; cp -r ~/client-config/* /etc/chef/; chef-client" ); then
echo "Unable to register with chef-server"
err_cleanup_chef ${kvm_instance_name}
exit 1
fi
/opt/opscode/bin/knife node run_list add ${kvm_instance_name} role[jenkins-allinone]
/opt/opscode/bin/knife node run_list add ${kvm_instance_name} recipe[kong]
/opt/opscode/bin/knife node run_list add ${kvm_instance_name} recipe[exerstack]
ssh root@${IP} "chef-client "
sleep 20s
# These tests are not working on essex yet
ssh root@${IP} 'rm -rf /opt/exerstack/exercises/bundle.sh'
# ssh root@${IP} 'rm -rf /opt/exerstack/exercises/keystone-manage.sh'
ssh root@${IP} 'nova-manage service list'
if ! ( ssh root@${IP} 'cd /opt/exerstack; ONESHOT=1 ./exercise.sh essex-final euca.sh glance.sh keystone.sh nova-cli.sh ' ); then
scp root@${IP}:/var/log/nova/*.log .
scp root@${IP}:/var/log/glance/*.log .
scp root@${IP}:/var/log/keystone/*.log .
scp root@${IP}:/var/log/mysql/mysql.log .
echo "Exerstack test suite failed"
err_cleanup_chef ${kvm_instance_name}
exit 1
fi
if ! ( ssh root@${IP} 'cd /opt/kong; ./run_tests.sh --version essex-final --nova' ); then
scp root@${IP}:/var/log/nova/*.log .
scp root@${IP}:/var/log/glance/*.log .
scp root@${IP}:/var/log/keystone/*.log .
scp root@${IP}:/var/log/mysql/mysql.log .
echo "Kong test suite failed"
err_cleanup_chef ${kvm_instance_name}
exit 1
fi
# touching an ignore.log file to make the job not fail on artifact collection
touch ignore.log
trap - SIGINT SIGTERM ERR
echo "*** STARTING NODE SHUTDOWN"
# Delete node and client from chef-server
/opt/opscode/bin/knife node delete ${kvm_instance_name} -y || :
/opt/opscode/bin/knife client delete ${kvm_instance_name} -y || :
/opt/opscode/bin/knife environment delete -y ${kvm_instance_name} || :
sudo virsh destroy ${kvm_instance_name}
sleep 5
sudo lvremove -f ${LVM_ROOT}/${kvm_instance_name}