github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/libnetwork/test/integration/dnet/overlay-local.bats (about)

     1  # -*- mode: sh -*-
     2  #!/usr/bin/env bats
     3  
     4  load helpers
     5  
     6  function test_overlay_local() {
     7      dnet_suffix=$1
     8  
     9      echo $(docker ps)
    10  
    11      start=1
    12      end=3
    13      for i in `seq ${start} ${end}`;
    14      do
    15  	echo "iteration count ${i}"
    16  	dnet_cmd $(inst_id2port $i) network create -d overlay --id=mhid --subnet=10.1.0.0/16 --ip-range=10.1.${i}.0/24 --opt=com.docker.network.driver.overlay.vxlanid_list=1024 multihost
    17  	dnet_cmd $(inst_id2port $i) container create container_${i}
    18  	net_connect ${i} container_${i} multihost
    19      done
    20  
    21      # Now test connectivity between all the containers using service names
    22      for i in `seq ${start} ${end}`;
    23      do
    24  	if [ -z "${2}" -o "${2}" != "internal" ]; then
    25  	    runc $(dnet_container_name $i $dnet_suffix) $(get_sbox_id ${i} container_${i}) \
    26  		"ping -c 1 www.google.com"
    27  	else
    28  	    default_route=`runc $(dnet_container_name $i $dnet_suffix) $(get_sbox_id ${i} container_${i}) "ip route | grep default"`
    29  	    [ "$default_route" = "" ]
    30  	fi
    31  	for j in `seq ${start} ${end}`;
    32  	do
    33  	    if [ "$i" -eq "$j" ]; then
    34  		continue
    35  	    fi
    36  	    #runc $(dnet_container_name $i $dnet_suffix) $(get_sbox_id ${i} container_${i}) "ping -c 1 10.1.${j}.1"
    37  	    runc $(dnet_container_name $i $dnet_suffix) $(get_sbox_id ${i} container_${i}) "ping -c 1 container_${j}"
    38  	done
    39      done
    40  
    41      # Teardown the container connections and the network
    42      for i in `seq ${start} ${end}`;
    43      do
    44  	net_disconnect ${i} container_${i} multihost
    45  	dnet_cmd $(inst_id2port $i) container rm container_${i}
    46      done
    47  
    48      if [ -z "${2}" -o "${2}" != "skip_rm" ]; then
    49  	dnet_cmd $(inst_id2port 2) network rm multihost
    50      fi
    51  }
    52  
    53  @test "Test overlay network in local scope" {
    54      skip_for_circleci
    55      test_overlay_local local
    56  }
    57  
    58  #"ping -c 1 10.1.${j}.1"