Open saartochner-lumigo opened 4 years ago
@saartochner you can fork this repo and create a PR for it - that's the way how pull requests are usually created in github for OSS projects. Still, this is a bit of a controversial change because it doesn't play well with the idea of "mocha-parallel-tests" where it only supports "mocha" flags. Maybe it's better to just pass all environment variables from the main process to workers?
@1999 Thanks for your answer! I'll open the fork as you suggested and create a PR for it :-)
The idea behind dynamically synchronizing the environment variables is to synchronize the workers. As you stated correctly, mocha doesn't have this feature because they don't need to synchronize anything- they can simply use global variables.
Here's a word about my case, which causes me to think about this feature: I'm writing e2e tests that perform restAPI calls to outer service. There are several services and each worker should decide which service to connect (there is isolation between services but not within two calls to the same service). Therefore, each test should decide which service he will connect, and we need to maintain that parallel tests will never interact with the same service.
Hey, here's the open PR: https://github.com/mocha-parallel/mocha-parallel-tests/pull/274
Gotcha. I'd say your use case is pretty advanced so let's continue the discussion in your PR.
Not sure where to post this but this seems the closest issue to what I'm running into. I need to be able to pass in different environment variables to each process. I'm planning to use this with physical hardware with each process having its own device that can't be shared. The idea being each process can have the ip address of the assigned device's ip but I don't see a way to do this. Appreciate the help.
Hey, Feature idea: adding
--share-envs
to the CLI, which will allow sharing environment variables between the workers. basically, this is simple https://nodejs.org/api/worker_threads.html#worker_threads_worker_share_envP.S. I implemented it and would be happy to open this as a PR. Unfortunately, I don't have permission to open branches here so my hands are tied :( The code is attached as zip parallel.zip