2022-05-11 22:47:31 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
# remember this is running in "ci" folder..
|
|
|
|
|
|
|
|
|
|
# Colors
|
|
|
|
|
BLUE='\E[1;34m'
|
|
|
|
|
CYAN='\E[1;36m'
|
|
|
|
|
GREEN='\E[1;32m'
|
|
|
|
|
RESET='\E[0m'
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
|
|
# $1: container_name
|
|
|
|
|
get_container_ip () {
|
|
|
|
|
local container_name=$1
|
|
|
|
|
local container
|
|
|
|
|
local ip
|
2023-04-11 11:26:09 +00:00
|
|
|
|
container=$(docker-compose ps --all -q "${container_name}" | tail -n1)
|
2022-05-11 22:47:31 +00:00
|
|
|
|
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
|
2023-04-11 11:26:09 +00:00
|
|
|
|
container=$(docker-compose ps --all -q "${container_name}" | tail -n1)
|
2022-05-11 22:47:31 +00:00
|
|
|
|
ip=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK_NAME}.Aliases}}" "$container")
|
|
|
|
|
echo "$ip"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Bring up a stack, in steps so we can inject IPs everywhere
|
|
|
|
|
docker-compose up -d pdns pdns-db
|
|
|
|
|
PDNS_IP=$(get_container_ip "pdns")
|
|
|
|
|
echo -e "${BLUE}❯ ${YELLOW}PDNS IP is ${PDNS_IP}${RESET}"
|
|
|
|
|
|
|
|
|
|
# adjust the dnsrouter config
|
|
|
|
|
LOCAL_DNSROUTER_CONFIG="$DIR/../../docker/dev/dnsrouter-config.json"
|
|
|
|
|
rm -rf "$LOCAL_DNSROUTER_CONFIG.tmp"
|
|
|
|
|
# IMPORTANT: changes to dnsrouter-config.json will affect this line:
|
|
|
|
|
jq --arg a "$PDNS_IP" '.servers[0].upstreams[1].upstream = $a' "$LOCAL_DNSROUTER_CONFIG" > "$LOCAL_DNSROUTER_CONFIG.tmp"
|
|
|
|
|
|
|
|
|
|
docker-compose up -d dnsrouter
|
|
|
|
|
DNSROUTER_IP=$(get_container_ip "dnsrouter")
|
|
|
|
|
echo -e "${BLUE}❯ ${YELLOW}DNS Router IP is ${DNSROUTER_IP}"
|
|
|
|
|
|
|
|
|
|
# mount the resolver
|
|
|
|
|
LOCAL_RESOLVE="$DIR/../../docker/dev/resolv.conf"
|
|
|
|
|
rm -rf "${LOCAL_RESOLVE}"
|
|
|
|
|
printf "nameserver %s\noptions ndots:0" "${DNSROUTER_IP}" > "${LOCAL_RESOLVE}"
|
|
|
|
|
|
|
|
|
|
# bring up all remaining containers, except cypress!
|
|
|
|
|
docker-compose up -d --remove-orphans fullstack stepca
|
|
|
|
|
|
|
|
|
|
# wait for main container to be healthy
|
2023-04-11 11:26:09 +00:00
|
|
|
|
bash "$DIR/../wait-healthy" "$(docker-compose ps --all -q fullstack)" 120
|
2022-05-11 22:47:31 +00:00
|
|
|
|
|
|
|
|
|
# Run tests
|
|
|
|
|
rm -rf "$DIR/../../test/results"
|
|
|
|
|
docker-compose up cypress
|
|
|
|
|
|
|
|
|
|
# Get results
|
2023-04-11 11:26:09 +00:00
|
|
|
|
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/"
|
2022-05-11 22:47:31 +00:00
|
|
|
|
|
|
|
|
|
echo -e "${BLUE}❯ ${GREEN}Fullstack cypress testing complete${RESET}"
|