Skip to content

Commit

Permalink
Add pytest plugin and prepare release
Browse files Browse the repository at this point in the history
* Add basic pytest plugin setup
* Update change-log
* Update dependencies
* Bump version number
  • Loading branch information
Nicoretti authored Mar 21, 2023
1 parent a1cfee4 commit f9698db
Show file tree
Hide file tree
Showing 18 changed files with 2,234 additions and 384 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../../../pulls) for the same update/change? <!-- markdown-link-check-disable-line -->
* [ ] Are you mentioning the issue which this PullRequest fixes ("Fixes...")
* [ ] Before you merge don't forget to run all tests for all Exasol version, by adding `[run all tests]` to the commit message
* [ ] Are the CLI usage examples up to date?
2 changes: 2 additions & 0 deletions doc/changes/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changes

* [1.5.0](changes_1.5.0.md)
* [1.4.0](changes_1.4.0.md)
* [1.3.0](changes_1.3.0.md)
* [1.2.0](changes_1.2.0.md)
Expand All @@ -24,6 +25,7 @@
---
hidden:
---
changes_1.5.0
changes_1.4.0
changes_1.3.0
changes_1.2.0
Expand Down
56 changes: 56 additions & 0 deletions doc/changes/changes_1.5.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Integration-Test-Docker-Environment 1.5.0, released 2023-03-21

## Summary

Added pytest plugin and fixed itde cli command

### Supported Exasol Versions

* **7.0**: up to 7.0.20, **except 7.0.5**
* **7.1**: up to 7.1.17

If you need further versions, please open an issue.

## Feature
- Added pytest plugin and fixtures

- Show settings related to itde plugin

```shell
pytest --help | grep "itde\|exasol\|bucketfs"
```
- Show fixtures related to itde

```shell
pytest --fixtures | grep pytest_itde -A 3
```

- Use itde to setup a test db etc. for a test

```python
# In order to use itde, just request it as fixture
# ATTENTION: initial startup may be up to ~1-2 minutes
# (Somtimes even longer if images must be fetched for the first time)
def test_smoke_test_plugin(itde):
db = itde.exasol_config,
bucketfs = itde.bucketfs_config,
itde_cfg = itde.itde_config,
ctrl_connection = itde.connection,
assert True
```

## Changes
- Fixed `itde` cli command and subcommands
- Provide all available subcommands in help
- Provide examples and basic doc string for commands
- Fix subcommand imports
- Example Usage:

```shell
$ itde spawn-test-environment --environment-name test \\
--database-port-forward 8888 --bucketfs-port-forward 6666 \\
--docker-db-image-version 7.1.9 --db-mem-size 4GB
```

## Internal
- Updated dependencies
17 changes: 17 additions & 0 deletions exasol_integration_test_docker_environment/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,21 @@

@click.group()
def cli():
"""
ITDE - Integration Test Docker Environment
Create and control a docker based exasol database test setup.
Examples:
Check the health of the execution environment:
$ itde health
Spawn a itde test environment:
$ itde spawn-test-environment --environment-name test \\
--database-port-forward 8888 --bucketfs-port-forward 6666 \\
--docker-db-image-version 7.1.9 --db-mem-size 4GB
"""
pass
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys

from exasol_integration_test_docker_environment.cli.cli import cli
from exasol_integration_test_docker_environment.lib import api
from exasol_integration_test_docker_environment.lib.api.api_errors import HealthProblem
from exasol_integration_test_docker_environment.lib import api


@cli.command()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,90 +1,139 @@
from typing import Optional, Tuple

import click

