From b2689541e27379e6157ee7777f5915d16b9a9724 Mon Sep 17 00:00:00 2001
From: joshemb <josh@elixxir.io>
Date: Fri, 22 Jul 2022 13:56:24 -0700
Subject: [PATCH] Add non-ephemeral connection tests

---
 basice2e/clients.goldoutput/client204.txt |   3 +
 basice2e/clients.goldoutput/client205.txt |   8 ++
 basice2e/clients.goldoutput/client206.txt |   5 +
 basice2e/clients.goldoutput/client207.txt |   8 ++
 basice2e/run.sh                           | 129 +++++++++++-----------
 5 files changed, 86 insertions(+), 67 deletions(-)
 create mode 100644 basice2e/clients.goldoutput/client204.txt
 create mode 100644 basice2e/clients.goldoutput/client205.txt
 create mode 100644 basice2e/clients.goldoutput/client206.txt
 create mode 100644 basice2e/clients.goldoutput/client207.txt

diff --git a/basice2e/clients.goldoutput/client204.txt b/basice2e/clients.goldoutput/client204.txt
new file mode 100644
index 0000000..832c11d
--- /dev/null
+++ b/basice2e/clients.goldoutput/client204.txt
@@ -0,0 +1,3 @@
+Established connection server, begin listening...
+Established connection with client
+ConnectionServer heard message "Hello 200 from 201, using connections"
diff --git a/basice2e/clients.goldoutput/client205.txt b/basice2e/clients.goldoutput/client205.txt
new file mode 100644
index 0000000..79da732
--- /dev/null
+++ b/basice2e/clients.goldoutput/client205.txt
@@ -0,0 +1,8 @@
+Loading ephemerally
+Sending connection request
+Established connection with server
+Sent message "Hello 200 from 201, using connections" to connection partner.
+Loading ephemerally
+Sending connection request
+Established connection with server
+Disconnected from partner
diff --git a/basice2e/clients.goldoutput/client206.txt b/basice2e/clients.goldoutput/client206.txt
new file mode 100644
index 0000000..6b73f59
--- /dev/null
+++ b/basice2e/clients.goldoutput/client206.txt
@@ -0,0 +1,5 @@
+Established connection server, begin listening...
+Established authenticated connection with client
+AuthServer heard message "Hello 202 from 203, using connections"
+Established authenticated connection with client
+
diff --git a/basice2e/clients.goldoutput/client207.txt b/basice2e/clients.goldoutput/client207.txt
new file mode 100644
index 0000000..6608551
--- /dev/null
+++ b/basice2e/clients.goldoutput/client207.txt
@@ -0,0 +1,8 @@
+Loading ephemerally
+Sending connection request
+Established authenticated connection with server.
+Sent message "Hello 202 from 203, using connections" to connection partner.
+Loading ephemerally
+Sending connection request
+Established authenticated connection with server.
+Disconnected from partner
diff --git a/basice2e/run.sh b/basice2e/run.sh
index fbbd6fa..a495809 100755
--- a/basice2e/run.sh
+++ b/basice2e/run.sh
@@ -1103,14 +1103,11 @@ wait $PIDVAL1
 
 echo "BROADCAST CHANNELS FINISHED..."
 
-
-
 ###############################################################################
-# Test  connections
+# Test ephemeral connections
 ###############################################################################
 
-echo "TESTING CONNECTIONS..."
-echo "Testing Ephemeral Initialization..."
+echo "TESTING EPEHMERAL CONNECTIONS..."
 # Initiate server
 CLIENTCMD="timeout 240s ../bin/client connection --ephemeral -s blob200 $CONNECTIONOPTS --writeContact $CLIENTOUT/client200-server.bin -l $CLIENTOUT/client200.log --startServer --serverTimeout 2m"
 eval $CLIENTCMD > $CLIENTOUT/client200.txt 2>&1 || true &
@@ -1132,42 +1129,13 @@ PIDVAL2=$!
 echo "$CLIENTCMD -- $PIDVAL2"
 wait $PIDVAL2
 wait $PIDVAL1
