-
Notifications
You must be signed in to change notification settings - Fork 83
feat(integration-tests): Spin up and tear down the clp-text and clp-json packages.
#1437
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
Open
quinntaylormitchell
wants to merge
59
commits into
y-scope:main
Choose a base branch
from
quinntaylormitchell:testing-start-stop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
59 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 44ee20e
Merge branch 'main' into feature branch
quinntaylormitchell bbe0575
Expand to clp-text and clp-json; store JSON config pairs in temp conf…
quinntaylormitchell 5cd47f8
Merge branch 'main' into feature branch
quinntaylormitchell c5375eb
Include and employ clp_py_utils.clp_config; refrain from using the us…
quinntaylormitchell 2be837f
Lint.
quinntaylormitchell bf14b5e
Refactor; move all utility functions to utils files as appropriate.
quinntaylormitchell 27b7f5b
Add comments.
quinntaylormitchell e041f0e
Streamline logger calls.
quinntaylormitchell 75672fc
Deduplicate fixture code.
quinntaylormitchell 0822a79
Merge branch 'main' into feature branch
quinntaylormitchell 2df9515
Change method of clp_config import; temporary, will change again once…
quinntaylormitchell 63f3ae4
Generalize code so that it's better equipped to handle future CLP_MOD…
quinntaylormitchell 0011447
Merge branch 'main' into feature branch
quinntaylormitchell 0ff9465
Combine PackageConfig, PackageModeConfig, and PackageInstanceConfig i…
quinntaylormitchell cdcfaee
Employ a 'CLPConfig'-centric approach rather than 'dict'-centric.
quinntaylormitchell 53e7343
Store list of required components for each mode
quinntaylormitchell 796ffe3
Generalize the method by which the mode of operation is determined.
quinntaylormitchell bae12de
Move all mode-related utilities to their own file.
quinntaylormitchell 9c9ef74
Minor error.
quinntaylormitchell 0f3dcd5
Move load_yaml_to_dict to general utilities file.
quinntaylormitchell f9865a8
Add taskfile tasks for package tests.
quinntaylormitchell 865e9ed
Address rabbit comments.
quinntaylormitchell 09d5200
Add mariadb_config install for linting purposes (will be unecessary a…
quinntaylormitchell 5fffc32
Lint YAML.
quinntaylormitchell 571f313
Merge branch 'main' into feature branch
quinntaylormitchell e348be0
Adapt code after #1549 merge.
quinntaylormitchell 30f186f
Merge branch 'main' into feature branch
quinntaylormitchell e5da7e9
Merge branch 'main' into feature branch
quinntaylormitchell 292ec70
Merge branch 'main' into feature branch
quinntaylormitchell 0c4cfa4
Remove 'python -m'.
quinntaylormitchell bee738a
Address Bill-hbrhbr comments.
quinntaylormitchell 49eaf97
Brush up docstrings.
quinntaylormitchell e3c4a3b
Merge branch 'main' into feature branch
quinntaylormitchell 4cd92e6
Adapt to PascalCase ClpConfig.
quinntaylormitchell 87c4809
Merge branch 'main' into feature branch
quinntaylormitchell baddcfe
Address Bill's comments; add helper function that returns a list of r…
quinntaylormitchell 7cf597d
Rabbit.
quinntaylormitchell 8372a9f
Refactor PackageConfig and PackageInstance classes into three separat…
quinntaylormitchell b92ee22
Apply suggestions from code review
Bill-hbrhbr f950df0
Merge branch 'main' into testing-start-stop
Bill-hbrhbr aac6fcb
lint fix and variable substitution
Bill-hbrhbr 9f995b9
Update according to coderabbit AI suggestion.
Bill-hbrhbr 03cb974
Merge branch 'main' into testing-start-stop
Bill-hbrhbr 0e0567a
Apply Bill's comments.
quinntaylormitchell d44ab95
Merge branch 'main' into feature branch
quinntaylormitchell 324ade4
Add ClpConfig data member to PackageConfig class; use 'fixt_' at begi…
quinntaylormitchell e7e79e1
Merge branch 'main' into feature branch
quinntaylormitchell 7116cfc
Post-merge main.
quinntaylormitchell 3471168
Remove return from _write_temp_config_file.
quinntaylormitchell a324248
Remove unecessary logging statements.
quinntaylormitchell 6caf53a
Move content to other PRs.
quinntaylormitchell f3e533d
Add task for package integration tests.
quinntaylormitchell a71bcb0
Revert "Move content to other PRs."
quinntaylormitchell b5cf248
Revert "Revert "Move content to other PRs.""
quinntaylormitchell b496025
Revert "Add task for package integration tests."
quinntaylormitchell 86ab692
Address Bill's comments.
quinntaylormitchell ce822d8
Address missed comments.
quinntaylormitchell 8224985
Merge branch 'main' into feature branch
quinntaylormitchell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| """Make the fixtures defined in `tests/fixtures/` globally available without imports.""" | ||
| """Global pytest setup.""" | ||
|
|
||
| # Make the fixtures defined in `tests/fixtures/` globally available without imports. | ||
| pytest_plugins = [ | ||
| "tests.fixtures.integration_test_logs", | ||
| "tests.fixtures.path_configs", | ||
| "tests.fixtures.package_instance", | ||
| "tests.fixtures.package_config", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| """Fixtures that create and remove temporary config files for CLP packages.""" | ||
quinntaylormitchell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| from collections.abc import Iterator | ||
|
|
||
| import pytest | ||
|
|
||
| from tests.utils.clp_mode_utils import get_clp_config_from_mode | ||
| from tests.utils.config import PackageConfig, PackagePathConfig | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def fixt_package_config( | ||
| request: pytest.FixtureRequest, | ||
| fixt_package_path_config: PackagePathConfig, | ||
| ) -> Iterator[PackageConfig]: | ||
| """ | ||
| Creates and maintains a PackageConfig object for a specific CLP mode. | ||
|
|
||
| :param request: | ||
| :return: An iterator that yields the PackageConfig object for the specified mode. | ||
| """ | ||
| mode_name: str = request.param | ||
|
|
||
| # Get the ClpConfig for this mode. | ||
| clp_config_obj = get_clp_config_from_mode(mode_name) | ||
|
|
||
| # Construct PackageConfig. | ||
| package_config = PackageConfig( | ||
| path_config=fixt_package_path_config, | ||
| mode_name=mode_name, | ||
| clp_config=clp_config_obj, | ||
| ) | ||
|
|
||
| try: | ||
| yield package_config | ||
| finally: | ||
| package_config.temp_config_file_path.unlink(missing_ok=True) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| """Fixtures that start and stop CLP package instances for integration tests.""" | ||
quinntaylormitchell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| from collections.abc import Iterator | ||
|
|
||
| import pytest | ||
|
|
||
| from tests.utils.config import ( | ||
| PackageConfig, | ||
| PackageInstance, | ||
| ) | ||
| from tests.utils.package_utils import ( | ||
| start_clp_package, | ||
| stop_clp_package, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def fixt_package_instance(fixt_package_config: PackageConfig) -> Iterator[PackageInstance]: | ||
| """ | ||
| Starts a CLP package instance for the given configuration and stops it during teardown. | ||
| :param fixt_package_config: | ||
| :return: Iterator that yields the running package instance. | ||
| """ | ||
| mode_name = fixt_package_config.mode_name | ||
|
|
||
| try: | ||
| start_clp_package(fixt_package_config) | ||
| instance = PackageInstance(package_config=fixt_package_config) | ||
| yield instance | ||
| except RuntimeError: | ||
| pytest.fail(f"Failed to start the {mode_name} package.") | ||
| finally: | ||
| stop_clp_package(fixt_package_config) | ||
quinntaylormitchell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| """Integration tests verifying that the CLP package can be started and stopped.""" | ||
|
|
||
| import logging | ||
|
|
||
| import pytest | ||
|
|
||
| from tests.utils.clp_mode_utils import CLP_MODE_CONFIGS | ||
| from tests.utils.config import PackageInstance | ||
|
|
||
| TEST_MODES = CLP_MODE_CONFIGS.keys() | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| @pytest.mark.package | ||
| @pytest.mark.parametrize("fixt_package_config", TEST_MODES, indirect=True) | ||
| def test_clp_package(fixt_package_instance: PackageInstance) -> None: | ||
| """ | ||
| Validate that the CLP package starts up successfully for the selected mode of operation. | ||
| :param fixt_package_instance: | ||
| """ | ||
| # TODO: write code that properly validates that the package is running. This is a placeholder. | ||
| mode_name = fixt_package_instance.package_config.mode_name | ||
| message = f"The '{mode_name}' package has been spun up successfully." | ||
| logger.info(message) | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| """Provides utilities related to the user-level configurations of CLP's operating modes.""" | ||
|
|
||
| from collections.abc import Callable | ||
|
|
||
| from clp_py_utils.clp_config import ( | ||
| ClpConfig, | ||
| Package, | ||
| QueryEngine, | ||
| StorageEngine, | ||
| ) | ||
|
|
||
| CLP_MODE_CONFIGS: dict[str, Callable[[], ClpConfig]] = { | ||
| "clp-text": lambda: ClpConfig( | ||
| package=Package( | ||
| storage_engine=StorageEngine.CLP, | ||
| query_engine=QueryEngine.CLP, | ||
| ), | ||
| ), | ||
| "clp-json": lambda: ClpConfig( | ||
| package=Package( | ||
| storage_engine=StorageEngine.CLP_S, | ||
| query_engine=QueryEngine.CLP_S, | ||
| ), | ||
| ), | ||
| } | ||
|
|
||
|
|
||
| def get_clp_config_from_mode(mode_name: str) -> ClpConfig: | ||
| """ | ||
| Return a ClpConfig object for the given mode name. | ||
|
|
||
| :param mode_name: | ||
| :return: ClpConfig object corresponding to the mode. | ||
| :raise ValueError: If the mode is not supported. | ||
| """ | ||
| try: | ||
| config = CLP_MODE_CONFIGS[mode_name] | ||
| except KeyError as err: | ||
| err_msg = f"Unsupported mode: {mode_name}" | ||
| raise ValueError(err_msg) from err | ||
| return config() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| """Provides utility functions related to the CLP package used across `integration-tests`.""" | ||
|
|
||
| import subprocess | ||
|
|
||
| from tests.utils.config import ( | ||
| PackageConfig, | ||
| ) | ||
|
|
||
|
|
||
| def start_clp_package(package_config: PackageConfig) -> None: | ||
| """ | ||
| Starts an instance of the CLP package. | ||
| :param package_config: | ||
| :raise RuntimeError: If the package fails to start. | ||
| """ | ||
| path_config = package_config.path_config | ||
| start_script_path = path_config.start_script_path | ||
| temp_config_file_path = package_config.temp_config_file_path | ||
| try: | ||
| # fmt: off | ||
| start_cmd = [ | ||
| str(start_script_path), | ||
| "--config", str(temp_config_file_path), | ||
| ] | ||
| # fmt: on | ||
| subprocess.run(start_cmd, check=True) | ||
| except Exception as err: | ||
| err_msg = f"Failed to start an instance of the {package_config.mode_name} package." | ||
| raise RuntimeError(err_msg) from err | ||
|
|
||
|
|
||
| def stop_clp_package(package_config: PackageConfig) -> None: | ||
| """ | ||
| Stops the running instance of the CLP package. | ||
| :param package_config: | ||
| :raise RuntimeError: If the package fails to stop. | ||
| """ | ||
| path_config = package_config.path_config | ||
| stop_script_path = path_config.stop_script_path | ||
| temp_config_file_path = package_config.temp_config_file_path | ||
| try: | ||
| # fmt: off | ||
| stop_cmd = [ | ||
| str(stop_script_path), | ||
| "--config", str(temp_config_file_path), | ||
| ] | ||
| # fmt: on | ||
| subprocess.run(stop_cmd, check=True) | ||
| except Exception as err: | ||
| err_msg = ( | ||
| f"Failed to stop the running {package_config.mode_name} package instance. Manual" | ||
| " container cleanup may be required." | ||
| ) | ||
| raise RuntimeError(err_msg) from err | ||
quinntaylormitchell marked this conversation as resolved.
Show resolved
Hide resolved
quinntaylormitchell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.