mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Fix flakey CI due to full stack network determination
This commit is contained in:
parent
1831fdff2d
commit
16c0276401
@ -1,11 +1,27 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
STACK="${1:-}"
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
# remember this is running in "ci" folder..
|
# remember this is running in "ci" folder..
|
||||||
|
|
||||||
|
# Some defaults for running this script outside of CI
|
||||||
|
export COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-npm_local_fulltest}"
|
||||||
|
export IMAGE="${IMAGE:-nginx-proxy-manager}"
|
||||||
|
export BRANCH_LOWER="${BRANCH_LOWER:-unknown}"
|
||||||
|
export BUILD_NUMBER="${BUILD_NUMBER:-0000}"
|
||||||
|
|
||||||
|
if [ "${COMPOSE_FILE:-}" = "" ]; then
|
||||||
|
export COMPOSE_FILE="docker/docker-compose.ci.yml"
|
||||||
|
if [ "$STACK" != "" ]; then
|
||||||
|
export COMPOSE_FILE="${COMPOSE_FILE}:docker/docker-compose.ci.${STACK}.yml"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
BLUE='\E[1;34m'
|
BLUE='\E[1;34m'
|
||||||
|
RED='\E[1;31m'
|
||||||
CYAN='\E[1;36m'
|
CYAN='\E[1;36m'
|
||||||
GREEN='\E[1;32m'
|
GREEN='\E[1;32m'
|
||||||
RESET='\E[0m'
|
RESET='\E[0m'
|
||||||
@ -14,8 +30,7 @@ YELLOW='\E[1;33m'
|
|||||||
export BLUE CYAN GREEN RESET YELLOW
|
export BLUE CYAN GREEN RESET YELLOW
|
||||||
|
|
||||||
echo -e "${BLUE}❯ ${CYAN}Starting fullstack cypress testing ...${RESET}"
|
echo -e "${BLUE}❯ ${CYAN}Starting fullstack cypress testing ...${RESET}"
|
||||||
|
echo -e "${BLUE}❯ $(docker-compose config)${RESET}"
|
||||||
NETWORK_NAME="${COMPOSE_PROJECT_NAME}_default"
|
|
||||||
|
|
||||||
# $1: container_name
|
# $1: container_name
|
||||||
get_container_ip () {
|
get_container_ip () {
|
||||||
@ -23,17 +38,7 @@ get_container_ip () {
|
|||||||
local container
|
local container
|
||||||
local ip
|
local ip
|
||||||
container=$(docker-compose ps --all -q "${container_name}" | tail -n1)
|
container=$(docker-compose ps --all -q "${container_name}" | tail -n1)
|
||||||
ip=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK_NAME}.IPAddress}}" "$container")
|
ip=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$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")
|
|
||||||
echo "$ip"
|
echo "$ip"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +57,11 @@ docker-compose up -d dnsrouter
|
|||||||
DNSROUTER_IP=$(get_container_ip "dnsrouter")
|
DNSROUTER_IP=$(get_container_ip "dnsrouter")
|
||||||
echo -e "${BLUE}❯ ${YELLOW}DNS Router IP is ${DNSROUTER_IP}"
|
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
|
# mount the resolver
|
||||||
LOCAL_RESOLVE="$DIR/../../docker/dev/resolv.conf"
|
LOCAL_RESOLVE="$DIR/../../docker/dev/resolv.conf"
|
||||||
rm -rf "${LOCAL_RESOLVE}"
|
rm -rf "${LOCAL_RESOLVE}"
|
||||||
@ -68,10 +78,15 @@ bash "$DIR/../wait-healthy" "$(docker-compose ps --all -q fullstack)" 120
|
|||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
rm -rf "$DIR/../../test/results"
|
rm -rf "$DIR/../../test/results"
|
||||||
docker-compose up cypress
|
docker-compose up --build cypress
|
||||||
|
|
||||||
# Get results
|
# Get results
|
||||||
docker cp -L "$(docker-compose ps --all -q cypress):/test/results" "$DIR/../../test/"
|
docker cp -L "$(docker-compose ps --all -q cypress):/test/results" "$DIR/../../test/"
|
||||||
docker cp -L "$(docker-compose ps --all -q fullstack):/data/logs" "$DIR/../../test/results/"
|
docker cp -L "$(docker-compose ps --all -q fullstack):/data/logs" "$DIR/../../test/results/"
|
||||||
|
|
||||||
|
if [ "$2" = "cleanup" ]; then
|
||||||
|
echo -e "${BLUE}❯ ${CYAN}Cleaning up containers ...${RESET}"
|
||||||
|
docker-compose down --remove-orphans --volumes -t 30
|
||||||
|
fi
|
||||||
|
|
||||||
echo -e "${BLUE}❯ ${GREEN}Fullstack cypress testing complete${RESET}"
|
echo -e "${BLUE}❯ ${GREEN}Fullstack cypress testing complete${RESET}"
|
||||||
|
Loading…
Reference in New Issue
Block a user