blob: 82e647b18a2a808c7cff63f04249237542ef1077 [file] [log] [blame]
Yi Huang7990f092014-04-18 04:51:58 -07001#!/usr/bin/env bash
2mkdir -p logs
3
4clean_up() {
5 r=$(killall ndn-traffic-server 2>&1)
6 r=$(sudo killall nfd 2>&1)
7}
8
9# Start NFD.
Yi Huang53fa8712014-06-10 20:14:26 -070010sudo nfd &> logs/nfd.log &
11sleep 2
Yi Huang7990f092014-04-18 04:51:58 -070012
13# Start ndn-traffic-server to serve `ndn:/test-caching`, FreshnessPeriod=2800ms
14ndn-traffic-server NDNTrafficServer.conf > logs/server.log 2>&1 &
15sleep 1
16
Eric Newberryd4ed6222015-06-10 14:12:42 -070017# Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered.
18output=$(ndnpeek -fp ndn:/test-caching/A)
Yi Huang7990f092014-04-18 04:51:58 -070019if [[ $output != 'AAAAAAAA' ]]
20then
21 echo "FAIL: Expected data for first interest: 'AAAAAAAA', Actual: '$output'"
22 clean_up
23 exit 1
24fi
25
26# Pause 1000ms.
27sleep 1
28
Eric Newberryd4ed6222015-06-10 14:12:42 -070029# Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered.
30output=$(ndnpeek -fp ndn:/test-caching/A)
Yi Huang7990f092014-04-18 04:51:58 -070031if [[ $output != 'AAAAAAAA' ]]
32then
33 echo "FAIL: Expected data for second interest: 'AAAAAAAA', Actual: '$output'"
34 clean_up
35 exit 2
36fi
37
38# Kill ndn-traffic-server. Check "total Interests received" equals 1.
39killall ndn-traffic-server
40sleep 5
41output=$(grep 'Total Interests Received' logs/server.log | head -1 | cut -d = -f2 | cut -d' ' -f2)
42if [[ $output != '1' ]]
43then
Eric Newberryf3248ea2016-08-07 11:48:50 -070044 echo "FAIL: Expected ndn-traffic-server to receive 1 interest. Actual: $output"
Yi Huang7990f092014-04-18 04:51:58 -070045 clean_up
46 exit 3
47fi
48
Eric Newberryf3248ea2016-08-07 11:48:50 -070049# Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is answered with Data.
Eric Newberryd4ed6222015-06-10 14:12:42 -070050output=$(ndnpeek -fp ndn:/test-caching/A)
Eric Newberryf3248ea2016-08-07 11:48:50 -070051if [[ $? == "0" ]]
Yi Huang7990f092014-04-18 04:51:58 -070052then
Eric Newberryf3248ea2016-08-07 11:48:50 -070053 echo "FAIL: Expected no data to be received in response to third interest. Received: '$output'"
Yi Huang7990f092014-04-18 04:51:58 -070054 clean_up
55 exit 4
56fi
57sleep 1
58
Eric Newberryd4ed6222015-06-10 14:12:42 -070059# Invoke ndnpeek to send Interest `ndn:/test-caching/A` without MustBeFresh. Fail if this Interest is unanswered.
60output=$(ndnpeek -p ndn:/test-caching/A)
Yi Huang7990f092014-04-18 04:51:58 -070061if [[ $output != 'AAAAAAAA' ]]
62then
63 echo "FAIL: Expected data for fourth interest: 'AAAAAAAA', Actual: '$output'"
64 clean_up
65 exit 5
66fi
67
68# clean up
69clean_up
70echo "ContentStore and freshness test scenario PASSED"