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 datastore/functions test timing out #2993

Merged
merged 1 commit into from
Jan 19, 2023
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
6 changes: 3 additions & 3 deletions datastore/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"test": "mocha test/*.test.js --timeout=5000"
},
"dependencies": {
"@google-cloud/datastore": "^7.0.0",
"is-reachable": "^5.0.0"
"@google-cloud/datastore": "^7.0.0"
},
"devDependencies": {
"@google-cloud/functions-framework": "^3.0.0",
Expand All @@ -24,6 +23,7 @@
"node-fetch": "^2.6.1",
"proxyquire": "^2.1.0",
"sinon": "^15.0.0",
"uuid": "^8.0.0"
"uuid": "^8.0.0",
"wait-port": "^1.0.4"
}
}
19 changes: 5 additions & 14 deletions datastore/functions/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const path = require('path');
const uuid = require('uuid');
const sinon = require('sinon');
const fetch = require('node-fetch');
const isReachable = require('is-reachable');
const waitPort = require('wait-port');
const {Datastore} = require('@google-cloud/datastore');

const datastore = new Datastore();
Expand Down Expand Up @@ -49,16 +49,7 @@ const handleLinuxFailures = async proc => {
}
};

// Wait for the HTTP server to start listening
const waitForReady = async baseUrl => {
let ready = false;
while (!ready) {
await new Promise(r => setTimeout(r, 500));
ready = await isReachable(baseUrl);
}
};

describe.skip('functions/datastore', () => {
describe('functions/datastore', () => {
describe('set', () => {
let ffProc;
const PORT = 8080;
Expand All @@ -69,7 +60,7 @@ describe.skip('functions/datastore', () => {
`functions-framework --target=set --signature-type=http --port=${PORT}`,
{timeout: FF_TIMEOUT, shell: true, cwd}
);
await waitForReady(BASE_URL);
await waitPort({port: PORT});
});

after(async () => {
Expand Down Expand Up @@ -150,7 +141,7 @@ describe.skip('functions/datastore', () => {
`functions-framework --target=get --signature-type=http --port=${PORT}`,
{timeout: FF_TIMEOUT, shell: true, cwd}
);
await waitForReady(BASE_URL);
await waitPort({port: PORT});
});

after(async () => {
Expand Down Expand Up @@ -236,7 +227,7 @@ describe.skip('functions/datastore', () => {
`functions-framework --target=del --signature-type=http --port=${PORT}`,
{timeout: FF_TIMEOUT, shell: true, cwd}
);
await waitForReady(BASE_URL);
await waitPort({port: PORT});
});

after(async () => {
Expand Down