Skip to content

Commit 16c0276

Browse files
committed
Fix flakey CI due to full stack network determination
1 parent 1831fdf commit 16c0276

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

scripts/ci/fulltest-cypress

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
#!/bin/bash
22
set -e
33

4+
STACK="${1:-}"
5+
46
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
57
# remember this is running in "ci" folder..
68

9+
# Some defaults for running this script outside of CI
10+
export COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-npm_local_fulltest}"
11+
export IMAGE="${IMAGE:-nginx-proxy-manager}"
12+
export BRANCH_LOWER="${BRANCH_LOWER:-unknown}"
13+
export BUILD_NUMBER="${BUILD_NUMBER:-0000}"
14+
15+
if [ "${COMPOSE_FILE:-}" = "" ]; then
16+
export COMPOSE_FILE="docker/docker-compose.ci.yml"
17+
if [ "$STACK" != "" ]; then
18+
export COMPOSE_FILE="${COMPOSE_FILE}:docker/docker-compose.ci.${STACK}.yml"
19+
fi
20+
fi
21+
722
# Colors
823
BLUE='\E[1;34m'
24+
RED='\E[1;31m'
925
CYAN='\E[1;36m'
1026
GREEN='\E[1;32m'
1127
RESET='\E[0m'
@@ -14,26 +30,15 @@ YELLOW='\E[1;33m'
1430
export BLUE CYAN GREEN RESET YELLOW
1531

1632
echo -e "${BLUE}${CYAN}Starting fullstack cypress testing ...${RESET}"
17-
18-
NETWORK_NAME="${COMPOSE_PROJECT_NAME}_default"
33+
echo -e "${BLUE}$(docker-compose config)${RESET}"
1934

2035
# $1: container_name
2136
get_container_ip () {
2237
local container_name=$1
2338
local container
2439
local ip
2540
container=$(docker-compose ps --all -q "${container_name}" | tail -n1)
26-
ip=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK_NAME}.IPAddress}}" "$container")
27-
echo "$ip"
28-
}
29-
30-
# $1: container_name
31-
get_container_aliases () {
32-
local container_name=$1
33-
local container
34-
local ip
35-
container=$(docker-compose ps --all -q "${container_name}" | tail -n1)
36-
ip=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK_NAME}.Aliases}}" "$container")
41+
ip=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container")
3742
echo "$ip"
3843
}
3944

@@ -52,6 +57,11 @@ docker-compose up -d dnsrouter
5257
DNSROUTER_IP=$(get_container_ip "dnsrouter")
5358
echo -e "${BLUE}${YELLOW}DNS Router IP is ${DNSROUTER_IP}"
5459

60+
if [ "${DNSROUTER_IP:-}" = "" ]; then
61+
echo -e "${RED}❯ ERROR: DNS Router IP is not set${RESET}"
62+
exit 1
63+
fi
64+
5565
# mount the resolver
5666
LOCAL_RESOLVE="$DIR/../../docker/dev/resolv.conf"
5767
rm -rf "${LOCAL_RESOLVE}"
@@ -68,10 +78,15 @@ bash "$DIR/../wait-healthy" "$(docker-compose ps --all -q fullstack)" 120
6878

6979
# Run tests
7080
rm -rf "$DIR/../../test/results"
71-
docker-compose up cypress
81+
docker-compose up --build cypress
7282

7383
# Get results
7484
docker cp -L "$(docker-compose ps --all -q cypress):/test/results" "$DIR/../../test/"
7585
docker cp -L "$(docker-compose ps --all -q fullstack):/data/logs" "$DIR/../../test/results/"
7686

87+
if [ "$2" = "cleanup" ]; then
88+
echo -e "${BLUE}${CYAN}Cleaning up containers ...${RESET}"
89+
docker-compose down --remove-orphans --volumes -t 30
90+
fi
91+
7792
echo -e "${BLUE}${GREEN}Fullstack cypress testing complete${RESET}"

0 commit comments

Comments
 (0)