Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add a test to check that the Docker image config works #5968

Merged
merged 25 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d90f4c9
ci: add a test to validate Zebra's config file and path
gustavovalverde Jan 16, 2023
eb99f64
fix: use `ZEBRA_CONF_PATH` as single variable locating the conf
gustavovalverde Jan 16, 2023
20246fe
fix: do not remove the containers
gustavovalverde Jan 16, 2023
a56e16a
fix: use extended regex
gustavovalverde Jan 16, 2023
d886b1f
fix: use different steps to validate the conf tests
gustavovalverde Jan 16, 2023
dce28b8
fix: do not specify a default CMD for running Docker in test builds
gustavovalverde Jan 16, 2023
25a05f3
fix: use actual starting commands for entrypoint
gustavovalverde Jan 16, 2023
761a402
fix: do not add cargo twice if cargo is in $1
gustavovalverde Jan 16, 2023
5ac8b4f
fix: allow to run `zebrad` in the `tests` stage of Dockerfile
gustavovalverde Jan 16, 2023
c5a1e7e
fix: new entrypoint does not allow an empty CMD
gustavovalverde Jan 16, 2023
823c56c
fix: do not duplicate the `zebrad` command
gustavovalverde Jan 16, 2023
ee4d714
fix: segregate configuration jobs
gustavovalverde Jan 17, 2023
0799b8a
refactor(entrypoint): handle better parameters conditions
gustavovalverde Jan 17, 2023
56083e9
fix: make `zebrad` an executable command in `tests` stage
gustavovalverde Jan 18, 2023
59850e5
Show the commands that are being executed in the new docker test
teor2345 Jan 19, 2023
a09e05b
Show full logs without tee or grep
teor2345 Jan 20, 2023
06a5a7b
Apply suggestions from code review
gustavovalverde Jan 22, 2023
49f50f5
fix: use the actual path inside docker
gustavovalverde Jan 22, 2023
3b5fc86
fix: use `grep` with exit code
gustavovalverde Jan 22, 2023
06f9152
fix: use `grep -q` to get an exit code
gustavovalverde Jan 23, 2023
96ec071
fix: fail if any error is detected
gustavovalverde Jan 23, 2023
3ff322d
fix: fail if this test takes more than 5 minutes
gustavovalverde Jan 23, 2023
b32c447
fix: update patch workflows
gustavovalverde Jan 23, 2023
1beaebd
feat: test Dockerfile `runtime` config
gustavovalverde Jan 23, 2023
5dbc549
fix: depend on the configuration test to continue
gustavovalverde Jan 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/continous-integration-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,36 @@ jobs:
env:
ZEBRA_TEST_LIGHTWALLETD: '1'

# Test that Zebra works using the default config with the latest Zebra version
#
# Also check that $ZEBRA_CONF_PATH works
test-configuration-file:
name: Test Zebra configuration file
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' && github.event.inputs.run-lwd-send-tx != 'true' }}
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
with:
short-length: 7

- name: Run tests using the default config
run: |
docker pull ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }}
docker run --detach --name default-conf-tests -t ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} zebrad start
docker logs --tail all --follow default-conf-tests | tee --output-error=exit /dev/stderr | grep --extended-regexp --max-count=1 -e 'estimated progress to chain tip.*BeforeOverwinter'
docker stop default-conf-tests
teor2345 marked this conversation as resolved.
Show resolved Hide resolved

- name: Run tests using the $ZEBRA_CONF_PATH
run: |
docker pull ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }}
docker run --detach -e ZEBRA_CONF_PATH --name variable-conf-tests -t ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} zebrad -c $ZEBRA_CONF_PATH start
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
docker logs --tail all --follow variable-conf-tests | tee --output-error=exit /dev/stderr | grep --extended-regexp --max-count=1 -e 'v1.0.0-rc.2.toml'
docker stop variable-conf-tests
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
env:
ZEBRA_CONF_PATH: 'zebra/zebrad/tests/common/configs/v1.0.0-rc.2.toml'

# zebrad cached checkpoint state tests

# Regenerate mandatory checkpoint Zebra cached state disks.
Expand Down
16 changes: 9 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ RUN chmod u+x /entrypoint.sh

