Skip to content

Commit

Permalink
test: address flaky test (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored and irataxy committed Jan 18, 2023
1 parent 2ce1999 commit 3b9def2
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions media/transcoder/test/transcoder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ const outputUriForAdHoc = `gs://${bucketName}/test-output-adhoc/`;
const cwd = path.join(__dirname, '..');
const resourceFile = `testdata/${testFileName}`;

function wait(ms) {
return new Promise(resolve => {
setTimeout(() => {
return resolve();
}, ms);
});
}

before(async () => {
assert(
process.env.GOOGLE_CLOUD_PROJECT_NUMBER,
Expand Down Expand Up @@ -147,15 +155,15 @@ describe('Job functions preset', () => {
assert.ok(output.includes(jobName));
});

it('should pause for job to run', done => {
setTimeout(done, 60000);
});

it('should check that the job succeeded', function () {
it('should check that the job succeeded', async function () {
this.retries(5);
await wait(30000);
const output = execSync(
`node getJobState.js ${projectId} ${location} ${this.presetJobId}`,
{cwd}
);
// TODO(bcoe): remove this debug information once passing:
console.info(output.toString('utf8'));
assert.ok(output.includes('Job state: SUCCEEDED'));
});
});
Expand Down Expand Up @@ -207,15 +215,15 @@ describe('Job functions template', () => {
assert.ok(output.includes(jobName));
});

it('should pause for job to run', done => {
setTimeout(done, 60000);
});

it('should check that the job succeeded', function () {
it('should check that the job succeeded', async function () {
this.retries(5);
await wait(30000);
const output = execSync(
`node getJobState.js ${projectId} ${location} ${this.templateJobId}`,
{cwd}
);
// TODO(bcoe): remove this debug information once passing:
console.info(output.toString('utf8'));
assert.ok(output.includes('Job state: SUCCEEDED'));
});
});
Expand Down Expand Up @@ -257,15 +265,15 @@ describe('Job functions adhoc', () => {
assert.ok(output.includes(jobName));
});

it('should pause for job to run', done => {
setTimeout(done, 60000);
});

it('should check that the job succeeded', function () {
it('should check that the job succeeded', async function () {
this.retries(5);
await wait(30000);
const output = execSync(
`node getJobState.js ${projectId} ${location} ${this.adhocJobId}`,
{cwd}
);
// TODO(bcoe): remove this debug information once passing:
console.info(output.toString('utf8'));
assert.ok(output.includes('Job state: SUCCEEDED'));
});
});

0 comments on commit 3b9def2

Please sign in to comment.