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(test)] tests are flaky #60

Closed
shadowgate15 opened this issue Dec 2, 2020 · 10 comments
Closed

[fix(test)] tests are flaky #60

shadowgate15 opened this issue Dec 2, 2020 · 10 comments
Assignees

Comments

@shadowgate15
Copy link
Member

currently tests are so flaky that coverage will change from test run to test run.

@shadowgate15 shadowgate15 self-assigned this Dec 2, 2020
@naz
Copy link
Member

naz commented Dec 14, 2020

Have a suspicion the flakiness comes partially from compilation step. There's a value testing against compiled files as that's what gets distributed. That said, think we might benefit from running the coverage against unprocessed source as that's the real and less prone to flakiness source of truth.

Have you had any successful experiments around this issue @shadowgate15 ?

@naz
Copy link
Member

naz commented Jan 5, 2021

I'm adding few tests to increase test coverage and hopefully make the build pass at lease on Node v10. It still puzzles me what's the main source of difference between test coverage in v10 vs v12

naz added a commit that referenced this issue Jan 5, 2021
@naz
Copy link
Member

naz commented Jan 5, 2021

The master is 🟢 again! Have added coverage and reworked how logger = _.cloneDeep(console) was used. The problem with cloning console is that it produces way to much junk output during the test run and was hiding the information about which test has caused an unhandled exception. Having explicit logger variable declarations also gives tests more readability imo.

@naz naz closed this as completed Jan 5, 2021
@shadowgate15
Copy link
Member Author

shadowgate15 commented Jan 5, 2021 via email

@naz
Copy link
Member

naz commented Jan 5, 2021

@shadowgate15 is there a plan for this planned refactor somewhere? What is the goal that needs achieving through the refactor?

@shadowgate15
Copy link
Member Author

shadowgate15 commented Jan 5, 2021 via email

@naz
Copy link
Member

naz commented Jan 5, 2021

Sounds awesome. Having one giant test.js file was getting hard to reason about. Also would be good to clarify the cases when "serial" test cases should be used. My guess was they were made serial because of the flakiness?

@shadowgate15
Copy link
Member Author

shadowgate15 commented Jan 5, 2021 via email

@shadowgate15
Copy link
Member Author

So the flaky tests were coming from job terminates after closeWorkerAfterMs. Below is my attempt to fix but it is still messing up. any thoughts @naz @niftylettuce?

test.serial('job terminates after closeWorkerAfterMs', async (t) => {
  t.plan(2);

  const logger = {};
  logger.info = () => {};
  logger.error = () => {};

  const clock = FakeTimers.install({ now: Date.now() });

  const bree = new Bree({
    root,
    jobs: [{ name: 'long', closeWorkerAfterMs: 100 }]
    // Logger
  });

  bree.run('long');
  const start = clock.now;
  t.true(typeof bree.closeWorkerAfterMs.long === 'object');
  await delay(1);

  bree.workers.long.on('exit', (code) => {
    t.is(start + 100, clock.now);
    t.is(code, 1);
  });

  clock.runAll();
  clock.uninstall();
});

@niftylettuce
Copy link
Contributor

all good now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants