Change the port used in tests
damienalexandre opened this issue · 3 comments
We use the default 9200 port for all the tests, but as we run some destructive requests to Elasticsearch, maybe all tests should try to connect on another, safer port.
That way there is no data destruction risk if someone runs the tests locally on his own ES server.
It would be nice if the port could be defined in general; not just in tests. I currently have 2 ES local instances running; 1 for normal dev use and 1 which is used for local testing.
Currently using api-platform, which has read support for ES. By using that, I have an ELASTICSEARCH_URL
env variable defined, which has a value of protocol://host:port
(currently http://elasticsearch:9200
). Maybe this env variable can be re-used in elastically? Or maybe it's possible to allow the same value for the ELASTICSEARCH_HOST
env variable, but then its not just a HOST
anymore...
By allowing to define a port, in dev
environment I can connect to port 9200
, and in test
environment I can connect to 9222
(or whichever port anyone prefers).
Hi, I think you can already configure Elastica with an URL:
Is that what you need?
Ah! Most definitely. I stared blind at the example, not realizing its actually passing the $config
to the Elastica\Client
constructor. (see ClientConfiguration for other options)
Note for whoever needs it: the url
needs a /
(forward slash) suffixed. So:
JoliCode\Elastically\Client:
arguments:
$config:
url: '%env(ELASTICSEARCH_URL)%/'