blob: 7149fd67e6d0129ae59b37036db892a271623dcd [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() {
Yi Huang53fa8712014-06-10 20:14:26 -07007 r=$(rm $HOME/.ndn/client.conf 2>&1)
Junxiao Shia59f2072014-04-27 20:52:25 -07008 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
Eric Newberry6fc88222015-06-19 10:43:24 -070014ssh $CTRL_B "mkdir -p $workdir/logs/in;\
15 sudo nfd &> $workdir/logs/in/nfd.log &\
Junxiao Shia59f2072014-04-27 20:52:25 -070016 sleep 2;\
Eric Newberry6fc88222015-06-19 10:43:24 -070017 ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/in/server.log &"
Junxiao Shia59f2072014-04-27 20:52:25 -070018sleep 2
19
20# set up socat on A
Eric Newberry6fc88222015-06-19 10:43:24 -070021socat -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 -060022echo "transport=unix:///tmp/localhost-test-B.sock" > $HOME/.ndn/client.conf
Junxiao Shia59f2072014-04-27 20:52:25 -070023sleep 1
24
25# send interest
Eric Newberryd4ed6222015-06-10 14:12:42 -070026response=$(ndnpeek -p ndn:/localhost/test-in/A 2>&1)
Junxiao Shia59f2072014-04-27 20:52:25 -070027if [[ ! -z $response ]]
28then
29 echo "FAIL: Expected no data come back for ndn:/localhost/test-in/A, Actual: '$response'"
30 clean_up
31 exit 2
32fi
33
34# copy back the server log
35ssh $CTRL_B "killall ndn-traffic-server"
Eric Newberry6fc88222015-06-19 10:43:24 -070036scp $CTRL_B:$workdir/logs/in/server.log $workdir/logs/in
Junxiao Shia59f2072014-04-27 20:52:25 -070037
38# analyze server log
Eric Newberry6fc88222015-06-19 10:43:24 -070039output=$(grep "Total Interests Received" $workdir/logs/in/server.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
Eric Newberryafb5c5f2015-06-09 08:57:58 -070040if [[ $output != 0?(.+(0)) ]]
Junxiao Shia59f2072014-04-27 20:52:25 -070041then
42 echo "Expected no Interests received on host B. Actual: $output"
Eric Newberry6fc88222015-06-19 10:43:24 -070043 echo "For more information, please examine the log at \"$(pwd)/logs/in\""
Junxiao Shia59f2072014-04-27 20:52:25 -070044 clean_up
45 exit 3
46fi
47
48clean_up
49
50echo "localhost incoming test PASSED"