Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#56 Added more ITDE options #57

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pytest-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,21 @@ 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(...)](https://github.com/exasol/integration-test-docker-environment/blob/92cc67b8f9ab78c52106c1c4ba19fe64811bcb2c/exasol_integration_test_docker_environment/lib/api/spawn_test_environment.py#L35)
function. The parameter values can be provided in the CLI options. Currently, it is possible to set values of the following parameters:
- db-mem-size
- db-disk-size
- nameserver
- db-version

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

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

These options are ignored if the "onprem" backend is not selected.
2 changes: 2 additions & 0 deletions pytest-backend/doc/changes/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [0.1.0](changes_0.1.0.md)
* [0.2.0](changes_0.2.0.md)
* [0.2.1](changes_0.2.1.md)
* [0.3.0](changes_0.3.0.md)

<!--- This MyST Parser Sphinx directive is necessary to keep Sphinx happy. We need list here all release letters again, because release droid and other scripts assume Markdown --->
```{toctree}
Expand All @@ -14,5 +15,6 @@ unreleased
changes_0.1.0
changes_0.2.0
changes_0.2.1
changes_0.3.0

```
9 changes: 9 additions & 0 deletions pytest-backend/doc/changes/changes_0.3.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 0.3.0 - 2024-09-18

## Summary

🚀 Extended list of enabled ITDE parameters.

## Feature

* #56: Added options to set parameters of the ITDE spawn_test_environment() functions.
16 changes: 9 additions & 7 deletions pytest-backend/exasol/pytest_backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def start_itde(itde_config,
database_port_forward=exasol_config.port,
bucketfs_port_forward=bucketfs_url.port,
ssh_port_forward=ssh_config.port,
db_mem_size="4GB",
db_mem_size=itde_config.db_mem_size,
db_disk_size=itde_config.db_disk_size,
nameserver=tuple(itde_config.nameserver),
docker_db_image_version=itde_config.db_version,
)
yield env_info
Expand Down Expand Up @@ -161,18 +163,18 @@ def _env(var: str) -> str:


@pytest.fixture(scope="session")
def saas_host() -> str:
return _env("SAAS_HOST")
def saas_host(use_saas) -> str:
return _env("SAAS_HOST") if use_saas else ""


@pytest.fixture(scope="session")
def saas_pat() -> str:
return _env("SAAS_PAT")
def saas_pat(use_saas) -> str:
return _env("SAAS_PAT") if use_saas else ""


@pytest.fixture(scope="session")
def saas_account_id() -> str:
return _env("SAAS_ACCOUNT_ID")
def saas_account_id(use_saas) -> str:
return _env("SAAS_ACCOUNT_ID") if use_saas else ""


@pytest.fixture(scope="session")
Expand Down
33 changes: 32 additions & 1 deletion pytest-backend/exasol/pytest_backend/itde.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class ItdeConfig:
"""Itde configuration settings"""

db_version: str
db_mem_size: str
db_disk_size: str
nameserver: list


_ONPREM_DB_OPTIONS = config.OptionGroup(
Expand Down Expand Up @@ -105,16 +108,42 @@ class ItdeConfig:
),
)

DEFAULT_ITDE_DB_VERSION = "8.18.1"
DEFAULT_ITDE_DB_MEM_SIZE = "2 GiB"
DEFAULT_ITDE_DB_DISK_SIZE = "2 GiB"

_ITDE_OPTIONS = config.OptionGroup(
prefix="itde",
options=(
{
"name": "db_version",
"type": str,
"default": "8.18.1",
"default": DEFAULT_ITDE_DB_VERSION,
"help_text": "DB version to start, if value is 'external' an existing instance will be used",
},
{
"name": "db_mem_size",
"type": str,
"default": DEFAULT_ITDE_DB_MEM_SIZE,
"help_text": ("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."),
},
{
"name": "db_disk_size",
"type": str,
"default": DEFAULT_ITDE_DB_DISK_SIZE,
"help_text": ("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."),
},
{
"name": "nameserver",
"type": str,
"default": [],
"help_text": ("A nameserver to be added to the list of DNS nameservers which the docker-db "
"should use for resolving domain names. This option can be repeated "
"multiple times.")
}
),
)

Expand All @@ -126,8 +155,10 @@ def _add_option_group(parser, group):
for option in group.options:
parser_group.addoption(
option.cli,
default=option.default,
type=option.type,
help=option.help,
action='append' if isinstance(option.default, list) else 'store'
)


Expand Down
4 changes: 2 additions & 2 deletions pytest-backend/exasol/pytest_backend/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# Do not edit this file manually!
# If you need to change the version, do so in the project.toml, e.g. by using `poetry version X.Y.Z`.
MAJOR = 0
MINOR = 2
PATCH = 1
MINOR = 3
PATCH = 0
VERSION = f"{MAJOR}.{MINOR}.{PATCH}"
Loading
Loading