Skip to content
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

Add FDC Integration Tests #8703

Merged
merged 34 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d6d2aaf
First pass at getting fdc tests to work
maneesht Jan 11, 2025
8b45245
Fixed formatting
maneesht Jan 11, 2025
200a2c8
Added logging
maneesht Jan 11, 2025
f4fbfba
Updated formatting
maneesht Jan 11, 2025
72de503
Fixed firebase integration action
maneesht Jan 11, 2025
d8603d6
configure password
maneesht Jan 11, 2025
2420317
log POSTGRES_PASSWORD
maneesht Jan 11, 2025
1abbe54
Fixed integration tests
maneesht Jan 13, 2025
50d074f
Fixed more integration
maneesht Jan 13, 2025
d62d264
Updated ignored tests
maneesht Jan 13, 2025
3225eda
Renamed job
maneesht Jan 13, 2025
244464a
Updated test config
maneesht Jan 13, 2025
4c96d8c
Fixed integration tests?
maneesht Jan 13, 2025
1391cc8
Ignored fdc
maneesht Jan 13, 2025
b224296
Updated ports
maneesht Jan 13, 2025
5ec4c4f
Updated formatting
maneesht Jan 13, 2025
13b490c
Updated changed yaml
maneesht Jan 13, 2025
7d03de6
Fixed failed test
maneesht Jan 13, 2025
f3a5bb4
Updated queries
maneesht Jan 13, 2025
8d71140
Fix testing
maneesht Jan 13, 2025
bffe9dd
Fix emulator port
maneesht Jan 13, 2025
e3848e8
Updated readme and logging
maneesht Jan 13, 2025
b1dfea9
Removed single run
maneesht Jan 13, 2025
46a4c40
Added more logging
maneesht Jan 13, 2025
4737466
Trigger Build
maneesht Jan 13, 2025
699a700
Fixed CI tests
maneesht Jan 14, 2025
cc03960
Added test IDs
maneesht Jan 14, 2025
4c45262
Updated yml
maneesht Jan 14, 2025
338f970
Addressed comments'
maneesht Jan 14, 2025
b5a8c4e
Removed console.logs
maneesht Jan 14, 2025
74e296e
Fixed formatting
maneesht Jan 14, 2025
74e970d
Addressed comments
maneesht Jan 14, 2025
bac7e1c
Removed unnecessary connection string
maneesht Jan 14, 2025
80e4ff0
Updated emualtor configs
maneesht Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 64 additions & 2 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ jobs:
- name: Set start timestamp env var
run: echo "FIREBASE_CI_TEST_START_TIME=$(date +%s)" >> $GITHUB_ENV
- name: Run unit tests
# Ignore auth and firestore since they're handled in their own separate jobs.
# Ignore auth data-connect and firestore since they're handled in their own separate jobs.
maneesht marked this conversation as resolved.
Show resolved Hide resolved
run: |
xvfb-run yarn lerna run --ignore '{firebase-messaging-integration-test,@firebase/auth*,@firebase/firestore*,firebase-firestore-integration-test}' test:ci
xvfb-run yarn lerna run --ignore '{firebase-messaging-integration-test,@firebase/auth*,@firebase/data-connect*,@firebase/firestore*,firebase-firestore-integration-test}' test:ci
node scripts/print_test_logs.js
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_CLI_TOKEN }}
Expand Down Expand Up @@ -154,6 +154,68 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./lcov-all.info
continue-on-error: true
test-data-connect:
name: (Data Connect) Node.js and Browser (Chrome) Tests
needs: build
services:
postgres:
maneesht marked this conversation as resolved.
Show resolved Hide resolved
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
name: Test Firebase Namespace
runs-on: ubuntu-latest
maneesht marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
# install Chrome first, so the correct version of webdriver can be installed by chromedriver
# when setting up the repo
- name: install Chrome stable
run: |
npx @puppeteer/browsers install chrome@stable
chromeVersionString=$(ls chrome)
if [ "$CHROME_VALIDATED_VERSION" != "$chromeVersionString" ]; then
echo "::warning ::The Chrome version doesn't match the previously validated version. Consider updating CHROME_VALIDATED_VERSION in the GitHub workflow if tests pass."
echo "::warning ::Previously validated version: ${CHROME_VALIDATED_VERSION} vs. Installed version: $chromeVersionString"
echo "CHROME_VERSION_NOTES=$CHROME_VERSION_MISMATCH_MESSAGE" >> "$GITHUB_ENV"
fi
- name: Test Evn TEMP
run: |
echo $CHROME_VERSION_NOTES=$CHROME_VERSION_MISMATCH_MESSAGE
- name: Download build archive
uses: actions/download-artifact@v4
with:
name: build.tar.gz
- name: Unzip build artifact
run: tar xf build.tar.gz
- name: Set up Node (20)
maneesht marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/setup-node@v4
with:
node-version: 22.10.0
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: Set start timestamp env var
run: echo "FIREBASE_CI_TEST_START_TIME=$(date +%s)" >> $GITHUB_ENV
- name: Run unit tests
run: |
xvfb-run yarn lerna run test:ci --scope '@firebase/data-connect*'
node scripts/print_test_logs.js
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_CLI_TOKEN }}
POSTGRES_PASSWORD: postgres
- name: Generate coverage file
run: yarn ci:coverage
- name: Run coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./lcov-all.info
continue-on-error: true

test-firestore:
name: (Firestore) Node.js and Browser (Chrome) Tests
Expand Down
126 changes: 126 additions & 0 deletions .github/workflows/test-changed-data-connect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Test Data Connect

