summaryrefslogtreecommitdiffstats
path: root/controller/run_remote
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2014-10-22 08:54:05 +0200
committerPavel Raiskup <praiskup@redhat.com>2014-10-22 08:54:05 +0200
commit2422a081a5be0d5ac5afb122361bc283da67341f (patch)
treecb255582060af6547dd9318c56ba0e8c761846a1 /controller/run_remote
parent922089746e1029de9be986672fcdeb6bc82e18d7 (diff)
downloadpostgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.tar.gz
postgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.tar.xz
postgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.zip
big reorg: prepare for generalization
Try to split into three separate components -> controller, tester, and 'tasks' (postgresql-tasks in our case). The controller component is the main part which is able to run the task remotely. Tester is more-like library for 'tasks' component (should be reusable on the raw git level). * controller: Almost separated component. * postgresql-tasks: Likewise. * tester: Likewise.
Diffstat (limited to 'controller/run_remote')
-rwxr-xr-xcontroller/run_remote101
1 files changed, 101 insertions, 0 deletions
diff --git a/controller/run_remote b/controller/run_remote
new file mode 100755
index 0000000..0f7ccc3
--- /dev/null
+++ b/controller/run_remote
@@ -0,0 +1,101 @@
+#!/bin/bash
+
+. config/config.sh || {
+ echo >&2 "sorry, but config/config.sh not found"
+ exit 1
+}
+
+longopts="verbose,help,force,testid:,listonly"
+
+run_playbook=${run_playbook-ansible/fedora.yml}
+
+opt_workdir=/var/tmp/dbt-results
+opt_distro=fedora
+opt_openstack_instance="$DTF_OPENSTACK_ID"
+opt_distro_ver=20
+opt_extra_rpms=
+opt_taskdir=
+
+die() { echo >&2 "$@" ; exit 1 ; }
+
+longopts="distro:,distro-version:,workdir:,openstack-instance:,extra-rpms-file:"
+longopts+=",taskdir:"
+ARGS=$(getopt -o "v" -l "$longopts" -n "getopt" -- "$@") \
+ || exit 1
+eval set -- "$ARGS"
+
+while true; do
+ case "$1" in
+ --taskdir)
+ opt=$(sed -e 's/^--//' -e 's/[^[a-zA-Z0-9]/_/g'<<<"$1")
+ eval "opt_$opt=\"${2,,}\""
+ shift 2
+ ;;
+
+ --distro)
+ opt_distro="$2"
+ shift 2
+ ;;
+
+ --distro-version)
+ opt_distro_ver="$2"
+ shift 2
+ ;;
+
+ --openstack-instance)
+ opt_openstack_instance="$2"
+ shift 2
+ ;;
+
+ --workdir)
+ # where the remote results are fetched into
+ opt_workdir="$2"
+ shift 2
+ ;;
+
+ --extra-rpms-file)
+ opt_extra_rpms="$(readlink -f "$2")"
+ shift 2
+ ;;
+
+ --)
+ shift
+ break
+ ;;
+ esac
+done
+
+test -z "$opt_taskdir" && die "you must specify --taskdir"
+
+credsfile="$(readlink -f "./private/os/$opt_openstack_instance.yml")"
+test -z "$credsfile" && die "--ansible-creds option must be specified"
+test ! -f "$credsfile" && die "file $credsfile not found"
+
+config_os_file="$(readlink -f "./config/os/$opt_openstack_instance.sh")"
+test ! -r "$config_os_file" && die "file $config_os_file not found"
+. "$config_os_file"
+
+config_os_id="$opt_distro$opt_distro_ver"
+
+tarball()
+(
+ testsuite_name="$(basename "$opt_taskdir")"
+ echo "$testsuite_name"
+ "$opt_taskdir/run" --dist | gzip > "$opt_workdir/$testsuite_name.tar.gz"
+)
+
+testsuite_name="$(tarball)" || die "can not create dist tarball"
+
+export ANSIBLE_HOST_KEY_CHECKING=False
+ansible-playbook "$run_playbook" \
+ --extra-vars "opt_distro=$opt_distro" \
+ --extra-vars "opt_distro_ver=$opt_distro_ver" \
+ --extra-vars "opt_workdir=$opt_workdir" \
+ --extra-vars "opt_credsfile=$credsfile" \
+ --extra-vars "os_flavor_id=${os_flavor_ids[$config_os_id]}" \
+ --extra-vars "os_image_id=${os_image_ids[$config_os_id]}" \
+ --extra-vars "os_keypair=${os_keypair}" \
+ --extra-vars "os_security_group=${os_security_group}" \
+ --extra-vars "os_network_dev=${os_network_dev}" \
+ --extra-vars "opt_testsuite_name=${testsuite_name}" \
+ --extra-vars "${opt_extra_rpms:+dtf_rpm_files_list=$opt_extra_rpms}"