vm flag and wip vsh rework
Signed-off-by: Ava Hahn <a.hahn@f5.com>
This commit is contained in:
parent
8c91778fe1
commit
b47476bd69
5 changed files with 266 additions and 195 deletions
188
test.sh
188
test.sh
|
|
@ -5,17 +5,26 @@ source $dirn/common.sh
|
|||
source $dirn/virt.sh
|
||||
source $dirn/nginx.sh
|
||||
|
||||
if [[ ! $(vms_avail) ]]; then
|
||||
log "no VMs available!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nginx_dir=""
|
||||
otel_dir=""
|
||||
tests_dir=""
|
||||
vm_list=""
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
-h | --help)
|
||||
log "test.sh: build and test code on many libvirt VMs at once"
|
||||
log " -h, --help: show this help text"
|
||||
log " -n <dir>, --nginx <dir>: specify an nginx directory"
|
||||
log " -o <dir>, --otel <dir>: specify an nginx-otel directory"
|
||||
log " -t <dir>, --tests <dir>: specify an nginx-tests directory"
|
||||
log " -n <dir>, --nginx <dir>: specify an nginx directory"
|
||||
log " -o <dir>, --otel <dir>: specify an nginx-otel directory"
|
||||
log " -t <dir>, --tests <dir>: specify an nginx-tests directory"
|
||||
log " --vm <name>: (optional) specify a VM to operate on"
|
||||
log " may be specified multiple times, or none"
|
||||
log " defaults to all available VMs"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
|
|
@ -43,6 +52,17 @@ while [ $# -gt 0 ]; do
|
|||
tests_dir=$2
|
||||
;;
|
||||
|
||||
--vm)
|
||||
[ $2 ] || ( \
|
||||
log "VM must be specified" && \
|
||||
exit 1 )
|
||||
[[ $vms_available == *"$2"* ]] || ( \
|
||||
log "VM not available" && \
|
||||
exit 1 )
|
||||
[ $vm_list ] && vm_list+="\n"
|
||||
vm_list+=$2
|
||||
;;
|
||||
|
||||
*)
|
||||
log "unknown argument: $1"
|
||||
exit 1
|
||||
|
|
@ -52,9 +72,13 @@ while [ $# -gt 0 ]; do
|
|||
shift
|
||||
done
|
||||
|
||||
vm_nginx_dir=$(basename $nginx_dir)
|
||||
vm_otel_dir=$(basename $otel_dir)
|
||||
vm_tests_dir=$(basename $tests_dir)
|
||||
[ $nginx_dir ] && vm_nginx_dir=$(basename $nginx_dir)
|
||||
[ $otel_dir ] && vm_otel_dir=$(basename $otel_dir)
|
||||
[ $tests_dir ] && vm_tests_dir=$(basename $tests_dir)
|
||||
|
||||
if [ ! $vm_list ]; then
|
||||
vm_list=$(vms_avail)
|
||||
fi
|
||||
|
||||
section "script init..."
|
||||
if [[ ! -d $test_log_dir ]]; then
|
||||
|
|
@ -70,76 +94,93 @@ log "nginx code dir: $nginx_dir"
|
|||
log "nginx test dir: $tests_dir"
|
||||
log "otel code dir: $otel_dir"
|
||||
|
||||
function syncs() {
|
||||
sync_dir_to_vm $1 $nginx_dir
|
||||
sync_dir_to_vm $1 $tests_dir
|
||||
sync_dir_to_vm $1 $otel_dir
|
||||
function sync_all_to_remote() {
|
||||
# test inverse because function can only return false
|
||||
# when a command fails
|
||||
|
||||
([[ ! $nginx_dir ]] || sync_dir_to_vm $1 $nginx_dir) && \
|
||||
([[ ! $tests_dir ]] || sync_dir_to_vm $1 $tests_dir) && \
|
||||
([[ ! $otel_dir ]] || sync_dir_to_vm $1 $otel_dir )
|
||||
}
|
||||
|
||||
function build_nginx() {
|
||||
vm_shell $1 \
|
||||
"echo 'BEGIN BUILD'; set -ex; \
|
||||
$(typeset -f build_nginx_remote); \
|
||||
cd $vm_nginx_dir; \
|
||||
build_nginx_remote;"
|
||||
return $?
|
||||
function build_nginx_remote() {
|
||||
vm_cmd $1 \
|
||||
"set -ex;
|
||||
$(typeset WHT)
|
||||
$(typeset END)
|
||||
$(typeset -f log)
|
||||
$(typeset -f num_jobs)
|
||||
$(typeset -f build_nginx)
|
||||
cd $vm_nginx_dir;
|
||||
build_nginx"
|
||||
}
|
||||
|
||||
function build_otel() {
|
||||
vm_shell $1 \
|
||||
"echo 'BEGIN BUILD'; set -ex; \
|
||||
$(typeset -f build_otel_remote); \
|
||||
cd $vm_otel_dir; \
|
||||
build_otel_remote;"
|
||||
return $?
|
||||
function build_otel_remote() {
|
||||
vm_cmd $1 \
|
||||
"set -ex;
|
||||
$(typeset WHT)
|
||||
$(typeset END)
|
||||
$(typeset -f log)
|
||||
$(typeset -f num_jobs)
|
||||
$(typeset -f build_otel)
|
||||
cd $vm_otel_dir;
|
||||
build_otel"
|
||||
}
|
||||
|
||||
function test_nginx() {
|
||||
vm_shell $1 \
|
||||
"echo 'BEGIN TESTS'; set -ex; \
|
||||
$(typeset -f test_nginx_remote); \
|
||||
cd $vm_tests_dir; \
|
||||
test_nginx_remote;"
|
||||
return $?
|
||||
function test_nginx_remote() {
|
||||
vm_cmd $1 \
|
||||
"set -ex;
|
||||
$(typeset WHT)
|
||||
$(typeset END)
|
||||
$(typeset -f log)
|
||||
$(typeset -f num_jobs)
|
||||
$(typeset -f test_nginx)
|
||||
cd $vm_tests_dir;
|
||||
test_nginx"
|
||||
}
|
||||
|
||||
function test_otel() {
|
||||
vm_shell $1 \
|
||||
"echo 'BEGIN TESTS'; set -ex; \
|
||||
$(typeset -f test_otel_remote); \
|
||||
cd $vm_otel_dir; \
|
||||
test_otel_remote;"
|
||||
return $?
|
||||
function test_otel_remote() {
|
||||
vm_cmd $1 \
|
||||
"set -ex;
|
||||
$(typeset WHT)
|
||||
$(typeset END)
|
||||
$(typeset -f log)
|
||||
$(typeset -f num_jobs)
|
||||
$(typeset -f test_otel)
|
||||
cd $vm_otel_dir;
|
||||
test_otel"
|
||||
}
|
||||
|
||||
function clean_nginx() {
|
||||
vm_shell $1 \
|
||||
"set -ex; \
|
||||
$(typeset -f clean_nginx_remote); \
|
||||
cd $vm_nginx_dir; \
|
||||
clean_nginx_remote;"
|
||||
return $?
|
||||
function clean_nginx_remote() {
|
||||
vm_cmd $1 \
|
||||
"set -ex;
|
||||
$(typeset -f clean_nginx)
|
||||
cd $vm_nginx_dir;
|
||||
clean_nginx"
|
||||
}
|
||||
|
||||
function clean_otel() {
|
||||
vm_shell $1 \
|
||||
"set -ex; \
|
||||
$(typeset -f clean_otel_remote); \
|
||||
cd $vm_otel_dir; \
|
||||
clean_otel_remote;"
|
||||
return $?
|
||||
function clean_otel_remote() {
|
||||
vm_cmd $1 \
|
||||
"set -ex;
|
||||
$(typeset -f clean_otel)
|
||||
cd $vm_otel_dir;
|
||||
clean_otel"
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
section "cleanup!"
|
||||
log "cleaning build directories"
|
||||
if ! parallel_invoke_and_wait \
|
||||
clean_nginx "$vm_list" "$test_log_dir/clean_nginx"; then
|
||||
clean_nginx_remote \
|
||||
"$vm_list" \
|
||||
"$test_log_dir/clean_nginx_"; then
|
||||
error "Failed to clean NGINX build directory"
|
||||
fi
|
||||
|
||||
if ! parallel_invoke_and_wait \
|
||||
clean_otel "$vm_list" "$test_log_dir/clean_otel"; then
|
||||
clean_otel_remote \
|
||||
"$vm_list" \
|
||||
"$test_log_dir/clean_otel_"; then
|
||||
error "Failed to clean otel build directory"
|
||||
fi
|
||||
|
||||
|
|
@ -151,14 +192,6 @@ function cleanup() {
|
|||
}
|
||||
|
||||
section "launching VMs"
|
||||
vms_avail
|
||||
if [[ "$ret" == "" ]]; then
|
||||
log "no VMs available!"
|
||||
exit 1
|
||||
fi
|
||||
vm_list=$ret
|
||||
ret=""
|
||||
|
||||
if ! parallel_invoke_and_wait \
|
||||
turn_on_vm_and_wait \
|
||||
"$vm_list" \
|
||||
|
|
@ -170,50 +203,61 @@ fi
|
|||
|
||||
section "syncing code to VMs"
|
||||
if ! parallel_invoke_and_wait \
|
||||
syncs "$vm_list" "$test_log_dir/sync_"; then
|
||||
sync_all_to_remote \
|
||||
"$vm_list" \
|
||||
"$test_log_dir/sync_"; then
|
||||
error "Failed to sync files to VMs"
|
||||
cleanup
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $nginx_dir ]; then
|
||||
if [ "$nginx_dir" ]; then
|
||||
section "building NGINX"
|
||||
if ! parallel_invoke_and_wait \
|
||||
build_nginx "$vm_list" "$test_log_dir/build_nginx_"; then
|
||||
build_nginx_remote \
|
||||
"$vm_list" \
|
||||
"$test_log_dir/build_nginx_"; then
|
||||
error "NGINX build failures detected"
|
||||
cleanup
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $otel_dir ]; then
|
||||
if [ "$otel_dir" ]; then
|
||||
section "building NGINX Otel module"
|
||||
if ! parallel_invoke_and_wait \
|
||||
build_otel "$vm_list" "$test_log_dir/build_otel_"; then
|
||||
build_otel_remote \
|
||||
"$vm_list" \
|
||||
"$test_log_dir/build_otel_"; then
|
||||
error "Otel build failures detected"
|
||||
cleanup
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $tests_dir ]; then
|
||||
if [ $nginx_dir ]; then
|
||||
if [ "$tests_dir" ]; then
|
||||
if [ "$nginx_dir" ]; then
|
||||
section "testing NGINX"
|
||||
if ! parallel_invoke_and_wait \
|
||||
test_nginx "$vm_list" "$test_log_dir/test_nginx_"; then
|
||||
test_nginx_remote \
|
||||
"$vm_list" \
|
||||
"$test_log_dir/test_nginx_"; then
|
||||
error "NGINX test failures detected"
|
||||
cleanup
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $otel_dir ]; then
|
||||
if [ "$otel_dir" ]; then
|
||||
section "testing NGINX Otel module"
|
||||
if ! parallel_invoke_and_wait \
|
||||
test_otel "$vm_list" "$test_log_dir/test_otel_"; then
|
||||
test_otel_remote \
|
||||
"$vm_list" \
|
||||
"$test_log_dir/test_otel_"; then
|
||||
error "Otel test failures detected"
|
||||
cleanup
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue