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

getPort.makeRange clashing when running parallel tests #37

Closed
HunorMarton opened this issue Dec 2, 2019 · 2 comments
Closed

getPort.makeRange clashing when running parallel tests #37

HunorMarton opened this issue Dec 2, 2019 · 2 comments

Comments

@HunorMarton
Copy link

HunorMarton commented Dec 2, 2019

I'm using ava to set up multiple CDCT tests starting with this:

const test = require('ava')
const getPort = require('get-port')
const { Pact } = require('@pact-foundation/pact')

...

test.before('async() => {
  port = await getPort()
  console.log(`Setting up port ${port}`)

  provider = new Pact({
    port,
    ...
  })

  await provider.setup()
})

...

Works great, tests are running in parallel and different ports are used:

Setting up on port 64873
Setting up on port 64874

But Pact gives me a warning saying I'm using a port outside it's recommended range:

WARN: pact-node@10.2.2/90509 on MBP.localdomain: Like a Boss, you used a port outside of the recommended range (1024 to 49151); I too like to live dangerously.

While it's just a warning, it's still not nice, so I change it to this:

test.before('async() => {
  port = await getPort({ port: getPort.makeRange(1024, 49151) })
  console.log(`Setting up port ${port}`)
  ...
})

But then both end up to be on the same port and my tests fail

Setting up on port 1024
Setting up on port 1024

Could the makeRange be randomized the same way as the default behaviour is?

@sindresorhus
Copy link
Owner

Duplicate of #23

@sindresorhus sindresorhus marked this as a duplicate of #23 Dec 18, 2019
@sindresorhus
Copy link
Owner

The in-process race condition you're experiencing was fixed by 73e21d8.

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