Newer
Older
# NOTE: This is verbose on purpose.
set -e
rm blob* || true
mkdir -p .elixxir
DUMMYOUT=results/dummy-console.txt
UDBOUT=results/udb-console.txt
CLIENTCLEAN=results/clients-cleaned
CLIENTOPTS="-v -n ndf.json --skipNDFVerification -P dummypassword "
mkdir -p $CLIENTCLEAN
Rick Carback
committed
# Start a user discovery bot server
echo "STARTING UDB..."
UDBCMD="../bin/udb -v --config udb.yaml "
$UDBCMD >> $UDBOUT 2>&1 &
PIDVAL=$!
echo $PIDVAL >> results/serverpids
echo "$UDBCMD -- $PIDVAL"
PERMCMD="../bin/permissioning -c permissioning.yaml "
$PERMCMD > $SERVERLOGS/permissioning.log 2>&1 &
PIDVAL=$!
echo "$PERMCMD -- $PIDVAL"
for SERVERID in $(seq 5 -1 1)
SERVERCMD="../bin/server --disablePermissioning -v -i $IDX --roundBufferTimeout 300s --config server-$SERVERID.yaml"
if [ $SERVERID -eq 4 ]; then
sleep 15 # This will force a CDE timeout
fi
$SERVERCMD > $SERVERLOGS/server-$SERVERID-console.txt 2>&1 &
Rick Carback
committed
PIDVAL=$!
echo "$SERVERCMD -- $PIDVAL"
sleep 5 # Give servers some time to boot
# Start gateways
for GWID in $(seq 5 -1 1)
do
IDX=$(($GWID - 1))
GATEWAYCMD="../bin/gateway -v -i $IDX --disablePermissioning --config gateway-$GWID.yaml"
$GATEWAYCMD > $GATEWAYLOGS/gateway-$GWID-console.txt 2>&1 &
PIDVAL=$!
echo "$GATEWAYCMD -- $PIDVAL"
done
jobs -p > results/serverpids
# NOTE: jobs -p doesn't work in a signal handler
for job in $(cat results/serverpids)
#tail $SERVERLOGS/*
#tail $CLIENTCLEAN/*
#diff -ruN clients.goldoutput $CLIENTCLEAN
Rick Carback
committed
trap finish INT
sleep 15 # FIXME: We should not need this, but the servers don't respond quickly
runclients() {
echo "Starting clients..."
Rick Carback
committed
# Now send messages to each other
# TODO: Change the recipients to send multiple messages. We can't
# run multiple clients with the same user id so we need
# updates to make that work.
# for nid in 1 2 3 4; do
Rick Carback
committed
for nid in 1
do
nid=$(((($cid + 1) % 4) + 4))
eval NICK=\${NICK${cid}}
CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob$cid -E email$cid@email.com -i $cid -d $nid -m \"Hello, $nid\""
eval $CLIENTCMD >> $CLIENTOUT/client$cid$nid.txt 2>&1 &
Rick Carback
committed
PIDVAL=$!
eval CLIENTS${CTR}=$PIDVAL
echo "$CLIENTCMD -- $PIDVAL"
CTR=$(($CTR + 1))
done
echo "WAITING FOR $CTR CLIENTS TO EXIT..."
for i in $(seq 0 $(($CTR - 1)))
eval echo "Waiting on \${CLIENTS${i}} ..."
eval wait \${CLIENTS${i}}
echo "RUNNING BASIC CLIENTS (2nd time)..."
runclients
# Register two users and then do UDB search on each other
echo "REGISTERING AND SEARCHING WITH PRECANNED USERS..."
CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob9 -E niamh@elixxir.io -i 9 -d 9 -m \"Hi\""
eval $CLIENTCMD >> $CLIENTOUT/client9.txt 2>&1 &
PIDVAL=$!
echo "$CLIENTCMD -- $PIDVAL"
wait $PIDVAL
Rick Carback
committed
CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob18 -E bernardo@elixxir.io -i 18 -d 9 -s \"niamh@elixxir.io\" --keyParams 3,4,2,1.0,2"
eval $CLIENTCMD >> $CLIENTOUT/client18.txt 2>&1 &
PIDVAL=$!
echo "$CLIENTCMD -- $PIDVAL"
wait $PIDVAL
Rick Carback
committed
CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob9 -i 9 -d 18 -s \"bernardo@elixxir.io\" --keyParams 3,4,2,1.0,2"
eval $CLIENTCMD >> $CLIENTOUT/client9.txt 2>&1 &
PIDVAL=$!
echo "$CLIENTCMD -- $PIDVAL"
wait $PIDVAL
# Send multiple E2E encrypted messages between users that discovered each other
echo "SENDING MESSAGES TO PRECANNED USERS AND FORCING A REKAY..."
Rick Carback
committed
CLIENTCMD="timeout 180s ../bin/client $CLIENTOPTS -c 20 -w 20 -i 18 -d 9 -s \"niamh@elixxir.io\" -f blob18 -m \"Hello, 9, with E2E Encryption\" --end2end"
eval $CLIENTCMD >> $CLIENTOUT/client18_rekey.txt 2>&1 || true &
PIDVAL=$!
echo "$CLIENTCMD -- $PIDVAL"
Rick Carback
committed
CLIENTCMD="timeout 180s ../bin/client $CLIENTOPTS -c 20 -w 20 -i 9 -d 18 -s \"bernardo@elixxir.io\" -f blob9 -m \"Hello, 18, with E2E Encryption\" --end2end"
eval $CLIENTCMD >> $CLIENTOUT/client9_rekey.txt 2>&1 || true &
PIDVAL=$!
echo "$CLIENTCMD -- $PIDVAL"
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Register non-precanned users
echo "REGISTERING NEW USERS..."
CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob42 -E rick42@elixxir.io --privateKey rick42-priv.pem"
eval $CLIENTCMD >> $CLIENTOUT/client42.txt 2>&1 &
PIDVAL=$!
echo "$CLIENTCMD -- $PIDVAL"
CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob43 -E ben43@elixxir.io --privateKey ben43-priv.pem"
eval $CLIENTCMD >> $CLIENTOUT/client43.txt 2>&1 &
PIDVAL2=$!
echo "$CLIENTCMD -- $PIDVAL"
wait $PIDVAL
wait $PIDVAL2
# Have each non-precanned user search for each other
echo "SEARCHING FOR NEW USERS..."
CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob42 -s \"ben43@elixxir.io\" --keyParams 3,4,2,1.0,2"
eval $CLIENTCMD >> $CLIENTOUT/client42.txt 2>&1 &
PIDVAL=$!
echo "$CLIENTCMD -- $PIDVAL"
CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob43 -s \"rick42@elixxir.io\" --keyParams 3,4,2,1.0,2"
eval $CLIENTCMD >> $CLIENTOUT/client43.txt 2>&1 &
PIDVAL2=$!
echo "$CLIENTCMD -- $PIDVAL"
wait $PIDVAL
wait $PIDVAL2
TMPID=$(cat $CLIENTOUT/client42.txt | grep "Successfully registered user" | awk -F' ' '{print $8}')
RICKID=${TMPID%?} # remove ! from end
TMPID=$(cat $CLIENTOUT/client43.txt | grep "Successfully registered user" | awk -F' ' '{print $8}')
BENID=${TMPID%?} # remove ! from end
# Non-precanned user messaging
echo "SENDING E2E MESSAGES TO NEW USERS..."
CLIENTCMD="timeout 180s ../bin/client $CLIENTOPTS -c 1 -w 1 --dest64 $BENID -s \"ben43@elixxir.io\" -f blob42 -m \"Hello from Rick42, with E2E Encryption\" --end2end"
eval $CLIENTCMD >> $CLIENTOUT/client42.txt 2>&1 || true &
PIDVAL=$!
echo "$CLIENTCMD -- $PIDVAL"
CLIENTCMD="timeout 180s ../bin/client $CLIENTOPTS -c 1 -w 1 --dest64 $RICKID -s \"rick42@elixxir.io\" -f blob43 -m \"Hello from Ben43, with E2E Encryption\" --end2end"
eval $CLIENTCMD >> $CLIENTOUT/client43.txt 2>&1 || true &
PIDVAL2=$!
echo "$CLIENTCMD -- $PIDVAL"
wait $PIDVAL
wait $PIDVAL2
# FIXME: Go into client and clean up it's output so this is not necessary
for C in $(ls -1 $CLIENTOUT); do
# Remove the [CLIENT] Lines and cut them down
Rick Carback
committed
strings $CLIENTOUT/$C | grep "\[CLIENT\]" | cut -d\ -f5- | grep -e "Received\:" -e "Sending Message" -e "Message from" > $CLIENTCLEAN/$C || true
# Take the clean lines and add them
Rick Carback
committed
strings $CLIENTOUT/$C | grep -v "\[CLIENT\]" | grep -e "Received\:" -e "Sending Message" -e "Message from" >> $CLIENTCLEAN/$C || true
strings $CLIENTOUT/$C | grep -v "\[CLIENT\]" | cut -d\ -f5- | grep -e "Received\:" >> $CLIENTCLEAN/$C || true
Rick Carback
committed
head -10 $CLIENTCLEAN/client9_rekey.txt | strings | grep -v "\.\.\." > $CLIENTCLEAN/client9.txt || true
head -10 $CLIENTCLEAN/client18_rekey.txt | strings | grep -v "\.\.\." > $CLIENTCLEAN/client18.txt || true
rm $CLIENTCLEAN/client9_rekey.txt $CLIENTCLEAN/client18_rekey.txt || true
strings $CLIENTCLEAN/client42.txt | grep -v "\.\.\." > $CLIENTCLEAN/client42-clean.txt || true
strings $CLIENTCLEAN/client43.txt | grep -v "\.\.\." > $CLIENTCLEAN/client43-clean.txt || true
mv $CLIENTCLEAN/client42-clean.txt $CLIENTCLEAN/client42.txt
mv $CLIENTCLEAN/client43-clean.txt $CLIENTCLEAN/client43.txt
for C in $(ls -1 $CLIENTCLEAN); do
echo "TESTS EXITED SUCCESSFULLY, CHECKING OUTPUT..."
diff -ruN clients.goldoutput $CLIENTCLEAN
Rick Carback
committed
cat $CLIENTOUT/* | strings | grep -e "ERROR" -e "FATAL" > results/client-errors || true
diff -ruN results/client-errors.txt noerrors.txt
Rick Carback
committed
cat $SERVERLOGS/server-*.log | grep "ERROR" | grep -v "context" | grep -v "metrics" | grep -v "database" > results/server-errors.txt || true
cat $SERVERLOGS/server-*.log | grep "FATAL" | grep -v "context" | grep -v "database" >> results/server-errors.txt || true
Rick Carback
committed
diff -ruN results/server-errors.txt noerrors.txt
cat $DUMMYOUT | grep "ERROR" | grep -v "context" | grep -v "failed\ to\ read\ certificate" > results/dummy-errors.txt || true
cat $DUMMYOUT | grep "FATAL" | grep -v "context" >> results/dummy-errors.txt || true
diff -ruN results/dummy-errors.txt noerrors.txt
IGNOREMSG="GetRoundBufferInfo: Error received: rpc error: code = Unknown desc = round buffer is empty"
cat $GATEWAYLOGS/*.log | grep "ERROR" | grep -v "context" | grep -v "certificate" | grep -v "Failed to read key" | grep -v "$IGNOREMSG" > results/gateway-errors.txt || true
cat $GATEWAYLOGS/*.log | grep "FATAL" | grep -v "context" >> results/gateway-errors.txt || true
diff -ruN results/gateway-errors.txt noerrors.txt