# By default, runs the entrypoint tests specified by the environmental variables (if any are set)
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "cargo" ]

# In this stage we build a release (generate the zebrad binary)
#
Expand Down Expand Up @@ -140,12 +139,15 @@ ARG CHECKPOINT_SYNC=true
ARG NETWORK=Mainnet

# Use a configurable dir and file for the zebrad configuration file
ARG ZEBRA_CONF_PATH=/etc/zebra
ENV ZEBRA_CONF_PATH ${ZEBRA_CONF_PATH}
ARG ZEBRA_CONF_DIR=/etc/zebra
ENV ZEBRA_CONF_DIR ${ZEBRA_CONF_DIR}

ARG ZEBRA_CONF_FILE=zebrad.toml
ENV ZEBRA_CONF_FILE ${ZEBRA_CONF_FILE}

ARG ZEBRA_CONF_PATH=${ZEBRA_CONF_DIR}/${ZEBRA_CONF_FILE}
ENV ZEBRA_CONF_PATH ${ZEBRA_CONF_PATH}

# Build the `zebrad.toml` before starting the container, using the arguments from build
# time, or using the default values set just above. And create the conf path and file if
# it does not exist.
Expand All @@ -160,8 +162,8 @@ ENV ZEBRA_CONF_FILE ${ZEBRA_CONF_FILE}
# - move this file creation to an entrypoint as we can use default values at runtime,
# and modify those as needed when starting the container (at runtime and not at build time)
# - make `cache_dir`, `rpc.listen_addr`, `metrics.endpoint_addr`, and `tracing.endpoint_addr` into Docker arguments
RUN mkdir -p ${ZEBRA_CONF_PATH} \
&& touch ${ZEBRA_CONF_PATH}/${ZEBRA_CONF_FILE}
RUN mkdir -p ${ZEBRA_CONF_DIR} \
&& touch ${ZEBRA_CONF_PATH}
RUN set -ex; \
{ \
echo "[network]"; \
Expand All @@ -177,7 +179,7 @@ RUN set -ex; \
echo "#endpoint_addr = '127.0.0.1:9999'"; \
echo "[tracing]"; \
echo "#endpoint_addr = '127.0.0.1:3000'"; \
} > "${ZEBRA_CONF_PATH}/${ZEBRA_CONF_FILE}"
} > "${ZEBRA_CONF_PATH}"

EXPOSE 8233 18233

Expand All @@ -188,4 +190,4 @@ ARG SENTRY_DSN
ENV SENTRY_DSN ${SENTRY_DSN}

# TODO: remove the specified config file location and use the default expected by zebrad
CMD zebrad -c "${ZEBRA_CONF_PATH}/${ZEBRA_CONF_FILE}" start
CMD zebrad -c "${ZEBRA_CONF_PATH}" start
17 changes: 7 additions & 10 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ echo "ZEBRA_CACHED_STATE_DIR=$ZEBRA_CACHED_STATE_DIR"
echo "LIGHTWALLETD_DATA_DIR=$LIGHTWALLETD_DATA_DIR"

case "$1" in
-- | cargo)
-- | zebrad)
exec zebrad "$@"
;;
-*)
exec zebrad "$@"
;;
*)
# For these tests, we activate the gRPC feature to avoid recompiling `zebrad`,
# but we might not actually run any gRPC tests.
if [[ "$RUN_ALL_TESTS" -eq "1" ]]; then
Expand Down Expand Up @@ -86,17 +92,8 @@ case "$1" in
# Starting with a cached Zebra tip, test sending a block to Zebra's RPC port.
ls -lh "$ZEBRA_CACHED_STATE_DIR"/*/* || (echo "No $ZEBRA_CACHED_STATE_DIR/*/*"; ls -lhR "$ZEBRA_CACHED_STATE_DIR" | head -50 || echo "No $ZEBRA_CACHED_STATE_DIR directory")
cargo test --locked --release --features getblocktemplate-rpcs --package zebrad --test acceptance -- --nocapture --include-ignored submit_block

# These command-lines are provided by the caller.
#
# TODO: test that the following 3 cases actually work, or remove them
else
exec "$@"
fi
;;
zebrad)
exec zebrad "$@"
;;
*)
exec "$@"
esac