Skip to content

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

@geelen

Description

@geelen

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions