@@ -292,6 +292,110 @@ function test_overlay() {
292292 dnet_cmd $( inst_id2port 2) network rm multihost
293293}
294294
295+ function check_etchosts() {
296+ local dnet sbid retval
297+ dnet=${1}
298+ shift
299+ sbid=${1}
300+ shift
301+
302+ retval=" true"
303+
304+ for i in $* ;
305+ do
306+ run runc ${dnet} ${sbid} " cat /etc/hosts"
307+ if [ " $status " -ne 0 ]; then
308+ retval=" ${output} "
309+ break
310+ fi
311+
312+ line=$( echo ${output} | grep ${i} )
313+ if [ " ${line} " == " " ]; then
314+ retval=" false"
315+ fi
316+ done
317+
318+ echo ${retval}
319+ }
320+
321+ function test_overlay_etchosts() {
322+ local clist dnet_suffix
323+
324+ dnet_suffix=$1
325+ shift
326+
327+ echo $( docker ps)
328+
329+ start=1
330+ end=3
331+ # Setup overlay network and connect containers ot it
332+ dnet_cmd $( inst_id2port 1) network create -d overlay multihost
333+
334+ for iter in ` seq 1 2` ;
335+ do
336+ for i in ` seq ${start} ${end} ` ;
337+ do
338+ dnet_cmd $( inst_id2port $i ) container create container_${iter} _${i}
339+ net_connect ${i} container_${iter} _${i} multihost
340+ done
341+
342+ # Now test the /etc/hosts content of all the containers
343+ for i in ` seq ${start} ${end} ` ;
344+ do
345+ clist=" "
346+ oldclist=" "
347+ for j in ` seq ${start} ${end} ` ;
348+ do
349+ if [ " $i " -eq " $j " ]; then
350+ continue
351+ fi
352+ clist=" $clist container_${iter} _$j "
353+ oldclist=" $oldclist container_1_$j "
354+ done
355+ rv=$( check_etchosts $( dnet_container_name $i $dnet_suffix ) \
356+ $( get_sbox_id ${i} container_${iter} _${i} ) \
357+ ${clist} )
358+ [ " $rv " = " true" ]
359+
360+ # check to see the containers don't have stale entries from previous iteration
361+ if [ " $iter " -eq 2 ]; then
362+ rv=$( check_etchosts $( dnet_container_name $i $dnet_suffix ) \
363+ $( get_sbox_id ${i} container_${iter} _${i} ) \
364+ ${oldclist} )
365+ [ " $rv " = " false" ]
366+ fi
367+ done
368+
369+ # Teardown the container connections and the network
370+ clist=" "
371+ for i in ` seq ${start} ${end} ` ;
372+ do
373+ net_disconnect ${i} container_${iter} _${i} multihost
374+ dnet_cmd $( inst_id2port $i ) container rm container_${iter} _${i}
375+
376+ # check if the /etc/hosts of other containers does not contain this container
377+ for j in ` seq ${start} ${end} ` ;
378+ do
379+ if [ " $i " -eq " $j " ]; then
380+ continue
381+ fi
382+
383+ if [[ " ${clist} " =~ .* container_${iter} _${j} .* ]]; then
384+ continue
385+ fi
386+
387+ rv=$( check_etchosts $( dnet_container_name $j $dnet_suffix ) \
388+ $( get_sbox_id ${j} container_${iter} _${j} ) \
389+ container_${iter} _${i} )
390+ [ " $rv " = " false" ]
391+ done
392+ clist=" ${clist} container_${iter} _${i} "
393+ done
394+ done
395+
396+ dnet_cmd $( inst_id2port 2) network rm multihost
397+ }
398+
295399function test_overlay_singlehost() {
296400 dnet_suffix=$1
297401 shift
0 commit comments