Skip to content

Commit

Permalink
Fix flakey CI due to full stack network determination
Browse files Browse the repository at this point in the history
  • Loading branch information
jc21 committed May 22, 2024
1 parent bed387e commit d3a654b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 2 additions & 0 deletions docker/docker-compose.ci.mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ services:
MYSQL_PASSWORD: 'npmpass'
volumes:
- mysql_vol:/var/lib/mysql
networks:
- fulltest

volumes:
mysql_vol:
16 changes: 13 additions & 3 deletions docker/docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
interval: 10s
timeout: 3s
networks:
default:
fulltest:
aliases:
- website1.example.com
- website2.example.com
Expand All @@ -32,7 +32,7 @@ services:
- './dev/resolv.conf:/etc/resolv.conf:ro'
- '/etc/localtime:/etc/localtime:ro'
networks:
default:
fulltest:
aliases:
- ca.internal

Expand All @@ -59,7 +59,7 @@ services:
depends_on:
- pdns-db
networks:
default:
fulltest:
aliases:
- ns1.pdns
- ns2.pdns
Expand All @@ -75,11 +75,15 @@ services:
- 'pdns_mysql_vol:/var/lib/mysql'
- '/etc/localtime:/etc/localtime:ro'
- './dev/pdns-db.sql:/docker-entrypoint-initdb.d/01_init.sql:ro'
networks:
- fulltest

dnsrouter:
image: jc21/dnsrouter
volumes:
- ./dev/dnsrouter-config.json.tmp:/dnsrouter-config.json:ro
networks:
- fulltest

cypress:
image: "${IMAGE}-cypress:ci-${BUILD_NUMBER}"
Expand All @@ -92,9 +96,15 @@ services:
- 'cypress_logs:/results'
- './dev/resolv.conf:/etc/resolv.conf:ro'
command: cypress run --browser chrome --config-file=cypress/config/ci.js
networks:
- fulltest

volumes:
cypress_logs:
npm_data_ci:
npm_le_ci:
pdns_mysql_vol:

networks:
fulltest:
name: "npm-${BRANCH_LOWER}-ci-${BUILD_NUMBER}"
21 changes: 8 additions & 13 deletions scripts/ci/fulltest-cypress
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -26,26 +27,15 @@ 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 () {
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}.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"
}

Expand All @@ -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}"
Expand Down

0 comments on commit d3a654b

Please sign in to comment.