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

Fix emulator tests failing on CircleCI #591

Merged
merged 3 commits into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ dependencies:
# Run your tests
test:
override:
- functions start && cd functions/datastore && npm run system-test && functions stop
- functions start && cd functions/helloworld && npm run test && functions stop
- functions-emulator config set projectId $GCLOUD_PROJECT && functions-emulator start && cd functions/datastore && npm run system-test && functions-emulator stop
- functions-emulator config set projectId $GCLOUD_PROJECT && functions-emulator start && cd functions/helloworld && npm run test && functions-emulator stop
- samples test run --cmd nyc -- --cache ava --verbose -T 30s 'functions/background/test/**/*.test.js'
- samples test run --cmd nyc -- --cache ava --verbose -T 30s 'functions/gcs/test/**/*.test.js'
- samples test run --cmd nyc -- --cache ava --verbose -T 30s 'functions/http/test/**/*.test.js'
Expand Down
2 changes: 1 addition & 1 deletion functions/helloworld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lint": "repo-tools lint",
"pretest": "npm run lint",
"e2e-test": "export FUNCTIONS_CMD='gcloud beta functions' && sh test/updateFunctions.sh && BASE_URL=\"https://$GCF_REGION-$GCLOUD_PROJECT.cloudfunctions.net/\" ava -T 20s --verbose test/*.test.js",
"test": "export FUNCTIONS_CMD='functions-emulator' && sh test/updateFunctions.sh && export BASE_URL=\"http://localhost:8010/$GCLOUD_PROJECT/$GCF_REGION\" && ava -T 20s --verbose test/index.test.js test/*unit*test.js test/*integration*test.js",
"test": "export FUNCTIONS_CMD='functions-emulator' && sh test/updateFunctions.sh && export BASE_URL=\"http://localhost:8010/$GCLOUD_PROJECT/$GCF_REGION\" && ava -T 20s --verbose -c 1 test/index.test.js test/*unit*test.js test/*integration*test.js",
"system-test": "export FUNCTIONS_CMD='functions-emulator' && sh test/updateFunctions.sh && export BASE_URL=\"http://localhost:8010/$GCLOUD_PROJECT/$GCF_REGION\" && ava -T 20s --verbose test/*.test.js"
},
"dependencies": {
Expand Down
19 changes: 9 additions & 10 deletions functions/helloworld/test/sample.integration.storage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const childProcess = require(`child_process`);
const test = require(`ava`);
const uuid = require(`uuid`);

test(`helloGCS: should print uploaded message`, async (t) => {
test.serial(`helloGCS: should print uploaded message`, async (t) => {
t.plan(1);
const startTime = new Date(Date.now()).toISOString();
const filename = uuid.v4(); // Use a unique filename to avoid conflicts
Expand All @@ -30,15 +30,14 @@ test(`helloGCS: should print uploaded message`, async (t) => {
metageneration: '1'
});

childProcess.execSync(`functions call helloGCS --data '${data}'`);
childProcess.execSync(`functions-emulator call helloGCS --data '${data}'`);

// Check the emulator's logs
const logs = childProcess.execSync(`functions logs read helloGCS --start-time ${startTime}`).toString();
const logs = childProcess.execSync(`functions-emulator logs read helloGCS --start-time ${startTime}`).toString();
t.true(logs.includes(`File ${filename} uploaded.`));
});

// TODO: ace-n figure out why these tests started failing
test.skip(`helloGCS: should print metadata updated message`, async (t) => {
test.serial(`helloGCS: should print metadata updated message`, async (t) => {
t.plan(1);
const startTime = new Date(Date.now()).toISOString();
const filename = uuid.v4(); // Use a unique filename to avoid conflicts
Expand All @@ -50,14 +49,14 @@ test.skip(`helloGCS: should print metadata updated message`, async (t) => {
metageneration: '2'
});

childProcess.execSync(`functions call helloGCS --data '${data}'`);
childProcess.execSync(`functions-emulator call helloGCS --data '${data}'`);

// Check the emulator's logs
const logs = childProcess.execSync(`functions logs read helloGCS --start-time ${startTime}`).toString();
const logs = childProcess.execSync(`functions-emulator logs read helloGCS --start-time ${startTime}`).toString();
t.true(logs.includes(`File ${filename} metadata updated.`));
});

test(`helloGCS: should print deleted message`, async (t) => {
test.serial(`helloGCS: should print deleted message`, async (t) => {
t.plan(1);
const startTime = new Date(Date.now()).toISOString();
const filename = uuid.v4(); // Use a unique filename to avoid conflicts
Expand All @@ -69,10 +68,10 @@ test(`helloGCS: should print deleted message`, async (t) => {
metageneration: '3'
});

childProcess.execSync(`functions call helloGCS --data '${data}'`);
childProcess.execSync(`functions-emulator call helloGCS --data '${data}'`);

// Check the emulator's logs
const logs = childProcess.execSync(`functions logs read helloGCS --start-time ${startTime}`).toString();
const logs = childProcess.execSync(`functions-emulator logs read helloGCS --start-time ${startTime}`).toString();
t.true(logs.includes(`File ${filename} deleted.`));
});
// [END functions_storage_integration_test]