Skip to content

Commit 089f2b5

Browse files
authored
[Tests] Managed spot test option (skypilot-org#1611)
* Revert setup failure * add option for --managed-spot * remove exception raising * format * format * address comment * comments
1 parent 9d9f95e commit 089f2b5

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ pytest --lf
3535
# Run one of the smoke tests
3636
pytest tests/test_smoke.py::test_minimal
3737
38+
# Only run managed spot tests
39+
pytest tests/test_smoke.py --managed-spot
40+
3841
# Only run test for AWS + generic tests
3942
pytest tests/test_smoke.py --aws
4043

tests/conftest.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# due to the cloud credit limit for the development account.
1414
# To only run tests for a specific cloud (as well as generic tests), use
1515
# --aws, --gcp, or --azure.
16+
# To only run tests for managed spot (without generic tests), use --managed-spot.
1617
# A "generic test" tests a generic functionality (e.g., autostop) that
1718
# should work on any cloud we support. The cloud used for such a test
1819
# is controlled by `--generic-cloud` (typically you do not need to set it).
@@ -25,12 +26,16 @@ def pytest_addoption(parser):
2526
parser.addoption('--runslow',
2627
action='store_true',
2728
default=False,
28-
help='run slow tests')
29+
help='run slow tests.')
2930
for cloud in all_clouds_in_smoke_tests:
3031
parser.addoption(f'--{cloud}',
3132
action='store_true',
3233
default=False,
33-
help=f'Only run {cloud.upper()} tests')
34+
help=f'Only run {cloud.upper()} tests.')
35+
parser.addoption('--managed-spot',
36+
action='store_true',
37+
default=False,
38+
help='Only run tests for managed spot.')
3439
parser.addoption(
3540
'--generic-cloud',
3641
type=str,
@@ -59,8 +64,10 @@ def _get_cloud_to_run(config) -> List[str]:
5964

6065

6166
def pytest_collection_modifyitems(config, items):
62-
skip_slow = pytest.mark.skip(reason='need --runslow option to run')
6367
skip_marks = {}
68+
skip_marks['slow'] = pytest.mark.skip(reason='need --runslow option to run')
69+
skip_marks['managed_spot'] = pytest.mark.skip(
70+
reason='skipped, because --managed-spot option is set')
6471
for cloud in all_clouds_in_smoke_tests:
6572
skip_marks[cloud] = pytest.mark.skip(
6673
reason=f'tests for {cloud} is skipped, try setting --{cloud}')
@@ -69,11 +76,15 @@ def pytest_collection_modifyitems(config, items):
6976

7077
for item in items:
7178
if 'slow' in item.keywords and not config.getoption('--runslow'):
72-
item.add_marker(skip_slow)
79+
item.add_marker(skip_marks['slow'])
7380
for cloud in all_clouds_in_smoke_tests:
7481
if cloud in item.keywords and cloud not in cloud_to_run:
7582
item.add_marker(skip_marks[cloud])
7683

84+
if (not 'managed_spot'
85+
in item.keywords) and config.getoption('--managed-spot'):
86+
item.add_marker(skip_marks['managed_spot'])
87+
7788

7889
@pytest.fixture
7990
def generic_cloud(request) -> str:

tests/test_smoke.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ def test_use_spot(generic_cloud: str):
10991099

11001100

11011101
# ---------- Testing managed spot ----------
1102+
@pytest.mark.managed_spot
11021103
def test_spot(generic_cloud: str):
11031104
"""Test the spot yaml."""
11041105
name = _get_cluster_name()
@@ -1125,6 +1126,7 @@ def test_spot(generic_cloud: str):
11251126

11261127
# ---------- Testing managed spot recovery ----------
11271128
@pytest.mark.aws
1129+
@pytest.mark.managed_spot
11281130
def test_spot_recovery_aws():
11291131
"""Test managed spot recovery."""
11301132
name = _get_cluster_name()
@@ -1155,6 +1157,7 @@ def test_spot_recovery_aws():
11551157

11561158

11571159
@pytest.mark.gcp
1160+
@pytest.mark.managed_spot
11581161
def test_spot_recovery_gcp():
11591162
"""Test managed spot recovery."""
11601163
name = _get_cluster_name()
@@ -1185,6 +1188,7 @@ def test_spot_recovery_gcp():
11851188
run_one_test(test)
11861189

11871190

1191+
@pytest.mark.managed_spot
11881192
def test_spot_recovery_default_resources(generic_cloud: str):
11891193
"""Test managed spot recovery for default resources."""
11901194
name = _get_cluster_name()
@@ -1202,6 +1206,7 @@ def test_spot_recovery_default_resources(generic_cloud: str):
12021206

12031207

12041208
@pytest.mark.aws
1209+
@pytest.mark.managed_spot
12051210
def test_spot_recovery_multi_node_aws():
12061211
"""Test managed spot recovery."""
12071212
name = _get_cluster_name()
@@ -1233,6 +1238,7 @@ def test_spot_recovery_multi_node_aws():
12331238

12341239

12351240
@pytest.mark.gcp
1241+
@pytest.mark.managed_spot
12361242
def test_spot_recovery_multi_node_gcp():
12371243
"""Test managed spot recovery."""
12381244
name = _get_cluster_name()
@@ -1266,6 +1272,7 @@ def test_spot_recovery_multi_node_gcp():
12661272

12671273

12681274
@pytest.mark.aws
1275+
@pytest.mark.managed_spot
12691276
def test_spot_cancellation_aws():
12701277
name = _get_cluster_name()
12711278
region = 'us-east-2'
@@ -1326,6 +1333,7 @@ def test_spot_cancellation_aws():
13261333

13271334

13281335
@pytest.mark.gcp
1336+
@pytest.mark.managed_spot
13291337
def test_spot_cancellation_gcp():
13301338
name = _get_cluster_name()
13311339
zone = 'us-west3-b'
@@ -1381,6 +1389,7 @@ def test_spot_cancellation_gcp():
13811389

13821390

13831391
# ---------- Testing storage for managed spot ----------
1392+
@pytest.mark.managed_spot
13841393
def test_spot_storage(generic_cloud: str):
13851394
"""Test storage with managed spot"""
13861395
name = _get_cluster_name()
@@ -1408,6 +1417,7 @@ def test_spot_storage(generic_cloud: str):
14081417

14091418
# ---------- Testing spot TPU ----------
14101419
@pytest.mark.gcp
1420+
@pytest.mark.managed_spot
14111421
def test_spot_tpu():
14121422
"""Test managed spot on TPU."""
14131423
name = _get_cluster_name()
@@ -1443,6 +1453,7 @@ def test_inline_env(generic_cloud: str):
14431453

14441454

14451455
# ---------- Testing env for spot ----------
1456+
@pytest.mark.managed_spot
14461457
def test_inline_spot_env(generic_cloud: str):
14471458
"""Test env"""
14481459
name = _get_cluster_name()

0 commit comments

Comments
 (0)