From da25d368aecaf10a9c35c5589baa3199642b9562 Mon Sep 17 00:00:00 2001 From: Alka Trivedi Date: Sat, 11 Jul 2026 20:25:50 +0530 Subject: [PATCH 1/2] test: run the spanner system tests in google cloud build against regular sessions --- .../spanner/cloudbuild-regular-sessions.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 handwritten/spanner/cloudbuild-regular-sessions.yaml diff --git a/handwritten/spanner/cloudbuild-regular-sessions.yaml b/handwritten/spanner/cloudbuild-regular-sessions.yaml new file mode 100644 index 00000000000..17c1cae7f24 --- /dev/null +++ b/handwritten/spanner/cloudbuild-regular-sessions.yaml @@ -0,0 +1,77 @@ +steps: +# 1. Set up Node.js environment +- name: 'node:24' + entrypoint: 'bash' + args: + - '-c' + - | + npm install + dir: 'handwritten/spanner' + 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., Spanner Admin, Spanner 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/spanner' + 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' + - 'GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS=false' + - 'GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_PARTITIONED_OPS=false' + - 'GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_FOR_RW=false' + id: 'run-system-tests-regular' + 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/spanner' + 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: '3600s' From a2c7409a409934a6a28e14f2555b591e493cf02b Mon Sep 17 00:00:00 2001 From: Alka Trivedi Date: Sun, 12 Jul 2026 01:03:05 +0530 Subject: [PATCH 2/2] gemini review comment --- handwritten/spanner/cloudbuild-regular-sessions.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handwritten/spanner/cloudbuild-regular-sessions.yaml b/handwritten/spanner/cloudbuild-regular-sessions.yaml index 17c1cae7f24..d3d9d84d142 100644 --- a/handwritten/spanner/cloudbuild-regular-sessions.yaml +++ b/handwritten/spanner/cloudbuild-regular-sessions.yaml @@ -61,7 +61,7 @@ steps: echo "Codecov reporting (if desired) would be integrated here." dir: 'handwritten/spanner' id: 'coverage-report' - waitFor: ['run-system-tests'] + waitFor: ['run-system-tests-regular'] # If you use Secret Manager for credentials, uncomment and configure: # availableSecrets: