overlay-local.bats 1.7 KB

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