-
Notifications
You must be signed in to change notification settings - Fork 625
Update functions instances used by device-tests and smoke-tests. #2429
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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 @@ | ||
{} |
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,66 @@ | ||
# 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 |
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,27 @@ | ||
# Function definitions required for smoke tests | ||
|
||
The tests assume that these functions are deployed to the project used by smoke tests. | ||
|
||
To deploy the functions, run the following commands: | ||
|
||
```bash | ||
# if not already logged into firebase-cli run | ||
firebase login | ||
firebase use $PROJECT_ID | ||
|
||
# build and deploy functions | ||
echo $(cd functions && npm install) | ||
firebase deploy --only functions | ||
``` | ||
|
||
To verify that deployment is successful, run the following commands: | ||
|
||
```bash | ||
curl -X POST -H "Content-Type:application/json" https://us-central1-fireescape-smoke-tests.cloudfunctions.net/addNumbers -d '{"data":{"firstNumber":13,"secondNumber":17}}' | ||
``` | ||
|
||
It should return back: | ||
|
||
```bash | ||
{"result":{"firstNumber":13,"secondNumber":17,"operator":"+","operationResult":30}} | ||
``` |
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,7 @@ | ||
{ | ||
"functions": { | ||
"predeploy": [ | ||
"npm --prefix \"$RESOURCE_DIR\" run lint" | ||
] | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
smoke-tests/src/androidTest/backend/functions/functions/.eslintrc.js
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,14 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
es6: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"google", | ||
], | ||
rules: { | ||
quotes: ["error", "double"], | ||
}, | ||
}; |
43 changes: 43 additions & 0 deletions
43
smoke-tests/src/androidTest/backend/functions/functions/index.js
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,43 @@ | ||
// Copyright 2021 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. | ||
|
||
const functions = require("firebase-functions"); | ||
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. Since this is actual code, AFAIK it needs the copyright header. 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. Done. |
||
|
||
// // Create and Deploy Your First Cloud Functions | ||
// // https://firebase.google.com/docs/functions/write-firebase-functions | ||
// | ||
// exports.helloWorld = functions.https.onRequest((request, response) => { | ||
// functions.logger.info("Hello logs!", {structuredData: true}); | ||
// response.send("Hello from Firebase!"); | ||
// }); | ||
|
||
exports.addNumbers = functions.https.onCall((data) => { | ||
const firstNumber = data.firstNumber; | ||
const secondNumber = data.secondNumber; | ||
|
||
if (!Number.isFinite(firstNumber) || !Number.isFinite(secondNumber)) { | ||
throw new functions.https.HttpsError( | ||
"invalid-argument", | ||
"The function must be called with " + | ||
"two arguments \"firstNumber\" and \"secondNumber\" " + | ||
"which must both be numbers."); | ||
} | ||
|
||
return { | ||
firstNumber: firstNumber, | ||
secondNumber: secondNumber, | ||
operator: "+", | ||
operationResult: firstNumber + secondNumber, | ||
}; | ||
}); |
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.
We don't need the emulator anymore?
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.
This npm module has been deprecated: https://www.npmjs.com/package/@google-cloud/functions-emulator. One of the recommended alternative is to start emulator with
firebase-tools
, which is the same tool used to deploy functions. So I think it's no longer needed here.