Skip to content

Commit d3a654b

Browse files
committed
Fix flakey CI due to full stack network determination
1 parent bed387e commit d3a654b

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

docker/docker-compose.ci.mysql.yml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ services:
2020
MYSQL_PASSWORD: 'npmpass'
2121
volumes:
2222
- mysql_vol:/var/lib/mysql
23+
networks:
24+
- fulltest
2325

2426
volumes:
2527
mysql_vol:

docker/docker-compose.ci.yml

+13-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
interval: 10s
2121
timeout: 3s
2222
networks:
23-
default:
23+
fulltest:
2424
aliases:
2525
- website1.example.com
2626
- website2.example.com
@@ -32,7 +32,7 @@ services:
3232
- './dev/resolv.conf:/etc/resolv.conf:ro'
3333
- '/etc/localtime:/etc/localtime:ro'
3434
networks:
35-
default:
35+
fulltest:
3636
aliases:
3737
- ca.internal
3838

@@ -59,7 +59,7 @@ services:
5959
depends_on:
6060
- pdns-db
6161
networks:
62-
default:
62+
fulltest:
6363
aliases:
6464
- ns1.pdns
6565
- ns2.pdns
@@ -75,11 +75,15 @@ services:
7575
- 'pdns_mysql_vol:/var/lib/mysql'
7676
- '/etc/localtime:/etc/localtime:ro'
7777
- './dev/pdns-db.sql:/docker-entrypoint-initdb.d/01_init.sql:ro'
78+
networks:
79+
- fulltest
7880

7981
dnsrouter:
8082
image: jc21/dnsrouter
8183
volumes:
8284
- ./dev/dnsrouter-config.json.tmp:/dnsrouter-config.json:ro
85+
networks:
86+
- fulltest
8387

8488
cypress:
8589
image: "${IMAGE}-cypress:ci-${BUILD_NUMBER}"
@@ -92,9 +96,15 @@ services:
9296
- 'cypress_logs:/results'
9397
- './dev/resolv.conf:/etc/resolv.conf:ro'
9498
command: cypress run --browser chrome --config-file=cypress/config/ci.js
99+
networks:
100+
- fulltest
95101

96102
volumes:
97103
cypress_logs:
98104
npm_data_ci:
99105
npm_le_ci:
100106
pdns_mysql_vol:
107+
108+
networks:
109+
fulltest:
110+
name: "npm-${BRANCH_LOWER}-ci-${BUILD_NUMBER}"

scripts/ci/fulltest-cypress

+8-13
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fi
1818

1919
# Colors
2020
BLUE='\E[1;34m'
21+
RED='\E[1;31m'
2122
CYAN='\E[1;36m'
2223
GREEN='\E[1;32m'
2324
RESET='\E[0m'
@@ -26,26 +27,15 @@ YELLOW='\E[1;33m'
2627
export BLUE CYAN GREEN RESET YELLOW
2728

2829
echo -e "${BLUE}${CYAN}Starting fullstack cypress testing ...${RESET}"
29-
30-
NETWORK_NAME="${COMPOSE_PROJECT_NAME}_default"
30+
echo -e "${BLUE}$(docker-compose config)${RESET}"
3131

3232
# $1: container_name
3333
get_container_ip () {
3434
local container_name=$1
3535
local container
3636
local ip
3737
container=$(docker-compose ps --all -q "${container_name}" | tail -n1)
38-
ip=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK_NAME}.IPAddress}}" "$container")
39-
echo "$ip"
40-
}
41-
42-
# $1: container_name
43-
get_container_aliases () {
44-
local container_name=$1
45-
local container
46-
local ip
47-
container=$(docker-compose ps --all -q "${container_name}" | tail -n1)
48-
ip=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK_NAME}.Aliases}}" "$container")
38+
ip=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container")
4939
echo "$ip"
5040
}
5141

@@ -64,6 +54,11 @@ docker-compose up -d dnsrouter
6454
DNSROUTER_IP=$(get_container_ip "dnsrouter")
6555
echo -e "${BLUE}${YELLOW}DNS Router IP is ${DNSROUTER_IP}"
6656

57+
if [ "${DNSROUTER_IP:-}" = "" ]; then
58+
echo -e "${RED}❯ ERROR: DNS Router IP is not set${RESET}"
59+
exit 1
60+
fi
61+
6762
# mount the resolver
6863
LOCAL_RESOLVE="$DIR/../../docker/dev/resolv.conf"
6964
rm -rf "${LOCAL_RESOLVE}"

0 commit comments

Comments
 (0)