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

Async setup blocks running at same time, and twice per test case #56

Open
geelen opened this issue Apr 12, 2023 · 0 comments
Open

Async setup blocks running at same time, and twice per test case #56

geelen opened this issue Apr 12, 2023 · 0 comments

Comments

@geelen
Copy link

geelen commented Apr 12, 2023

In my code, I have:

await b.suite(
  `Random reads from table with 10M rows`,

  b.add('case 1', async () => {
    const hostname = await setupServerA({rows: 10_000_000})
    return async () => {
      const id = Math.floor(Math.random() * 10_000_000)
      const query = `SELECT * FROM randoms WHERE id = ${id}`
      await doQuery(`${hostname}/query`, query)
    }
  }),

  b.add('case 2', async () => {
    const hostname = await setupServerB({rows: 10_000_000})
    return async () => {
      const id = Math.floor(Math.random() * 10_000_000)
      const query = `SELECT * FROM randoms WHERE id = ${id}`
      await doQuery(`${hostname}/query`, query)
    }
  }),

  b.cycle(),
  b.complete()
)

What I'm noticing is that setupServerA and setupServerB are getting called twice each, straight away. I previously was making some assumptions that only one server would be active at once which got me tripped up, but even after I fixed it the fact that the setups are all booting at the same time is causing some problems.

What's the reasoning behind calling each setup twice? Is that configurable? Additionally, could each async setup stage be executed sequentially rather than in parallel?

Thanks for building a really useful little tool!

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

1 participant