Skip to content

Commit

Permalink
Jest global timeout and fixes (#693)
Browse files Browse the repository at this point in the history
* Jest global timeout

* remove unused

* avoid setinterval in test
  • Loading branch information
DavidGOrtega authored Aug 16, 2021
1 parent 8bee5db commit 899c6d2
Show file tree
Hide file tree
Showing 12 changed files with 3,478 additions and 4,296 deletions.
2 changes: 0 additions & 2 deletions bin/cml-pr.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
jest.setTimeout(200000);

const { exec } = require('../src/utils');

describe('CML e2e', () => {
Expand Down
2 changes: 0 additions & 2 deletions bin/cml-publish.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
jest.setTimeout(200000);

const fs = require('fs');
const { exec } = require('../src/utils');

Expand Down
2 changes: 0 additions & 2 deletions bin/cml-send-comment.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
jest.setTimeout(200000);

const { exec } = require('../src/utils');
const fs = require('fs').promises;

Expand Down
2 changes: 0 additions & 2 deletions bin/cml-send-github-check.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
jest.setTimeout(200000);

const { exec } = require('../src/utils');
const fs = require('fs').promises;

Expand Down
40 changes: 20 additions & 20 deletions bin/cml-tensorboard-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { spawn } = require('child_process');
const { homedir } = require('os');
const tempy = require('tempy');

const { exec, watermarkUri } = require('../src/utils');
const { exec, watermarkUri, sleep } = require('../src/utils');

const { TB_CREDENTIALS } = process.env;
const isCLI = require.main === module;
Expand All @@ -22,30 +22,30 @@ const closeFd = (fd) => {
}
};

const tbLink = (opts = {}) => {
const { stdout, stderror, title, name, rmWatermark, md } = opts;
const tbLink = async (opts = {}) => {
const { stdout, stderror, title, name, rmWatermark, md, timeout = 60 } = opts;

return new Promise((resolve, reject) => {
const parserWatcher = setInterval(async () => {
const data = await fs.readFile(stdout, 'utf8');
const urls = data.match(/(https?:\/\/[^\s]+)/) || [];
let chrono = 0;
const chronoStep = 2;
while (chrono < timeout) {
const data = await fs.readFile(stdout, 'utf8');
const urls = data.match(/(https?:\/\/[^\s]+)/) || [];

if (urls.length) {
let [output] = urls;
if (urls.length) {
let [output] = urls;

if (!rmWatermark) output = watermarkUri({ uri: output, type: 'tb' });
if (md) output = `[${title || name}](${output})`;
if (!rmWatermark) output = watermarkUri({ uri: output, type: 'tb' });
if (md) output = `[${title || name}](${output})`;

resolve(output);
clearInterval(parserWatcher);
}
}, 1 * 5 * 1000);
return output;
}

setTimeout(async () => {
const error = await fs.readFile(stderror, 'utf8');
reject(new Error(`Tensorboard took too long. ${error}`));
}, 1 * 60 * 1000);
});
await sleep(chronoStep);
chrono = chrono + chronoStep;
}

const error = await fs.readFile(stderror, 'utf8');
throw new Error(`Tensorboard took too long. ${error}`);
};

const run = async (opts) => {
Expand Down
6 changes: 2 additions & 4 deletions bin/cml-tensorboard-dev.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
jest.setTimeout(200000);

const fs = require('fs').promises;
const tempy = require('tempy');
const { exec, isProcRunning, sleep } = require('../src/utils');
Expand Down Expand Up @@ -31,7 +29,7 @@ describe('tbLink', () => {
await fs.writeFile(stderror, message);

try {
await tbLink({ stdout, stderror });
await tbLink({ stdout, stderror, timeout: 5 });
} catch (err) {
error = err;
}
Expand All @@ -47,7 +45,7 @@ describe('tbLink', () => {
await fs.writeFile(stdout, message);
await fs.writeFile(stderror, '');

const link = await tbLink({ stderror, stdout });
const link = await tbLink({ stderror, stdout, timeout: 5 });
expect(link).toBe(`${message}/?cml=tb`);
});
});
Expand Down
Loading

35 comments on commit 899c6d2

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@0x2b3bfa0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

Please sign in to comment.