From 5e7b3b225aa3290b84aa8f6c7e07a03d86f53e7b Mon Sep 17 00:00:00 2001
From: Rick Carback <rick@privategrity.com>
Date: Wed, 31 Jul 2019 23:36:03 +0000
Subject: [PATCH] Working integration test with latest tools for dispatch
 branch

---
 basice2e/clients.goldoutput/client18.out |  9 ++--
 basice2e/clients.goldoutput/client4.out  |  4 ++
 basice2e/clients.goldoutput/client5.out  |  4 ++
 basice2e/clients.goldoutput/client6.out  |  4 ++
 basice2e/clients.goldoutput/client67.out |  1 -
 basice2e/clients.goldoutput/client7.out  |  4 ++
 basice2e/clients.goldoutput/client9.out  |  9 ++--
 basice2e/run.sh                          | 63 ++++++++++++++----------
 8 files changed, 62 insertions(+), 36 deletions(-)
 create mode 100644 basice2e/clients.goldoutput/client4.out
 create mode 100644 basice2e/clients.goldoutput/client5.out
 create mode 100644 basice2e/clients.goldoutput/client6.out
 create mode 100644 basice2e/clients.goldoutput/client7.out

diff --git a/basice2e/clients.goldoutput/client18.out b/basice2e/clients.goldoutput/client18.out
index 92bb903..f2c95d5 100644
--- a/basice2e/clients.goldoutput/client18.out
+++ b/basice2e/clients.goldoutput/client18.out
@@ -1,5 +1,4 @@
-UDB search successful. Returned user [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9]
-6
-6
-2
-2
+Received: Hello, 18, with E2E Encryption
+Received: Hello, 18, with E2E Encryption
+Received: Hello, 18, with E2E Encryption
+Received: Hello, 18, with E2E Encryption
diff --git a/basice2e/clients.goldoutput/client4.out b/basice2e/clients.goldoutput/client4.out
new file mode 100644
index 0000000..fd9e581
--- /dev/null
+++ b/basice2e/clients.goldoutput/client4.out
@@ -0,0 +1,4 @@
+Sending Message to 4, Jim: Hello, 4
+Message from 4, Jim Received: Hello, 4
+Sending Message to 4, Jim: Hello, 4
+Message from 4, Jim Received: Hello, 4
diff --git a/basice2e/clients.goldoutput/client5.out b/basice2e/clients.goldoutput/client5.out
new file mode 100644
index 0000000..2c2c83b
--- /dev/null
+++ b/basice2e/clients.goldoutput/client5.out
@@ -0,0 +1,4 @@
+Sending Message to 5, Ben: Hello, 5
+Message from 5, Ben Received: Hello, 5
+Sending Message to 5, Ben: Hello, 5
+Message from 5, Ben Received: Hello, 5
diff --git a/basice2e/clients.goldoutput/client6.out b/basice2e/clients.goldoutput/client6.out
new file mode 100644
index 0000000..f40dff8
--- /dev/null
+++ b/basice2e/clients.goldoutput/client6.out
@@ -0,0 +1,4 @@
+Sending Message to 6, Steph: Hello, 6
+Message from 6, Steph Received: Hello, 6
+Sending Message to 6, Steph: Hello, 6
+Message from 6, Steph Received: Hello, 6
diff --git a/basice2e/clients.goldoutput/client67.out b/basice2e/clients.goldoutput/client67.out
index 0fba43b..0071b32 100644
--- a/basice2e/clients.goldoutput/client67.out
+++ b/basice2e/clients.goldoutput/client67.out
@@ -1,4 +1,3 @@
 Sending Message to 7, Rick: Hello, 7
-Message from 5, Ben Received: Hello, 6
 Sending Message to 7, Rick: Hello, 7
 Message from 5, Ben Received: Hello, 6
