I am attempting to use parallel_tests gem with my ruby rspec builds. I rightly ran into issues starting / stopping my elasticsearch server during test runs when I initially had the port hard-coded to 9250 (port conflicts). I then used the ENV variable provided by parallel_tests to dynamically choose a port number for starting the Elasticsearch server, something like
port: 9250 + ENV["TEST_ENV_NUMBER"].to_i.
It now chooses a unique port number for each parallel run, but I am now receiving intermittent failures when trying to start the server:
Errno::EADDRNOTAVAIL: Failed to open TCP connection to localhost:9254 (Cannot assign requested address - connect(2) for "localhost" port 9254)
Even if the test suite has not previously started any Elasticsearch server, I still get intermittent failures when trying to use these dynamic port numbers (note: I’ve never had issues just starting from port 9250).
I’m hoping for some insight on what would prevent Elasticsearch server from starting on ports specifically 9252, 9253, 9254.