diff --git a/.github/workflows/continous-integration-docker.yml b/.github/workflows/continous-integration-docker.yml index 567c5df73..23b18083d 100644 --- a/.github/workflows/continous-integration-docker.yml +++ b/.github/workflows/continous-integration-docker.yml @@ -282,9 +282,29 @@ jobs: test_description: Test lightwalletd full sync test_variables: '-e TEST_LWD_FULL_SYNC=1 -e ZEBRA_TEST_LIGHTWALLETD=1 -e ZEBRA_FORCE_USE_COLOR=1 -e ZEBRA_CACHED_STATE_DIR=/var/cache/zebrad-cache -e LIGHTWALLETD_DATA_DIR=/var/cache/lwd-cache' needs_zebra_state: true + needs_lwd_state: false saves_to_disk: true disk_prefix: lwd-cache disk_suffix: tip root_state_path: '/var/cache' zebra_state_dir: 'zebrad-cache' - lwd_state_dir: 'lwd-cache' \ No newline at end of file + lwd_state_dir: 'lwd-cache' + + # Test update sync of lightwalletd with a lightwalletd and Zebra tip state + lightwalletd-update-sync: + needs: build + uses: ./.github/workflows/deploy-gcp-tests.yml + if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }} + with: + app_name: lightwalletd + test_id: lwd-update-sync + test_description: Test lightwalletd update sync with both states + test_variables: '-e TEST_LWD_UPDATE_SYNC=1 -e ZEBRA_TEST_LIGHTWALLETD=1 -e ZEBRA_FORCE_USE_COLOR=1 -e ZEBRA_CACHED_STATE_DIR=/var/cache/zebrad-cache -e LIGHTWALLETD_DATA_DIR=/var/cache/lwd-cache' + needs_zebra_state: true + needs_lwd_state: true + saves_to_disk: false + disk_prefix: lwd-cache + disk_suffix: tip + root_state_path: '/var/cache' + zebra_state_dir: 'zebrad-cache' + lwd_state_dir: 'lwd-cache' diff --git a/.github/workflows/deploy-gcp-tests.yml b/.github/workflows/deploy-gcp-tests.yml index 64b66b27c..a3466ab9f 100644 --- a/.github/workflows/deploy-gcp-tests.yml +++ b/.github/workflows/deploy-gcp-tests.yml @@ -48,6 +48,11 @@ on: needs_zebra_state: required: true type: boolean + description: 'Indicates if a test needs a disk with a Zebra cached state to run' + needs_lwd_state: + required: false + type: boolean + description: 'Indicates if a test needs a disk with Lightwalletd cached state to run (which also includes a Zebra cached state)' saves_to_disk: required: true type: boolean @@ -212,23 +217,34 @@ jobs: # - network (network) - mainnet or testnet # - disk target height kind (disk_suffix) - checkpoint or tip # + # If the test needs a lightwalletd state (needs_lwd_state) set the variable DISK_PREFIX accordingly + # - To ${{ inputs.lwd_state_dir }}" if needed + # - To ${{ inputs.zebra_state_dir || inputs.disk_prefix }} if not + # # If there are multiple disks: # - prefer images generated from the `main` branch, then any other branch # - prefer newer images to older images # - # Passes the disk name to subsequent steps using $CACHED_DISK_NAME env variable. + # Passes the disk name to subsequent steps using $CACHED_DISK_NAME env variable + # Passes the state version to subsequent steps using $STATE_VERSION env variable - name: Find cached state disk id: get-disk-name run: | LOCAL_STATE_VERSION=$(grep -oE "DATABASE_FORMAT_VERSION: .* [0-9]+" "$GITHUB_WORKSPACE/zebra-state/src/constants.rs" | grep -oE "[0-9]+" | tail -n1) echo "STATE_VERSION: $LOCAL_STATE_VERSION" + if [[ "${{ inputs.needs_lwd_state }}" == "true" ]]; then + DISK_PREFIX=${{ inputs.lwd_state_dir }} + else + DISK_PREFIX=${{ inputs.zebra_state_dir || inputs.disk_prefix }} + fi + # Try to find an image generated from the main branch # Fields are listed in the "Create image from state disk" step # # TODO: require ${NETWORK} in the name after PR #4391 merges to main, and runs a full sync # network should replace [a-z]* - CACHED_DISK_NAME=$(gcloud compute images list --filter="name~${{ inputs.zebra_state_dir || inputs.disk_prefix }}-main-[0-9a-f]+-v${LOCAL_STATE_VERSION}-[a-z]*-${{ inputs.disk_suffix }}" --format="value(NAME)" --sort-by=~creationTimestamp --limit=1) + CACHED_DISK_NAME=$(gcloud compute images list --filter="name~${DISK_PREFIX}-main-[0-9a-f]+-v${LOCAL_STATE_VERSION}-[a-z]*-${{ inputs.disk_suffix }}" --format="value(NAME)" --sort-by=~creationTimestamp --limit=1) echo "main Disk: $CACHED_DISK_NAME" if [[ -z "$CACHED_DISK_NAME" ]]; then @@ -236,7 +252,7 @@ jobs: # # TODO: require ${NETWORK} in the name after PRs #4391 and #4385 merge to main # network should replace [a-z]* - CACHED_DISK_NAME=$(gcloud compute images list --filter="name~${{ inputs.zebra_state_dir || inputs.disk_prefix }}-.+-[0-9a-f]+-v${LOCAL_STATE_VERSION}-[a-z]*-${{ inputs.disk_suffix }}" --format="value(NAME)" --sort-by=~creationTimestamp --limit=1) + CACHED_DISK_NAME=$(gcloud compute images list --filter="name~${DISK_PREFIX}-.+-[0-9a-f]+-v${LOCAL_STATE_VERSION}-[a-z]*-${{ inputs.disk_suffix }}" --format="value(NAME)" --sort-by=~creationTimestamp --limit=1) echo "Disk: $CACHED_DISK_NAME" fi @@ -249,6 +265,7 @@ jobs: echo "Description: $(gcloud compute images describe $CACHED_DISK_NAME --format='value(DESCRIPTION)')" + echo "STATE_VERSION=$LOCAL_STATE_VERSION" >> $GITHUB_ENV echo "CACHED_DISK_NAME=$CACHED_DISK_NAME" >> $GITHUB_ENV # Creates Compute Engine virtual machine and attach a cached state disk using the @@ -284,7 +301,9 @@ jobs: # $ZEBRA_CACHED_STATE_DIR. The inputs like ${{ inputs.zebra_state_dir }} are only used # to match that variable paths. - name: Run ${{ inputs.test_id }} test - if: ${{ !inputs.lwd_state_dir }} + # This step mounts the volume only when a single cached state is needed, in this case + # the cached state from Zebra. + if: ${{ inputs.needs_zebra_state && !inputs.needs_lwd_state }} run: | gcloud compute ssh \ ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \ @@ -325,7 +344,9 @@ jobs: # will only respect the values from $ZEBRA_CACHED_STATE_DIR and $LIGHTWALLETD_DATA_DIR, # the inputs like ${{ inputs.lwd_state_dir }} are only used to match those variables paths. - name: Run ${{ inputs.test_id }} test - if: ${{ inputs.lwd_state_dir }} + # This step mounts the volume only when both cached states are needed, in this case + # the cached state from Zebra and Lightwalletd + if: ${{ inputs.needs_zebra_state && inputs.needs_lwd_state }} run: | gcloud compute ssh \ ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index d86115ea5..4129edd94 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -37,6 +37,9 @@ case "$1" in elif [[ "$TEST_LWD_FULL_SYNC" -eq "1" ]]; then # Starting at a cached Zebra tip, run a lightwalletd sync to tip. exec cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored lightwalletd_full_sync + elif [[ "$TEST_LWD_UPDATE_SYNC" -eq "1" ]]; then + # Starting with a cached Zebra and lightwalletd tip, run a quick update sync. + exec cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored lightwalletd_update_sync # These tests actually use gRPC. elif [[ "$TEST_LWD_TRANSACTIONS" -eq "1" ]]; then