blob: 281e8f1dba0dde0888d4d5706f53dab7cac45ee0 [file] [log] [blame]
#!/usr/bin/env bash
source ../multi-host.conf
start_nfd() {
sudo nfd &> $workdir/logs/nfd.log &
ssh $CTRL_B "sudo nfd &"
sleep 2
}
set_up() {
workdir=$(pwd)
mkdir -p $workdir/logs
start_nfd
}
clean_up() {
nfd-stop
exit 0
}
register() {
name=$1
expirationPeriod=$2
nextHop=$3
result=$(nfdc register -e $(($expirationPeriod * 1000)) $name udp4://$nextHop | grep -o 'FaceId: [0-9]*' | sed s/'FaceId: '//)
echo $result
}
is_expiration_period_correct() {
name=$1
nextHop=$2
lowerBound=$3
upperBound=$4
expirationPeriod=$(nfd-status -r | grep -iF ''$name'' | grep -o 'faceid='$nextHop' ([a-zA-Z0-9 =]*)' |\
grep -o 'expires=[0-9]*' | sed 's/'expires='//')
if [[ "$expirationPeriod" -lt $lowerBound || "$expirationPeriod" -gt $upperBound ]]; then
echo $name "has an expiration period of $expirationPeriod seconds which is not between the expected $lowerBound-$upperBound seconds"
exit 1
else
echo $name "has a correct expiration period between $lowerBound and $upperBound seconds"
fi
}
expect_entry_does_not_exist() {
name=$1
count=$(nfd-status -r | grep -c ' $name ')
if [[ $count -gt 0 ]]; then
echo $name "exists past its expected expiration period."
exit 2
else
echo $name "has expired successfully"
fi
}
expect_route_does_not_exist() {
name=$1
faceId=$2
count=$(nfd-status -r | grep -iF ''$name'' | grep -c 'faceid='$faceId'')
if [[ $count -gt 0 ]]; then
echo "Route for $name with FaceId: $faceId exists past its expected expiration period."
exit 2
else
echo "Route for $name with FaceId: $faceId has expired successfully"
fi
}
sleep_for_seconds() {
echo -e "Sleeping for $1 seconds...\n"
sleep $1
}