forked from facebook/wdt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wdt_e2e_simple_test.sh
executable file
·138 lines (107 loc) · 4.38 KB
/
wdt_e2e_simple_test.sh
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#! /bin/bash
#
# Smaller/minimal version of wdt_e2e_simple_test.sh
#
echo "Run from the cmake build dir (or ~/fbcode - or fbmake runtests)"
# Set DO_VERIFY:
# to 1 : slow/expensive but checks correctness
# to 0 : fast for repeated benchmarking not for correctness
DO_VERIFY=1
# Verbose / to debug failure:
#WDTBIN="_bin/wdt/wdt -minloglevel 0 -v 99"
# Normal:
WDTBIN_OPTS="-minloglevel=0 -sleep_millis 1 -max_retries 999 -full_reporting "\
"-avg_mbytes_per_sec=3000 -max_mbytes_per_sec=3500 "\
"-num_ports=4 -throttler_log_time_millis=200 -enable_checksum=true"
WDTBIN="_bin/wdt/wdt $WDTBIN_OPTS"
if [ -z "$HOSTNAME" ] ; then
echo "HOSTNAME not set, will try with 'localhost'"
HOSTNAME=localhost
else
echo "Will self connect to HOSTNAME=$HOSTNAME"
fi
BASEDIR=/tmp/wdtTest
mkdir -p $BASEDIR
DIR=`mktemp -d $BASEDIR/XXXXXX`
echo "Testing in $DIR"
#pkill -x wdt
mkdir $DIR/src
mkdir $DIR/extsrc
#cp -R wdt folly /usr/bin /usr/lib /usr/lib64 /usr/libexec /usr/share $DIR/src
#cp -R wdt folly /usr/bin /usr/lib /usr/lib64 /usr/libexec $DIR/src
#cp -R wdt $DIR/src
#for size in 1k 64K 512K 1M 16M 256M 512M 1G
#for size in 512K 1M 16M 256M 512M 1G
# Mac's dd doesn't understand K,M,G...
for size in 1024 65536 524288 1232896 19726336
do
base=inp$size
echo dd if=/dev/... of=$DIR/src/$base.1 bs=$size count=1
dd if=/dev/urandom of=$DIR/src/$base.1 bs=$size count=1
# dd if=/dev/zero of=$DIR/src/$base.1 bs=$size count=1
for i in {2..8}
do
cp $DIR/src/$base.1 $DIR/src/$base.$i
done
done
echo "done with setup"
# test symlink issues
(cd $DIR/src ; touch a; ln -s doesntexist badlink; dd if=/dev/zero of=c bs=1024 count=1; mkdir d; ln -s ../d d/e; ln -s ../c d/a)
(cd $DIR/extsrc; mkdir TestDir; mkdir TestDir/test; cd TestDir; echo "Text1" >> file1; cd test; echo "Text2" >> file1; ln -s $DIR/extsrc/TestDir; cp -R $DIR/extsrc/TestDir $DIR/src)
# Can't have both client and server send to stdout in parallel or log lines
# get mangled/are missing - so we redirect the server one
echo "$WDTBIN -minloglevel=1 -directory $DIR/dst > $DIR/server.log 2>&1 &"
$WDTBIN -minloglevel=1 -directory $DIR/dst > $DIR/server.log 2>&1 &
# client now retries connects so no need wait for server to be up
pidofreceiver=$!
# To test only 1 socket (single threaded send/receive)
#$WDTBIN -num_sockets=1 -directory $DIR/src -destination ::1
# Normal
echo "$WDTBIN -directory $DIR/src -destination $HOSTNAME 2>&1 | tee $DIR/client.log"
time $WDTBIN -directory $DIR/src -destination $HOSTNAME 2>&1 | tee $DIR/client.log
# 2nd Receiver:
echo "$WDTBIN -directory $DIR/dst_symlinks >> $DIR/server.log 2>&1 &"
$WDTBIN -directory $DIR/dst_symlinks >> $DIR/server.log 2>&1 &
echo "$WDTBIN -follow_symlinks -directory $DIR/src -destination $HOSTNAME 2>&1 | tee -a $DIR/client.log"
time $WDTBIN -follow_symlinks -directory $DIR/src -destination $HOSTNAME 2>&1 | tee -a $DIR/client.log
if [ $DO_VERIFY -eq 1 ] ; then
echo "Verifying for run without follow_symlinks"
echo "Checking for difference `date`"
NUM_FILES=`(cd $DIR/dst ; ( find . -type f | wc -l))`
echo "Transfered `du -ks $DIR/dst` kbytes across $NUM_FILES files"
(cd $DIR/src ; ( find . -type f -print0 | xargs -0 md5sum | sort ) \
> ../src.md5s )
(cd $DIR/dst ; ( find . -type f -print0 | xargs -0 md5sum | sort ) \
> ../dst.md5s )
echo "Should be no diff"
(cd $DIR; diff -u src.md5s dst.md5s)
STATUS=$?
echo "Verifying for run with follow_symlinks"
echo "Checking for difference `date`"
NUM_FILES=`(cd $DIR/dst_symlinks; ( find . -type f | wc -l))`
echo "Transfered `du -ks $DIR/dst_symlinks` kbytes across $NUM_FILES files"
(cd $DIR/src ; ( find -L . -type f -print0 | xargs -0 md5sum | sort ) \
> ../src_symlinks.md5s )
(cd $DIR/dst_symlinks ; ( find . -type f -print0 | xargs -0 md5sum \
| sort ) > ../dst_symlinks.md5s )
echo "Should be no diff"
(cd $DIR; diff -u src_symlinks.md5s dst_symlinks.md5s)
SYMLINK_STATUS=$?
if [ $STATUS -eq 0 ] ; then
STATUS=$SYMLINK_STATUS
fi
#(cd $DIR; ls -lR src/ dst/ )
else
echo "Skipping independant verification"
STATUS=0
fi
echo "Server logs:"
cat $DIR/server.log
if [ $STATUS -eq 0 ] ; then
echo "Good run, deleting logs in $DIR"
find $DIR -type d | xargs chmod 755 # cp -r can make some unreadable dir
rm -rf $DIR
else
echo "Bad run ($STATUS) - keeping full logs and partial transfer in $DIR"
fi
exit $STATUS