All Projects → ClearcodeHQ → pytest-elasticsearch

ClearcodeHQ / pytest-elasticsearch

Licence: LGPL-3.0, GPL-3.0 licenses found Licenses found LGPL-3.0 COPYING.lesser GPL-3.0 COPYING
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.

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to pytest-elasticsearch

pytest-pipeline
Pytest plugin for functional testing of data analysis pipelines
Stars: ✭ 19 (-70.77%)
Mutual labels:  pytest-plugin
pytest-snapshot
A plugin for snapshot testing with pytest.
Stars: ✭ 68 (+4.62%)
Mutual labels:  pytest-plugin
Pudb
Full-screen console debugger for Python
Stars: ✭ 2,267 (+3387.69%)
Mutual labels:  pytest-plugin
pytest-mock-server
Mock server plugin for pytest
Stars: ✭ 19 (-70.77%)
Mutual labels:  pytest-plugin
pytest-localstack
Pytest plugin for local AWS integration tests
Stars: ✭ 66 (+1.54%)
Mutual labels:  pytest-plugin
pytest-redis
Redis fixtures and fixture factories for Pytest.This is a pytest plugin, that enables you to test your code that relies on a running Redis database. It allows you to specify additional fixtures for Redis process and client.
Stars: ✭ 68 (+4.62%)
Mutual labels:  pytest-plugin
pytest-test-groups
A Pytest plugin that gives you a way to split your tests into groups of a specific size
Stars: ✭ 37 (-43.08%)
Mutual labels:  pytest-plugin
pytest-neo
Matrix has you...
Stars: ✭ 44 (-32.31%)
Mutual labels:  pytest-plugin
pytest-split
Pytest plugin which splits the test suite to equally sized "sub suites" based on test execution time.
Stars: ✭ 93 (+43.08%)
Mutual labels:  pytest-plugin
Pytest Testinfra
With Testinfra you can write unit tests in Python to test actual state of your servers configured by management tools like Salt, Ansible, Puppet, Chef and so on.
Stars: ✭ 1,987 (+2956.92%)
Mutual labels:  pytest-plugin
pytest-eth
PyTest plugin for testing smart contracts for Ethereum blockchain.
Stars: ✭ 23 (-64.62%)
Mutual labels:  pytest-plugin
pytest-notebook
A pytest plugin for regression testing and regenerating Jupyter Notebooks
Stars: ✭ 35 (-46.15%)
Mutual labels:  pytest-plugin
pytest-djangoapp
Nice pytest plugin to help you with Django pluggable application testing.
Stars: ✭ 35 (-46.15%)
Mutual labels:  pytest-plugin
pytest-snail
Plugin for adding a marker to slow running tests. 🐌
Stars: ✭ 15 (-76.92%)
Mutual labels:  pytest-plugin
Seleniumbase
A Python framework that inspires developers to become better test automation engineers. 🧠💡
Stars: ✭ 2,520 (+3776.92%)
Mutual labels:  pytest-plugin
pytest-mongo
This is a pytest plugin, that enables you to test your code that relies on a running MongoDB database. It allows you to specify fixtures for MongoDB process and client.
Stars: ✭ 18 (-72.31%)
Mutual labels:  pytest-plugin
pytest-arraydiff
pytest plugin to facilitate comparison of results to a pre-defined reference
Stars: ✭ 12 (-81.54%)
Mutual labels:  pytest-plugin
overhave
Web-framework for BDD: scalable, configurable, easy to use, based on Flask Admin and Pydantic.
Stars: ✭ 61 (-6.15%)
Mutual labels:  pytest-plugin
pytest-rabbitmq
This is a pytest plugin, that enables you to test your code that relies on a running RabbitMQ Queues. It allows you to specify additional fixtures for RabbitMQ process and client.
Stars: ✭ 34 (-47.69%)
Mutual labels:  pytest-plugin
pytest-reportlog
Replacement for the --resultlog option, focused in simplicity and extensibility
Stars: ✭ 36 (-44.62%)
Mutual labels:  pytest-plugin

https://raw.githubusercontent.com/ClearcodeHQ/pytest-elasticsearch/master/logo.png

pytest-elasticsearch

Latest PyPI version Wheel Status Supported Python Versions License

What is this?

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.

How to use

Warning

This plugin requires at least version 6.0 of elasticsearch to work.

The plugin contains two fixtures:

  • elasticsearch - a client fixture that has functional scope, and which cleans Elasticsearch at the end of each test.
  • elasticsearch_proc - a session scoped fixture, that starts Elasticsearch instance at its first use and stops at the end of the tests.
  • elasticsearch_nooproc - a nooprocess fixture, that's holds connection data to already running elasticsearch

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:

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.

Connecting to already existing Elasticsearch service

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.

es_external = factories.elasticsearch('elasticsearch_nooproc')

By default the elasticsearch_nooproc fixture would connect to elasticsearch instance using 9300 port.

Configuration

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:

  1. Fixture factory argument
  2. Command line option
  3. Configuration option in your pytest.ini file
Configuration options
ElasticSearch option Fixture factory argument Command line option pytest.ini option Noop process fixture Default
Elasticsearch executable executable --elasticsearch-executable elasticsearch_executable   /usr/share/elasticsearch/bin/elasticsearch
host host --elasticsearch-host elasticsearch_host host 127.0.0.1
port port -elasticsearch-port elasticsearch_port 6300 random
Elasticsearch cluster name cluster_name --elasticsearch-cluster-name elasticsearch_cluster_name
elasticsearch_cluster_<port>
index storage type index_store_type --elasticsearch-index-store-type elasticsearch_index_store_type
mmapfs
network publish host network_publish_host --elasticsearch-network-publish-host elasticsearch_network_publish_host
127.0.0.1
transport tcp port transport_tcp_port --elasticsearch-transport-tcp-port elasticsearch_transport_tcp_port
random

Example usage:

  • pass it as an argument in your own fixture

    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:

    [pytest]
    elasticsearch_cluster_name = awsome_cluster

Known issues

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:

  • /etc/default/elasticsearch

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.

Package resources

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].