forked from AnythingLinux/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
180 lines (154 loc) · 4.2 KB
/
test.sh
File metadata and controls
180 lines (154 loc) · 4.2 KB
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
#!/bin/bash -xl
# note: the -l is needed here for bash to always make a login shell and load rvm if it hasn't been loaded
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# test script for build.sh which tries a variety of options/configs to make different vms
set -e
DEBUG="${DEBUG:-}"
TRACE="${TRACE:-0}"
###
### Configuration
###
if [[ "${DEBUG}" == "1" ]]; then
set -x
fi
# which test to run
test_to_run=${1:-}
# build.sh settings for running the tests
appliance=debianbase
version=`date "+%Y%m%d%H%M%S"`
branch=`git status | grep '# On branch' | awk '{print $4}'`
BUILD_NUMBER="${BUILD_NUMBER:-}"
ssh_key=
# where we are running the tests from
CURR_DIR=${PWD}
# where this script is
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# ensure we are running in isolation
if [ ${CURR_DIR} == ${SCRIPT_DIR} ]; then
mkdir -p ../appliance-work
cd ../appliance-work
CURR_DIR=${PWD}
fi
###
### testing 'framework'
###
function test_result() {
log INFO "$@"
add_on_exit log INFO "$@"
}
function run_test() {
set +e
cleanup
fixture
log INFO running test: "$@"
eval $@
result=$?
if ${result}; then
test_result "$@" FAIL
else
test_result "$@" OK
fi
cleanup
set -e
}
function cleanup() {
(
cd ${CURR_DIR};
rm -rf iso definitions Gemfile shar_cloud_scripts convert_ovf_vbox_to_esx.xslt .rvmrc;
)
}
function fixture() {
(
cd ${CURR_DIR};
mkdir -p ${SCRIPT_DIR}/iso;
ln -s ${SCRIPT_DIR}/iso;
mkdir definitions;
ln -s ${SCRIPT_DIR}/definitions/${appliance} definitions/${appliance};
ln -s ${SCRIPT_DIR}/Gemfile;
ln -s ${SCRIPT_DIR}/shar_cloud_scripts.sh;
ln -s ${SCRIPT_DIR}/convert_ovf_vbox_to_esx.xslt;
ln -s ${SCRIPT_DIR}/.rvmrc;
)
}
###
### Test definitions
###
function do_test_vm() {
prepare
create_definition
veewee_build
retry 10 check_appliance_shutdown
retry 10 remove_shares
veewee_destroy
}
function do_test_export() {
prepare
create_definition
veewee_build
retry 10 check_appliance_shutdown
retry 10 remove_shares
# Get appliance uuids
local vm_info=`vboxmanage showvminfo "${appliance_build_name}"`
local machine_uuid=`echo "${vm_info}" | grep UUID | head -1 | awk '{print $2}'`
local hdd_uuid=`echo "${vm_info}" | grep vdi | head -1 | awk '{print $8}' | cut -d ')' -f 1`
local hdd_path=`vboxmanage list hdds | grep "${appliance_build_name}\/" | grep vdi | \
cut -c 14- | sed ${sed_regex_option} 's/^ *//'`
compact_hdd "${hdd_uuid}"
xen_server_export "${hdd_path}"
kvm_export "${hdd_path}"
vmware_export "${machine_uuid}" "${hdd_uuid}"
hyperv_export "${hdd_uuid}"
veewee_destroy
}
function test_basic_veewee_invocation() {
appliance=debianbase
appliance_build_name=${appliance}${branch_tag}${version_tag}
do_test_vm
}
function test_export() {
appliance=debianbase
appliance_build_name=${appliance}${branch_tag}${version_tag}
do_test_export
}
function test_systemvm() {
appliance=systemvmtemplate
appliance_build_name=${appliance}${branch_tag}${version_tag}
do_test_vm
}
function test_systemvm64() {
appliance=systemvm64template
appliance_build_name=${appliance}${branch_tag}${version_tag}
do_test_vm
}
function test_suite() {
if [ "${test_to_run}" == "" ]; then
# list of all tests goes here
run_test test_basic_veewee_invocation
run_test test_systemvm
run_test test_systemvm64
run_test test_export
else
run_test "${test_to_run}"
fi
}
###
### Main invocation
###
source ${SCRIPT_DIR}/build.sh
return 2>/dev/null || test_suite