allegro / embedded-elasticsearch

Tool that ease up creation of integration tests with Elasticsearch
Apache License 2.0
269 stars 81 forks source link

Ability to run elasticsearch with specific user #52

Closed ItamarBenjamin closed 6 years ago

ItamarBenjamin commented 6 years ago

since ES cannot run as root, it should be able to specify a user to run ES with when executing user is root.

gaczm commented 6 years ago

Duplicate of #45 TLDR: I won't add this, as this is very os specific feature. Root user is not a good choice for running tests, so it will be better to setup test environment properly instead of adding such feature.

ItamarBenjamin commented 6 years ago

Is it possible maybe to add elastic launcher script? Or a way to override the start command? Fixing the environment is not possible in my case as the builds are running inside dockers that execute everything as root and i have no control over it.

Thanks!

gaczm commented 6 years ago

Ok, but why you can't run docker as another user?

ItamarBenjamin commented 6 years ago

i don't have control over the CD pipeline environment, so can't run the docker differently. from what i understood from my teammate the build script does some privileged actions (like cgroups initialization) and then runs gradle. we tried separating the build to two different steps but it is not a simple task as it seems, we decided that the easiest solution would be to run elasticsearch with a wrapper or something similar that switches the user before execution.

gaczm commented 6 years ago

So what about script that would starts gradle as another user?

ItamarBenjamin commented 6 years ago

That should work... will try it. thanks

pkrajanand commented 5 years ago

HI @ItamarBenjamin ,

Hope you have resolved your issue to start the elastic search on a different user. I came across similar case with my maven project that I managed to run with a non-root user. However, it does not proceed due to a Caused by: pl.allegro.tech.embeddedelasticsearch.EmbeddedElasticsearchStartupException: Failed to start elasticsearch within time-out exception without any further clues about it, unlike the case when I get a similar exception due to cannot start as root. I tried with a different timeouts like 60, 120 and 180 seconds without luck. Wondering if you come across a situation like this or not.

Raj

pkrajanand commented 5 years ago

I had a timeout of 60 seconds configured with it. Now when it increased to 180 seconds gradually, the server is started. This definitely smells like a workaround, so wondering if there is a decent way to get around this.