summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Peck <bpeck@redhat.com>2015-04-10 13:56:50 -0400
committerBill Peck <bpeck@redhat.com>2015-04-10 13:56:50 -0400
commit81b2cb2b49906f22c3d586c9ef3fadd71c5f37c6 (patch)
tree8cd5929d3097120e828dc81410550442674fd48b
parent9fe51c205047d822e75084026a065186175ae333 (diff)
downloadtests-81b2cb2b49906f22c3d586c9ef3fadd71c5f37c6.tar.gz
tests-81b2cb2b49906f22c3d586c9ef3fadd71c5f37c6.tar.xz
tests-81b2cb2b49906f22c3d586c9ef3fadd71c5f37c6.zip
See if command will still be running after test finishes
-rw-r--r--restraint/nohup/metadata12
-rwxr-xr-xrestraint/nohup/remotehost-sync.sh106
-rwxr-xr-xrestraint/nohup/runtest.sh7
3 files changed, 125 insertions, 0 deletions
diff --git a/restraint/nohup/metadata b/restraint/nohup/metadata
new file mode 100644
index 0000000..ee669e1
--- /dev/null
+++ b/restraint/nohup/metadata
@@ -0,0 +1,12 @@
+[General]
+name=/restraint/nohup
+owner=Bill Peck <bpeck@redhat.com>
+description=test if a process will be still running after
+license=GPLv2
+confidential=no
+destructive=no
+
+[restraint]
+entry_point=./runtest.sh
+dependencies=coreutils
+max_time=15m
diff --git a/restraint/nohup/remotehost-sync.sh b/restraint/nohup/remotehost-sync.sh
new file mode 100755
index 0000000..c9a63c7
--- /dev/null
+++ b/restraint/nohup/remotehost-sync.sh
@@ -0,0 +1,106 @@
+#!/bin/sh
+
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
+# remotehost-sync-setup
+# - Set variables for PORT/DELAY/DIR
+# - create directory for state_messages
+# - run web server used for sharing/checking state_messages
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
+function remotehost-sync-setup()
+{
+ echo "$FUNCNAME $@"
+
+ local RETURNCODE=0
+ export IPA_SYNC_PORT=8907
+ export IPA_SYNC_DELAY=30
+ export IPA_SYNC_DIR=/tmp/ipasync
+
+ mkdir -p $IPA_SYNC_DIR
+ pushd $IPA_SYNC_DIR
+ if [ $(python --version 2>&1|awk '{print $2}'|cut -f1 -d.) -eq 2 ]; then
+ IPA_SYNC_WEBMOD=SimpleHTTPServer;
+ else
+ IPA_SYNC_WEBMOD=http.server;
+ fi
+
+ ps -ef|grep "Simple[H]TTPServer.*${IPA_SYNC_PORT}"
+ if [ $? -eq 1 ]; then
+ echo "remotehost-sync web server not running on $IPA_SYNC_PORT. starting"
+ python -m $IPA_SYNC_WEBMOD $IPA_SYNC_PORT > /var/log/python_web_server.log 2>&1 &
+ else
+ echo "remotehost-sync web server running on $IPA_SYNC_PORT. Using that one."
+ fi
+
+ if [ $? -eq 0 ]; then
+ export IPA_SYNC_PID=$(ps -ef|grep "py[t]hon.*$IPA_SYNC_PORT"|awk '{print $2}')
+ else
+ echo "[ FAIL ] :: WEB SERVER FAILED TO START!!!!!!!!!!!!!!!"
+ export IPA_SYNC_PID="SERVERFAILED"
+ RETURNCODE=1
+ fi
+ popd
+ return $RETURNCODE
+}
+
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
+# remotehost-sync-block -s <state_message> <hostname> [<hostname> ...]
+# - block actions on server where it is run until <hostname> sets
+# expected <state_message>
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
+function remotehost-sync-block()
+{
+ echo "$FUNCNAME $@"
+ export IPA_SYNC_PORT=8907
+ export IPA_SYNC_DELAY=30
+ export IPA_SYNC_DIR=/tmp/ipasync
+
+ local DASH_S=$1
+ local MESSAGE=$2
+ local HOSTS="$3 $4 $5 $6 $7 $8 $9"
+ local HOST=""
+
+ ps -ef|grep "${IPA_SYNC_PID}.*Simple[H]TTPServer.*${IPA_SYNC_PORT}"
+ if [ $? -eq 1 ]; then
+ echo "ipa-sync web server not running on $IPA_SYNC_PORT. starting"
+ remotehost-sync-setup
+ fi
+
+ while true; do
+ for HOST in $HOSTS; do
+ #echo "wget -O/dev/null http://$HOST:$IPA_SYNC_PORT/$MESSAGE"
+ wget -qO/dev/null http://$HOST:$IPA_SYNC_PORT/$MESSAGE
+ if [ $? -eq 0 ]; then
+ HOSTS="$(echo $HOSTS|sed s/$HOST//|sed 's/ / /g')"
+ fi
+ done
+ if [ -n "$HOSTS" ]; then
+ sleep $IPA_SYNC_DELAY
+ else
+ break
+ fi
+ done
+}
+
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
+# remotehost-sync-set -s <state_message> [-m <hostname>]
+# - set <state_message> on localhost (even if <hostname given>)
+# - unblocks servers using remotehost-sync-block waiting on <state_message>
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
+function remotehost-sync-set()
+{
+ echo "$FUNCNAME $@"
+ export IPA_SYNC_PORT=8907
+ export IPA_SYNC_DELAY=30
+ export IPA_SYNC_DIR=/tmp/ipasync
+
+ local DASH_S=$1
+ local MESSAGE=$2
+
+ ps -ef|grep "${IPA_SYNC_PID}.*Simple[H]TTPServer.*${IPA_SYNC_PORT}"
+ if [ $? -eq 1 ]; then
+ echo "ipa-sync web server not running on $IPA_SYNC_PORT. starting"
+ remotehost-sync-setup
+ fi
+
+ touch "$IPA_SYNC_DIR/$MESSAGE"
+}
diff --git a/restraint/nohup/runtest.sh b/restraint/nohup/runtest.sh
new file mode 100755
index 0000000..33461b4
--- /dev/null
+++ b/restraint/nohup/runtest.sh
@@ -0,0 +1,7 @@
+#!/bin/bash -x
+
+. ./remotehost-sync.sh
+
+remotehost-sync-set -s FOO
+
+sleep 300 && rstrnt-report-result $RSTRNT_TASKNAME PASS