Skip to main content

No project description provided

Project description

pytest-exasol-backend Plugin

The pytest-exasol-backend plugin is a collection of pytest fixtures commonly used for testing projects related to Exasol. In particular, it provides unified access to both Exasol On-Prem and SaaS backends. This eliminates the need to build different sets of tests for different backends.

Features

  • Provides session level fixtures that can be turned into connection factories for the database and the BucketFS.
  • Automatically makes the tests running on the selected backends.
  • Allows selecting either or both backends from the CLI that executes the pytest.
  • Starts the selected backends preemptively and in parallel.

Installation

The pytest-exasol-backend plugin can be installed using pip:

pip install pytest-exasol-backend

Usage in Tests

Below is an example of a test that requires access to the database. Note, that by default this test will run twice - once for each backend.

import pyexasol

def test_number_of_rows_in_my_table(backend_aware_database_params):
    with pyexasol.connect(**backend_aware_database_params, schema='MY_SCHEMA') as conn:
        num_of_rows = conn.execute('SELECT COUNT(*) FROM MY_TABLE;').fetchval()
        assert num_of_rows == 5

Here is an example of a test that requires access to the BucketFS. Again, this test will run for each backend, unless one of them is disabled in the CLI.

import exasol.bucketfs as bfs

def test_my_file_exists(backend_aware_bucketfs_params):
    my_bfs_dir = bfs.path.build_path(**backend_aware_bucketfs_params, path='MY_BFS_PATH')
    my_bfs_file = my_bfs_dir / 'my_file.dat'
    assert my_bfs_file.exists()

Sometimes it may be necessary to know which backend the test is running with. In such a case the backend fixture can be used, as in the example below.

def test_something_backend_sensitive(backend):
    if backend == 'onprem':
        # Do something special for the On-Prem database.
        pass
    elif backend == 'saas':
        # Do something special for the SaaS database.
        pass
    else:
        raise RuntimeError(f'Unknown backend {backend}')

Selecting Backends in CLI

By default, none of the backends is selected for testing. Please use the --backend option to specify the target backend. The command below runs the tests on an on-prem database.

pytest --backend=onprem my_test_suite.py

This following command runs the test on two backends.

pytest --backend=onprem --backend=saas my_test_suite.py

The next command runs the test on all backends, which currently is equivalent to the previous command since there are only two backends available.

pytest --backend=all my_test_suite.py

Please note that all selected backends starts preemptively, regardless of their actual usage in tests. Therefore, it is important to make sure the backends are not selected where they are not needed, for instance when running unit tests only.

Setting ITDE parameters in CLI

Sometimes the default ITDE parameters cannot satisfy the test requirements. The plugin allows setting some of the parameters of the api.spawn_test_environment(...) function. The parameter values can be provided in the CLI options. Currently, it is possible to set values of the following parameters:

  • --itde-db-mem-size
  • --itde-db-disk-size
  • --itde-nameserver
  • --itde-additional-db-parameter
  • --itde-db-version

In the example below the tests are run using an instance of the DockerDB with increased memory.

pytest --backend=onprem --itde-db-mem-size "8 GiB" my_test_suite.py

These options are ignored if the "onprem" backend is not selected.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_exasol_backend-1.2.4.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_exasol_backend-1.2.4-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest_exasol_backend-1.2.4.tar.gz.

File metadata

  • Download URL: pytest_exasol_backend-1.2.4.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.10.19 Linux/6.11.0-1018-azure

File hashes

Hashes for pytest_exasol_backend-1.2.4.tar.gz
Algorithm Hash digest
SHA256 ea8680a0fe7cc45626159a451da386ef7c6b90b19ad8c707e86cb7102b08de23
MD5 47313873ec2572fa10ec60cdc398319e
BLAKE2b-256 ebd56cb41d0dbf5fb6f2c9abdb17a5f517d6f77ad17d597ba7ea3331bba08d5a

See more details on using hashes here.

File details

Details for the file pytest_exasol_backend-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: pytest_exasol_backend-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.10.19 Linux/6.11.0-1018-azure

File hashes

Hashes for pytest_exasol_backend-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f7fde35be9cea11369a2c249a431f697ecae64276e3ad4764f4140fe5bb2e6e4
MD5 32f7604105b8dcb395523fbdb1b25358
BLAKE2b-256 485aa84879bdb0bfae3a43aef0c1c834d2839c14b18221c3dbca598d2bd5fd7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page