Is there a method by which you can easily / programmatically obtain the HTTP / Transport port number when starting a node using the -Ehttp.port=0 or -Etransport.tcp.port=0 arguments?
Specifically, i'm bringing up an ES node as part of an integration test, which will eventually run on a CI server. As multiple jobs may run concurrently, I need to avoid hard coding the ports numbers when bringing up the node. I can use the above arguments (or a range) to ensure that if there is a port conflict with an already running process, the node will still come up on another port - but short of parsing the elasticsearch.log file (or inspecting the output of a command like netstat for the node pid), is there a way to obtain the ports used.
For example, you can use the -p option to save off the PID to a file, but there isn't a similar (documented) option for ports.
(Yes Docker would be one solution, but not what i'm looking for comment on here)
You can not run elasticsearch embedded. Read this blog post.
Note that to run integration tests (not unit tests) you would probably prefer running that in something close to a production environment, like a real elasticsearch server instance. I shared some ideas about integration testing in this thread: In memory testing with RestHighLevelClient
David, I'm not trying to run it embedded, i am starting a node as its own process with the -Ehttp.port=0 cli argument to bin/elasticseach, which will start the http service on a random unassigned port. what i need is a way to discover that port assignment for use with the high-level rest client.
As noted, i could log scrap to get it but I was hoping for a better method.
i'm bringing up an ES node as part of an integration test
TBH I was not aware that you can start a node with -Ehttp.port=0 or -Etransport.tcp.port=0.
As noted, i could log scrap to get it but I was hoping for a better method.
I guess that's the only method for now. Wondering if this is something that would deserve a feature request... First time I'm seeing that need TBH so I'm unsure about what the team will say.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.