overlay-consul.bats 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # -*- mode: sh -*-
  2. #!/usr/bin/env bats
  3. load helpers
  4. @test "Test overlay network with consul" {
  5. test_overlay consul
  6. }
  7. @test "Test overlay network singlehost with consul" {
  8. test_overlay_singlehost consul
  9. }
  10. @test "Test overlay network with dnet restart" {
  11. test_overlay consul skip_rm
  12. docker restart dnet-1-consul
  13. wait_for_dnet $(inst_id2port 1) dnet-1-consul
  14. docker restart dnet-2-consul
  15. wait_for_dnet $(inst_id2port 2) dnet-2-consul
  16. docker restart dnet-3-consul
  17. wait_for_dnet $(inst_id2port 3) dnet-3-consul
  18. test_overlay consul skip_add
  19. }
  20. @test "Test overlay network internal network with consul" {
  21. test_overlay consul internal
  22. }
  23. @test "Test overlay network with dnet ungraceful shutdown" {
  24. dnet_cmd $(inst_id2port 1) network create -d overlay multihost
  25. start=1
  26. end=3
  27. for i in `seq ${start} ${end}`;
  28. do
  29. dnet_cmd $(inst_id2port $i) container create container_${i}
  30. net_connect ${i} container_${i} multihost
  31. done
  32. hrun runc $(dnet_container_name 1 consul) $(get_sbox_id 1 container_1) "ifconfig eth0"
  33. container_1_ip=$(echo ${output} | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
  34. # ungracefully kill dnet-1-consul container
  35. docker rm -f dnet-1-consul
  36. # forcefully unpublish the service from dnet2 when dnet1 is dead.
  37. dnet_cmd $(inst_id2port 2) service unpublish -f container_1.multihost
  38. dnet_cmd $(inst_id2port 2) container create container_1
  39. net_connect 2 container_1 multihost
  40. hrun runc $(dnet_container_name 2 consul) $(get_sbox_id 2 container_1) "ifconfig eth0"
  41. container_1_new_ip=$(echo ${output} | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
  42. if [ "$container_1_ip" != "$container_1_new_ip" ]; then
  43. exit 1
  44. fi
  45. }