@@ -247,6 +247,8 @@ Functions and test data are automatically cleaned up:
247
247
# # Commands
248
248
249
249
# ## Running Tests
250
+
251
+ # ### Local Testing
250
252
` ` ` bash
251
253
# Run all tests sequentially
252
254
npm run test:all:sequential
@@ -266,6 +268,20 @@ npm run run-tests -- --sequential v1_firestore v1_database
266
268
npm run run-tests -- --filter=v2 --exclude=auth
267
269
` ` `
268
270
271
+ # ### Cloud Build Testing
272
+ ` ` ` bash
273
+ # Run V1 tests in Cloud Build
274
+ npm run cloudbuild:v1
275
+
276
+ # Run V2 tests in Cloud Build
277
+ npm run cloudbuild:v2
278
+
279
+ # Run both V1 and V2 tests in parallel
280
+ npm run cloudbuild:both
281
+ # or
282
+ npm run cloudbuild:all
283
+ ` ` `
284
+
269
285
# ## Generate Functions Only
270
286
` ` ` bash
271
287
npm run generate <suite-name>
@@ -335,32 +351,84 @@ Cloud Build uses Application Default Credentials (ADC) automatically. However, t
335
351
- ` roles/cloudtestservice.testAdmin` - For Firebase Test Lab integration tests
336
352
- ` roles/firebase.admin` - For Firebase services (already included)
337
353
- ` roles/pubsub.publisher` - For Pub/Sub integration tests (already included)
354
+ - ` roles/iam.serviceAccountUser` - For Firebase Functions deployment (Service Account User)
338
355
339
356
**Multi-Project Setup:**
340
- Tests deploy to multiple projects (typically one for V1 tests and one for V2 tests). The Cloud Build service account needs the above permissions on **all target projects** :
357
+ Tests deploy to multiple projects (V1 tests to `functions-integration-tests`, V2 tests to `functions-integration-tests-v2` ). Each Cloud Build runs on its own project, so **no cross-project permissions are needed**.
341
358
359
+ **V1 Project Setup:**
342
360
` ` ` bash
343
- # Grant permissions to each target project
344
- gcloud projects add-iam-policy-binding TARGET_PROJECT_ID \
361
+ # Grant permissions to V1 project (functions-integration-tests)
362
+ gcloud projects add-iam-policy-binding functions-integration-tests \
345
363
--member="serviceAccount:[email protected] " \
346
364
--role="roles/cloudtasks.admin"
347
365
348
- gcloud projects add-iam-policy-binding TARGET_PROJECT_ID \
366
+ gcloud projects add-iam-policy-binding functions-integration-tests \
349
367
--member="serviceAccount:[email protected] " \
350
368
--role="roles/cloudscheduler.admin"
351
369
352
- gcloud projects add-iam-policy-binding TARGET_PROJECT_ID \
370
+ gcloud projects add-iam-policy-binding functions-integration-tests \
353
371
--member="serviceAccount:[email protected] " \
354
372
--role="roles/cloudtestservice.testAdmin"
355
373
356
- gcloud projects add-iam-policy-binding TARGET_PROJECT_ID \
374
+ gcloud projects add-iam-policy-binding functions-integration-tests \
357
375
--member="serviceAccount:[email protected] " \
358
376
--role="roles/firebase.admin"
377
+
378
+ gcloud projects add-iam-policy-binding functions-integration-tests \
379
+ --member="serviceAccount:[email protected] " \
380
+ --role="roles/iam.serviceAccountUser"
359
381
` ` `
360
382
361
- Replace :
362
- - ` TARGET_PROJECT_ID` with each project where tests will be deployed
363
- - ` CLOUD_BUILD_PROJECT_NUMBER` with the project number where Cloud Build runs
383
+ **V2 Project Setup:**
384
+ ` ` ` bash
385
+ # Grant permissions to V2 project (functions-integration-tests-v2)
386
+ gcloud projects add-iam-policy-binding functions-integration-tests-v2 \
387
+ --member="serviceAccount:[email protected] " \
388
+ --role="roles/cloudtasks.admin"
389
+
390
+ gcloud projects add-iam-policy-binding functions-integration-tests-v2 \
391
+ --member="serviceAccount:[email protected] " \
392
+ --role="roles/cloudscheduler.admin"
393
+
394
+ gcloud projects add-iam-policy-binding functions-integration-tests-v2 \
395
+ --member="serviceAccount:[email protected] " \
396
+ --role="roles/cloudtestservice.testAdmin"
397
+
398
+ gcloud projects add-iam-policy-binding functions-integration-tests-v2 \
399
+ --member="serviceAccount:[email protected] " \
400
+ --role="roles/firebase.admin"
401
+
402
+ gcloud projects add-iam-policy-binding functions-integration-tests-v2 \
403
+ --member="serviceAccount:[email protected] " \
404
+ --role="roles/iam.serviceAccountUser"
405
+ ` ` `
406
+
407
+ Replace `CLOUD_BUILD_PROJECT_NUMBER` with the project number where Cloud Build runs.
408
+
409
+ # ### Running Cloud Build
410
+
411
+ The integration tests use **separate Cloud Build configurations** for V1 and V2 tests to avoid cross-project permission complexity :
412
+
413
+ **V1 Tests:**
414
+ ` ` ` bash
415
+ # Run V1 tests on functions-integration-tests project
416
+ gcloud builds submit --config=integration_test/cloudbuild-v1.yaml
417
+ ` ` `
418
+
419
+ **V2 Tests:**
420
+ ` ` ` bash
421
+ # Run V2 tests on functions-integration-tests-v2 project
422
+ gcloud builds submit --config=integration_test/cloudbuild-v2.yaml
423
+ ` ` `
424
+
425
+ **Both Tests (Parallel):**
426
+ ` ` ` bash
427
+ # Run both V1 and V2 tests simultaneously
428
+ gcloud builds submit --config=integration_test/cloudbuild-v1.yaml &
429
+ gcloud builds submit --config=integration_test/cloudbuild-v2.yaml &
430
+ wait
431
+ ` ` `
364
432
365
433
# ### Running Cloud Build with Custom Projects
366
434
@@ -378,9 +446,13 @@ To use your own projects, edit the YAML configuration files:
378
446
projectId: your-v2-project-id
379
447
` ` `
380
448
381
- 3. **Run Cloud Build** :
449
+ 3. **Run Cloud Build** (use the appropriate config for your target project) :
382
450
` ` ` bash
383
- gcloud builds submit --config=integration_test/cloudbuild.yaml
451
+ # For V1 tests
452
+ gcloud builds submit --config=integration_test/cloudbuild-v1.yaml
453
+
454
+ # For V2 tests
455
+ gcloud builds submit --config=integration_test/cloudbuild-v2.yaml
384
456
` ` `
385
457
386
458
**Default behavior (Firebase team):**
@@ -447,6 +519,11 @@ If you see authentication errors like "Could not refresh access token" or "Permi
447
519
gcloud projects add-iam-policy-binding TARGET_PROJECT_ID \
448
520
--member="serviceAccount:[email protected] " \
449
521
--role="roles/firebase.admin"
522
+
523
+ # For Service Account User (required for Functions deployment)
524
+ gcloud projects add-iam-policy-binding TARGET_PROJECT_ID \
525
+ --member="serviceAccount:[email protected] " \
526
+ --role="roles/iam.serviceAccountUser"
450
527
` ` `
451
528
452
529
# ## Cleanup Issues
0 commit comments