diff --git a/.github/workflows/continous-delivery.yml b/.github/workflows/continous-delivery.yml index 1adb5297d70..97a10ebf40d 100644 --- a/.github/workflows/continous-delivery.yml +++ b/.github/workflows/continous-delivery.yml @@ -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: diff --git a/.github/workflows/continous-integration-docker.patch.yml b/.github/workflows/continous-integration-docker.patch.yml index c0a34842233..ae7f8f2a894 100644 --- a/.github/workflows/continous-integration-docker.patch.yml +++ b/.github/workflows/continous-integration-docker.patch.yml @@ -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 diff --git a/.github/workflows/continous-integration-docker.yml b/.github/workflows/continous-integration-docker.yml index 2b42f717be3..233302e4096 100644 --- a/.github/workflows/continous-integration-docker.yml +++ b/.github/workflows/continous-integration-docker.yml @@ -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. diff --git a/docker/Dockerfile b/docker/Dockerfile index c3689b1f0e9..c2c0c3d6e9c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index b7fa28f15c3..e17bfbcc163 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -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