ci: add a test to check that the Docker image config works (#5968)
* ci: add a test to validate Zebra's config file and path * fix: use `ZEBRA_CONF_PATH` as single variable locating the conf * fix: do not remove the containers * fix: use extended regex * fix: use different steps to validate the conf tests * fix: do not specify a default CMD for running Docker in test builds * fix: use actual starting commands for entrypoint * fix: do not add cargo twice if cargo is in $1 * fix: allow to run `zebrad` in the `tests` stage of Dockerfile * fix: new entrypoint does not allow an empty CMD * fix: do not duplicate the `zebrad` command * fix: segregate configuration jobs * refactor(entrypoint): handle better parameters conditions * fix: make `zebrad` an executable command in `tests` stage * Show the commands that are being executed in the new docker test * Show full logs without tee or grep * Apply suggestions from code review Co-authored-by: teor <teor@riseup.net> * fix: use the actual path inside docker * fix: use `grep` with exit code If the container is logging to stderr, piping works only for stdout, so we're adding `2>&1` * fix: use `grep -q` to get an exit code * fix: fail if any error is detected * fix: fail if this test takes more than 5 minutes * fix: update patch workflows * feat: test Dockerfile `runtime` config * fix: depend on the configuration test to continue Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
parent
d72211fbbe
commit
85bcbbdf16
|
|
@ -77,6 +77,28 @@ jobs:
|
|||
zebra_skip_ipv6_tests: '1'
|
||||
rust_log: info
|
||||
|
||||
# Test that Zebra works using the default config with the latest Zebra version
|
||||
test-configuration-file:
|
||||
name: Test Zebra default Docker config file
|
||||
timeout-minutes: 5
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v4
|
||||
with:
|
||||
short-length: 7
|
||||
|
||||
- name: Run tests using the default config
|
||||
run: |
|
||||
set -ex
|
||||
docker pull ${{ env.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }}
|
||||
docker run --detach --name default-conf-tests -t ${{ env.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }}
|
||||
EXIT_STATUS=$(docker logs --tail all --follow default-conf-tests 2>&1 | grep -q --extended-regexp --max-count=1 -e 'estimated progress to chain tip.*BeforeOverwinter'; echo $?; )
|
||||
docker stop default-conf-tests
|
||||
docker logs default-conf-tests
|
||||
exit "$EXIT_STATUS"
|
||||
|
||||
# This jobs handles the deployment of a Managed Instance Group (MiG) with 2 nodes in
|
||||
# the us-central1 region. Two different groups of MiGs are deployed one for pushes to
|
||||
# the main branch and another for version releases of Zebra
|
||||
|
|
@ -90,7 +112,7 @@ jobs:
|
|||
# - on every release, when it's published
|
||||
deploy-nodes:
|
||||
name: Deploy ${{ inputs.network || 'Mainnet' }} nodes
|
||||
needs: [ build, versioning ]
|
||||
needs: [ build, test-configuration-file, versioning ]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
permissions:
|
||||
|
|
@ -184,7 +206,7 @@ jobs:
|
|||
# Note: this instances are not automatically replaced or deleted
|
||||
deploy-instance:
|
||||
name: Deploy single instance
|
||||
needs: build
|
||||
needs: [ build, test-configuration-file ]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
permissions:
|
||||
|
|
|
|||
|
|
@ -66,6 +66,18 @@ jobs:
|
|||
steps:
|
||||
- run: 'echo "No build required"'
|
||||
|
||||
test-configuration-file:
|
||||
name: Test Zebra default Docker config file
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: 'echo "No build required"'
|
||||
|
||||
test-zebra-conf-path:
|
||||
name: Test Zebra custom Docker config file
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: 'echo "No build required"'
|
||||
|
||||
test-stateful-sync:
|
||||
name: Zebra checkpoint update / Run sync-past-checkpoint test
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
|||
|
|
@ -299,6 +299,54 @@ jobs:
|
|||
env:
|
||||
ZEBRA_TEST_LIGHTWALLETD: '1'
|
||||
|
||||
# Test that Zebra works using the default config with the latest Zebra version
|
||||
test-configuration-file:
|
||||
name: Test Zebra default Docker config file
|
||||
timeout-minutes: 5
|
||||
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: |
|
||||
set -ex
|
||||
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
|
||||
EXIT_STATUS=$(docker logs --tail all --follow default-conf-tests 2>&1 | grep -q --extended-regexp --max-count=1 -e 'estimated progress to chain tip.*BeforeOverwinter'; echo $?; )
|
||||
docker stop default-conf-tests
|
||||
docker logs default-conf-tests
|
||||
exit "$EXIT_STATUS"
|
||||
|
||||
# Test that Zebra works using the $ZEBRA_CONF_PATH config
|
||||
test-zebra-conf-path:
|
||||
name: Test Zebra custom Docker config file
|
||||
timeout-minutes: 5
|
||||
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 $ZEBRA_CONF_PATH
|
||||
run: |
|
||||
set -ex
|
||||
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 }} -c $ZEBRA_CONF_PATH start
|
||||
EXIT_STATUS=$(docker logs --tail all --follow variable-conf-tests 2>&1 | grep -q --extended-regexp --max-count=1 -e 'v1.0.0-rc.2.toml'; echo $?; )
|
||||
docker stop variable-conf-tests
|
||||
docker logs variable-conf-tests
|
||||
exit "$EXIT_STATUS"
|
||||
env:
|
||||
ZEBRA_CONF_PATH: 'zebrad/tests/common/configs/v1.0.0-rc.2.toml'
|
||||
|
||||
# zebrad cached checkpoint state tests
|
||||
|
||||
# Regenerate mandatory checkpoint Zebra cached state disks.
|
||||
|
|
|
|||
|
|
@ -104,13 +104,13 @@ RUN cargo chef cook --release --features sentry,lightwalletd-grpc-tests --worksp
|
|||
|
||||
COPY . .
|
||||
RUN cargo test --locked --release --features lightwalletd-grpc-tests --workspace --no-run
|
||||
RUN cp /opt/zebrad/target/release/zebrad /usr/local/bin
|
||||
|
||||
COPY ./docker/entrypoint.sh /
|
||||
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)
|
||||
#
|
||||
|
|
@ -140,12 +140,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.
|
||||
|
|
@ -160,8 +163,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]"; \
|
||||
|
|
@ -177,7 +180,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
|
||||
|
||||
|
|
@ -188,4 +191,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
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@ echo "ZEBRA_CACHED_STATE_DIR=$ZEBRA_CACHED_STATE_DIR"
|
|||
echo "LIGHTWALLETD_DATA_DIR=$LIGHTWALLETD_DATA_DIR"
|
||||
|
||||
case "$1" in
|
||||
-- | cargo)
|
||||
--* | -*)
|
||||
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
|
||||
|
|
@ -86,17 +89,7 @@ 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue