Skip to content

Commit 9ec5803

Browse files
committed
fix(): increased timeoutm and tasks to run v1 and v2. Updated testing config
1 parent 842b6c6 commit 9ec5803

File tree

8 files changed

+96
-23
lines changed

8 files changed

+96
-23
lines changed

.github/workflows/postmerge.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545

4646
- name: "Run integration test"
4747
run: npm run test:postmerge
48+
env:
49+
PROJECT_ID: ${{ secrets.PROJECT_ID }}
4850

4951
- name: Print debug logs
5052
if: failure()
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Cloud Build configuration for Firebase Functions All Integration Tests
2+
# Runs all test suites (both V1 and V2) sequentially
3+
4+
options:
5+
machineType: "E2_HIGHCPU_8"
6+
logging: CLOUD_LOGGING_ONLY
7+
8+
timeout: "7200s"
9+
10+
steps:
11+
# Build SDK and run all test suites sequentially
12+
# Using the official Google Cloud SDK image which includes gcloud pre-installed
13+
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk:stable"
14+
id: "build-sdk-and-test-all"
15+
entrypoint: "bash"
16+
args:
17+
- "-c"
18+
- |
19+
# Install Node.js 20.x
20+
echo "Installing Node.js 20..."
21+
apt-get update -qq
22+
apt-get install -y -qq curl
23+
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
24+
apt-get install -y -qq nodejs
25+
node --version
26+
npm --version
27+
28+
# Step 1: Build and pack the firebase-functions SDK from source
29+
echo "Building firebase-functions SDK from source..."
30+
pwd
31+
ls -la
32+
npm ci
33+
npm run build
34+
npm pack
35+
# Move the tarball to where integration tests expect it
36+
mv firebase-functions-*.tgz integration_test/firebase-functions-local.tgz
37+
echo "SDK built and packed successfully"
38+
39+
# Step 2: Run all integration tests with the local SDK
40+
cd integration_test
41+
echo "Installing test dependencies..."
42+
npm ci
43+
# Install firebase-tools globally
44+
npm install -g firebase-tools
45+
# gcloud is already available in this image
46+
gcloud config set project "$PROJECT_ID"
47+
# Verify tools are installed
48+
firebase --version
49+
gcloud --version
50+
# Verify gcloud project is set correctly
51+
gcloud config get-value project
52+
# Set environment variables
53+
export PROJECT_ID="$PROJECT_ID"
54+
echo "Running all tests on project: $PROJECT_ID"
55+
# Use Application Default Credentials (Cloud Build service account)
56+
# Run all test suites sequentially
57+
node scripts/run-tests.js --sequential --skip-cleanup
58+
59+
# Artifacts to store
60+
artifacts:
61+
objects:
62+
location: "gs://${PROJECT_ID}_cloudbuild/artifacts/${BUILD_ID}"
63+
paths:
64+
- "logs/**/*.log"

integration_test/cloudbuild-v1.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Cloud Build configuration for Firebase Functions V1 Integration Tests
2-
# Runs all V1 test suites sequentially to avoid rate limits
2+
# Runs V1 test suites only
33

44
options:
55
machineType: "E2_HIGHCPU_8"
66
logging: CLOUD_LOGGING_ONLY
77

8-
timeout: "3600s"
8+
timeout: "7200s"
99

1010
steps:
1111
# Build SDK and run all V1 test suites sequentially
@@ -38,12 +38,12 @@ steps:
3838
export PROJECT_ID="$PROJECT_ID"
3939
echo "Running all tests on project: $PROJECT_ID"
4040
# Use Application Default Credentials (Cloud Build service account)
41-
# Run all test suites sequentially
42-
node scripts/run-tests.js --sequential --skip-cleanup
41+
# Run V1 test suites only
42+
node scripts/run-tests.js --sequential 'v1_*' --skip-cleanup
4343
4444
# Artifacts to store
4545
artifacts:
4646
objects:
47-
location: "gs://${PROJECT_ID}-artifacts/${BUILD_ID}"
47+
location: "gs://${PROJECT_ID}_cloudbuild/artifacts/${BUILD_ID}"
4848
paths:
4949
- "logs/**/*.log"

integration_test/cloudbuild-v2.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Cloud Build configuration for Firebase Functions V2 Integration Tests
2-
# Runs all V2 test suites sequentially to avoid rate limits
2+
# Runs V2 test suites only
33

44
options:
55
machineType: "E2_HIGHCPU_8"
66
logging: CLOUD_LOGGING_ONLY
77

8-
timeout: "3600s"
8+
timeout: "7200s"
99

1010
steps:
1111
# Build SDK and run all V2 test suites sequentially
@@ -53,12 +53,12 @@ steps:
5353
export PROJECT_ID="$PROJECT_ID"
5454
echo "Running all tests on project: $PROJECT_ID"
5555
# Use Application Default Credentials (Cloud Build service account)
56-
# Run all test suites sequentially
57-
node scripts/run-tests.js --sequential --skip-cleanup
56+
# Run V2 test suites only
57+
node scripts/run-tests.js --sequential 'v2_*' --skip-cleanup
5858
5959
# Artifacts to store
6060
artifacts:
6161
objects:
62-
location: "gs://${PROJECT_ID}-artifacts/${BUILD_ID}"
62+
location: "gs://${PROJECT_ID}_cloudbuild/artifacts/${BUILD_ID}"
6363
paths:
6464
- "logs/**/*.log"

integration_test/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
"test:all:sequential": "node scripts/run-tests.js --sequential",
1818
"test:v1:auth-before-create": "node scripts/run-tests.js v1_auth_before_create",
1919
"test:v1:auth-before-signin": "node scripts/run-tests.js v1_auth_before_signin",
20-
"cloudbuild:v1": "gcloud builds submit --config=cloudbuild-v1.yaml --project=${PROJECT_ID:-functions-integration-tests}",
21-
"cloudbuild:v2": "gcloud builds submit --config=cloudbuild-v2.yaml --project=${PROJECT_ID:-functions-integration-tests}",
22-
"cloudbuild:unified": "gcloud builds submit --config=cloudbuild-v2.yaml --project=${PROJECT_ID:-functions-integration-tests}",
23-
"cloudbuild:both": "gcloud builds submit --config=cloudbuild-v1.yaml --project=${PROJECT_ID:-functions-integration-tests} & gcloud builds submit --config=cloudbuild-v2.yaml --project=${PROJECT_ID:-functions-integration-tests} & wait",
20+
"cloudbuild:v1": "gcloud builds submit --config=cloudbuild-v1.yaml ",
21+
"cloudbuild:v2": "gcloud builds submit --config=cloudbuild-v2.yaml ",
22+
"cloudbuild:all": "gcloud builds submit --config=cloudbuild-all.yaml",
2423
"cleanup": "./scripts/cleanup-suite.sh",
2524
"cleanup:list": "./scripts/cleanup-suite.sh --list-artifacts",
2625
"clean": "rm -rf generated/*"

integration_test/scripts/run-tests.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,20 @@ class TestRunner {
250250
if (pattern.includes("*") || pattern.includes("?")) {
251251
// Check both v1 and v2 configs
252252
if (existsSync(V1_CONFIG_PATH)) {
253-
const v1Matches = getSuitesByPattern(pattern, V1_CONFIG_PATH);
254-
suites.push(...v1Matches.map((s) => s.name));
253+
try {
254+
const v1Matches = getSuitesByPattern(pattern, V1_CONFIG_PATH);
255+
suites.push(...v1Matches.map((s) => s.name));
256+
} catch (error) {
257+
// No matches in V1 config, continue to V2
258+
}
255259
}
256260
if (existsSync(V2_CONFIG_PATH)) {
257-
const v2Matches = getSuitesByPattern(pattern, V2_CONFIG_PATH);
258-
suites.push(...v2Matches.map((s) => s.name));
261+
try {
262+
const v2Matches = getSuitesByPattern(pattern, V2_CONFIG_PATH);
263+
suites.push(...v2Matches.map((s) => s.name));
264+
} catch (error) {
265+
// No matches in V2 config, continue
266+
}
259267
}
260268
} else {
261269
// Direct suite name
@@ -1055,8 +1063,8 @@ class TestRunner {
10551063

10561064
// Add delay between suites to allow Firebase to fully process cleanup
10571065
if (i < suiteNames.length - 1) {
1058-
this.log("⏳ Waiting 60 seconds between suites for complete Firebase cleanup...", "info");
1059-
await new Promise((resolve) => setTimeout(resolve, 60000));
1066+
this.log("⏳ Waiting 120 seconds between suites for complete Firebase cleanup...", "info");
1067+
await new Promise((resolve) => setTimeout(resolve, 120000));
10601068
}
10611069

10621070
this.log("");

integration_test/tests/v2/firestore.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as admin from "firebase-admin";
2-
import { retry } from "../utils";
32
import { initializeFirebase } from "../firebaseSetup";
3+
import { retry } from "../utils";
44

55
describe("Cloud Firestore (v2)", () => {
66
const projectId = process.env.PROJECT_ID;
@@ -41,7 +41,7 @@ describe("Cloud Firestore (v2)", () => {
4141
.then((logSnapshot) => logSnapshot.data()),
4242
{ maxRetries: 40 }
4343
);
44-
});
44+
}, 300_000);
4545

4646
it("should not have event.app", () => {
4747
expect(loggedContext?.app).toBeUndefined();

mocha/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as chai from "chai";
2-
import * as chaiAsPromised from "chai-as-promised";
32
import * as nock from "nock";
3+
import chaiAsPromised = require("chai-as-promised");
44

55
chai.use(chaiAsPromised);
66

0 commit comments

Comments
 (0)