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

Share environment variables between workers #273

Open
saartochner-lumigo opened this issue Jan 5, 2020 · 5 comments
Open

Share environment variables between workers #273

saartochner-lumigo opened this issue Jan 5, 2020 · 5 comments

Comments

@saartochner-lumigo
Copy link

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_env

P.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

@1999
Copy link
Collaborator

1999 commented Jan 6, 2020

@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?

@saartochner-lumigo
Copy link
Author

@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.

@saartochner-lumigo
Copy link
Author

Hey,
here's the open PR:
#274

@1999
Copy link
Collaborator

1999 commented Jan 6, 2020

Gotcha. I'd say your use case is pretty advanced so let's continue the discussion in your PR.

@triwav
Copy link

triwav commented Jun 5, 2020

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.

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

3 participants