whitfin / local-cluster

Easy local cluster creation for Elixir to aid in unit testing
MIT License
223 stars 30 forks source link

Can we start nodes with test env (MIX_ENV=test)? #3

Closed pggalaviz closed 5 years ago

pggalaviz commented 5 years ago

Is there a way to start the nodes with test env (MIX_ENV=test)? I'm using Swarm as a dependency, and by default it logs a lot of data when running in dev mode (info and debug). While using Local Cluster in a test, I can see all the logs Swarm produces from all nodes on the test cluster as they're running with dev environment.

Is there a way to prevent all these logs to appear during tests but keep them for dev?

whitfin commented 5 years ago

If you're starting your local cluster in test, then the started nodes will also be in test. Can you log out Mix.env() from a remote node and see what comes up?

pggalaviz commented 5 years ago

It returns :test, nothing wrong there.

Looking at Swarm's cluster test helper: https://github.com/bitwalker/swarm/blob/14302120fdec9b16c3368df6dd143b583d5d901e/test/support/cluster.ex#L44 Seems they set the logger level by passing it as an argument when starting the node.

Could this fix the logging issue?

If I log Logger.level() from a node it returns :debug instead of :warn.

whitfin commented 5 years ago

@pggalaviz want to fork and try it out? Happy to merge a PR if that fixes it for you. Here is the likely line.

whitfin commented 5 years ago

@pggalaviz this should be ok now in v1.0.3, want to try it out?

pggalaviz commented 5 years ago

Working fine! No more unwanted logs 👍