3

My scenario consists of a server that notify to attached websockets when some event occurs. The websocket query params specify for which kind of events the client should be notified.

I have a set of predefined events for the notification, and a set of websocket URLs for which the expected matching events are known.

What I would like to obtain is to:

  1. Start the notification service (waiting for the stream of events)
  2. For each test attach a client through websocket
  3. Start the stream of events
  4. Stop the notification server once the stream is completed (closing the websocket)
  5. Clients (the tests) check on the websocket closure that the received events match the expected ones

This scenario can only work if all the tests are run at the same time. For this reason I thought of using pytest-xdist using "-n ".

Unfortunately this does not seems to work. Having 8 tests what I obtained is that 4 tests runs immediately as I would have expected, but the last 4 are started only when the first ones end.

If I understand correctly the pytest-xdist code (dession.py:366-368) it looks like tests are divided among the slaves in chunks of at least 2 tests each.

This, obviously, jeopardizes my setup and explains the behaviour.

Could someone come up with a workaround to this problem?

MrBean Bremen
  • 14,916
  • 3
  • 26
  • 46
Teudimundo
  • 2,610
  • 20
  • 28

0 Answers0