on: pull_request

env:
# make chromedriver detect installed Chrome version and download the corresponding driver
DETECT_CHROMEDRIVER_VERSION: true
# The default behavior of chromedriver uses the older Chrome download URLs. We need to override
# the behavior to use the new URLs.
CHROMEDRIVER_CDNURL: https://googlechromelabs.github.io/
CHROMEDRIVER_CDNBINARIESURL: https://storage.googleapis.com/chrome-for-testing-public
CHROME_VALIDATED_VERSION: linux-120.0.6099.71
# Bump Node memory limit
NODE_OPTIONS: "--max_old_space_size=4096"

jobs:
test-chrome:
name: Test Data Connect on Chrome and Node If Changed
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
runs-on: ubuntu-latest
steps:
# install Chrome first, so the correct version of webdriver can be installed by chromedriver
# when setting up the repo
#
# Note: we only need to check the chrome version change in one job as the warning annotation
# is appended to the entire workflow results, not just this job's results.
- name: install Chrome stable
env:
CHROME_VERSION_MISMATCH_MESSAGE: "The Chrome version doesn't match the previously validated version. Consider updating CHROME_VALIDATED_VERSION in the GitHub workflow if tests pass."
run: |
npx @puppeteer/browsers install chrome@stable
chromeVersionString=$(ls chrome)
if [ "$CHROME_VALIDATED_VERSION" != "$chromeVersionString" ]; then
echo "::warning ::The Chrome version doesn't match the previously validated version. Consider updating CHROME_VALIDATED_VERSION in the GitHub workflow if tests pass."
echo "::warning ::Previously validated version: ${CHROME_VALIDATED_VERSION} vs. Installed version: $chromeVersionString"
echo "CHROME_VERSION_NOTES=$CHROME_VERSION_MISMATCH_MESSAGE" >> "$GITHUB_ENV"
fi
- name: Test Evn TEMP
run: |
echo $CHROME_VERSION_NOTES=$CHROME_VERSION_MISMATCH_MESSAGE
- name: Checkout Repo
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so run-changed script can diff properly.
fetch-depth: 0
- name: Set up Node (20)
uses: actions/setup-node@v4
with:
node-version: 22.10.0
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: build
run: yarn build:changed data-connect
- name: Run tests on changed packages
run: xvfb-run yarn test:changed data-connect
env:
POSTGRES_PASSWORD: postgres
test-firefox:
name: Test Data Connect on Firefox If Changed
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
runs-on: ubuntu-latest

steps:
- name: install Firefox stable
run: npx @puppeteer/browsers install firefox@stable
- name: Checkout Repo
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so run-changed script can diff properly.
fetch-depth: 0
- name: Set up Node (20)
uses: actions/setup-node@v4
with:
node-version: 22.10.0
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: build
run: yarn build:changed data-connect
- name: Run tests on data-connect changed packages
run: xvfb-run yarn test:changed data-connect
env:
POSTGRES_PASSWORD: postgres
BROWSERS: 'Firefox'
# Note: webkit tests were removed due to docker not being available on macos
14 changes: 13 additions & 1 deletion .github/workflows/test-firebase-integration.yml
maneesht marked this conversation as resolved.
Show resolved Hide resolved
maneesht marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ env:

jobs:
test:
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
name: Test Firebase Namespace
runs-on: ubuntu-latest

Expand All @@ -46,4 +56,6 @@ jobs:
- name: build
run: yarn build:changed firebase-integration
- name: Run tests on changed packages
run: yarn test:changed firebase-integration
run: yarn test:changed firebase-integration
env:
POSTGRES_PASSWORD: postgres
5 changes: 5 additions & 0 deletions packages/data-connect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Firebase Data Connect

## Local Development

Check `test/dataconnect.yaml` to ensure that the correct values are filled in.
7 changes: 4 additions & 3 deletions packages/data-connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
"prettier": "prettier --write '*.js' '*.ts' '@(src|test)/**/*.ts'",
"build:deps": "lerna run --scope @firebase/'{app,data-connect}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p --npm-path npm test:emulator",
"test": "run-p --npm-path npm lint test:emulator",
maneesht marked this conversation as resolved.
Show resolved Hide resolved
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:emulator",
"test:all": "run-p --npm-path npm lint test:unit",
"test:browser": "karma start --single-run",
"test:browser:unit": "karma start --unit",
maneesht marked this conversation as resolved.
Show resolved Hide resolved
"test:all": "run-p --npm-path npm lint test:browser test:node",
"test:browser": "karma start",
maneesht marked this conversation as resolved.
Show resolved Hide resolved
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
"test:unit": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/unit/**/*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
"test:emulator": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/dataconnect-test-runner.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/data-connect/src/api/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function queryRef<Data, Variables>(
dataConnect: dcInstance,
refType: QUERY_STR,
name: queryName,
variables: variables
variables
};
}
/**
Expand Down
1 change: 1 addition & 0 deletions packages/data-connect/src/network/transport/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export class RESTTransport implements DataConnectTransport {
body: U
) => {
const abortController = new AbortController();

// TODO(mtewani): Update to proper value
const withAuth = this.withRetry(() =>
dcFetch<T, U>(
Expand Down
5 changes: 5 additions & 0 deletions packages/data-connect/test/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "jscore-sandbox-141b5"
}
}
69 changes: 69 additions & 0 deletions packages/data-connect/test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 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

# dataconnect generated files
.dataconnect

This file was deleted.

Loading
Loading