-
Notifications
You must be signed in to change notification settings - Fork 214
V2 integration tests #1717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
V2 integration tests #1717
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6ddd5e0
refactor(int): integration tests rewrite - wip
kirstywilliams 800c272
chore: remove functions.yaml
kirstywilliams debd4d5
chore: ignore functions.yaml
kirstywilliams fb58e19
wip: v2 func not deploying
kirstywilliams ae411f7
chore: update gitignore
kirstywilliams 45e85fc
feat: integration tests
kirstywilliams 1124b7f
chore: update readme
kirstywilliams 6c22d40
feat: Update firebase_admin t0 12.3.0 in sample env
exaby73 cbf0840
wip: Integration tests fixes
exaby73 6f482e5
wip(integration-tests): Update .env.example
exaby73 75379ce
wip(integration-tests): Remove FIRESTORE_REGION
exaby73 0532b2f
remove(integration_test): Storage V1 delete tests
exaby73 571f3fc
wip(integration_test): Multiple fixes for tests
exaby73 7e8939f
fix(integration_test): Use bash for source command
exaby73 b47761b
fix(integration_test): Rename integration_tests to integration_test
exaby73 1152ffe
fix(integration_test): Use bash for missed source command
exaby73 9155c1b
fix(integration_test): Runtime for Python
exaby73 b4ef09e
fix(integration_test): Pass DEBUG to CLI env
exaby73 d55c021
wip(integration_test): Remove predeploy command
exaby73 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
steps: | ||
- name: "node:18" | ||
id: "Install dependencies" | ||
dir: "integration_test" | ||
entrypoint: "npm" | ||
args: ["install"] | ||
- name: "node:18" | ||
id: "Set Project ID" | ||
dir: "integration_test" | ||
entrypoint: "npx" | ||
args: ["firebase", "use", "cf3-integration-tests-d7be6"] | ||
- name: "node:18" | ||
id: "Run tests" | ||
dir: "integration_test" | ||
entrypoint: "npm" | ||
args: ["start"] | ||
|
||
options: | ||
defaultLogsBucketBehavior: REGIONAL_USER_OWNED_BUCKET |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
DEBUG=true | ||
TEST_RUNTIME=node | ||
REGION=us-central1 | ||
PROJECT_ID= | ||
DATABASE_URL= | ||
STORAGE_BUCKET= | ||
NODE_VERSION=18 | ||
FIREBASE_ADMIN=^12.6.0 | ||
FIREBASE_APP_ID= | ||
FIREBASE_MEASUREMENT_ID= | ||
FIREBASE_AUTH_DOMAIN= | ||
FIREBASE_API_KEY= | ||
GOOGLE_ANALYTICS_API_SECRET= | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
firebase-debug.log* | ||
firebase-debug.*.log* | ||
|
||
# Firebase cache | ||
.firebase/ | ||
|
||
# Firebase config | ||
|
||
# Uncomment this if you'd like others to create their own Firebase project. | ||
# For a team working on the same Firebase project(s), it is recommended to leave | ||
# it commented so all members can deploy to the same project(s) in .firebaserc. | ||
# .firebaserc | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# Firebase/GCP config | ||
.firebaserc | ||
serviceAccount.json | ||
functions.yaml | ||
functions/src/package.json | ||
functions/package/ | ||
|
||
.nvmrc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,40 @@ | ||
## How to Use | ||
# Integration Test Suite | ||
|
||
**_ATTENTION_**: Running this test will wipe the contents of the Firebase project(s) you run it against. Make sure you use disposable Firebase project(s)! | ||
## How to use | ||
|
||
Run the integration test as follows: | ||
### Prerequisites | ||
|
||
Tests use locally installed firebase to invoke commands for deploying functions. | ||
The tests also require that you have gcloud CLI installed and authenticated | ||
(`gcloud auth login`). | ||
|
||
Tests are deployed with a unique identifier, which enables the teardown of its own resources, without affecting other test runs. | ||
|
||
1. Add a service account at root serviceAccount.json | ||
2. Add a .env `cp .env.example .env` | ||
3. Ensure service account has required roles for each cloud service | ||
4. Ensure any resources such as eventarc channel ("firebase" is used as default) are configured | ||
|
||
### Running setup and tests | ||
|
||
This will deploy functions with unique names, set up environment for running the jest files, and run the jest test suite. | ||
|
||
```bash | ||
./run_tests.sh <project_id> [<project_id2>] | ||
yarn start | ||
``` | ||
|
||
Test runs cycles of testing, once for Node.js 14 and another for Node.js 16. | ||
|
||
Test uses locally installed firebase to invoke commands for deploying function. The test also requires that you have | ||
gcloud CLI installed and authenticated (`gcloud auth login`). | ||
## TODO | ||
|
||
Integration test is triggered by invoking HTTP function integrationTest which in turns invokes each function trigger | ||
by issuing actions necessary to trigger it (e.g. write to storage bucket). | ||
[x] Deploy functions with unique name | ||
[x] Update existing tests to use jest (v1 and v2) | ||
[x] Add missing coverage for v1 and v2 (WIP) | ||
[x] Ensure proper teardown of resources (only those for current test run) | ||
[] Analytics: since you cannot directly trigger onLog events from Firebase Analytics in a CI environment, the primary strategy is to isolate and test the logic within the Cloud Functions by mocking Firebase services and the Analytics event data. This is done elsewhere via unit tests, so no additional coverage added. | ||
[] Alerts: same as analytics, couldn't find way to trigger. | ||
[] Auth blocking functions can only be deployed one at a time, half-way solution is to deploy v1 functions, run v1 tests, teardown, and repeat for v2. However, this still won't allow for multiple runs to happen in parallel. Solution needed before re-enabling auth/identity tests. You can run the suite with either v1 or v2 commented out to check test runs. | ||
[] Https tests were commented out previously, comments remain as before | ||
[] Python runtime support | ||
|
||
### Debugging | ||
## Troubleshooting | ||
|
||
The status and result of each test is stored in RTDB of the project used for testing. You can also inspect Cloud Logging | ||
for more clues. | ||
- Sometimes I ran into this reported [issue](https://github.com/firebase/firebase-tools/issues/793), I had to give it some period of time and attempt deploy again. Probably an upstream issue but may affect our approach here. Seems to struggle with deploying the large amount of trigger functions...? Falls over on Firebase Storage functions (if you comment these out everything else deploys as expected). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project ID
cf3-integration-tests-d7be6
is hardcoded. This makes the build configuration less portable. It's better to use a substitution variable (e.g.,$_PROJECT_ID
or$PROJECT_ID
) which can be provided at build time. This allows the same configuration to be used for different projects or environments.