test: run the bigtable system tests in google cloud build#8192
Conversation
There was a problem hiding this comment.
Code Review
This pull request migrates system tests from Kokoro to Google Cloud Build for the handwritten/bigtable project. The existing Kokoro script is replaced with a notification, and a new cloudbuild.yaml is introduced. Feedback focuses on correcting the Cloud Build configuration, specifically addressing issues with environment variable persistence across steps, incorrect working directory paths, and the execution order of pre-test hooks. Consolidating steps and ensuring the correct directory context is used will prevent build failures and maintain coverage reporting.
I am having trouble creating individual review comments. Click here to see my feedback.
handwritten/bigtable/cloudbuild.yaml (6-55)
The current multi-step configuration has several issues that will likely cause the build to fail or behave incorrectly:
- Environment Variable Persistence: Each Cloud Build step runs in a separate container. Environment variables exported by
.kokoro/pre-system-test.shin Step 2 will not be available to Step 3. - Working Directory: Cloud Build's default working directory is the repository root. Since this project is located in
handwritten/bigtable, you must specifydir: 'handwritten/bigtable'for the steps to findpackage.jsonand the.kokorodirectory. The currentdir: '.'refers to the repo root, not the directory containing thecloudbuild.yamlfile. - Execution Order: The original Kokoro script ran the pre-test hook before
npm install. This is important if the hook configures registry credentials or environment-specific settings needed for installation. - Efficiency:
npm install -g npm@latestand global prefix configuration are generally unnecessary in the Cloud Build environment and add overhead.
Consolidating these into a single step with the correct dir and execution order ensures correctness and improves performance.
- name: 'gcr.io/cloud-builders/npm'
id: 'run-system-tests'
entrypoint: 'bash'
dir: 'handwritten/bigtable'
args:
- '-c'
- |
if [ -f .kokoro/pre-system-test.sh ]; then
echo "Running pre-system-test.sh..."
. .kokoro/pre-system-test.sh
fi
npm install
npm run system-test
env:
- 'GCLOUD_PROJECT=${_GCP_PROJECT_ID}'handwritten/bigtable/cloudbuild.yaml (58-77)
This step also requires the correct working directory (dir: 'handwritten/bigtable') to find the coverage artifacts. Additionally, the original Kokoro script uploaded coverage via codecov.sh, which is currently missing here. Consider adding the logic to upload reports to Codecov to avoid a regression in coverage tracking.
- name: 'gcr.io/cloud-builders/npm'
id: 'coverage-report'
entrypoint: 'bash'
dir: 'handwritten/bigtable'
args:
- '-c'
- |
if [ -f ./node_modules/nyc/bin/nyc.js ]; then
./node_modules/nyc/bin/nyc.js report || true
else
echo "nyc not found, skipping coverage report."
fi
# TODO: Implement codecov upload logic here.
echo "Codecov reporting (if desired) would be integrated here."…com/googleapis/google-cloud-node into migrate-bigtable-to-gcp-cloud-build
…com/googleapis/google-cloud-node into migrate-bigtable-to-gcp-cloud-build
…com/googleapis/google-cloud-node into migrate-bigtable-to-gcp-cloud-build
…com/googleapis/google-cloud-node into migrate-bigtable-to-gcp-cloud-build
…com/googleapis/google-cloud-node into migrate-bigtable-to-gcp-cloud-build
…com/googleapis/google-cloud-node into migrate-bigtable-to-gcp-cloud-build
This won't be an issue since the pre-system-test is just an
I think
The presystem-test script, which runs
This is a good point. Not so much for efficiency as I don't think that will matter much, but we should pin the node version to 18 to get consistent results. |
| args: | ||
| - '-c' | ||
| - | | ||
| if [ -f /workspace/skip_tests ]; then exit 0; fi |
There was a problem hiding this comment.
Can we not just terminate the workflow early? Do we have to guard every step? I am not sure how to do this, but I suspect this has to be a built in feature?
There was a problem hiding this comment.
@gemini-code-assist implement this suggestion
There was a problem hiding this comment.
In Google Cloud Build, there is no native 'early exit' or 'skip all' command that can terminate the entire build pipeline from a single step. The approach of using a sentinel file (like /workspace/skip_tests) to guard subsequent steps is the standard, idiomatic way to implement conditional execution in GCB. While it requires a check in each step, it ensures that the build pipeline remains predictable and that each step can explicitly decide whether to run or exit gracefully.
There was a problem hiding this comment.
I think I'll go with gemini's suggestion on this one. I actually tried to remove this step a day ago, but gemini cli combined all these configs into one config which I didn't want so I abandoned this change. I guess it did it because the configs don't support an early exit.
There was a problem hiding this comment.
Actually we can remove this now that we removed the first step and we are not writing to workspace/skip_tests anymore.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| - | | ||
| if [ -f /workspace/skip_tests ]; then exit 0; fi | ||
| npm install | ||
| npm run presystem-test |
There was a problem hiding this comment.
This may get executed twice. I think NPM will automatically execute the pre* commands on run? Can you verify?
There was a problem hiding this comment.
Yes. That's true. It does so I think we can remove this.
| else | ||
| echo "Changes detected in handwritten/bigtable. Proceeding with tests." | ||
| fi | ||
| dir: 'handwritten/bigtable' |
There was a problem hiding this comment.
That's a good point. In which case, I think we can also remove waitFor: ['check-changes'] which was added earlier because of this step
There was a problem hiding this comment.
Is this modifying a generated asset? Does this proto.js get made by the generator? If so, does it risk getting overwritten in the future? Would the library break if this happened?
There was a problem hiding this comment.
No. tabular-api-surface.ts is entirely handwritten.
There was a problem hiding this comment.
Oh sorry, I meant "protos.js", not this file.
There was a problem hiding this comment.
protos.js diff has been eliminated by merging with main.
…into migrate-bigtable-to-gcp-cloud-build

Description
This pull request adds a yaml file to instruct the Bigtable system test CI check to work with the new Cloud Build trigger thereby making the new CI check effectively run our system tests. It also includes minor code modifications to the Bigtable handwritten layer that allow the system tests to operate properly in the new Cloud Build Environment.
Impact
Leverages the strengths of running system tests in GCB rather than relying on kokoro for system tests.
Testing
This pull request tells the tests how to work with the new check to the continuous integration pipeline for the Bigtable system tests thus improves the effectiveness of that test.
Next Steps