Fix flakey CI due to full stack network determination

This commit is contained in:
Jamie Curnow
2024-05-23 08:12:51 +10:00
parent bed387ebd4
commit d3a654b546
3 changed files with 23 additions and 16 deletions

View File

@ -18,6 +18,7 @@ fi
# Colors
BLUE='\E[1;34m'
RED='\E[1;31m'
CYAN='\E[1;36m'
GREEN='\E[1;32m'
RESET='\E[0m'
@ -26,8 +27,7 @@ YELLOW='\E[1;33m'
export BLUE CYAN GREEN RESET YELLOW
echo -e "${BLUE} ${CYAN}Starting fullstack cypress testing ...${RESET}"
NETWORK_NAME="${COMPOSE_PROJECT_NAME}_default"
echo -e "${BLUE} $(docker-compose config)${RESET}"
# $1: container_name
get_container_ip () {
@ -35,17 +35,7 @@ get_container_ip () {
local container
local ip
container=$(docker-compose ps --all -q "${container_name}" | tail -n1)
ip=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK_NAME}.IPAddress}}" "$container")
echo "$ip"
}
# $1: container_name
get_container_aliases () {
local container_name=$1
local container
local ip
container=$(docker-compose ps --all -q "${container_name}" | tail -n1)
ip=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK_NAME}.Aliases}}" "$container")
ip=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container")
echo "$ip"
}
@ -64,6 +54,11 @@ docker-compose up -d dnsrouter
DNSROUTER_IP=$(get_container_ip "dnsrouter")
echo -e "${BLUE} ${YELLOW}DNS Router IP is ${DNSROUTER_IP}"
if [ "${DNSROUTER_IP:-}" = "" ]; then
echo -e "${RED} ERROR: DNS Router IP is not set${RESET}"
exit 1
fi
# mount the resolver
LOCAL_RESOLVE="$DIR/../../docker/dev/resolv.conf"
rm -rf "${LOCAL_RESOLVE}"