{"id":47795039,"url":"https://github.com/eclipse-score/testing_tools","last_synced_at":"2026-04-03T16:13:55.720Z","repository":{"id":318479758,"uuid":"1000473172","full_name":"eclipse-score/testing_tools","owner":"eclipse-score","description":"Repository for testing utilities","archived":false,"fork":false,"pushed_at":"2026-02-19T09:50:36.000Z","size":127,"stargazers_count":1,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-19T14:30:22.803Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eclipse-score.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-11T20:56:12.000Z","updated_at":"2026-02-19T09:48:15.000Z","dependencies_parsed_at":"2025-10-07T13:31:24.341Z","dependency_job_id":"05bfca86-45c4-4b52-be93-72a7ce659a0e","html_url":"https://github.com/eclipse-score/testing_tools","commit_stats":null,"previous_names":["eclipse-score/testing_tools"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/eclipse-score/testing_tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-score%2Ftesting_tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-score%2Ftesting_tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-score%2Ftesting_tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-score%2Ftesting_tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eclipse-score","download_url":"https://codeload.github.com/eclipse-score/testing_tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-score%2Ftesting_tools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31362716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T15:19:21.178Z","status":"ssl_error","status_checked_at":"2026-04-03T15:19:20.670Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-03T16:13:54.918Z","updated_at":"2026-04-03T16:13:55.708Z","avatar_url":"https://github.com/eclipse-score.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `testing-utils`\n\nTest framework tools and helpers for performance stack project.\n\n## Overview\n\nThis repository provided utilities to assist with test automation, log handling, and result parsing.\nIt is designed to be a set of helper libraries for test frameworks or custom test runners.\n\n\n## Logging\n\n`testing-utils` uses Python's standard logging module. All modules log via a package logger, which you can configure in your application.\nBy default, the logger uses a `NullHandler`. To see logs, configure logging in your main script:\n\n```python\nimport logging\nlogging.basicConfig(level=logging.INFO)\n```\n\nor provide logging config in pytest configuration:\n\n```ini\nlog_cli = true\nlog_cli_level = DEBUG\nlog_cli_format = %(asctime)s %(levelname)s %(message)s\nlog_cli_date_format = %Y-%m-%d %H:%M:%S\n```\n\nYou can also attach handlers or change the log level for the `testing_utils` logger specifically:\n\n```python\nimport logging\nlogger = logging.getLogger(\"testing_utils\")\nlogger.setLevel(logging.DEBUG)\n```\n\n## Features\n\n- **Test scenarios libraries**: Rust and C++ libraries for implementing test scenarios.\n- **Build tools**: Utilities for interacting with Bazel and Cargo.\n- **Log container**: A container for storing and querying logs.\n- **`ResultEntry`** and subclasses: Structured representation of test log entries.\n- **Scenario**: Utilities for defining and running test scenarios.\n\n## Installation\n\n`virtualenv` usage is recommended:\n\n```bash\npython -m venv .venv\nsource .venv/bin/activate\n```\n\nInstall `testing-utils`:\n\n```bash\npip install . --config-settings editable_mode=strict\n```\n\nInstall `testing-utils` in editable mode with additional dev dependencies:\n\n```bash\npip install -e .[dev] --config-settings editable_mode=strict\n```\n\n\u003e `--config-settings editable_mode=strict` is required by Pylance plugin in VS Code.\n\u003e Package will work without it, but autocompletion won't work properly.\n\n## Usage\n\n### Test scenarios utilities\n\nLibraries should be included as a dependency in `Cargo.toml` (Rust) or `BUILD` (C++).\n\nMain components:\n\n- `TestContext` - responsible for listing and running scenarios.\n- `Scenario` and `ScenarioGroup` - base classes for defining scenarios and groups.\n- `run_cli_app` - runs CLI application based on provided arguments and test context.\n\n### Build tools\n\n#### Get Cargo metadata\n\nCargo metadata is obtained using \"cargo metadata\" command.\nCWD must be set to Cargo project.\n\n```python\nfrom typing import Any\nfrom testing_utils import cargo_metadata\n\nmetadata: dict[str, Any] = cargo_metadata()\n```\n\n#### Find target path\n\nFind path to executable based on provided target name.\n\n```python\nfrom pathlib import Path\nfrom testing_utils import BazelTools\n\ntarget_name = \"target_name\"\nbuild_tools = BazelTools()\ntarget_path: Path = build_tools.find_target_path(target_name)\n...\n```\n\n#### Select executable\n\nThis feature is to ensure flexible usage in pytest context.\nAdditional configuration is required.\n\nExpected flags depend on implementation, refer to `select_target_path` docs.\nAdd options to `conftest.py`:\n\n```python\nfrom pathlib import Path\n\ndef pytest_addoption(parser):\n    parser.addoption(\n        \"--target-path\",\n        type=Path,\n        help=\"Path to test scenarios executable. Search is performed by default.\",\n    )\n    parser.addoption(\n        \"--target-name\",\n        type=str,\n        default=\"rust_test_scenarios\",\n        help='Test scenario executable name. Overwritten by \"--target-path\".',\n    )\n```\n\nUsage:\n\n```python\nimport pytest\nfrom pathlib import Path\nfrom testing_utils import BazelTools\n\ndef test_example(request: pytest.FeatureRequest) -\u003e None:\n    build_tools = BazelTools()\n    target_path: Path = build_tools.select_target_path(request.config)\n    ...\n```\n\n#### Run build\n\nRun build for selected target.\n\n```python\nfrom testing_utils import BazelTools\n\ntarget_name = \"target_name\"\nbuild_tools = BazelTools()\ntarget_path: Path = build_tools.build(target_name)\n...\n```\n\n### Log container and `ResultEntry` example\n\nUsage as container:\n\n```python\nfrom testing_utils import LogContainer, ResultEntry\n\nlc = LogContainer()\nlc.add_log(\n    ResultEntry({\n        \"timestamp\": \"2025-06-05T07:46:11.796134Z\",\n        \"level\": \"DEBUG\",\n        \"fields\": {\"message\": \"Debug message\"},\n        \"target\": \"target::DEBUG_message\",\n        \"threadId\": \"ThreadId(1)\",\n    })\n)\nlogs = lc.get_logs()\n# Output: debug message.\nprint(logs[0].message)\n```\n\nUsage as JSON log trace parser:\n\n```python\nfrom testing_utils import LogContainer, ResultEntry\n\n# \"messages\" is a list of JSON logs.\nlogs = [ResultEntry(msg) for msg in messages]\nlc = LogContainer(logs)\nlc.contains_log(field=\"message\", pattern=\"SomeExampleAction\")  # True\n```\n\nUsage as log filter:\n\n```python\nfrom testing_utils import LogContainer, ResultEntry\n\n# \"messages\" is a list of JSON logs.\nlogs = [ResultEntry(msg) for msg in messages]\nlc = LogContainer(logs)\nlc_only_info = lc.get_logs_by_field(field=\"level\", pattern=\"INFO\")\n```\n\n### Scenario example\n\n`Scenario` is a base class containing basic test behavior.\nTest execution results are provided using two fixtures:\n\n- `results` - executable run results\n- `logs` - logs from run\n\n`build_tools`, `scenario_name` and `test_config` are marked as abstract and must be implemented.\n\nExample implementation:\n\n```python\nimport pytest\nfrom testing_utils import Scenario, ScenarioResult, LogContainer, CargoTools, BuildTools\n\nclass TestExample(Scenario):\n    @pytest.fixture(scope=\"class\")\n    def build_tools(self) -\u003e BuildTools:\n        return CargoTools()\n\n    @pytest.fixture(scope=\"class\")\n    def scenario_name(self) -\u003e str:\n        return \"example_scenario_name\"\n\n    @pytest.fixture(scope=\"class\")\n    def test_config(self) -\u003e dict[str, Any]:\n        return {\"runtime\": {\"task_queue_size\": 256, \"workers\": 1}}\n\n    def test_example(self, results: ScenarioResult, logs: LogContainer) -\u003e None:\n        ...\n```\n\nExecution timeout uses `\"--default-execution-timeout\"` set in `conftest.py`, or is set to 5 seconds by default.\n\n`stderr` is shown, but not captured by default.\nTo capture `stderr` use:\n\n```python\nclass TestExample(Scenario):\n    def capture_stderr(self) -\u003e bool:\n        return True\n\n    ...\n```\n\nMethods can be overridden to utilize test-specific fixtures:\n\n```python\nimport pytest\nfrom testing_utils import Scenario\n\nclass TestExample(Scenario)\n    @pytest.fixture(scope=\"class\", params=[1, 4, 256])\n    def queue_size(self, request: pytest.FixtureRequest) -\u003e int:\n        return request.param\n\n    @pytest.fixture(scope=\"class\")\n    def test_config(self, queue_size: int) -\u003e dict[str, Any]:\n        return {\"runtime\": {\"task_queue_size\": queue_size, \"workers\": 1}}\n\n    ...\n```\n\n## Development\n\n- Python 3.12+ required.\n- Code style is enforced with [ruff](https://github.com/astral-sh/ruff).\n\nTo run the tests, use:\n\n```bash\npytest -vs .\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feclipse-score%2Ftesting_tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feclipse-score%2Ftesting_tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feclipse-score%2Ftesting_tools/lists"}