blob: f1be323e98d0a35e05d53679aeed14112d00492e [file] [log] [blame]
#!/usr/bin/env bash
mkdir -p logs
clean_up() {
r=$(killall ndn-traffic-server 2>&1)
r=$(sudo killall nfd 2>&1)
}
# Start NFD.
sudo nfd > logs/nfd.log 2>&1 &
sleep 1
# Start ndn-traffic-server to serve `ndn:/test-caching`, FreshnessPeriod=2800ms
ndn-traffic-server NDNTrafficServer.conf > logs/server.log 2>&1 &
sleep 1
# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered.
output=$(ndn-tlv-peek -fp ndn:/test-caching/A)
if [[ $output != 'AAAAAAAA' ]]
then
echo "FAIL: Expected data for first interest: 'AAAAAAAA', Actual: '$output'"
clean_up
exit 1
fi
# Pause 1000ms.
sleep 1
# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered.
output=$(ndn-tlv-peek -fp ndn:/test-caching/A)
if [[ $output != 'AAAAAAAA' ]]
then
echo "FAIL: Expected data for second interest: 'AAAAAAAA', Actual: '$output'"
clean_up
exit 2
fi
# Kill ndn-traffic-server. Check "total Interests received" equals 1.
killall ndn-traffic-server
sleep 5
output=$(grep 'Total Interests Received' logs/server.log | head -1 | cut -d = -f2 | cut -d' ' -f2)
if [[ $output != '1' ]]
then
echo "FAIL: Expected ndn-traffic-server receives 1 interest. Actual: $output"
clean_up
exit 3
fi
# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is answered.
output=$(ndn-tlv-peek -fp ndn:/test-caching/A)
if [[ ! -z $output ]]
then
echo "FAIL: Expected no data received for third interest. Actual data received: '$output'"
clean_up
exit 4
fi
sleep 1
# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A` without MustBeFresh. Fail if this Interest is unanswered.
output=$(ndn-tlv-peek -p ndn:/test-caching/A)
if [[ $output != 'AAAAAAAA' ]]
then
echo "FAIL: Expected data for fourth interest: 'AAAAAAAA', Actual: '$output'"
clean_up
exit 5
fi
# clean up
clean_up
echo "ContentStore and freshness test scenario PASSED"