diff --git a/basice2e/clients.goldoutput/client7.out b/basice2e/clients.goldoutput/client7.out
new file mode 100644
index 0000000..0c4fe9b
--- /dev/null
+++ b/basice2e/clients.goldoutput/client7.out
@@ -0,0 +1,4 @@
+Sending Message to 7, Rick: Hello, 7
+Message from 7, Rick Received: Hello, 7
+Sending Message to 7, Rick: Hello, 7
+Message from 7, Rick Received: Hello, 7
diff --git a/basice2e/clients.goldoutput/client9.out b/basice2e/clients.goldoutput/client9.out
index b4602d7..7386bcf 100644
--- a/basice2e/clients.goldoutput/client9.out
+++ b/basice2e/clients.goldoutput/client9.out
@@ -1,5 +1,4 @@
-UDB search successful. Returned user [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18]
-6
-6
-2
-2
+Received: Hello, 9, with E2E Encryption
+Received: Hello, 9, with E2E Encryption
+Received: Hello, 9, with E2E Encryption
+Received: Hello, 9, with E2E Encryption
diff --git a/basice2e/run.sh b/basice2e/run.sh
index 91dcda9..6ee73ef 100755
--- a/basice2e/run.sh
+++ b/basice2e/run.sh
@@ -12,12 +12,14 @@ GATEWAYLOGS=results/gateways
 CLIENTOUT=results/clients
 DUMMYOUT=results/dummy.console
 UDBOUT=results/udb.console
+CLIENTCLEAN=results/clients-cleaned
 
 CLIENTOPTS="-n ndf.json --skipNDFVerification"
 
 mkdir -p $SERVERLOGS
 mkdir -p $GATEWAYLOGS
 mkdir -p $CLIENTOUT
+mkdir -p $CLIENTCLEAN
 
 echo "STARTING SERVERS..."
 
