Skip to content

Commit

Permalink
Simplified tests
Browse files Browse the repository at this point in the history
It is sufficient to use nslookup pointed at the docksal-dns container to test DNS resolution.
  • Loading branch information
lmakarov committed Nov 5, 2021
1 parent 8c7b361 commit 3f331c8
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -68,41 +68,25 @@ _healthcheck_wait ()
unset output
}

@test ".docksal name resolution" {
@test ".docksal name resolution via docksal-dns" {
[[ $SKIP == 1 ]] && skip

run _healthcheck_wait
unset output

# Check .docksal domain resolution via ping
run ping -c 1 -t 1 anything.docksal
[[ "${output}" == *"${DOCKSAL_IP}"* ]]
unset output

# Check .docksal domain resolution via dig
run dig @${DOCKSAL_IP} anything.docksal
[[ "${output}" == *"SERVER: ${DOCKSAL_IP}"* ]]
[[ "${output}" == *"ANSWER: 1"* ]]
run nslookup -timeout=1 anything.docksal ${DOCKSAL_IP}
[[ ${status} == 0 ]]
unset output
}

@test "External name resolution" {
@test "External name resolution via docksal-dns" {
[[ $SKIP == 1 ]] && skip

run _healthcheck_wait
unset output

# Real domain
run ping -c 1 -t 1 www.google.com
# Use case insensitive comparison (,, modifier), as ping produces different output on different platforms
[[ "${output,,}" == *"ping www.google.com "* ]]
[[ "${output,,}" != *"unknown host"* ]]
run nslookup -timeout=1 docksal.site ${DOCKSAL_IP}
[[ ${status} == 0 ]]
unset output

# Fake domain
run ping -c 1 -t 1 www.google2.com
# Use case insensitive comparison (,, modifier), as ping produces different output on different platforms
[[ "${output,,}" != *"ping www.google2.com "* ]]
[[ "${output,,}" == *"not known"* ]] || [[ "${output,,}" == *"unknown host"* ]] || [[ "${output,,}" == *"cannot resolve"* ]]
run nslookup -timeout=1 docksal.xyz ${DOCKSAL_IP}
[[ ${status} != 0 ]]
unset output
}

0 comments on commit 3f331c8

Please sign in to comment.