mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add IT case for proper /etc/hosts handling
Added an IT case for checking proper /etc/hosts handling in the overlay network. This also to see if there are any stale entries in the /etc/hosts Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
This commit is contained in:
parent
e5b34e1435
commit
92f7f2e1a0
2 changed files with 109 additions and 0 deletions
|
@ -292,6 +292,110 @@ function test_overlay() {
|
||||||
dnet_cmd $(inst_id2port 2) network rm multihost
|
dnet_cmd $(inst_id2port 2) network rm multihost
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_etchosts() {
|
||||||
|
local dnet sbid retval
|
||||||
|
dnet=${1}
|
||||||
|
shift
|
||||||
|
sbid=${1}
|
||||||
|
shift
|
||||||
|
|
||||||
|
retval="true"
|
||||||
|
|
||||||
|
for i in $*;
|
||||||
|
do
|
||||||
|
run runc ${dnet} ${sbid} "cat /etc/hosts"
|
||||||
|
if [ "$status" -ne 0 ]; then
|
||||||
|
retval="${output}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
line=$(echo ${output} | grep ${i})
|
||||||
|
if [ "${line}" == "" ]; then
|
||||||
|
retval="false"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ${retval}
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_overlay_etchosts() {
|
||||||
|
local clist dnet_suffix
|
||||||
|
|
||||||
|
dnet_suffix=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
echo $(docker ps)
|
||||||
|
|
||||||
|
start=1
|
||||||
|
end=3
|
||||||
|
# Setup overlay network and connect containers ot it
|
||||||
|
dnet_cmd $(inst_id2port 1) network create -d overlay multihost
|
||||||
|
|
||||||
|
for iter in `seq 1 2`;
|
||||||
|
do
|
||||||
|
for i in `seq ${start} ${end}`;
|
||||||
|
do
|
||||||
|
dnet_cmd $(inst_id2port $i) container create container_${iter}_${i}
|
||||||
|
net_connect ${i} container_${iter}_${i} multihost
|
||||||
|
done
|
||||||
|
|
||||||
|
# Now test the /etc/hosts content of all the containers
|
||||||
|
for i in `seq ${start} ${end}`;
|
||||||
|
do
|
||||||
|
clist=""
|
||||||
|
oldclist=""
|
||||||
|
for j in `seq ${start} ${end}`;
|
||||||
|
do
|
||||||
|
if [ "$i" -eq "$j" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
clist="$clist container_${iter}_$j"
|
||||||
|
oldclist="$oldclist container_1_$j"
|
||||||
|
done
|
||||||
|
rv=$(check_etchosts $(dnet_container_name $i $dnet_suffix) \
|
||||||
|
$(get_sbox_id ${i} container_${iter}_${i}) \
|
||||||
|
${clist})
|
||||||
|
[ "$rv" = "true" ]
|
||||||
|
|
||||||
|
# check to see the containers don't have stale entries from previous iteration
|
||||||
|
if [ "$iter" -eq 2 ]; then
|
||||||
|
rv=$(check_etchosts $(dnet_container_name $i $dnet_suffix) \
|
||||||
|
$(get_sbox_id ${i} container_${iter}_${i}) \
|
||||||
|
${oldclist})
|
||||||
|
[ "$rv" = "false" ]
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Teardown the container connections and the network
|
||||||
|
clist=""
|
||||||
|
for i in `seq ${start} ${end}`;
|
||||||
|
do
|
||||||
|
net_disconnect ${i} container_${iter}_${i} multihost
|
||||||
|
dnet_cmd $(inst_id2port $i) container rm container_${iter}_${i}
|
||||||
|
|
||||||
|
#check if the /etc/hosts of other containers does not contain this container
|
||||||
|
for j in `seq ${start} ${end}`;
|
||||||
|
do
|
||||||
|
if [ "$i" -eq "$j" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${clist}" =~ .*container_${iter}_${j}.* ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
rv=$(check_etchosts $(dnet_container_name $j $dnet_suffix) \
|
||||||
|
$(get_sbox_id ${j} container_${iter}_${j}) \
|
||||||
|
container_${iter}_${i})
|
||||||
|
[ "$rv" = "false" ]
|
||||||
|
done
|
||||||
|
clist="${clist} container_${iter}_${i}"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
dnet_cmd $(inst_id2port 2) network rm multihost
|
||||||
|
}
|
||||||
|
|
||||||
function test_overlay_singlehost() {
|
function test_overlay_singlehost() {
|
||||||
dnet_suffix=$1
|
dnet_suffix=$1
|
||||||
shift
|
shift
|
||||||
|
|
|
@ -12,3 +12,8 @@ load helpers
|
||||||
skip_for_circleci
|
skip_for_circleci
|
||||||
test_overlay_singlehost consul
|
test_overlay_singlehost consul
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "test overlay network etc hosts with consul" {
|
||||||
|
skip_for_circleci
|
||||||
|
test_overlay_etchosts consul
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue