-
Notifications
You must be signed in to change notification settings - Fork 4
Add Cluster-based E2E tests for VCT #288
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
base: main
Are you sure you want to change the base?
Changes from 14 commits
ca2ff47
6c30936
49b273b
f3a4c1b
2886a7e
9b7a886
f5befe0
a9314fa
ae0d6aa
1975d7e
fd55a6e
f9d27c5
438ae7c
758c1d6
94be2d7
701d5db
f67e3e5
0fe8766
1390925
7d5e4ef
388c1b5
540de85
b4cdd8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,78 @@ | ||
| import shutil | ||
| from datetime import datetime | ||
|
|
||
| import pytest | ||
| from _pytest.config import Config, argparsing | ||
| from _pytest.python import Function | ||
|
|
||
| SLOW_TEST_DAY = "Sunday" | ||
|
|
||
|
|
||
| def pytest_addoption(parser: argparsing.Parser) -> None: | ||
| parser.addoption("--runslow", action="store_true", default=False, help="run slow tests") | ||
| parser.addoption( | ||
| "--slurm-project", | ||
| type=str, | ||
| default="proj_simscience", | ||
| help="SLURM project for cluster tests (default: proj_simscience)", | ||
| ) | ||
|
|
||
|
|
||
| def pytest_configure(config: Config) -> None: | ||
| config.addinivalue_line("markers", "slow: mark test as slow to run") | ||
| config.addinivalue_line( | ||
| "markers", "cluster: mark test as requiring a SLURM cluster environment" | ||
| ) | ||
|
|
||
|
|
||
| def pytest_collection_modifyitems(config: Config, items: list[Function]) -> None: | ||
| if config.getoption("--runslow"): | ||
| # --runslow given in cli: do not skip slow tests | ||
| return | ||
| skip_slow = pytest.mark.skip(reason="need --runslow option to run") | ||
| for item in items: | ||
| if "slow" in item.keywords: | ||
| item.add_marker(skip_slow) | ||
| if not config.getoption("--runslow"): | ||
| skip_slow = pytest.mark.skip(reason="need --runslow option to run") | ||
| for item in items: | ||
| if "slow" in item.keywords: | ||
| item.add_marker(skip_slow) | ||
|
|
||
| if not is_on_slurm(): | ||
| skip_cluster = pytest.mark.skip(reason="not running on SLURM cluster") | ||
| for item in items: | ||
| if "cluster" in item.keywords: | ||
| item.add_marker(skip_cluster) | ||
|
|
||
| # E2E tests (cluster + slow) also require it to be the slow test day | ||
| if not is_slow_test_day(): | ||
| skip_e2e = pytest.mark.skip(reason="not the designated slow test day for e2e tests") | ||
| for item in items: | ||
| if "weekly" in item.keywords: | ||
| item.add_marker(skip_e2e) | ||
|
|
||
|
|
||
| def is_on_slurm() -> bool: | ||
|
||
| """Returns True if the current environment is a SLURM cluster.""" | ||
| return shutil.which("sbatch") is not None | ||
|
|
||
|
|
||
| def is_slow_test_day(slow_test_day: str = SLOW_TEST_DAY) -> bool: | ||
|
||
| """Determine if today is the day to run slow/weekly tests. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| slow_test_day | ||
| The day to run the weekly tests on. Acceptable values are "Monday", | ||
| "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", or "Sunday". | ||
| Default is "Sunday". | ||
|
|
||
| Notes | ||
| ----- | ||
| There is some risk that a test will be inadvertently skipped if there is a | ||
| significant delay between when a pipeline is kicked off and when the test | ||
| itself is run. | ||
| """ | ||
| return [ | ||
| "Monday", | ||
| "Tuesday", | ||
| "Wednesday", | ||
| "Thursday", | ||
| "Friday", | ||
| "Saturday", | ||
| "Sunday", | ||
| ][datetime.today().weekday()] == slow_test_day | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Minimal branch configuration for E2E testing. | ||
| # 2 draws x 2 seeds x 1 branch (empty) = 4 total jobs. | ||
| input_draw_count: 2 | ||
| random_seed_count: 2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Minimal vivarium model specification for E2E testing. | ||
| # Runs 2 time steps with 10 simulants -- completes in seconds. | ||
| # No components, no data artifact, no results observers. | ||
|
||
| components: | ||
| vivarium.examples.disease_model: | ||
| population: | ||
| - BasePopulation() | ||
| configuration: | ||
| time: | ||
| start: | ||
| year: 2025 | ||
| month: 1 | ||
| day: 1 | ||
| end: | ||
| year: 2025 | ||
| month: 1 | ||
| day: 15 | ||
| step_size: 7 # days | ||
| population: | ||
| population_size: 10 | ||
| randomness: | ||
| key_columns: [] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic seems to be duplicated across many repos. Is it possible to move it into VTU?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apparently so!