1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
summary: Test httputil/retry.go ShouldRetryError(err)/NoNetwork(err)
details: |
Test the httputil/retry.go helpers that determine when errors are due to
transient network faults such as temporary DNS failures.
# ubuntu-core: no go-compiler
# ubuntu-14.04: no nsenter
systems: [-ubuntu-core-*, -ubuntu-14.04-*]
prepare: |
go build -o detect-retry ./detect-retry.go
restore: |
ip netns delete testns || true
umount /run/netns || true
debug: |
cat output.txt || true
cat stderr || true
execute: |
echo "Add totally unconnected network namespace"
ip netns add testns
# Make sure we don't use a proxy to access http endpoint, otherwise the NoNetwork will be false
http_proxy="" HTTP_PROXY="" SNAPD_DEBUG=1 nsenter --net=/var/run/netns/testns ./detect-retry http://www.ubuntu.com > output.txt 2>stderr
# XXX: ShouldRetryError is slightly misbehaving, if we know we don't have
# a network connection we should not retry. However we keep it as
# it is for now to be sure we don't add regressions.
MATCH "ShouldRetryError: true" < output.txt
MATCH "NoNetwork: true" < output.txt
# be paranoid and look at the low-level go error as well
MATCH "(Temporary failure in name resolution|network is unreachable)" < stderr
echo "Now without DNS resolver with ipv4"
UBUNTU_IP="$(getent ahostsv4 www.ubuntu.com|awk '{print $1 }' | head -n1)"
# when ubuntu.com is configured in no_proxy, then we need to add the ip as well
if echo "$NO_PROXY" | MATCH 'ubuntu.com'; then
export NO_PROXY="$NO_PROXY","$UBUNTU_IP"
fi
http_proxy="" HTTP_PROXY="" SNAPD_DEBUG=1 nsenter --net=/var/run/netns/testns ./detect-retry "http://$UBUNTU_IP" > output.txt 2>stderr
# XXX: ShouldRetryError is slightly misbehaving, see comment above
MATCH "ShouldRetryError: true" < output.txt
MATCH "NoNetwork: true" < output.txt
# be paranoid and look at the low-level go error as well
MATCH "network is unreachable" < stderr
# Without having "lo" up the ipv6 test will retrun EADDRNOTAVAIL which
# is misleading, it just means that there is no ipv6 addresses in the
# namespace, adding localhost fixes this.
echo "but make sure we have localhost available so that ipv6 works"
ip netns exec testns ip link set dev lo up
echo "Now without DNS resolver for ipv6"
UBUNTU_IP="$(getent ahostsv6 www.ubuntu.com|awk '{print $1 }' | head -n1)"
# when ubuntu.com is configured in no_proxy, then we need to add the ip as well
if echo "$NO_PROXY" | MATCH 'ubuntu.com'; then
export NO_PROXY="$NO_PROXY","$UBUNTU_IP"
fi
http_proxy="" HTTP_PROXY="" SNAPD_DEBUG=1 nsenter --net=/var/run/netns/testns ./detect-retry "http://[$UBUNTU_IP]" > output.txt 2>stderr
# XXX: ShouldRetryError is slightly misbehaving, see comment above
MATCH "ShouldRetryError: true" < output.txt
MATCH "NoNetwork: true" < output.txt
# be paranoid and look at the low-level go error as well
MATCH "network is unreachable" < stderr
|