blob: 8a6b6d32aab457a927e250c23be27aa67bf0d70d [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
19# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered.
20output=$(ndn-tlv-peek -fp ndn:/test-caching/A)
21if [[ $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
31# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered.
32output=$(ndn-tlv-peek -fp ndn:/test-caching/A)
33if [[ $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
51# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is answered.
52output=$(ndn-tlv-peek -fp ndn:/test-caching/A)
53if [[ ! -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
61# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A` without MustBeFresh. Fail if this Interest is unanswered.
62output=$(ndn-tlv-peek -p ndn:/test-caching/A)
63if [[ $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"