mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-09 13:58:02 -05:00
Updating docker tests to make it easier to follow & ensure it listens on the right interface on docker (#1851)
* making the tests easier to read * updating tests to run inside a container so the goss executable works on osx Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
This commit is contained in:
3
docker/.gitignore
vendored
3
docker/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
pantheon-*.tar.gz
|
||||
pantheon/*
|
||||
pantheon-*
|
||||
pantheon-*
|
||||
reports/*
|
||||
@@ -4,21 +4,26 @@ export GOSS_PATH=tests/goss-linux-amd64
|
||||
export GOSS_OPTS="$GOSS_OPTS --format junit"
|
||||
export GOSS_FILES_STRATEGY=cp
|
||||
DOCKER_IMAGE=$1
|
||||
DOCKER_FILE="${2:-$PWD/Dockerfile}"
|
||||
|
||||
i=0
|
||||
|
||||
## Checks on the Dockerfile
|
||||
GOSS_FILES_PATH=tests/00 \
|
||||
bash tests/dgoss dockerfile $DOCKER_IMAGE $DOCKER_FILE \
|
||||
> ./reports/00.xml || i=`expr $i + 1`
|
||||
# fail fast if we dont pass static checks
|
||||
if [[ $i != 0 ]]; then exit $i; fi
|
||||
|
||||
# Test for normal startup with ports opened
|
||||
# we test that things listen on the right interface/port, not what interface the advertise
|
||||
# hence we dont set p2p-host=0.0.0.0 because this sets what its advertising to devp2p; the important piece is that it defaults to listening on all interfaces
|
||||
GOSS_FILES_PATH=tests/01 \
|
||||
bash tests/dgoss \
|
||||
run $DOCKER_IMAGE \
|
||||
bash tests/dgoss run $DOCKER_IMAGE \
|
||||
--network=dev \
|
||||
--p2p-host=0.0.0.0 \
|
||||
--rpc-http-enabled \
|
||||
--rpc-http-host=0.0.0.0 \
|
||||
--rpc-ws-enabled \
|
||||
--rpc-ws-host=0.0.0.0 \
|
||||
--graphql-http-enabled \
|
||||
--graphql-http-host=0.0.0.0 \
|
||||
> ./reports/01.xml || i=`expr $i + 1`
|
||||
|
||||
exit $i
|
||||
|
||||
12
docker/tests/00/goss.yaml
Normal file
12
docker/tests/00/goss.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
# static Dockerfile tests
|
||||
|
||||
# ensure there are env vars set in the dockerfile
|
||||
file:
|
||||
/goss/Dockerfile:
|
||||
exists: true
|
||||
contains:
|
||||
- "/ENV PANTHEON_RPC_HTTP_HOST 0.0.0.0/"
|
||||
- "/ENV PANTHEON_RPC_WS_HOST 0.0.0.0/"
|
||||
- "/ENV PANTHEON_GRAPHQL_HTTP_HOST 0.0.0.0/"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
---
|
||||
# runtime docker tests
|
||||
file:
|
||||
/opt/pantheon/bin/pantheon:
|
||||
exists: true
|
||||
@@ -20,21 +22,6 @@ file:
|
||||
group: root
|
||||
filetype: file
|
||||
contains: []
|
||||
port:
|
||||
tcp:8545:
|
||||
listening: true
|
||||
tcp:8546:
|
||||
listening: true
|
||||
tcp:8547:
|
||||
listening: true
|
||||
tcp:30303:
|
||||
listening: true
|
||||
ip:
|
||||
- 0.0.0.0
|
||||
udp:30303:
|
||||
listening: true
|
||||
ip:
|
||||
- 0.0.0.0
|
||||
process:
|
||||
java:
|
||||
running: true
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
---
|
||||
# runtime docker tests for interfaces & ports
|
||||
port:
|
||||
tcp:30303:
|
||||
listening: true
|
||||
ip:
|
||||
- 0.0.0.0
|
||||
udp:30303:
|
||||
listening: true
|
||||
ip:
|
||||
- 0.0.0.0
|
||||
tcp:8545:
|
||||
listening: true
|
||||
ip:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
USAGE="USAGE: $(basename "$0") [run|edit] <docker_run_params>"
|
||||
USAGE="USAGE: $(basename "$0") [run|edit|dockerfile] <docker_params>"
|
||||
GOSS_FILES_PATH="${GOSS_FILES_PATH:-.}"
|
||||
|
||||
info() {
|
||||
@@ -23,13 +23,18 @@ cleanup() {
|
||||
fi
|
||||
}
|
||||
|
||||
run(){
|
||||
# Copy in goss
|
||||
# Copy goss & any config into a folder which then gets mounted as a volume
|
||||
# Run the container and perform the checks
|
||||
setup_container(){
|
||||
info "Setting up test dir"
|
||||
cp "${GOSS_PATH}" "$tmp_dir/goss"
|
||||
chmod 755 "$tmp_dir/goss"
|
||||
[[ -e "${GOSS_FILES_PATH}/goss.yaml" ]] && cp "${GOSS_FILES_PATH}/goss.yaml" "$tmp_dir"
|
||||
[[ -e "${GOSS_FILES_PATH}/goss_wait.yaml" ]] && cp "${GOSS_FILES_PATH}/goss_wait.yaml" "$tmp_dir"
|
||||
[[ ! -z "${GOSS_VARS}" ]] && [[ -e "${GOSS_FILES_PATH}/${GOSS_VARS}" ]] && cp "${GOSS_FILES_PATH}/${GOSS_VARS}" "$tmp_dir"
|
||||
# copy the Dockerfile if path has been provided
|
||||
[[ ! -z "${3}" ]] && [[ "${3}" == *"Dockerfile"* ]] && cp "${3}" "$tmp_dir"
|
||||
info "Setup complete"
|
||||
|
||||
# Switch between mount or cp files strategy
|
||||
GOSS_FILES_STRATEGY=${GOSS_FILES_STRATEGY:="mount"}
|
||||
@@ -54,7 +59,7 @@ run(){
|
||||
info "Container ID: ${id:0:8}"
|
||||
}
|
||||
|
||||
get_docker_file() {
|
||||
get_file_from_docker() {
|
||||
if docker exec "$id" sh -c "test -e $1" > /dev/null;then
|
||||
mkdir -p "${GOSS_FILES_PATH}"
|
||||
info "Copied '$1' from container to '${GOSS_FILES_PATH}'"
|
||||
@@ -75,7 +80,8 @@ GOSS_SLEEP=${GOSS_SLEEP:-0.2}
|
||||
|
||||
case "$1" in
|
||||
run)
|
||||
run "$@"
|
||||
info "Run Docker tests"
|
||||
setup_container "$@"
|
||||
if [[ -e "${GOSS_FILES_PATH}/goss_wait.yaml" ]]; then
|
||||
info "Found goss_wait.yaml, waiting for it to pass before running tests"
|
||||
if [[ -z "${GOSS_VARS}" ]]; then
|
||||
@@ -100,13 +106,19 @@ case "$1" in
|
||||
docker exec "$id" sh -c "/goss/goss -g /goss/goss.yaml --vars='/goss/${GOSS_VARS}' validate $GOSS_OPTS"
|
||||
fi
|
||||
;;
|
||||
dockerfile)
|
||||
info "Run Dockerfile tests"
|
||||
setup_container "$@"
|
||||
docker exec "$id" sh -c "cat /goss/goss.yaml"
|
||||
docker exec "$id" sh -c "/goss/goss -g /goss/goss.yaml validate $GOSS_OPTS"
|
||||
;;
|
||||
edit)
|
||||
run "$@"
|
||||
setup_container "$@"
|
||||
info "Run goss add/autoadd to add resources"
|
||||
docker exec -it "$id" sh -c 'cd /goss; PATH="/goss:$PATH" exec sh'
|
||||
get_docker_file "/goss/goss.yaml"
|
||||
get_docker_file "/goss/goss_wait.yaml"
|
||||
[[ ! -z "${GOSS_VARS}" ]] && get_docker_file "/goss/${GOSS_VARS}"
|
||||
get_file_from_docker "/goss/goss.yaml"
|
||||
get_file_from_docker "/goss/goss_wait.yaml"
|
||||
[[ ! -z "${GOSS_VARS}" ]] && get_file_from_docker "/goss/${GOSS_VARS}"
|
||||
;;
|
||||
*)
|
||||
error "$USAGE"
|
||||
|
||||
Reference in New Issue
Block a user