diff --git a/handwritten/bigtable/cloudbuild.yaml b/handwritten/bigtable/cloudbuild.yaml new file mode 100644 index 000000000000..23c64be391e1 --- /dev/null +++ b/handwritten/bigtable/cloudbuild.yaml @@ -0,0 +1,74 @@ +steps: +# 1. Set up Node.js environment +- name: 'node:24' + entrypoint: 'bash' + args: + - '-c' + - | + npm install + dir: 'handwritten/bigtable' + id: 'install-dependencies' + +# 2. Configure environment variables for the tests and run system tests +# - GOOGLE_APPLICATION_CREDENTIALS: GCB steps run as a service account +# that is typically granted permissions directly. Explicitly setting +# GOOGLE_APPLICATION_CREDENTIALS might not be needed if the GCB service +# account has the right roles (e.g., Bigtable Admin, Bigtable User). +# If you need to use specific service account key JSON, you'd store it +# in Secret Manager and mount it here. For simplicity, we'll rely on +# the GCB service account's inherent permissions. +# - GCLOUD_PROJECT: Can be passed as a build variable. +- name: 'node:24' + entrypoint: 'bash' + args: + - '-c' + - | + npm run system-test + dir: 'handwritten/bigtable' + env: + - 'GCLOUD_PROJECT=${_GCP_PROJECT_ID}' # Pass project ID via build variable + # If you need specific credentials from Secret Manager, uncomment these: + # - 'GOOGLE_APPLICATION_CREDENTIALS=/secrets/sa-key.json' + id: 'run-system-tests' + waitFor: ['install-dependencies'] + # For Secret Manager, uncomment these (adjust secret name and volume path as needed): + # secretEnv: ['SA_KEY'] + # volumes: + # - name: 'sa-keys' + # path: '/secrets' + +# 3. (Optional) Code Coverage Reporting +- name: 'node:24' + entrypoint: 'bash' + args: + - '-c' + - | + # Check if nyc is installed and run report + if [ -f ./node_modules/nyc/bin/nyc.js ]; then + ./node_modules/nyc/bin/nyc.js report || true # `|| true` prevents build failure if nyc report itself exits non-zero + else + echo "nyc not found, skipping coverage report." + fi + # The original codecov.sh script from Kokoro needs to be made available to GCB. + # Options: + # a) Commit codecov.sh into your repo (e.g., .kokoro/codecov.sh) and call it: + # if [ -f .kokoro/codecov.sh ]; then . ./.kokoro/codecov.sh; fi + # b) Replicate its functionality directly in this step. + # c) Store it in a GCS bucket and fetch it. + echo "Codecov reporting (if desired) would be integrated here." + dir: 'handwritten/bigtable' + id: 'coverage-report' + waitFor: ['run-system-tests'] + +# If you use Secret Manager for credentials, uncomment and configure: +# availableSecrets: +# secretManager: +# - versionName: projects/${PROJECT_ID}/secrets/YOUR_SERVICE_ACCOUNT_KEY_SECRET_NAME/versions/latest +# env: 'SA_KEY' # This env var will hold the secret value. Use it as GOOGLE_APPLICATION_CREDENTIALS in step 3 if needed. + +# Define a substitution variable for your project ID +# Replace 'long-door-651' with the actual GCP Project ID your system tests should run against. +substitutions: + _GCP_PROJECT_ID: 'long-door-651' + +timeout: '10800s' diff --git a/handwritten/bigtable/src/tabular-api-surface.ts b/handwritten/bigtable/src/tabular-api-surface.ts index 7e2abd907a44..b9aba06c2d8e 100644 --- a/handwritten/bigtable/src/tabular-api-surface.ts +++ b/handwritten/bigtable/src/tabular-api-surface.ts @@ -25,7 +25,6 @@ import { } from './index'; import {BoundData, RawFilter} from './filter'; import {Row} from './row'; -import {BackoffSettings} from 'google-gax/build/src/gax'; import {google} from '../protos/protos'; import {CallOptions, grpc, ServiceError} from 'google-gax'; import {Transform} from 'stream'; @@ -38,13 +37,18 @@ import { } from './client-side-metrics/client-side-metrics-attributes'; import {mutateInternal} from './utils/mutateInternal'; +// StrictLongRunningType introduces a type equal to BackoffSettings so that we +// don't have to reach into the gax folder of build which is causing pack and +// play errors. +type StrictLongRunningType = NonNullable; + // See protos/google/rpc/code.proto // (4=DEADLINE_EXCEEDED, 8=RESOURCE_EXHAUSTED, 10=ABORTED, 14=UNAVAILABLE) export const RETRYABLE_STATUS_CODES = new Set([4, 8, 10, 14]); // (1=CANCELLED) export const IGNORED_STATUS_CODES = new Set([1]); -export const DEFAULT_BACKOFF_SETTINGS: BackoffSettings = { +export const DEFAULT_BACKOFF_SETTINGS: StrictLongRunningType = { initialRetryDelayMillis: 10, retryDelayMultiplier: 2, maxRetryDelayMillis: 60000, @@ -495,7 +499,7 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`); export function getNextDelay( numConsecutiveErrors: number, - config: BackoffSettings, + config: StrictLongRunningType, ) { // 0 - 100 ms jitter const jitter = Math.floor(Math.random() * 100); diff --git a/handwritten/bigtable/system-test/install.ts b/handwritten/bigtable/system-test/install.ts index 5257a7ba101c..1cb9d3ebd8ba 100644 --- a/handwritten/bigtable/system-test/install.ts +++ b/handwritten/bigtable/system-test/install.ts @@ -41,7 +41,7 @@ describe('📦 pack-n-play test', () => { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - ts: readFileSync( + cjs: readFileSync( './system-test/fixtures/sample/src/index.js', ).toString(), },