github.com/rumpl/bof@v23.0.0-rc.2+incompatible/libnetwork/test/integration/dnet/run-integration-tests.sh (about) 1 #!/usr/bin/env bash 2 3 set -e 4 5 export INTEGRATION_ROOT=./integration-tmp 6 export TMPC_ROOT=./integration-tmp/tmpc 7 8 declare -A cmap 9 10 trap "cleanup_containers" EXIT SIGINT 11 12 function cleanup_containers() { 13 for c in "${!cmap[@]}"; do 14 docker rm -f $c 1>> ${INTEGRATION_ROOT}/test.log 2>&1 || true 15 done 16 17 unset cmap 18 } 19 20 function run_bridge_tests() { 21 ## Setup 22 start_dnet 1 bridge 1>> ${INTEGRATION_ROOT}/test.log 2>&1 23 cmap[dnet - 1 - bridge]=dnet-1-bridge 24 25 ## Run the test cases 26 ./integration-tmp/bin/bats ./test/integration/dnet/bridge.bats 27 28 ## Teardown 29 stop_dnet 1 bridge 1>> ${INTEGRATION_ROOT}/test.log 2>&1 30 unset cmap[dnet-1-bridge] 31 } 32 33 function run_overlay_local_tests() { 34 ## Test overlay network in local scope 35 ## Setup 36 start_dnet 1 local 1>> ${INTEGRATION_ROOT}/test.log 2>&1 37 cmap[dnet - 1 - local]=dnet-1-local 38 start_dnet 2 local:$(dnet_container_ip 1 local) 1>> ${INTEGRATION_ROOT}/test.log 2>&1 39 cmap[dnet - 2 - local]=dnet-2-local 40 start_dnet 3 local:$(dnet_container_ip 1 local) 1>> ${INTEGRATION_ROOT}/test.log 2>&1 41 cmap[dnet - 3 - local]=dnet-3-local 42 43 ## Run the test cases 44 ./integration-tmp/bin/bats ./test/integration/dnet/overlay-local.bats 45 46 ## Teardown 47 stop_dnet 1 local 1>> ${INTEGRATION_ROOT}/test.log 2>&1 48 unset cmap[dnet-1-local] 49 stop_dnet 2 local 1>> ${INTEGRATION_ROOT}/test.log 2>&1 50 unset cmap[dnet-2-local] 51 stop_dnet 3 local 1>> ${INTEGRATION_ROOT}/test.log 2>&1 52 unset cmap[dnet-3-local] 53 } 54 55 function run_dnet_tests() { 56 # Test dnet configuration options 57 ./integration-tmp/bin/bats ./test/integration/dnet/dnet.bats 58 } 59 60 source ./test/integration/dnet/helpers.bash 61 62 if [ ! -d ${INTEGRATION_ROOT} ]; then 63 mkdir -p ${INTEGRATION_ROOT} 64 git clone https://github.com/sstephenson/bats.git ${INTEGRATION_ROOT}/bats 65 ./integration-tmp/bats/install.sh ./integration-tmp 66 fi 67 68 if [ ! -d ${TMPC_ROOT} ]; then 69 mkdir -p ${TMPC_ROOT} 70 docker pull busybox:ubuntu 71 docker export $(docker create busybox:ubuntu) > ${TMPC_ROOT}/busybox.tar 72 mkdir -p ${TMPC_ROOT}/rootfs 73 tar -C ${TMPC_ROOT}/rootfs -xf ${TMPC_ROOT}/busybox.tar 74 fi 75 76 # Suite setup 77 78 if [ -z "$SUITES" ]; then 79 suites="dnet bridge" 80 else 81 suites="$SUITES" 82 fi 83 84 echo "" 85 86 for suite in ${suites}; do 87 suite_func=run_${suite}_tests 88 echo "Running ${suite}_tests ..." 89 declare -F $suite_func > /dev/null && $suite_func 90 echo "" 91 done