[PATCH v3 0/7] Process synchronisation routines
by Hubert Kario
Hi all,
More or less final version, full functionality together with
test suite.
I haven't tested on RHEL 3 as the test harness doesn't work:
./test.sh: line 82: conditional binary operator expected
./test.sh: line 82: syntax error near `=~'
./test.sh: line 82: ` if [[ "$status" =~ ^$expected$ ]]; then'
RHEL 4 and RHEL5 (!) isn't much better:
File "/root/beakerlib/src/test/../python/journalling.py", line 351
with open("/etc/redhat-release", "r") as release_file:
^
SyntaxError: invalid syntax
rlJournalStart: Failed to initialize the journal. Bailing out...
I verified the library using the automated test suite on Fedora 19,
RHEL 6 and RHEL 7. I also manually checked if it works correctly
on RHEL 5 by copying it to /plugins and running few simple tests
the usual way. And, as I've mentioned in comments and previously,
it /should/ work on RHEL3 and later, trivial errors not
withstanding.
Regards,
Hubert
Hubert Kario (7):
new routines for socket based synchronisation
add synchronisation to system library
use internal killtree, to not leave running sleep commands behind
add rlWaitForCmd
change rlWaitForSocket to use shared code
add rlWaitForFile
add tests for all synchronisation routines
src/Makefile | 1 +
src/beakerlib.sh | 1 +
src/synchronisation.sh | 463 ++++++++++++++++++++++++++++++++++++++++
src/test/synchronisationTest.sh | 238 +++++++++++++++++++++
4 files changed, 703 insertions(+)
create mode 100644 src/synchronisation.sh
create mode 100644 src/test/synchronisationTest.sh
--
1.8.3.1
10 years, 4 months
rlCleanup / testwatcher test coverage
by Jiri Jaburek
Hi,
I've been working on (at least some) test coverage for the recently
added rlCleanup* functions and the (rather separate) testwatcher.py
and I found a few bugs in the process as well.
Everything related (patches) should be in References to this email,
see the commit messages or code comments for more details.
Thanks for the review (if any).
Also thanks to Roman Rakus for help with escaping quotes in bash.
-- JJ
10 years, 4 months
[PATCH 0/2] RFC: Functions for process synchronisation
by Hubert Kario
Hi all,
As the time when Tiers will be split to 1/2/3 draws near, and
with it tighter time limits on Tier 1 tasks, I thought that using
"sleep n" for process synchronisation is a little bit too hackish.
The first routine I made is able to wait for some process to
start listening on a socket (either network or UNIX). With that
I'm able to execute tasks need to start many network servers in
background much quicker on fast systems (majority of x86_64
machines) while the tasks still execute properly on s390x.
I'll be working on making a more universal solution, including
solution to bug 970143.
Hubert Kario (2):
new routines for socket based synchronisation
add synchronisation to system library
src/Makefile | 1 +
src/beakerlib.sh | 1 +
src/synchronisation.sh | 182 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 184 insertions(+)
create mode 100644 src/synchronisation.sh
--
1.8.3.1
10 years, 5 months
[PATCH] rlWaitForSocket - add waiting for socket closure
by Hubert Kario
Add ability to wait for the socket to stop listening.
Signed-off-by: Hubert Kario <hkario(a)redhat.com>
---
src/synchronisation.sh | 17 ++++++++++++++---
src/test/synchronisationTest.sh | 26 ++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/synchronisation.sh b/src/synchronisation.sh
index d29affd..15e5602 100644
--- a/src/synchronisation.sh
+++ b/src/synchronisation.sh
@@ -384,7 +384,7 @@ Pauses script execution until socket starts listening.
Returns 0 if socket started listening, 1 if timeout was reached or PID exited.
Return code is greater than 1 in case of error.
- rlWaitForSocket {port|path} [-p PID] [-t time] [-d delay]
+ rlWaitForSocket {port|path} [-p PID] [-t time] [-d delay] [--close]
=over
@@ -407,6 +407,10 @@ the socket is opened, the command returns with status code of 1.
Delay between subsequent checks for availability of socket. Default 1.
+=item --close
+
+Wait for the socket to stop listening.
+
=back
=cut
@@ -417,9 +421,10 @@ rlWaitForSocket(){
local proc_pid=1
local delay=1
local socket=""
+ local close=""
# that is the GNU extended getopt syntax!
- local TEMP=$(getopt -o t:p:d: -n 'rlWaitForSocket' -- "$@")
+ local TEMP=$(getopt -o t:p:d: --longoptions close -n 'rlWaitForSocket' -- "$@")
if [[ $? != 0 ]] ; then
rlLogError "rlWaitForSocket: Can't parse command options, terminating..."
return 127
@@ -435,6 +440,8 @@ rlWaitForSocket(){
;;
-d) delay="$2"; shift 2
;;
+ --close) close="true"; shift 1
+ ;;
--) shift 1
break
;;
@@ -464,7 +471,11 @@ rlWaitForSocket(){
local cmd="netstat -nl | grep -E '$grep_opt' >/dev/null"
- __INTERNAL_wait_for_cmd "rlWaitForSocket" "${cmd}" -t $timeout -p $proc_pid -d $delay
+ if [[ ${close:-false} == true ]]; then
+ __INTERNAL_wait_for_cmd "rlWaitForSocket" "${cmd}" -t $timeout -p $proc_pid -d $delay -r 1
+ else
+ __INTERNAL_wait_for_cmd "rlWaitForSocket" "${cmd}" -t $timeout -p $proc_pid -d $delay
+ fi
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/src/test/synchronisationTest.sh b/src/test/synchronisationTest.sh
index a7d81ca..6681741 100644
--- a/src/test/synchronisationTest.sh
+++ b/src/test/synchronisationTest.sh
@@ -34,6 +34,32 @@ test_rlWaitForSocketPositive() {
rm -rf $test_dir
}
+test_rlWaitForSocketClose() {
+ local test_dir=$(mktemp -d /tmp/beakerlib-test-XXXXXX)
+
+ (nc -l 12345 > $test_dir/out) &
+ local bg_pid=$!
+
+ (sleep 5; kill $bg_pid)&
+
+ silentIfNotDebug "rlWaitForSocket 12345"
+ local ret=$?
+ assertTrue "Check if rlWaitForSocket return 0 when socket is opened" "[[ $ret -eq 0 ]]"
+
+ silentIfNotDebug "echo 'hello world' | nc localhost 12345"
+
+ silentIfNotDebug "rlWaitForSocket 12345 --close"
+ local ret=$?
+ assertTrue "Check if rlWaitForSocket return 0 when socket is closed" "[[ $ret -eq 0 ]]"
+
+ kill -s SIGKILL $bg_pid 2>/dev/null 1>&2
+ wait $bg_pid 2>/dev/null 1>&2
+
+ assertTrue "Check if data was transferred" "grep 'hello world' $test_dir/out"
+
+ rm -rf $test_dir
+}
+
test_rlWaitForSocketTimeoutReached() {
local test_dir=$(mktemp -d /tmp/beakerlib-test-XXXXXX)
--
1.8.3.1
10 years, 5 months
[PATCH] Bash 'wait' wrapper
by Hubert Kario
Hi all,
during work to make few tests use the new synchronise functions,
I've noticed that I'm re-using the same piece od code in few places.
So, reduce it, I'm intorducing rlWait, used just like bash 'wait'
but with ability to specify timeout and the signal used to kill
the command we are waiting for. Since I want the return value of
the background task, rlWatchdog didn't really cut it...
Needs to be applied on top of the synchronisation.sh patches.
Hubert Kario (1):
add rlWait
src/synchronisation.sh | 95 +++++++++++++++++++++++++++++++++++------
src/test/synchronisationTest.sh | 57 +++++++++++++++++++++++++
2 files changed, 140 insertions(+), 12 deletions(-)
--
1.8.3.1
10 years, 5 months
[PATCH v2 0/6] RFC: Add synchronisation routines
by Hubert Kario
Hi all,
New set of patches, with suggested fixes, plus few extra things
I noticed during work.
Since there is no test suite, I'm leaving RFC in place.
Hubert Kario (6):
new routines for socket based synchronisation
add synchronisation to system library
use internal killtree, to not leave running sleep commands behind
add rlWaitForCmd
change rlWaitForSocket to use shared code
add rlWaitForFile
src/Makefile | 1 +
src/beakerlib.sh | 1 +
src/synchronisation.sh | 448 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 450 insertions(+)
create mode 100644 src/synchronisation.sh
--
1.8.3.1
10 years, 5 months