]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
tests: Adding parallelism helpers in ceph-helpers.sh
authorErwan Velu <erwan@redhat.com>
Thu, 24 Mar 2016 09:57:38 +0000 (10:57 +0100)
committerErwan Velu <erwan@redhat.com>
Tue, 5 Apr 2016 07:36:25 +0000 (09:36 +0200)
commitdb31cc6cbcdb2f42ff0acaed90bc029d1720cfca
treec5cac859be6b2f3f9fae3a8f1125c615f10eb0f1
parentcf5d2777b8c4e378001beb968aa6ca362017a775
tests: Adding parallelism helpers in ceph-helpers.sh

This commit introduce two new functions in ceph-helpers.sh to ease
parallelism in tests.

It's based on two functions : run_in_background() & wait_background()

The first one allow you to spawn processes or functions in background and saves
the associated pid in a variable passed as first argument.

The second one waits for thoses pids to complete and report their exit status.
If one or more failed then wait_background() reports a failure.

A typical usage looks like :

 pids1=""
 run_in_background pids1 bash -c 'sleep 5; exit 0'
 run_in_background pids1 bash -c 'sleep 1; exit 1'
 run_in_background pids1 my_bash_function
 wait_background pids1

The variable that contains pids is local making possible to do nested calls of
thoses two new functions.

Signed-off-by: Erwan Velu <erwan@redhat.com>
qa/workunits/ceph-helpers.sh