pytest-elasticsearch
pytest-elasticsearch copied to clipboard
Test elastic above 8.0.0 on an existing server
What action do you want to perform
There is 2 issue :
It looks like we can't connect pytest-elasticsearch with an elastic client above 8.0.0 on a server that already exist with the following line
es_client = factories.elasticsearch("elasticsearch_nooproc")
Elastic client changed their way to connect with the elastic-transport-python API and since there is the following error.
ValueError: URL must include a 'scheme', 'host', and 'port' component (ie 'https://localhost:9200')
~/.local/lib/python3.10/site-packages/elastic_transport/client_utils.py:212: ValueError
The second issue is smaller but when you use a toml file for configuration there is wrong type raised by elastic-transport-python that raise this error.
`TypeError: '<' not supported between instances of 'str' and 'int'`
~/.local/lib/python3.10/site-packages/elastic_transport/_models.py:305: TypeError
I've found a small (disgracious) work around in the factories.py file
yield NoopElasticsearch(host=es_host, port=es_port) # master
yield NoopElasticsearch(host=es_host, port=int(es_port)) # work around
The toml file I used
[tool.pytest.ini_options]
elasticsearch_port = 9200
maybe i've missed some breaking change with elasticsearch-py
BTW my requiriement.txt
pytest==7.4.0
pytest-elasticsearch==4.0.2
python-dotenv==1.0.0
elasticsearch==8.6.2
elasticsearch-dsl>=8.0.0,<9.0.0