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

clearMocks throws error on large test suite #11

Closed
napsta32 opened this issue Aug 6, 2020 · 5 comments
Closed

clearMocks throws error on large test suite #11

napsta32 opened this issue Aug 6, 2020 · 5 comments

Comments

@napsta32
Copy link

napsta32 commented Aug 6, 2020

After creating over 30 tests with 3 transactions each, I started getting a Parent database is not open error.
I have clearMocks flag enabled. When I disable it, error doesn't appear but my tests are no longer valid.

I have an 8 core linux machine and I tried to reduce concurrency to 1 and still got the same error.

See this log:

events.js:287
      throw er; // Unhandled 'error' event
      ^
Error [OpenError]: Parent database is not open
    at .../project/node_modules/levelup/lib/levelup.js:119:23
    at .../project/node_modules/abstract-leveldown/abstract-leveldown.js:38:14
    at .../project/node_modules/deferred-leveldown/deferred-leveldown.js:31:21
    at .../project/node_modules/encoding-down/node_modules/abstract-leveldown/abstract-leveldown.js:38:14
    at .../project/node_modules/subleveldown/node_modules/abstract-leveldown/abstract-leveldown.js:38:14
    at onopen (.../project/node_modules/subleveldown/leveldown.js:141:35)
    at processTicksAndRejections (internal/process/task_queues.js:79:11)
    at runNextTicks (internal/process/task_queues.js:66:3)
    at processImmediate (internal/timers.js:429:9)
    at process.topLevelDomainCallback (domain.js:137:15)
Emitted 'error' event on LevelUP instance at:
    at .../project/node_modules/levelup/lib/levelup.js:60:19
    at .../project/node_modules/levelup/lib/levelup.js:119:14
    at .../project/node_modules/abstract-leveldown/abstract-leveldown.js:38:14
    [... lines matching original stack trace ...]
    at processImmediate (internal/timers.js:429:9)

I tried to reproduce with minimal code but it is hard.

@napsta32
Copy link
Author

napsta32 commented Aug 6, 2020

I tried to simplify some things but still got this error after all tests finished running:

/.../node_modules/dynalite/index.js:263
      if (err) throw err
               ^
Error [ReadError]: Database is not open
    at /.../node_modules/levelup/lib/levelup.js:190:15
    at /.../node_modules/encoding-down/index.js:75:21
    at processTicksAndRejections (internal/process/task_queues.js:83:21)
error Command failed with exit code 1.

jest.config.js

clearMocks: false,
testTimeout: 10000,
maxConcurrency: 1,

test.test.js

test.each([[data],[data],... (60 tests)])('test', async() => {deleteTables();createTables();<dynamodb config>})

@corollari
Copy link
Contributor

Could you try disabling some of the tests that are being run? I've just tried running 70+ tests with both clearMocks enabled and disabled and in both cases all tests passed, however the error you are getting seems to be suspiciously similar to the error generated for other test-related problems, such as when there's an attempt to apply a get operation to an item that doesn't exist in the database.

Currently the error messages provided by the package are something that could be improved, I've raised the problem before in #8.

@napsta32
Copy link
Author

napsta32 commented Aug 6, 2020

Last time it worked with my 80 tests test suite. Now that I started using test.each (and some other changes) it stops working at 39 tests (it is working fine with 38 tests).

I will try to simplify more my test code.

@napsta32
Copy link
Author

napsta32 commented Aug 6, 2020

Ohh it was missing await. Looks like a put request was running outside the test loop. I am not sure if there is a way to prevent this.

@napsta32 napsta32 closed this as completed Aug 6, 2020
@corollari
Copy link
Contributor

Yep, the package definitely needs better error messages.

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

2 participants