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

merge queue: embarking main (d72211f) and #5968 together #6020

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 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
8e4938f
Merge of #5968
mergify[bot] 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
26 changes: 24 additions & 2 deletions .github/workflows/continous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/continous-integration-docker.patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/continous-integration-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 10 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#
Expand Down Expand Up @@ -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.
Expand All @@ -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]"; \
Expand All @@ -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

Expand All @@ -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 changes: 4 additions & 11 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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