Created
September 19, 2014 13:18
-
-
Save gdm85/e02b1c2d0eb7ada5b590 to your computer and use it in GitHub Desktop.
Testcase for DNS caching bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## @author gdm85 | |
## tests DNS caching in Docker | |
## | |
# | |
if pgrep dnsmasq >/dev/null; then | |
echo "You are running dnsmasq, this test would not be consistent" 1>&2 | |
exit 1 | |
fi | |
echo "Stopping running docker..." | |
service docker stop >/dev/null 2>/dev/null | |
echo "Adding index.docker.io override" | |
echo "127.0.0.1 index.docker.io" >> /etc/hosts | |
service docker start >/dev/null || exit $? | |
echo "Waiting for docker to be online..." | |
## wait for service to be responsive | |
while ! docker ps >/dev/null 2>/dev/null; do | |
sleep 1 | |
done | |
echo "Pulling (expected failure)" | |
docker pull ubuntu | |
echo "Pull result is: $? (expected 1)" | |
## remove the override from /etc/hosts | |
echo "Now removing index.docker.io override" | |
sed -i '$ d' /etc/hosts | |
## expected success | |
docker pull ubuntu | |
RV=$? | |
echo "Pull result is: $RV (expected 0)" | |
exit $RV |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment