Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8e75e15
Test a generic clp package start up and spin down (default: clp-text).
quinntaylormitchell Oct 17, 2025
44ee20e
Merge branch 'main' into feature branch
quinntaylormitchell Oct 23, 2025
bbe0575
Expand to clp-text and clp-json; store JSON config pairs in temp conf…
quinntaylormitchell Oct 24, 2025
5cd47f8
Merge branch 'main' into feature branch
quinntaylormitchell Oct 30, 2025
c5375eb
Include and employ clp_py_utils.clp_config; refrain from using the us…
quinntaylormitchell Nov 1, 2025
2be837f
Lint.
quinntaylormitchell Nov 1, 2025
bf14b5e
Refactor; move all utility functions to utils files as appropriate.
quinntaylormitchell Nov 2, 2025
27b7f5b
Add comments.
quinntaylormitchell Nov 2, 2025
e041f0e
Streamline logger calls.
quinntaylormitchell Nov 2, 2025
75672fc
Deduplicate fixture code.
quinntaylormitchell Nov 2, 2025
0822a79
Merge branch 'main' into feature branch
quinntaylormitchell Nov 5, 2025
2df9515
Change method of clp_config import; temporary, will change again once…
quinntaylormitchell Nov 5, 2025
63f3ae4
Generalize code so that it's better equipped to handle future CLP_MOD…
quinntaylormitchell Nov 5, 2025
0011447
Merge branch 'main' into feature branch
quinntaylormitchell Nov 6, 2025
0ff9465
Combine PackageConfig, PackageModeConfig, and PackageInstanceConfig i…
quinntaylormitchell Nov 6, 2025
cdcfaee
Employ a 'CLPConfig'-centric approach rather than 'dict'-centric.
quinntaylormitchell Nov 6, 2025
53e7343
Store list of required components for each mode
quinntaylormitchell Nov 6, 2025
796ffe3
Generalize the method by which the mode of operation is determined.
quinntaylormitchell Nov 6, 2025
bae12de
Move all mode-related utilities to their own file.
quinntaylormitchell Nov 6, 2025
9c9ef74
Minor error.
quinntaylormitchell Nov 6, 2025
0f3dcd5
Move load_yaml_to_dict to general utilities file.
quinntaylormitchell Nov 6, 2025
f9865a8
Add taskfile tasks for package tests.
quinntaylormitchell Nov 6, 2025
865e9ed
Address rabbit comments.
quinntaylormitchell Nov 7, 2025
09d5200
Add mariadb_config install for linting purposes (will be unecessary a…
quinntaylormitchell Nov 7, 2025
5fffc32
Lint YAML.
quinntaylormitchell Nov 7, 2025
571f313
Merge branch 'main' into feature branch
quinntaylormitchell Nov 7, 2025
e348be0
Adapt code after #1549 merge.
quinntaylormitchell Nov 7, 2025
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
3 changes: 3 additions & 0 deletions integration-tests/.pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ addopts =
--capture=no
--code-highlight=yes
--color=yes
-rA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious. Are there tests that will result in status other than the default pass/fail?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so; I just added this so that there is a test summary that shows up when all the tests that the user requested have finished running. is there a better way to do that?

--strict-config
--strict-markers
--verbose
env =
D:CLP_BUILD_DIR=../build
D:CLP_CORE_BINS_DIR=../build/core
D:CLP_PACKAGE_DIR=../build/clp-package
D:CLP_LOG_DIR=../build/clp-package/var/log
log_cli = True
log_cli_date_format = %Y-%m-%d %H:%M:%S,%f
log_cli_format = %(name)s %(asctime)s [%(levelname)s] %(message)s
Expand All @@ -18,3 +20,4 @@ markers =
clp: mark tests that use the CLP storage engine
clp_s: mark tests that use the CLP-S storage engine
core: mark tests that test the CLP core binaries
package: mark tests that test a CLP package
2 changes: 1 addition & 1 deletion integration-tests/.python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9
3.10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a specific reason why we are moving to 3.10 in this PR? I know all CLP python components are moving towards 3.10. I think if this PR doesn't require it, we can let others bump the py version

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I tried to run the tests the very first time, and the tests tried to start the package, I received some error message saying

ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'

and I figured out that was because the package had been built/compiled for python 3.10, and the tests were using 3.9. changing to 3.10 fixed the issue.

7 changes: 6 additions & 1 deletion integration-tests/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ readme = "README.md"
authors = [
{ name = "YScope Inc.", email = "[email protected]" }
]
requires-python = ">=3.9"
requires-python = ">=3.10"

[project.scripts]
integration-tests = "integration_tests:main"
Expand All @@ -21,6 +21,8 @@ dev = [
"ruff>=0.11.12",
"pytest>=8.4.1",
"pytest-env>=1.1.5",
"PyYAML>=6.0",
"types-PyYAML>=6.0.12.20240808",
]

[tool.mypy]
Expand All @@ -46,8 +48,10 @@ ignore = [
"D400", # First line of docstrings may not end in period
"D401", # Docstrings should be written in present tense (not imperative)
"D415", # First line of docstrings may not end in a period, question mark, or exclamation point
"EM102", # Exception must not use an f-string literal, assign to variable first
"FBT", # Allow bool positional parameters since other value positions are allowed
"FIX002", # Allow todo statements
"G004", # Logging statement uses f-string
"PERF401", # Allow for loops when creating lists
"PERF403", # Allow for loops when creating dicts
"S311", # Allow usage of `random` package
Expand All @@ -56,6 +60,7 @@ ignore = [
"SIM300", # Skip Yoda-condition format fixes
"TD002", # Author unnecessary for todo statement
"TD003", # Issue link unnecessary for todo statement
"TRY003", # Avoid specifying long messages outside the exception class
"UP015", # Explicit open modes are helpful
]
isort.order-by-type = false
Expand Down
1 change: 1 addition & 0 deletions integration-tests/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
pytest_plugins = [
"tests.fixtures.integration_test_config",
"tests.fixtures.integration_test_logs",
"tests.fixtures.integration_test_packages",
]
84 changes: 84 additions & 0 deletions integration-tests/tests/fixtures/integration_test_packages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""Define test packages fixtures."""

import logging
import subprocess
from collections.abc import Iterator
from typing import Literal

import pytest

from tests.utils.config import (
PackageConfig,
PackageRun,
)

logger = logging.getLogger(__name__)


@pytest.fixture(scope="session")
def clp_package(
package_config: PackageConfig,
) -> Iterator[PackageRun]:
"""Fixture that starts up an instance of clp, and stops the package after yield."""
mode: Literal["clp-text", "clp-json"] = "clp-text"
instance = _start_clp_package(package_config, mode)

yield instance
_stop_clp_package(instance)


def _start_clp_package(
package_config: PackageConfig,
mode: Literal["clp-text", "clp-json"],
) -> PackageRun:
"""Starts up an instance of clp."""
logger.info(f"Starting up the {mode} package...")

start_script_path = package_config.clp_package_dir / "sbin" / "start-clp.sh"

try:
# fmt: off
start_cmd = [
start_script_path
]
# fmt: on
subprocess.run(start_cmd, check=True)
except Exception as e:
err_msg = f"Failed to start an instance of the {mode} package."
raise RuntimeError(err_msg) from e

package_run = PackageRun(
package_config=package_config,
mode=mode,
)

logger.info(
f"An instance of the {package_run.mode} package was started successfully."
f" Its instance ID is '{package_run.clp_instance_id}'"
)

return package_run


def _stop_clp_package(
instance: PackageRun,
) -> None:
"""Stops an instance of clp."""
mode = instance.mode
instance_id = instance.clp_instance_id
logger.info(f"Now stopping the {mode} package with instance ID '{instance_id}'...")

stop_script_path = instance.package_config.clp_package_dir / "sbin" / "stop-clp.sh"

try:
# fmt: off
stop_cmd = [
stop_script_path
]
# fmt: on
subprocess.run(stop_cmd, check=True)
except Exception as e:
err_msg = f"Failed to stop an instance of the {mode} package."
raise RuntimeError(err_msg) from e

logger.info(f"The {mode} package with instance ID '{instance_id}' was stopped successfully.")
103 changes: 103 additions & 0 deletions integration-tests/tests/test_package_start.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
"""Integration tests verifying that the CLP package can be started and stopped."""

import logging
import shutil
import subprocess

import pytest

from tests.utils.config import (
PackageRun,
)

pytestmark = pytest.mark.package


package_configurations = pytest.mark.parametrize(
"test_package_fixture",
[
"clp_package",
],
)

logger = logging.getLogger(__name__)


@pytest.mark.package
@package_configurations
def test_clp_package(
request: pytest.FixtureRequest,
test_package_fixture: str,
) -> None:
"""
Validate that all of the components of the clp package start up successfully. The package is
started up in whatever configuration is currently described in clp-config.yml; default is
clp-text.
:param request:
:param test_package_fixture:
"""
package_run: PackageRun = request.getfixturevalue(test_package_fixture)

assert _is_package_running(package_run)


def _is_package_running(package_run: PackageRun) -> bool:
"""Checks that the package specified in package_run is running correctly."""
mode = package_run.mode
instance_id = package_run.clp_instance_id

component_basenames = [
"clp-database",
"clp-queue",
"clp-redis",
"clp-results_cache",
"clp-compression_scheduler",
"clp-query_scheduler",
"clp-compression_worker",
"clp-query_worker",
"clp-reducer",
"clp-webui",
"clp-garbage_collector",
]

logger.info(
"Checking if all components of %s package with instance ID '%s' are running properly.",
mode,
instance_id,
)

docker_bin = shutil.which("docker")
if docker_bin is None:
error_msg = "docker not found in PATH"
raise RuntimeError(error_msg)

for component in component_basenames:
name = f"{component}-{instance_id}"

proc = subprocess.run(
[docker_bin, "inspect", "-f", "{{.State.Running}}", name],
capture_output=True,
text=True,
check=False,
)

if proc.returncode != 0:
err = (proc.stderr or proc.stdout or "").strip()
if "No such object" in err:
logger.error("Component container not found: %s", name)
return False
error_msg = f"Error inspecting container {name}: {err}"
raise RuntimeError(error_msg)

status = (proc.stdout or "").strip().lower()
if status != "true":
logger.error("Component container not running: %s (status=%s)", name, status)
return False

logger.info(
"All components of the %s package with instance ID '%s' are running properly.",
mode,
instance_id,
)
return True
Loading
Loading