blob: d2f8d7f0831051c8460d7a926f8296e47a8c0c2c [file] [log] [blame]
Junxiao Shia59f2072014-04-27 20:52:25 -07001#!/usr/bin/env bash
2source ../multi-host.conf
Eric Newberry6fc88222015-06-19 10:43:24 -07003mkdir -p logs/in
Junxiao Shia59f2072014-04-27 20:52:25 -07004workdir=$(pwd)
5
6clean_up() {
Eric Newberry19a6c5a2015-07-05 11:19:49 -07007 rm -f $HOME/.ndn/client.conf
8 killall socat
9 rm -f /tmp/localhost-test-B.sock
10 ssh $CTRL_B "killall ndn-traffic-server;\
11 sudo killall nfd"
Junxiao Shia59f2072014-04-27 20:52:25 -070012}
13
14# start nfd and ndn-traffic-server on hostB
Eric Newberry6fc88222015-06-19 10:43:24 -070015ssh $CTRL_B "mkdir -p $workdir/logs/in;\
16 sudo nfd &> $workdir/logs/in/nfd.log &\
Junxiao Shia59f2072014-04-27 20:52:25 -070017 sleep 2;\
Eric Newberry6fc88222015-06-19 10:43:24 -070018 ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/in/server.log &"
Junxiao Shia59f2072014-04-27 20:52:25 -070019sleep 2
20
21# set up socat on A
Eric Newberry6fc88222015-06-19 10:43:24 -070022socat -v UNIX-LISTEN:/tmp/localhost-test-B.sock,fork TCP:$IP4_B1:6363 &> logs/in/socat.log &
Hila Ben Abrahamd5033e92015-01-15 20:30:55 -060023echo "transport=unix:///tmp/localhost-test-B.sock" > $HOME/.ndn/client.conf
Junxiao Shia59f2072014-04-27 20:52:25 -070024sleep 1
25
26# send interest
Eric Newberryd4ed6222015-06-10 14:12:42 -070027response=$(ndnpeek -p ndn:/localhost/test-in/A 2>&1)
Eric Newberry19a6c5a2015-07-05 11:19:49 -070028if [[ -n $response ]]
Junxiao Shia59f2072014-04-27 20:52:25 -070029then
30 echo "FAIL: Expected no data come back for ndn:/localhost/test-in/A, Actual: '$response'"
31 clean_up
32 exit 2
33fi
34
35# copy back the server log
36ssh $CTRL_B "killall ndn-traffic-server"
Eric Newberry6fc88222015-06-19 10:43:24 -070037scp $CTRL_B:$workdir/logs/in/server.log $workdir/logs/in
Junxiao Shia59f2072014-04-27 20:52:25 -070038
39# analyze server log
Eric Newberry6fc88222015-06-19 10:43:24 -070040output=$(grep "Total Interests Received" $workdir/logs/in/server.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
Eric Newberryafb5c5f2015-06-09 08:57:58 -070041if [[ $output != 0?(.+(0)) ]]
Junxiao Shia59f2072014-04-27 20:52:25 -070042then
43 echo "Expected no Interests received on host B. Actual: $output"
Eric Newberry6fc88222015-06-19 10:43:24 -070044 echo "For more information, please examine the log at \"$(pwd)/logs/in\""
Junxiao Shia59f2072014-04-27 20:52:25 -070045 clean_up
46 exit 3
47fi
48
49clean_up
50
51echo "localhost incoming test PASSED"