blob: cb22222e8c4fb1c8ded76b563400dc77262fb886 [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
12nrd &> logs/nrd.log &
13sleep 2
Yi Huang7990f092014-04-18 04:51:58 -070014
15# Start ndn-traffic-server to serve `ndn:/test-caching`, FreshnessPeriod=2800ms
16ndn-traffic-server NDNTrafficServer.conf > logs/server.log 2>&1 &
17sleep 1
18
Eric Newberryd4ed6222015-06-10 14:12:42 -070019# Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered.
20output=$(ndnpeek -fp ndn:/test-caching/A)
Yi Huang7990f092014-04-18 04:51:58 -070021if [[ $output != 'AAAAAAAA' ]]
22then
23 echo "FAIL: Expected data for first interest: 'AAAAAAAA', Actual: '$output'"
24 clean_up
25 exit 1
26fi
27
28# Pause 1000ms.
29sleep 1
30
Eric Newberryd4ed6222015-06-10 14:12:42 -070031# Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered.
32output=$(ndnpeek -fp ndn:/test-caching/A)
Yi Huang7990f092014-04-18 04:51:58 -070033if [[ $output != 'AAAAAAAA' ]]
34then
35 echo "FAIL: Expected data for second interest: 'AAAAAAAA', Actual: '$output'"
36 clean_up
37 exit 2
38fi
39
40# Kill ndn-traffic-server. Check "total Interests received" equals 1.
41killall ndn-traffic-server
42sleep 5
43output=$(grep 'Total Interests Received' logs/server.log | head -1 | cut -d = -f2 | cut -d' ' -f2)
44if [[ $output != '1' ]]
45then
46 echo "FAIL: Expected ndn-traffic-server receives 1 interest. Actual: $output"
47 clean_up
48 exit 3
49fi
50
Eric Newberryd4ed6222015-06-10 14:12:42 -070051# Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is answered.
52output=$(ndnpeek -fp ndn:/test-caching/A)
Yi Huang7990f092014-04-18 04:51:58 -070053if [[ ! -z $output ]]
54then
55 echo "FAIL: Expected no data received for third interest. Actual data received: '$output'"
56 clean_up
57 exit 4
58fi
59sleep 1
60
Eric Newberryd4ed6222015-06-10 14:12:42 -070061# Invoke ndnpeek to send Interest `ndn:/test-caching/A` without MustBeFresh. Fail if this Interest is unanswered.
62output=$(ndnpeek -p ndn:/test-caching/A)
Yi Huang7990f092014-04-18 04:51:58 -070063if [[ $output != 'AAAAAAAA' ]]
64then
65 echo "FAIL: Expected data for fourth interest: 'AAAAAAAA', Actual: '$output'"
66 clean_up
67 exit 5
68fi
69
70# clean up
71clean_up
72echo "ContentStore and freshness test scenario PASSED"