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

Remove emulator + shims from testing samples #1255

Merged
merged 58 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c306a4c
Remove emulator from testing samples + remove custom shim
Apr 23, 2019
7db63e0
Move HTTP integration test to functions framework
Apr 23, 2019
3173d9c
Address comments + clarify delays
May 2, 2019
a51efee
Remove timeouts + shorten region-tagged blocks
May 2, 2019
5a51a5f
Remove debug var
May 2, 2019
3f1a818
More region-tag-shortening
May 2, 2019
c7e4bab
Use retries instead of delays
Jun 6, 2019
18d399f
Add supertest back
Jun 6, 2019
5bb9142
Merge branch 'master' into deprecate-emulator
Jun 10, 2019
ce28a7a
Merge branch 'master' into deprecate-emulator
Jun 17, 2019
ff233cd
Fix lint + use handleLinuxErrors helper func
Jun 17, 2019
9f96452
Merge branch 'deprecate-emulator' of https://github.com/GoogleCloudPl…
Jun 17, 2019
2534085
Add delay package back + remove shim test
Jun 17, 2019
575f8c6
Use Node 8 syntax (for FF compatibility)
Jun 18, 2019
a96356e
Update non-integration tests w/ Node 8 syntax + removed emulator
Jun 18, 2019
70105f5
Switch to delay package in system tests
Jun 19, 2019
d6bd523
Fix lint
Jun 19, 2019
6fe31ea
Specify BASE_URL for non-Emulator tests
Jun 19, 2019
79b446d
Revamp system tests to get them passing
Jun 19, 2019
cbc5020
Remove BASE_URL from non-system tests
Jun 19, 2019
8732835
Move BASE_URL to Kokoro cfg + remove emulator script block
Jun 20, 2019
97b416a
Add FF dependency
Jun 20, 2019
ee39b9a
Merge branch 'master' into deprecate-emulator
Jun 21, 2019
e796926
Merge branch 'master' into deprecate-emulator
Jun 24, 2019
df5f63f
Switch to Node 8 image
Jun 24, 2019
4c26f20
Merge branch 'master' into deprecate-emulator
Jul 15, 2019
e19d6cd
Merge branch 'master' into deprecate-emulator
Jul 26, 2019
8ec1bbe
Merge branch 'master' into deprecate-emulator
fhinkel Aug 1, 2019
17ef073
Merge branch 'master' into deprecate-emulator
fhinkel Aug 6, 2019
54e77b5
Merge branch 'master' into deprecate-emulator
Sep 4, 2019
56a861d
Merge branch 'master' into deprecate-emulator
Sep 17, 2019
39a5de2
Fix tests: deconflict PORT values
Sep 17, 2019
96d1bb7
Fix tests: deconflict PORT values, take 2
Sep 17, 2019
4b129b5
Tweak test values + remove dbg code
Sep 18, 2019
f5d2b9c
DEBUG: glinux is VERY angry, so debug in CI instead
Sep 18, 2019
7540704
Attempt 1: get stdout on Linux machines
Sep 18, 2019
51e55a3
Attempt 2: remove dbg code + use err object
Sep 18, 2019
ca4a9ed
Apply previous fix to all tests
Sep 18, 2019
7f83560
Apply previous fixes to all samples
Sep 18, 2019
d22f42a
Increase FF timeouts
Sep 18, 2019
caa8670
Switch from Node timeouts to Unix-based ones
Sep 18, 2019
52c8803
Remove Linux failures handler, since Linux tolerates bash timeouts
Sep 18, 2019
af253e5
Label system tests + increase timeout
Sep 18, 2019
4548eec
Change bucket names to avoid conflicts
Sep 19, 2019
b26e07f
Add system test instructions to README
Sep 19, 2019
9700557
Merge branch 'master' into deprecate-emulator
Sep 19, 2019
3138505
Fix lint
Sep 19, 2019
aa27550
functions/pubsub: use separate port + Bash timeouts
Sep 19, 2019
2a6df9c
Kokoro: revert FUNCTIONS_BUCKET change + use FUNCTIONS_DELETABLE_BUCK…
Sep 19, 2019
fea797c
Typo-fix in pubsub sample
Sep 19, 2019
f3aace0
functions/pubsub: fix typos
Sep 19, 2019
5a616a0
FF: remove global dep + add to pubsub package.json
Sep 19, 2019
a590c12
Fix bad pubsub FF URL
Sep 19, 2019
635b3a1
Reduce timeout for system tests
Sep 19, 2019
4eddbe4
Fix package.json typo + increase functions/pubsub log backtrack period
Sep 19, 2019
6706236
DEBUG: debug pubsub system test
Sep 19, 2019
dc5ec93
DBG: add more pubsub debugging
Sep 19, 2019
2572cac
Revert debug commits
Sep 19, 2019
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
45 changes: 20 additions & 25 deletions functions/helloworld/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ exports.helloHttp = (req, res) => {
* @param {object} event The Cloud Functions event.
* @param {function} callback The callback function.
*/
exports.helloBackground = (event, callback) => {
callback(null, `Hello ${event.data.name || 'World'}!`);
exports.helloBackground = (data, context, callback) => {
callback(null, `Hello ${data.name || 'World'}!`);
};
// [END functions_helloworld_background]

Expand All @@ -70,42 +70,37 @@ exports.helloBackground = (event, callback) => {
* This function is exported by index.js, and executed when
* the trigger topic receives a message.
*
* @param {object} event The Cloud Functions event.
* @param {function} callback The callback function.
* @param {object} data The event payload.
* @param {object} context The event metadata.
*/
exports.helloPubSub = (event, callback) => {
const pubsubMessage = event.data;
const name = pubsubMessage.data
? Buffer.from(pubsubMessage.data, 'base64').toString()
exports.helloPubSub = (data, context) => {
const pubSubMessage = data;
const name = pubSubMessage.data
? Buffer.from(pubSubMessage.data, 'base64').toString()
: 'World';

console.log(`Hello, ${name}!`);

callback();
};
// [END functions_helloworld_pubsub]

// [START functions_helloworld_storage]
/**
* Background Cloud Function to be triggered by Cloud Storage.
*
* @param {object} event The Cloud Functions event.
* @param {function} callback The callback function.
* @param {object} data The event payload.
* @param {object} context The event metadata.
*/
exports.helloGCS = (event, callback) => {
const file = event.data;

exports.helloGCS = (data, context) => {
const file = data;
if (file.resourceState === 'not_exists') {
console.log(`File ${file.name} deleted.`);
} else if (file.metageneration === '1') {
// metageneration attribute is updated on metadata changes.
// value is 1 if file was newly created or overwritten
// on create value is 1
console.log(`File ${file.name} uploaded.`);
} else {
console.log(`File ${file.name} metadata updated.`);
}

callback();
};
// [END functions_helloworld_storage]

Expand All @@ -116,11 +111,11 @@ exports.helloGCS = (event, callback) => {
* @param {object} event The Cloud Functions event.
* @param {function} callback The callback function.
*/
exports.helloGCSGeneric = (event, callback) => {
const file = event.data;
exports.helloGCSGeneric = (data, context, callback) => {
const file = data;

console.log(` Event: ${event.eventId}`);
console.log(` Event Type: ${event.eventType}`);
console.log(` Event: ${context.eventId}`);
console.log(` Event Type: ${context.eventType}`);
console.log(` Bucket: ${file.bucket}`);
console.log(` File: ${file.name}`);
console.log(` Metageneration: ${file.metageneration}`);
Expand All @@ -138,7 +133,7 @@ exports.helloGCSGeneric = (event, callback) => {
* @param {function} callback The callback function.
*/

exports.helloError = (event, callback) => {
exports.helloError = (data, context, callback) => {
// [START functions_helloworld_error]
// These WILL be reported to Stackdriver Error Reporting
console.error(new Error('I failed you'));
Expand All @@ -156,7 +151,7 @@ exports.helloError = (event, callback) => {
*/
/* eslint-disable no-throw-literal */

exports.helloError2 = (event, callback) => {
exports.helloError2 = (data, context, callback) => {
// [START functions_helloworld_error]
// These will NOT be reported to Stackdriver Error Reporting
console.info(new Error('I failed you')); // Logging an Error object at the info level
Expand All @@ -173,7 +168,7 @@ exports.helloError2 = (event, callback) => {
* @param {function} callback The callback function.
*/
/* eslint-disable */
exports.helloError3 = (event, callback) => {
exports.helloError3 = (data, context, callback) => {
// This will NOT be reported to Stackdriver Error Reporting
// [START functions_helloworld_error]
callback('I failed you');
Expand Down
14 changes: 8 additions & 6 deletions functions/helloworld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@
"node": ">=8.0.0"
},
"scripts": {
"e2e-test": "export FUNCTIONS_CMD='gcloud functions' && sh test/updateFunctions.sh && BASE_URL=\"https://$GCP_REGION-$GCLOUD_PROJECT.cloudfunctions.net/\" mocha test/*.test.js --timeout=60000 --exit",
"test": "export FUNCTIONS_CMD='functions-emulator' && sh test/updateFunctions.sh && export BASE_URL=\"http://localhost:8010/$GCLOUD_PROJECT/$GCF_REGION\" && mocha test/*.test.js --timeout=60000 --exit",
"system-test": "export FUNCTIONS_CMD='functions-emulator' && sh test/updateFunctions.sh && export BASE_URL=\"http://localhost:8010/$GCLOUD_PROJECT/$GCF_REGION\" && mocha test/*.test.js --timeout=60000 --exit"
"test": "mocha test/*.test.js --timeout=5000 --exit"
},
"dependencies": {
"@google-cloud/debug-agent": "^4.0.0",
"escape-html": "^1.0.3",
"pug": "^2.0.3",
"safe-buffer": "^5.1.2"
"safe-buffer": "^5.1.2",
"supertest": "^4.0.2"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
"@google-cloud/pubsub": "^0.28.0",
"@google-cloud/storage": "^2.0.0",
"mocha": "^6.0.0",
"child-process-promise": "^2.2.1",
"delay": "^4.3.0",
"express": "^4.16.3",
"mocha": "^6.1.4",
"proxyquire": "^2.1.0",
"request": "^2.88.0",
"requestretry": "^4.0.0",
"sinon": "^7.0.0",
"supertest": "^4.0.0",
"uuid": "^3.1.0",
"yargs": "^13.0.0"
},
Expand Down
153 changes: 0 additions & 153 deletions functions/helloworld/shim.js

This file was deleted.

Loading