@@ -62,8 +64,8 @@ finish() {
         kill $job || true
     done
     tail $SERVERLOGS/*
-    tail $CLIENTOUT/*
-    diff -ruN clients.goldoutput $CLIENTOUT
+    tail $CLIENTCLEAN/*
+    diff -ruN clients.goldoutput $CLIENTCLEAN
 }
 
 trap finish EXIT
@@ -74,16 +76,16 @@ sleep 15 # FIXME: We should not need this, but the servers don't respond quickly
 
 runclients() {
     echo "Starting clients..."
-    CTR=0
 
     # Registration pass
+    CTR=0
     for cid in $(seq 4 7)
     do
         eval NICK=\${NICK${cid}}
         # Send a regular message
         # NOTE: This is deliberately broken not to send -E email$cid@email.com
         # when UDB is fixed to allow concurrent registration, put it back in.
-        CLIENTCMD="timeout 180s ../bin/client $CLIENTOPTS -f blob$cid -i $cid -d $cid -m \"Hello, $cid\""
+        CLIENTCMD="timeout 180s ../bin/client $CLIENTOPTS -f blob$cid -E email$cid@email.com -i $cid -d $cid -m \"Hello, $cid\""
         eval $CLIENTCMD >> $CLIENTOUT/client$cid.out 2>&1 &
             PIDVAL=$!
             eval CLIENTS${CTR}=$PIDVAL
@@ -99,6 +101,7 @@ runclients() {
     done
 
     # Now send messages to each other
+    CTR=0
     for cid in $(seq 4 7)
     do
         # TODO: Change the recipients to send multiple messages. We can't
@@ -144,26 +147,21 @@ PIDVAL=$!
 echo $PIDVAL >> results/serverpids
 echo "$DUMMYCMD -- $PIDVAL"
 
-echo "RUNNING CLIENTS..."
-runclients
-echo "RUNNING CLIENTS (2nd time)..."
-runclients
-
 # Register two users and then do UDB search on each other
-CLIENTCMD="timeout 60s ../bin/client  $CLIENTOPTS -f blob9 -E spencer@elixxir.io -i 9 -d 9 -m \"Hi\""
+CLIENTCMD="timeout 60s ../bin/client  $CLIENTOPTS -f blob9 -E niamh@elixxir.io -i 9 -d 9 -m \"Hi\""
 eval $CLIENTCMD >> $CLIENTOUT/client9.out 2>&1 &
 PIDVAL=$!
 echo "$CLIENTCMD -- $PIDVAL"
 wait $PIDVAL
 
-CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob18 -E bernardo@elixxir.io -i 18 -d 3 -m \"SEARCH EMAIL spencer@elixxir.io\" --keyParams 3,4,2,1.0,2"
-eval $CLIENTCMD >> $CLIENTOUT/client18.out 2>&1 || true &
+CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob18 -E bernardo@elixxir.io -i 18 -d 3 -m \"SEARCH EMAIL niamh@elixxir.io\" --keyParams 3,4,2,1.0,2"
+eval $CLIENTCMD >> $CLIENTOUT/client18.out 2>&1 &
 PIDVAL=$!
 echo "$CLIENTCMD -- $PIDVAL"
 wait $PIDVAL
 
 CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -f blob9 -i 9 -d 3  -m \"SEARCH EMAIL bernardo@elixxir.io\" --keyParams 3,4,2,1.0,2"
-eval $CLIENTCMD >> $CLIENTOUT/client9.out 2>&1 || true &
+eval $CLIENTCMD >> $CLIENTOUT/client9.out 2>&1 &
 PIDVAL=$!
 echo "$CLIENTCMD -- $PIDVAL"
 wait $PIDVAL
@@ -178,22 +176,37 @@ CLIENTCMD="timeout 60s ../bin/client $CLIENTOPTS -i 9 -d 18 -f blob9 -m \"Hello,
 eval $CLIENTCMD >> $CLIENTOUT/client9_rekey.out 2>&1 || true &
 PIDVAL=$!
 echo "$CLIENTCMD -- $PIDVAL"
-wait $PIDVAL
 
 
-# Confirm all messages and rekeys by counting with grep
-grep -ac "Sending Message to 9, Spencer" $CLIENTOUT/client18_rekey.out >> $CLIENTOUT/client18.out
-grep -ac "Message from 9, Spencer Received" $CLIENTOUT/client18_rekey.out >> $CLIENTOUT/client18.out
-grep -ac "Generated new send keys" $CLIENTOUT/client18_rekey.out  >> $CLIENTOUT/client18.out
-grep -ac "Generated new receiving keys" $CLIENTOUT/client18_rekey.out  >> $CLIENTOUT/client18.out
+echo "RUNNING CLIENTS..."
+runclients
+echo "RUNNING CLIENTS (2nd time)..."
+runclients
+
+trap - EXIT
+trap - INT
+
+# 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
+    cat $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
+    cat $CLIENTOUT/$C | grep -v "[CLIENT]" | grep -e "Received\:" -e "Sending Message" -e "Message from" >> $CLIENTCLEAN/$C || true
+done
+
+# only expect 4 messages from the e2e clients
+head -4 $CLIENTCLEAN/client9_rekey.out > $CLIENTCLEAN/client9.out || true
+head -4 $CLIENTCLEAN/client18_rekey.out > $CLIENTCLEAN/client18.out || true
+rm $CLIENTCLEAN/client9_rekey.out $CLIENTCLEAN/client18_rekey.out || true
+
+for C in $(ls -1 $CLIENTCLEAN); do
+    sort $CLIENTCLEAN/$C || true
+done
 
-grep -ac "Sending Message to 18, Bernardo" $CLIENTOUT/client9_rekey.out >> $CLIENTOUT/client9.out
-grep -ac "Message from 18, Bernardo Received" $CLIENTOUT/client9_rekey.out >> $CLIENTOUT/client9.out
-grep -ac "Generated new send keys" $CLIENTOUT/client9_rekey.out  >> $CLIENTOUT/client9.out
-grep -ac "Generated new receiving keys" $CLIENTOUT/client9_rekey.out  >> $CLIENTOUT/client9.out
-rm $CLIENTOUT/client18_rekey.out $CLIENTOUT/client9_rekey.out
+diff -ruN clients.goldoutput $CLIENTCLEAN
 
-diff -ruN clients.goldoutput $CLIENTOUT
+cat $CLIENTOUT/* | grep -e "ERROR" -e "FATAL" > results/client-errors || true
+diff -ruN results/client-errors.txt noerrors.txt
 cat $SERVERLOGS/*.log | grep "ERROR" > results/server-errors.txt || true
 cat $SERVERLOGS/*.log | grep "FATAL" >> results/server-errors.txt || true
 diff -ruN results/server-errors.txt noerrors.txt
-- 
GitLab