-echo "Ephemeral Test Complete."
-
-
-# TODO: TEST NON-EPHEMERAL CODE-PATH WHEN SUPPORTED
-#echo "Testing Non-Ephemeral Initialization..."
-## Initiate server
-#CLIENTCMD="timeout 240s ../bin/client connection -s blob200 $CONNECTIONOPTS --writeContact $CLIENTOUT/client200-server.bin -l $CLIENTOUT/client200.log --startServer --serverTimeout 2m"
-#eval $CLIENTCMD > $CLIENTOUT/client200.txt 2>&1 || true &
-#PIDVAL1=$!
-#echo "$CLIENTCMD -- $PIDVAL1"
-#echo "Sleeping to ensure connection server instantiation"
-#sleep 5
-## Initiate client and send message to server
-#CLIENTCMD="timeout 240s ../bin/client connection -s blob201 --connect $CLIENTOUT/client200-server.bin $CONNECTIONOPTS -l $CLIENTOUT/client201.log  -m \"Hello 200 from 201, using connections\" --receiveCount 0"
-#eval $CLIENTCMD > $CLIENTOUT/client201.txt 2>&1 || true &
-#PIDVAL2=$!
-#echo "$CLIENTCMD -- $PIDVAL2"
-#wait $PIDVAL2
-#
-## Disconnect
-#CLIENTCMD="timeout 240s ../bin/client connection -s blob201 $CONNECTIONOPTS -l $CLIENTOUT/client201.log --connect $CLIENTOUT/client200-server.bin --disconnect"
-#eval $CLIENTCMD >> $CLIENTOUT/client201.txt 2>&1 || true &
-#PIDVAL2=$!
-#echo "$CLIENTCMD -- $PIDVAL2"
-#wait $PIDVAL2
-#wait $PIDVAL1
-#echo "Non-Ephemeral Test Complete."
-#
-
-echo "CONNECTION TESTS FINISHED"
+
+echo "EPHEMERAL CONNECTION TESTS FINISHED"
 
 ###############################################################################
-# Test authenticated connections
+# Test ephemeral authenticated connections
 ###############################################################################
-echo "TESTING AUTHENTICATED CONNECTIONS..."
-echo "Testing Ephemeral Initialization..."
+echo "TESTING EPHEMERAL AUTHENTICATED CONNECTIONS..."
 # Initiate server
 CLIENTCMD="timeout 240s ../bin/client connection --ephemeral -s blob202 --authenticated $CONNECTIONOPTS --writeContact $CLIENTOUT/client202-server.bin -l $CLIENTOUT/client202.log --startServer --serverTimeout 2m"
 eval $CLIENTCMD > $CLIENTOUT/client202.txt 2>&1 || true &
@@ -1190,35 +1158,62 @@ PIDVAL2=$!
 echo "$CLIENTCMD -- $PIDVAL2"
 wait $PIDVAL2
 wait $PIDVAL1
