Skip to content

Fixing Redis adapter tests #5599

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

Merged
merged 1 commit into from
May 16, 2019

Conversation

davimacedo
Copy link
Member

It's weird, but I wrote the test below and it fails almost every time I run.

fit('timeout should wait', done => {
    let promise = Promise.resolve();
    for (let i = 0; i < 1000; i ++) {
      promise = promise
        .then(() => new Date())
        .then(startDate => new Promise(resolve => setTimeout(() => resolve(startDate), 2)))
        .then(startDate => {
          if ((new Date()) - startDate < 2) {
            done.fail();
          }
        });
    }
    promise.then(done);
  });

There are some tests that set a 1ms ttl, wait 2ms and check if it is expired (it is supposed to be). But because of this strange behavior of setTimeout function, sometimes the time difference between the two operations is below 2ms and Redis understand that the key is not yet expired. So I suggest increasing some waiting times to avoid builds to fail. That's what this PR is about.

@codecov
Copy link

codecov bot commented May 16, 2019

Codecov Report

Merging #5599 into master will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5599      +/-   ##
==========================================
- Coverage   94.07%   94.02%   -0.05%     
==========================================
  Files         129      129              
  Lines        9243     9243              
==========================================
- Hits         8695     8691       -4     
- Misses        548      552       +4
Impacted Files Coverage Δ
src/RestWrite.js 93.1% <0%> (-0.52%) ⬇️
...dapters/Storage/Postgres/PostgresStorageAdapter.js 96.81% <0%> (-0.09%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc7d3f1...7a40f5d. Read the comment docs.

Copy link
Member

@dplewis dplewis left a comment

Choose a reason for hiding this comment

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

LGTM! I think this is the last of the flaky tests.

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

Successfully merging this pull request may close these issues.

2 participants