![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
pytest-elasticsearch
Advanced tools
.. image:: https://raw.githubusercontent.com/ClearcodeHQ/pytest-elasticsearch/master/logo.png :width: 100px :height: 100px
.. image:: https://img.shields.io/pypi/v/pytest-elasticsearch.svg :target: https://pypi.python.org/pypi/pytest-elasticsearch/ :alt: Latest PyPI version
.. image:: https://img.shields.io/pypi/wheel/pytest-elasticsearch.svg :target: https://pypi.python.org/pypi/pytest-elasticsearch/ :alt: Wheel Status
.. image:: https://img.shields.io/pypi/pyversions/pytest-elasticsearch.svg :target: https://pypi.python.org/pypi/pytest-elasticsearch/ :alt: Supported Python Versions
.. image:: https://img.shields.io/pypi/l/pytest-elasticsearch.svg :target: https://pypi.python.org/pypi/pytest-elasticsearch/ :alt: License
This is a pytest plugin that enables you to test your code that relies on a running Elasticsearch search engine. It allows you to specify fixtures for Elasticsearch process and client.
.. warning::
This plugin requires at least version 6.0 of elasticsearch to work.
The plugin contains two fixtures:
Simply include one of these fixtures into your tests fixture list.
You can also create additional elasticsearch client and process fixtures if you'd need to:
.. code-block:: python
from pytest_elasticsearch import factories
elasticsearch_my_proc = factories.elasticsearch_proc(port=None)
elasticsearch_my = factories.elasticsearch('elasticsearch_my_proc')
.. note::
Each elasticsearch process fixture can be configured in a different way than the others through the fixture factory arguments.
Some projects are using already running Elasticsearch servers
(ie on docker instances). In order to connect to them, one would be using the
elasticsearch_nooproc
fixture.
.. code-block:: python
es_external = factories.elasticsearch('elasticsearch_nooproc')
By default the elasticsearch_nooproc
fixture would connect to elasticsearch
instance using 9300 port.
You can define your settings in three ways, it's fixture factory argument, command line option and pytest.ini configuration option. You can pick which you prefer, but remember that these settings are handled in the following order:
.. list-table:: Configuration options :header-rows: 1
Example usage:
pass it as an argument in your own fixture
.. code-block:: python
elasticsearch_proc = factories.elasticsearch_proc(
cluster_name='awsome_cluster)
specify your directory as elasticsearch_cluster_name
in your pytest.ini
file.
To do so, put a line like the following under the [pytest]
section of your pytest.ini
:
.. code-block:: ini
[pytest]
elasticsearch_cluster_name = awsome_cluster
It might happen, that the process can't be started due to lack of permissions. The files that user running tests has to have access to are:
Make sure that you either run tests as a user that has access to these files, or you give user proper permissions or add it to proper user groups.
In CI at the moment, we install elasticsearch from tar/zip archives, which do not set up additional permission restrictions, so it's not a problem on the CI/CD.
FAQs
Elasticsearch fixtures and fixture factories for Pytest.
We found that pytest-elasticsearch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.