Yi Huang | 7990f09 | 2014-04-18 04:51:58 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | mkdir -p logs |
| 3 | |
| 4 | clean_up() { |
| 5 | r=$(killall ndn-traffic-server 2>&1) |
| 6 | r=$(sudo killall nfd 2>&1) |
| 7 | } |
| 8 | |
| 9 | # Start NFD. |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 10 | sudo nfd &> logs/nfd.log & |
| 11 | sleep 2 |
Yi Huang | 7990f09 | 2014-04-18 04:51:58 -0700 | [diff] [blame] | 12 | |
| 13 | # Start ndn-traffic-server to serve `ndn:/test-caching`, FreshnessPeriod=2800ms |
| 14 | ndn-traffic-server NDNTrafficServer.conf > logs/server.log 2>&1 & |
| 15 | sleep 1 |
| 16 | |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 17 | # Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered. |
| 18 | output=$(ndnpeek -fp ndn:/test-caching/A) |
Yi Huang | 7990f09 | 2014-04-18 04:51:58 -0700 | [diff] [blame] | 19 | if [[ $output != 'AAAAAAAA' ]] |
| 20 | then |
| 21 | echo "FAIL: Expected data for first interest: 'AAAAAAAA', Actual: '$output'" |
| 22 | clean_up |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | # Pause 1000ms. |
| 27 | sleep 1 |
| 28 | |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 29 | # Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered. |
| 30 | output=$(ndnpeek -fp ndn:/test-caching/A) |
Yi Huang | 7990f09 | 2014-04-18 04:51:58 -0700 | [diff] [blame] | 31 | if [[ $output != 'AAAAAAAA' ]] |
| 32 | then |
| 33 | echo "FAIL: Expected data for second interest: 'AAAAAAAA', Actual: '$output'" |
| 34 | clean_up |
| 35 | exit 2 |
| 36 | fi |
| 37 | |
| 38 | # Kill ndn-traffic-server. Check "total Interests received" equals 1. |
| 39 | killall ndn-traffic-server |
| 40 | sleep 5 |
| 41 | output=$(grep 'Total Interests Received' logs/server.log | head -1 | cut -d = -f2 | cut -d' ' -f2) |
| 42 | if [[ $output != '1' ]] |
| 43 | then |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 44 | echo "FAIL: Expected ndn-traffic-server to receive 1 interest. Actual: $output" |
Yi Huang | 7990f09 | 2014-04-18 04:51:58 -0700 | [diff] [blame] | 45 | clean_up |
| 46 | exit 3 |
| 47 | fi |
| 48 | |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 49 | # Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is answered with Data. |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 50 | output=$(ndnpeek -fp ndn:/test-caching/A) |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 51 | if [[ $? == "0" ]] |
Yi Huang | 7990f09 | 2014-04-18 04:51:58 -0700 | [diff] [blame] | 52 | then |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 53 | echo "FAIL: Expected no data to be received in response to third interest. Received: '$output'" |
Yi Huang | 7990f09 | 2014-04-18 04:51:58 -0700 | [diff] [blame] | 54 | clean_up |
| 55 | exit 4 |
| 56 | fi |
| 57 | sleep 1 |
| 58 | |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 59 | # Invoke ndnpeek to send Interest `ndn:/test-caching/A` without MustBeFresh. Fail if this Interest is unanswered. |
| 60 | output=$(ndnpeek -p ndn:/test-caching/A) |
Yi Huang | 7990f09 | 2014-04-18 04:51:58 -0700 | [diff] [blame] | 61 | if [[ $output != 'AAAAAAAA' ]] |
| 62 | then |
| 63 | echo "FAIL: Expected data for fourth interest: 'AAAAAAAA', Actual: '$output'" |
| 64 | clean_up |
| 65 | exit 5 |
| 66 | fi |
| 67 | |
| 68 | # clean up |
| 69 | clean_up |
| 70 | echo "ContentStore and freshness test scenario PASSED" |