Skip to content

Commit

Permalink
adapt timings
Browse files Browse the repository at this point in the history
  • Loading branch information
oncilla committed Sep 5, 2019
1 parent 7371dc9 commit eaba8f9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
12 changes: 7 additions & 5 deletions acceptance/discovery_br_fetches_dynamic_acceptance/test
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ test_run() {
sleep 3
check_connectivity "initial check"

# Start serving dynamic topology with invalid beacon service.
jq ".BeaconService[].Addrs.IPv4.Public.Addr = \"127.42.42.42\" | .Timestamp = $( date +%s) | .TTL = 2" $TOPO | sponge $DYNAMIC_FULL
sleep 0.5
log "Staring to serve dynamic topology with wrong BS address."
jq ".BeaconService[].Addrs.IPv4.Public.Addr = \"127.42.42.42\" | .Timestamp = $( date +%s) | .TTL = 7" $TOPO | sponge $DYNAMIC_FULL
log "Waiting for BS to issue revocation and link going down"
sleep 4
check_connectivity_broken "invalid beacon service address"

# Wait until dynamic topology expires.
sleep 3
log "Waiting until dynamic topology expires and revocations are gone."
sleep 15
check_connectivity "dynamic topology expired"

log "Checking fail action."
check_br_fail_action "dynamic"
}

Expand Down
18 changes: 10 additions & 8 deletions acceptance/discovery_br_fetches_static_acceptance/test
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,24 @@ test_run() {
sleep 3
check_connectivity "initial check"

# Start serving dynamic topology with invalid beacon service.
jq ".BeaconService[].Addrs.IPv4.Public.Addr = \"127.42.42.42\" | .Timestamp = $( date +%s) | .TTL = 15" $TOPO | sponge $STATIC_FULL
sleep 0.5
log "Staring to serve static topology with wrong BS address."
jq ".BeaconService[].Addrs.IPv4.Public.Addr = \"127.42.42.42\" | .Timestamp = $( date +%s)" $TOPO | sponge $STATIC_FULL
log "Waiting for BS to issue revocation and link going down"
sleep 4
check_connectivity_broken "invalid beacon service address"

# Check that the logs contain setting and writing the topo.
sleep 1
log "Checking topology is set and written to file system."
check_logs "br$IA_FILE-1"
# Check that the written file does not differ from the served file.
diff -q $STATIC_FULL logs/br$IA_FILE-1-topo.json

# Set the valid static topology.
log "Setting original topology"
cp $TOPO $STATIC_FULL
sleep 0.5

log "Waiting for revocation to expire."
sleep 12
check_connectivity "serve original static topology"

log "Checking fail action."
check_br_fail_action "static"
}

Expand Down
8 changes: 6 additions & 2 deletions acceptance/discovery_infra_fetches_dynamic_acceptance/test
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,24 @@ test_setup() {

test_run() {
set -e
# Start serving dynamic topology. Full for infra services, default for sciond.
jq ".BorderRouters[].InternalAddrs.IPv4.PublicOverlay = {Addr: \"127.42.42.42\", OverlayPort: 39999} | .Timestamp = $( date +%s) | .TTL = 3" $TOPO | sponge $DYNAMIC_FULL

log "Starting to serve dynamic topology with modified border router."
jq ".BorderRouters[].InternalAddrs.IPv4.PublicOverlay = {Addr: \"127.42.42.42\", OverlayPort: 39999} | .Timestamp = $( date +%s) | .TTL = 1" $TOPO | sponge $DYNAMIC_FULL
cp $DYNAMIC_FULL $DYNAMIC_DEFAULT
sleep 2
check_file "dynamic"

check_logs "bs$IA_FILE-1"
check_logs "cs$IA_FILE-1"
check_logs "ps$IA_FILE-1"
check_logs "sd$IA_FILE"

log "Checking fail action."
check_infra_fail_action "dynamic"
}

check_logs() {
log "Checking logs for $1."
grep -q "\[discovery\] Set topology.*mode=dynamic" "logs/$1.log" || \
fail "Setting dynamic topology not found in logs. id=$1"
grep -q "\[itopo.cleaner\] Dropping expired dynamic topology" "logs/$1.log" || \
Expand Down
13 changes: 8 additions & 5 deletions acceptance/discovery_infra_fetches_static_acceptance/test
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,37 @@ test_setup() {

test_run() {
set -e
# Start serving static topology. Full for infra services, default for sciond.
jq ".BorderRouters[].InternalAddrs.IPv4.PublicOverlay = {Addr: \"127.42.42.42\", OverlayPort: 39999} | .Timestamp = $( date +%s) | .TTL = 3" $TOPO | sponge $STATIC_FULL

log "Starting to serve static topology with modified border router."
jq ".BorderRouters[].InternalAddrs.IPv4.PublicOverlay = {Addr: \"127.42.42.42\", OverlayPort: 39999} | .Timestamp = $( date +%s)" $TOPO | sponge $STATIC_FULL
cp $STATIC_FULL $STATIC_DEFAULT
sleep 2
# Check that the mock ds serves the file
check_file "static"
# Check that the logs contain setting and writing the topo.

check_logs "bs$IA_FILE-1"
check_logs "cs$IA_FILE-1"
check_logs "ps$IA_FILE-1"
check_logs "sd$IA_FILE"
# Check that the written file does not differ from the served file.

check_diff "bs$IA_FILE-1"
check_diff "cs$IA_FILE-1"
check_diff "ps$IA_FILE-1"
check_diff "sd$IA_FILE"

log "Checking fail action."
check_infra_fail_action "static"
}

check_logs() {
log "Checking logs for $1."
grep -q "\[discovery\] Set topology.*mode=static" "logs/$1.log" || \
fail "Setting static topology not found in logs. id=$1"
grep -q "\[discovery\] Topology written to filesystem.*mode=static" "logs/$1.log" || \
fail "Writing static topology not found in logs. id=$1"
}

check_diff () {
log "Checking the stored static topology for $1."
diff -q $STATIC_FULL gen-cache/$1-topo.json
}

Expand Down

0 comments on commit eaba8f9

Please sign in to comment.