rewrite Python tests as Bash tests
correct University of Arizona copyright statements
refs #4410
Change-Id: I2e34b28698336d39b64030f68984b711f4bdbd0d
diff --git a/test_interest_aggregation/interest-aggregation-test.sh b/test_interest_aggregation/interest-aggregation-test.sh
new file mode 100755
index 0000000..c0e3935
--- /dev/null
+++ b/test_interest_aggregation/interest-aggregation-test.sh
@@ -0,0 +1,140 @@
+#!/bin/bash
+source ../multi-host.conf
+
+clean_up() {
+ r=$(sudo killall ndn-traffic-server 2>&1)
+ r=$(sudo killall ndnpeek 2>&1)
+ r=$(sudo killall nfd 2>&1)
+}
+
+check_peek_exit() {
+ ps -p $2 > /dev/null
+ if [[ $? -ne 1 ]]; then
+ echo "Peek Client $1 did not exit"
+ clean_up
+ exit 1
+ fi
+}
+
+check_peek_output() {
+ local out=$(cat $2)
+ if [[ "$out" != "$3" ]]; then
+ echo "Peek Client $1 did not receive a Data containing '$3'. Actual: $out"
+ clean_up
+ exit 2
+ fi
+}
+
+check_server_receive_count() {
+ local actual=$(cat $2 | grep "Total Interests Received" | head -1 | cut -d"=" -f2 | tr -d " ")
+ if [[ $actual -ne $3 ]]; then
+ echo "Traffic Server $1 did not received expected $3 Interests. Actual: $actual"
+ clean_up
+ exit 3
+ fi
+}
+
+# A: Start NFD
+workdir=$(pwd)
+echo "Starting nfd on A..."
+mkdir -p $workdir/logs; sudo nfd &> $workdir/logs/nfd.log &
+sleep 1
+
+# A: Set NFD to use best-route v1 strategy
+echo "Setting strategy to best-route v1"
+nfdc strategy set / /localhost/nfd/strategy/best-route/%FD%01
+sleep 1
+
+# A: Start ndn-traffic-server (Prefix=/text-agg, ContentDelay=2000ms)
+echo "Starting Traffic Server 1 (Prefix=/test-agg, ContentDelay=2000ms)..."
+ndn-traffic-server $workdir/test-traffic-server.conf &> $workdir/logs/test-server-output-1.txt &
+sleep 1
+
+# A: Start two instances of ndnpeek to request /test-agg/A
+echo "Starting Peek Client 1 (Prefix=/test-agg/A)..."
+ndnpeek -p /test-agg/A &> $workdir/logs/test-peek-output-1.txt &
+peek1pid=$!
+echo "Starting Peek Client 2 (Prefix=/test-agg/A)..."
+ndnpeek -p /test-agg/A &> $workdir/logs/test-peek-output-2.txt &
+peek2pid=$!
+sleep 1
+
+# A: Stop ndn-traffic-server instance
+echo "Stopping Traffic Server 1..."
+sudo killall ndn-traffic-server 2>&1
+sleep 2
+
+# A: Ensure ndnpeek instances have quit
+check_peek_exit 1 $peek1pid
+check_peek_exit 2 $peek2pid
+
+# A: Ensure ndnpeek instances both received Data packets with correct payloads in response to their Interests
+check_peek_output 1 $workdir/logs/test-peek-output-1.txt AAAAAAAA
+check_peek_output 2 $workdir/logs/test-peek-output-2.txt AAAAAAAA
+
+# A: Ensure that Traffic Server 1 received only one Interest
+check_server_receive_count 1 $workdir/logs/test-server-output-1.txt 1
+
+# A: Start ndn-traffic-server (Prefix=/test-agg, ContentDelay=2000ms)
+echo "Starting Traffic Server 2 (Prefix=/test-agg, ContentDelay=2000ms)..."
+ndn-traffic-server $workdir/test-traffic-server.conf &> $workdir/logs/test-server-output-2.txt &
+sleep 1
+
+# A: Start two instances of ndnpeek to request /test-agg/B, with one setting CanBePrefix=false and
+# the other setting CanBePrefix=true
+echo "Starting Peek Client 3 (Prefix=/test-agg/B, CanBePrefix=false)..."
+ndnpeek -p /test-agg/B &> $workdir/logs/test-peek-output-3.txt &
+peek3pid=$!
+echo "Starting Peek Client 4 (Prefix=/test-agg/B, CanBePrefix=true)..."
+ndnpeek -P -p /test-agg/B &> $workdir/logs/test-peek-output-4.txt &
+peek4pid=$!
+sleep 1
+
+# A: Stop ndn-traffic-server instance
+echo "Stopping Traffic Server 2..."
+sudo killall ndn-traffic-server 2>&1
+sleep 2
+
+# A: Ensure ndnpeek instances have quit
+check_peek_exit 3 $peek3pid
+check_peek_exit 4 $peek4pid
+
+# A: Ensure ndnpeek instances both received Data packets with correct payload in response to their interests
+check_peek_output 3 $workdir/logs/test-peek-output-3.txt AAAAAAAA
+check_peek_output 4 $workdir/logs/test-peek-output-4.txt AAAAAAAA
+
+# A: Ensure that Traffic Server 2 received two Interests
+check_server_receive_count 2 $workdir/logs/test-server-output-2.txt 2
+
+# A: Start ndn-traffic-server (Prefix=/test-agg, ContentDelay=2000ms)
+echo "Starting Traffic Server 3 (Prefix=/test-agg, ContentDelay=2000ms)..."
+ndn-traffic-server $workdir/test-traffic-server.conf &> $workdir/logs/test-server-output-3.txt &
+sleep 1
+
+# A: Start two instances of ndnpeek to request /test-agg/C, with one setting InterestLifetime=6000ms
+# and the other setting InterestLifetime=8000ms
+echo "Starting Peek Client 5 (Prefix=/test-agg/C, InterestLifetime=6000ms)"
+ndnpeek --lifetime 6000 -p /test-agg/C > $workdir/logs/test-peek-output-5.txt &
+peek5pid=$!
+echo "Starting Peek Client 6 (Prefix=/test-agg/C, InterestLifetime=8000ms)..."
+ndnpeek --lifetime 8000 -p /test-agg/C > $workdir/logs/test-peek-output-6.txt &
+peek6pid=$!
+sleep 1
+
+# A: Stop ndn-traffic-server instance
+echo "Stopping Traffic Server 3..."
+sudo killall ndn-traffic-server 2>&1
+sleep 2
+
+# A: Ensure ndnpeek instances have quit
+check_peek_exit 5 $peek5pid
+check_peek_exit 6 $peek6pid
+
+# A: Ensure ndnpek instances both received Data packets with correct payload in response to their Interests
+check_peek_output 5 $workdir/logs/test-peek-output-5.txt AAAAAAAA
+check_peek_output 6 $workdir/logs/test-peek-output-6.txt AAAAAAAA
+
+# A: Ensure that Traffic Server 3 received only one Interest
+check_server_receive_count 3 $workdir/logs/test-server-output-3.txt 1
+
+clean_up