Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | source ../multi-host.conf |
| 3 | mkdir -p logs |
| 4 | workdir=$(pwd) |
| 5 | |
| 6 | clean_up() { |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame^] | 7 | r=$(rm $HOME/.ndn/client.conf 2>&1) |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 8 | r=$(killall socat 2>&1) |
| 9 | r=$(ssh $CTRL_B "killall ndn-traffic-server;\ |
| 10 | sudo killall nfd" 2>&1) |
| 11 | } |
| 12 | |
| 13 | # start nfd and ndn-traffic-server on hostB |
| 14 | ssh $CTRL_B "mkdir -p $workdir/logs;\ |
| 15 | sudo nfd &> $workdir/logs/nfd.log &\ |
| 16 | sleep 2;\ |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame^] | 17 | nrd &> $workdir/logs/nrd.log &\ |
| 18 | sleep 2;\ |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 19 | ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/server.log &" |
| 20 | sleep 2 |
| 21 | |
| 22 | # set up socat on A |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 23 | socat -v UNIX-LISTEN:/tmp/localhost-test-B.sock,fork TCP:$IP4_B1:6363 &> logs/socat.log & |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame^] | 24 | echo "unix_socket=/tmp/localhost-test-B.sock" > $HOME/.ndn/client.conf |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 25 | sleep 1 |
| 26 | |
| 27 | # send interest |
| 28 | response=$(ndn-tlv-peek -p ndn:/localhost/test-in/A 2>&1) |
| 29 | if [[ ! -z $response ]] |
| 30 | then |
| 31 | echo "FAIL: Expected no data come back for ndn:/localhost/test-in/A, Actual: '$response'" |
| 32 | clean_up |
| 33 | exit 2 |
| 34 | fi |
| 35 | |
| 36 | # copy back the server log |
| 37 | ssh $CTRL_B "killall ndn-traffic-server" |
| 38 | scp $CTRL_B:$workdir/logs/server.log $workdir/logs/ |
| 39 | |
| 40 | # analyze server log |
| 41 | output=$(grep "Total Interests Received" $workdir/logs/server.log | head -1 | cut -d= -f2 | cut -d' ' -f2) |
| 42 | if [[ $output != '0' ]] |
| 43 | then |
| 44 | echo "Expected no Interests received on host B. Actual: $output" |
| 45 | echo "For more information, please examine the log at \"$(pwd)/logs\"" |
| 46 | clean_up |
| 47 | exit 3 |
| 48 | fi |
| 49 | |
| 50 | clean_up |
| 51 | |
| 52 | echo "localhost incoming test PASSED" |