from exasol_integration_test_docker_environment.cli.cli import cli
from exasol_integration_test_docker_environment.cli.termination_handler import TerminationHandler
from exasol_integration_test_docker_environment.lib.api.common import add_options
from exasol_integration_test_docker_environment.cli.options.system_options import system_options, \
output_directory_option, tempory_base_directory_option
from exasol_integration_test_docker_environment.cli.options.test_environment_options import docker_db_options
from exasol_integration_test_docker_environment.cli.options.docker_repository_options import (
docker_repository_options,
)
from exasol_integration_test_docker_environment.cli.options.system_options import (
output_directory_option,
system_options,
tempory_base_directory_option,
)
from exasol_integration_test_docker_environment.cli.options.test_environment_options import (
docker_db_options,
)
from exasol_integration_test_docker_environment.cli.termination_handler import (
TerminationHandler,
)
from exasol_integration_test_docker_environment.lib import api
from exasol_integration_test_docker_environment.cli.options.docker_repository_options import docker_repository_options
from exasol_integration_test_docker_environment.lib.api.api_errors import ArgumentConstraintError
from exasol_integration_test_docker_environment.lib.api.api_errors import (
ArgumentConstraintError,
)
from exasol_integration_test_docker_environment.lib.api.common import add_options


@cli.command()
@click.option('--environment-name', type=str, required=True,
help="Name of the docker environment. This name gets used as suffix for the container db_container_<name> and test_container_<name>")
@click.option('--database-port-forward', type=int, default=None, show_default=True,
help="Host port to which the database port gets forwarded")
@click.option('--bucketfs-port-forward', type=int, default=None, show_default=True,
help="Host port to which the BucketFS port gets forwarded")
@click.option('--db-mem-size', type=str, default="2 GiB", show_default=True,
help="The main memory used by the database. Format <number> <unit>, e.g. 1 GiB. The minimum size is 1 GB, below that the database will not start.")
@click.option('--db-disk-size', type=str, default="2 GiB", show_default=True,
help="The disk size available for the database. Format <number> <unit>, e.g. 1 GiB. The minimum size is 100 MiB. However, the setup creates volume files with at least 2 GB larger size, because the database needs at least so much more disk.")
@click.option('--nameserver', type=str, default=[], multiple=True,
help="Add a nameserver to the list of DNS nameservers which the docker-db should use for resolving domain names. You can repeat this option to add further nameservers.")
@click.option('--docker-runtime', type=str, default=None, show_default=True,
help="The docker runtime used to start all containers")
@click.option(
"--environment-name",
type=str,
required=True,
help="Name of the docker environment. This name gets used as suffix for the container db_container_<name> and test_container_<name>",
)
@click.option(
"--database-port-forward",
type=int,
default=None,
show_default=True,
help="Host port to which the database port gets forwarded",
)
@click.option(
"--bucketfs-port-forward",
type=int,
default=None,
show_default=True,
help="Host port to which the BucketFS port gets forwarded",
)
@click.option(
"--db-mem-size",
type=str,
default="2 GiB",
show_default=True,
help="The main memory used by the database. Format <number> <unit>, e.g. 1 GiB. The minimum size is 1 GB, below that the database will not start.",
)
@click.option(
"--db-disk-size",
type=str,
default="2 GiB",
show_default=True,
help="The disk size available for the database. Format <number> <unit>, e.g. 1 GiB. The minimum size is 100 MiB. However, the setup creates volume files with at least 2 GB larger size, because the database needs at least so much more disk.",
)
@click.option(
"--nameserver",
type=str,
default=[],
multiple=True,
help="Add a nameserver to the list of DNS nameservers which the docker-db should use for resolving domain names. You can repeat this option to add further nameservers.",
)
@click.option(
"--docker-runtime",
type=str,
default=None,
show_default=True,
help="The docker runtime used to start all containers",
)
@add_options(docker_db_options)
@add_options(docker_repository_options)
@add_options([output_directory_option])
@add_options([tempory_base_directory_option])
@add_options(system_options)
def spawn_test_environment(
environment_name: str,
database_port_forward: Optional[int],
bucketfs_port_forward: Optional[int],
db_mem_size: str,
db_disk_size: str,
nameserver: Tuple[str, ...],
docker_runtime: Optional[str],
docker_db_image_version: str,
docker_db_image_name: str,
create_certificates: bool,
additional_db_parameter: Tuple[str, ...],
source_docker_repository_name: str,
source_docker_tag_prefix: str,
source_docker_username: Optional[str],
source_docker_password: Optional[str],
target_docker_repository_name: str,
target_docker_tag_prefix: str,
target_docker_username: Optional[str],
target_docker_password: Optional[str],
output_directory: str,
temporary_base_directory: str,
workers: int,
task_dependencies_dot_file: Optional[str]):
environment_name: str,
database_port_forward: Optional[int],
bucketfs_port_forward: Optional[int],
db_mem_size: str,
db_disk_size: str,
nameserver: Tuple[str, ...],
docker_runtime: Optional[str],
docker_db_image_version: str,
docker_db_image_name: str,
create_certificates: bool,
additional_db_parameter: Tuple[str, ...],
source_docker_repository_name: str,
source_docker_tag_prefix: str,
source_docker_username: Optional[str],
source_docker_password: Optional[str],
target_docker_repository_name: str,
target_docker_tag_prefix: str,
target_docker_username: Optional[str],
target_docker_password: Optional[str],
output_directory: str,
temporary_base_directory: str,
workers: int,
task_dependencies_dot_file: Optional[str],
):
"""
This command spawn a test environment with a docker-db container and a connected test-container.
The test-container is reachable by the database for output redirects of UDFs.
"""
with TerminationHandler():
try:
api.spawn_test_environment(environment_name,
database_port_forward,
bucketfs_port_forward,
db_mem_size,
db_disk_size,
nameserver,
docker_runtime,
docker_db_image_version,
docker_db_image_name,
create_certificates,
additional_db_parameter,
source_docker_repository_name,
source_docker_tag_prefix,
source_docker_username,
source_docker_password,
target_docker_repository_name,
target_docker_tag_prefix,
target_docker_username,
target_docker_password,
output_directory,
temporary_base_directory,
workers,
task_dependencies_dot_file)
api.spawn_test_environment(
environment_name,
database_port_forward,
bucketfs_port_forward,
db_mem_size,
db_disk_size,
nameserver,
docker_runtime,
docker_db_image_version,
docker_db_image_name,
create_certificates,
additional_db_parameter,
source_docker_repository_name,
source_docker_tag_prefix,
source_docker_username,
source_docker_password,
target_docker_repository_name,
target_docker_tag_prefix,
target_docker_username,
target_docker_password,
output_directory,
temporary_base_directory,
workers,
task_dependencies_dot_file,
)
except ArgumentConstraintError as e:
handle_wrong_argument_error(*e.args)

Expand Down
10 changes: 5 additions & 5 deletions exasol_integration_test_docker_environment/lib/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

from .health import health
from .build_test_container import build_test_container
from .push_test_container import push_test_container
from .spawn_test_environment import spawn_test_environment
from .spawn_test_environment_with_test_container import spawn_test_environment_with_test_container
from exasol_integration_test_docker_environment.lib.api.health import health
from exasol_integration_test_docker_environment.lib.api.build_test_container import build_test_container
from exasol_integration_test_docker_environment.lib.api.push_test_container import push_test_container
from exasol_integration_test_docker_environment.lib.api.spawn_test_environment import spawn_test_environment
from exasol_integration_test_docker_environment.lib.api.spawn_test_environment_with_test_container import spawn_test_environment_with_test_container
8 changes: 6 additions & 2 deletions exasol_integration_test_docker_environment/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#! /usr/bin/env python3
#
from exasol_integration_test_docker_environment.cli.cli import cli
import exasol_integration_test_docker_environment.cli.commands


def main():
# required so the cli will print the available subcommands
from exasol_integration_test_docker_environment.cli.commands import (
health,
spawn_test_environment
)
cli()


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading

0 comments on commit f9698db

Please sign in to comment.