copy-to-and-from-multi-providers.sh 1.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
#!/bin/bash -x

if [ -z $srcdir ]; then
    echo srcdir variable not set.
    exit 1
fi
source $srcdir/tests/test-util.sh

# start 1 server with 2 providers, 2 second wait, 20s timeout
test_start_servers_multi_providers 1 2 2 20 

# actual test case
#####################

# Writing foo1.dat to provider 1
echo "Hello world first provider." > $TMPBASE/foo1.dat
CPOUT=`run_to 10 src/bake-copy-to $TMPBASE/foo1.dat $svr1 1 1`
if [ $? -ne 0 ]; then
    run_to 10 src/bake-shutdown $svr1
    wait
    exit 1
fi
RID1=`echo "$CPOUT" | grep -o -P '/tmp.*$'`

# Writing foo2.dat to provider 2
echo "Hello world second provider." > $TMPBASE/foo2.dat
CPOUT=`run_to 10 src/bake-copy-to $TMPBASE/foo2.dat $svr1 2 1`
if [ $? -ne 0 ]; then
    run_to 10 src/bake-shutdown $svr1
    wait
    exit 1
fi
RID2=`echo "$CPOUT" | grep -o -P '/tmp.*$'`

# Reading from provider 1
run_to 10 src/bake-copy-from $svr1 1 $RID1 $TMPBASE/foo1-out.dat 
if [ $? -ne 0 ]; then
    run_to 10 src/bake-shutdown $svr1
    wait
    exit 1
fi

cat $TMPBASE/foo1-out.dat
sleep 1

# Reading from provider 2 
run_to 10 src/bake-copy-from $svr1 2 $RID2 $TMPBASE/foo2-out.dat 
if [ $? -ne 0 ]; then
    run_to 10 src/bake-shutdown $svr1
    wait
    exit 1
fi

cat $TMPBASE/foo2-out.dat
sleep 1

#####################

# tear down
run_to 10 src/bake-shutdown $svr1
if [ $? -ne 0 ]; then
    wait
    exit 1
fi

wait

echo cleaning up $TMPBASE
rm -rf $TMPBASE

exit 0