-echo "Ephemeral test complete."
-
-# TODO: TEST NON-EPHEMERAL CODE-PATH WHEN SUPPORTED
-#echo "Testing Non-Ephemeral Initialization..."
-## Initiate server
-#CLIENTCMD="timeout 240s ../bin/client connection -s blob202 --authenticated $CONNECTIONOPTS --writeContact $CLIENTOUT/client202-server.bin -l $CLIENTOUT/client202.log --startServer --serverTimeout 2m"
-#eval $CLIENTCMD > $CLIENTOUT/client202.txt 2>&1 || true &
-#PIDVAL1=$!
-#echo "$CLIENTCMD -- $PIDVAL1"
-#echo "Sleeping to ensure connection server instantiation"
-#sleep 5
-#
-## Initiate client and send message to server
-#CLIENTCMD="timeout 240s ../bin/client connection -s blob203 --authenticated --connect $CLIENTOUT/client202-server.bin $CONNECTIONOPTS -l $CLIENTOUT/client203.log  -m \"Hello 202 from 203, using connections\" --receiveCount 0"
-#eval $CLIENTCMD > $CLIENTOUT/client203.txt 2>&1 || true &
-#PIDVAL2=$!
-#echo "$CLIENTCMD -- $PIDVAL2"
-#wait $PIDVAL2
-#
-## Disconnect
-#CLIENTCMD="timeout 240s ../bin/client connection -s blob203 --authenticated $CONNECTIONOPTS -l $CLIENTOUT/client203.log --connect $CLIENTOUT/client202-server.bin --disconnect"
-#eval $CLIENTCMD >> $CLIENTOUT/client203.txt 2>&1 || true &
-#PIDVAL2=$!
-#echo "$CLIENTCMD -- $PIDVAL2"
-#wait $PIDVAL2
-#wait $PIDVAL1
-#echo "Non-Ephemeral Test Complete."
-
-echo "AUTHENTICATED CONNECTION TESTS FINISHED"
+
+echo "EPHEMERAL AUTHENTICATED CONNECTION TESTS FINISHED"
+
+###############################################################################
+# Test non-ephemeral authenticated connections
+###############################################################################
+
+echo "TESTING NON-EPHEMERAL CONNECTIONS"
+# Initiate server
+CLIENTCMD="timeout 240s ../bin/client connection -s blob204 $CONNECTIONOPTS --writeContact $CLIENTOUT/client204-server.bin -l $CLIENTOUT/client204.log --startServer --serverTimeout 2m"
+eval $CLIENTCMD > $CLIENTOUT/client204.txt 2>&1 || true &
+PIDVAL1=$!
+echo "$CLIENTCMD -- $PIDVAL1"
+echo "Sleeping to ensure connection server instantiation"
+sleep 5
+# Initiate client and send message to server
+CLIENTCMD="timeout 240s ../bin/client connection -s blob205 --connect $CLIENTOUT/client204-server.bin $CONNECTIONOPTS -l $CLIENTOUT/client205.log  -m \"Hello 204 from 205, using connections\" --receiveCount 0"
+eval $CLIENTCMD > $CLIENTOUT/client205.txt 2>&1 || true &
+PIDVAL2=$!
+echo "$CLIENTCMD -- $PIDVAL2"
+wait $PIDVAL2
+
+# Disconnect
+CLIENTCMD="timeout 240s ../bin/client connection -s blob205 $CONNECTIONOPTS -l $CLIENTOUT/client205.log --connect $CLIENTOUT/client204-server.bin --disconnect"
+eval $CLIENTCMD >> $CLIENTOUT/client205.txt 2>&1 || true &
+PIDVAL2=$!
+echo "$CLIENTCMD -- $PIDVAL2"
+wait $PIDVAL2
+wait $PIDVAL1
+echo "NON-EPHEMERAL CONNECTION TEST FINISHED."
+
+
+echo "TESTING EPHEMERAL AUTHENTICATED CONNECTIONS..."
+# Initiate server
+CLIENTCMD="timeout 240s ../bin/client connection -s blob206 --authenticated $CONNECTIONOPTS --writeContact $CLIENTOUT/client206-server.bin -l $CLIENTOUT/client206.log --startServer --serverTimeout 2m"
+eval $CLIENTCMD > $CLIENTOUT/client206.txt 2>&1 || true &
+PIDVAL1=$!
+echo "$CLIENTCMD -- $PIDVAL1"
+echo "Sleeping to ensure connection server instantiation"
+sleep 5
+
+# Initiate client and send message to server
+CLIENTCMD="timeout 240s ../bin/client connection -s blob207 --authenticated --connect $CLIENTOUT/client206-server.bin $CONNECTIONOPTS -l $CLIENTOUT/client207.log  -m \"Hello 206 from 207, using connections\" --receiveCount 0"
+eval $CLIENTCMD > $CLIENTOUT/client207.txt 2>&1 || true &
+PIDVAL2=$!
+echo "$CLIENTCMD -- $PIDVAL2"
+wait $PIDVAL2
+
+# Disconnect
+CLIENTCMD="timeout 240s ../bin/client connection -s blob207 --authenticated $CONNECTIONOPTS -l $CLIENTOUT/client207.log --connect $CLIENTOUT/client206-server.bin --disconnect"
+eval $CLIENTCMD >> $CLIENTOUT/client207.txt 2>&1 || true &
+PIDVAL2=$!
+echo "$CLIENTCMD -- $PIDVAL2"
+wait $PIDVAL2
+wait $PIDVAL1
+echo "Non-Ephemeral Test Complete."
 
 
 echo "TESTS EXITED SUCCESSFULLY, CHECKING OUTPUT..."
-- 
GitLab