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