-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathnoxconfig.py
73 lines (55 loc) · 1.8 KB
/
noxconfig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from typing import Iterable
from exasol.toolbox.nox.plugin import hookimpl
from nox import Session
DEFAULT_PORT = 8563
DEFAULT_DB_VERSION = "8.31.0"
CONTAINER_SUFFIX = "test"
CONTAINER_NAME = f"db_container_{CONTAINER_SUFFIX}"
def start_test_db(
session: Session, port: int = DEFAULT_PORT, db_version: str = DEFAULT_DB_VERSION
) -> None:
# For Docker in a VM setup, refer to the ``doc/user_guide/developer_guide.rst``
session.run(
"itde",
"spawn-test-environment",
"--create-certificates",
"--environment-name",
CONTAINER_SUFFIX,
"--database-port-forward",
f"{port}",
"--bucketfs-port-forward",
"2580",
"--docker-db-image-version",
db_version,
"--db-mem-size",
"4GB",
external=True,
)
def stop_test_db(session: Session) -> None:
session.run("docker", "kill", CONTAINER_NAME, external=True)
class StartDB:
@hookimpl
def pre_integration_tests_hook(self, session, config, context):
port = context.get("port", DEFAULT_PORT)
db_version = context.get("db_version", DEFAULT_DB_VERSION)
start_test_db(session=session, port=port, db_version=db_version)
class StopDB:
@hookimpl
def post_integration_tests_hook(self, session, config, context):
stop_test_db(session=session)
@dataclass(frozen=True)
class Config:
root: Path = Path(__file__).parent
doc: Path = Path(__file__).parent / "doc"
version_file: Path = Path(__file__).parent / "pyexasol" / "version.py"
path_filters: Iterable[str] = (
"dist",
".eggs",
"venv",
)
plugins = [StartDB, StopDB]
exasol_versions = [DEFAULT_DB_VERSION]
PROJECT_CONFIG = Config()