Skip to content

Commit 24afc64

Browse files
authored
test: run the bigtable system tests in google cloud build (#8192)
## 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. <img width="802" height="77" alt="image" src="https://togithub.com/user-attachments/assets/f6cd3d20-9262-4bdc-8c67-4fef2a5c1d07" /> ## Next Steps 1. Merge a pull request that removes the system tests from kokoro. This should be done in a separate pull request to separate the concerns of removing the kokoro system tests from adding the Google Cloud Build system tests. 2. Distribute a document detailing the process for migrating system tests from kokoro to GCB for all handwritten libraries.
1 parent a63b61d commit 24afc64

3 files changed

Lines changed: 82 additions & 4 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
steps:
2+
# 1. Set up Node.js environment
3+
- name: 'node:24'
4+
entrypoint: 'bash'
5+
args:
6+
- '-c'
7+
- |
8+
npm install
9+
dir: 'handwritten/bigtable'
10+
id: 'install-dependencies'
11+
12+
# 2. Configure environment variables for the tests and run system tests
13+
# - GOOGLE_APPLICATION_CREDENTIALS: GCB steps run as a service account
14+
# that is typically granted permissions directly. Explicitly setting
15+
# GOOGLE_APPLICATION_CREDENTIALS might not be needed if the GCB service
16+
# account has the right roles (e.g., Bigtable Admin, Bigtable User).
17+
# If you need to use specific service account key JSON, you'd store it
18+
# in Secret Manager and mount it here. For simplicity, we'll rely on
19+
# the GCB service account's inherent permissions.
20+
# - GCLOUD_PROJECT: Can be passed as a build variable.
21+
- name: 'node:24'
22+
entrypoint: 'bash'
23+
args:
24+
- '-c'
25+
- |
26+
npm run system-test
27+
dir: 'handwritten/bigtable'
28+
env:
29+
- 'GCLOUD_PROJECT=${_GCP_PROJECT_ID}' # Pass project ID via build variable
30+
# If you need specific credentials from Secret Manager, uncomment these:
31+
# - 'GOOGLE_APPLICATION_CREDENTIALS=/secrets/sa-key.json'
32+
id: 'run-system-tests'
33+
waitFor: ['install-dependencies']
34+
# For Secret Manager, uncomment these (adjust secret name and volume path as needed):
35+
# secretEnv: ['SA_KEY']
36+
# volumes:
37+
# - name: 'sa-keys'
38+
# path: '/secrets'
39+
40+
# 3. (Optional) Code Coverage Reporting
41+
- name: 'node:24'
42+
entrypoint: 'bash'
43+
args:
44+
- '-c'
45+
- |
46+
# Check if nyc is installed and run report
47+
if [ -f ./node_modules/nyc/bin/nyc.js ]; then
48+
./node_modules/nyc/bin/nyc.js report || true # `|| true` prevents build failure if nyc report itself exits non-zero
49+
else
50+
echo "nyc not found, skipping coverage report."
51+
fi
52+
# The original codecov.sh script from Kokoro needs to be made available to GCB.
53+
# Options:
54+
# a) Commit codecov.sh into your repo (e.g., .kokoro/codecov.sh) and call it:
55+
# if [ -f .kokoro/codecov.sh ]; then . ./.kokoro/codecov.sh; fi
56+
# b) Replicate its functionality directly in this step.
57+
# c) Store it in a GCS bucket and fetch it.
58+
echo "Codecov reporting (if desired) would be integrated here."
59+
dir: 'handwritten/bigtable'
60+
id: 'coverage-report'
61+
waitFor: ['run-system-tests']
62+
63+
# If you use Secret Manager for credentials, uncomment and configure:
64+
# availableSecrets:
65+
# secretManager:
66+
# - versionName: projects/${PROJECT_ID}/secrets/YOUR_SERVICE_ACCOUNT_KEY_SECRET_NAME/versions/latest
67+
# env: 'SA_KEY' # This env var will hold the secret value. Use it as GOOGLE_APPLICATION_CREDENTIALS in step 3 if needed.
68+
69+
# Define a substitution variable for your project ID
70+
# Replace 'long-door-651' with the actual GCP Project ID your system tests should run against.
71+
substitutions:
72+
_GCP_PROJECT_ID: 'long-door-651'
73+
74+
timeout: '10800s'

handwritten/bigtable/src/tabular-api-surface.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
} from './index';
2626
import {BoundData, RawFilter} from './filter';
2727
import {Row} from './row';
28-
import {BackoffSettings} from 'google-gax/build/src/gax';
2928
import {google} from '../protos/protos';
3029
import {CallOptions, grpc, ServiceError} from 'google-gax';
3130
import {Transform} from 'stream';
@@ -38,13 +37,18 @@ import {
3837
} from './client-side-metrics/client-side-metrics-attributes';
3938
import {mutateInternal} from './utils/mutateInternal';
4039

40+
// StrictLongRunningType introduces a type equal to BackoffSettings so that we
41+
// don't have to reach into the gax folder of build which is causing pack and
42+
// play errors.
43+
type StrictLongRunningType = NonNullable<CallOptions['longrunning']>;
44+
4145
// See protos/google/rpc/code.proto
4246
// (4=DEADLINE_EXCEEDED, 8=RESOURCE_EXHAUSTED, 10=ABORTED, 14=UNAVAILABLE)
4347
export const RETRYABLE_STATUS_CODES = new Set([4, 8, 10, 14]);
4448
// (1=CANCELLED)
4549
export const IGNORED_STATUS_CODES = new Set([1]);
4650

47-
export const DEFAULT_BACKOFF_SETTINGS: BackoffSettings = {
51+
export const DEFAULT_BACKOFF_SETTINGS: StrictLongRunningType = {
4852
initialRetryDelayMillis: 10,
4953
retryDelayMultiplier: 2,
5054
maxRetryDelayMillis: 60000,
@@ -495,7 +499,7 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`);
495499

496500
export function getNextDelay(
497501
numConsecutiveErrors: number,
498-
config: BackoffSettings,
502+
config: StrictLongRunningType,
499503
) {
500504
// 0 - 100 ms jitter
501505
const jitter = Math.floor(Math.random() * 100);

handwritten/bigtable/system-test/install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('📦 pack-n-play test', () => {
4141
packageDir: process.cwd(),
4242
sample: {
4343
description: 'JavaScript user can use the library',
44-
ts: readFileSync(
44+
cjs: readFileSync(
4545
'./system-test/fixtures/sample/src/index.js',
4646
).toString(),
4747
},

0 commit comments

Comments
 (0)