Skip to content

Commit

Permalink
t/t1004-kvs-namespace.t: Minor cleanup
Browse files Browse the repository at this point in the history
Use KVS_WAIT_ITERS instead of hard coding 50.

Call wait_watch_put() to remove duplicate code.

General code cleanup.
  • Loading branch information
chu11 committed Jan 4, 2018
1 parent 300b8de commit 5d155cb
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions t/t1004-kvs-namespace.t
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dir_kvs_namespace_exitvalue() {

namespace_create_loop() {
i=0
while ! flux kvs namespace-create $1 && [ $i -lt 50 ]
while ! flux kvs namespace-create $1 && [ $i -lt ${KVS_WAIT_ITERS} ]
do
sleep 0.1
i=$((i + 1))
Expand All @@ -100,7 +100,8 @@ namespace_create_loop() {

get_kvs_namespace_all_ranks_loop() {
i=0
while ! flux exec sh -c "export FLUX_KVS_NAMESPACE=$1; flux kvs get $2" && [ $i -lt 50 ]
while ! flux exec sh -c "export FLUX_KVS_NAMESPACE=$1; flux kvs get $2" \
&& [ $i -lt ${KVS_WAIT_ITERS} ]
do
sleep 0.1
i=$((i + 1))
Expand All @@ -110,7 +111,8 @@ get_kvs_namespace_all_ranks_loop() {

get_kvs_namespace_fails_all_ranks_loop() {
i=0
while ! flux exec sh -c "export FLUX_KVS_NAMESPACE=$1; ! flux kvs get $2" && [ $i -lt 50 ]
while ! flux exec sh -c "export FLUX_KVS_NAMESPACE=$1; ! flux kvs get $2" \
&& [ $i -lt ${KVS_WAIT_ITERS} ]
do
sleep 0.1
i=$((i + 1))
Expand All @@ -120,19 +122,16 @@ get_kvs_namespace_fails_all_ranks_loop() {

wait_watch_put_namespace() {
export FLUX_KVS_NAMESPACE=$1
i=0
while [ "$(flux kvs get --json $2 2> /dev/null)" != "$3" ] && [ $i -lt 50 ]
do
sleep 0.1
i=$((i + 1))
done
wait_watch_put $2 $3
exitvalue=$?
unset FLUX_KVS_NAMESPACE
return $(loophandlereturn $i)
return $exitvalue
}

wait_fencecount_nonzero() {
i=0
while [ "$(flux exec -r $1 sh -c "flux module stats --parse namespace.$2.#fences kvs" 2> /dev/null)" == "0" ] && [ $i -lt 50 ]
while [ "$(flux exec -r $1 sh -c "flux module stats --parse namespace.$2.#fences kvs" 2> /dev/null)" == "0" ] \
&& [ $i -lt ${KVS_WAIT_ITERS} ]
do
sleep 0.1
i=$((i + 1))
Expand Down

0 comments on commit 5d155cb

Please sign in to comment.