Skip to content
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

Split sanity test into functionality and security for test time reduction #4371

Merged
merged 66 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
ed5efec
add fixtures
sirutBuasai Oct 8, 2024
bb160b5
move telemetry
sirutBuasai Oct 8, 2024
81c7e62
move telemetry back
sirutBuasai Oct 8, 2024
f8c8fe0
move telemetry
sirutBuasai Oct 8, 2024
b9cb5c5
temp skip oss and ecr test
sirutBuasai Oct 8, 2024
e83e716
disable ap
sirutBuasai Oct 9, 2024
dda78ef
skip huggingface temp for to test telemetry
sirutBuasai Oct 9, 2024
474f6e7
update telemetry for mainline only
sirutBuasai Oct 9, 2024
88f523e
fix skip condition to not affect canary
sirutBuasai Oct 9, 2024
9ce86e0
telemetry != true
sirutBuasai Oct 9, 2024
27cbf87
Merge branch 'master' into test-time-reduction
sirutBuasai Oct 23, 2024
aed794c
use TEST_TYPE as env declaration for test split
sirutBuasai Oct 23, 2024
5a985e8
fix sanity marker
sirutBuasai Oct 23, 2024
b3c8ebd
fix security sanity fixture
sirutBuasai Oct 23, 2024
aa0485d
remove skip temp
sirutBuasai Oct 23, 2024
182ac1e
set telemetry in mainline context
sirutBuasai Oct 23, 2024
933cb2f
add specific test type for telemetry
sirutBuasai Oct 23, 2024
ed6d9d5
fix telemetry test type
sirutBuasai Oct 23, 2024
f8f6bff
add security and functionality env to pr json
sirutBuasai Oct 24, 2024
255ebca
default toml
sirutBuasai Oct 24, 2024
2346660
build test new pr
sirutBuasai Oct 24, 2024
57f8d54
fix skip condition for pr
sirutBuasai Oct 26, 2024
664dbea
build test
sirutBuasai Oct 26, 2024
5a37a29
test training
sirutBuasai Oct 26, 2024
2932b99
test graviton
sirutBuasai Oct 27, 2024
a988064
build test tf
sirutBuasai Oct 27, 2024
e7c5369
build test tf x86
sirutBuasai Oct 27, 2024
107f1a5
fix sanity
sirutBuasai Oct 27, 2024
3bc02cd
test tf grav
sirutBuasai Oct 27, 2024
1202618
Merge branch 'master' into test-time-reduction
sirutBuasai Oct 27, 2024
ea37be1
fix __inint__
sirutBuasai Oct 27, 2024
7942e0e
test tf and pt
sirutBuasai Oct 28, 2024
09a5c31
remove sanity config
sirutBuasai Oct 28, 2024
7bff589
test x86
sirutBuasai Oct 28, 2024
2be0e06
Merge branch 'master' into test-time-reduction
sirutBuasai Oct 28, 2024
0428144
test arm64
sirutBuasai Oct 28, 2024
3e9d31e
test tf training
sirutBuasai Oct 28, 2024
0c96bfe
test tf training
sirutBuasai Oct 28, 2024
20098f4
correct tf test
sirutBuasai Oct 28, 2024
dfa59b2
Merge branch 'master' into test-time-reduction
sirutBuasai Oct 29, 2024
e440af1
test graviton in pipeline
sirutBuasai Oct 29, 2024
00e6bcd
test tf
sirutBuasai Oct 29, 2024
f2dc34a
revert toml and remove temp skips
sirutBuasai Oct 29, 2024
c99b71a
revert buildspec
sirutBuasai Oct 29, 2024
505e448
revert buildspec 2
sirutBuasai Oct 29, 2024
4967093
change telemetry var
sirutBuasai Oct 29, 2024
156d12e
add quickchecks for checking that all sanity tests have a security/fu…
sirutBuasai Oct 30, 2024
d794ba3
fix comment
sirutBuasai Oct 30, 2024
2b262af
formatting
sirutBuasai Oct 30, 2024
08fea84
set debug logging level
sirutBuasai Oct 30, 2024
e8eeaa3
make comment clearer
sirutBuasai Oct 30, 2024
24e1dcb
rename variables
sirutBuasai Oct 30, 2024
f9a0656
remove unused imports
sirutBuasai Oct 30, 2024
06f626a
revert blank space
sirutBuasai Oct 30, 2024
40fe0c2
remove unused import 2
sirutBuasai Oct 30, 2024
a3b2f54
update comment
sirutBuasai Oct 30, 2024
df462cc
add docstring
sirutBuasai Oct 30, 2024
c23a063
update fixture logic
sirutBuasai Oct 30, 2024
ec16d46
disable ap
sirutBuasai Oct 30, 2024
eda569d
run env var check in telemetry test file
sirutBuasai Oct 30, 2024
8be0364
use pytest api for quicktest
sirutBuasai Oct 31, 2024
22bd6ca
use subprocess
sirutBuasai Oct 31, 2024
02e6294
use listdir instead of glob
sirutBuasai Oct 31, 2024
9e53f4c
set sanity path
sirutBuasai Oct 31, 2024
f813701
revert to read file for quick check
sirutBuasai Nov 1, 2024
8d2276b
Merge branch 'master' into test-time-reduction
sirutBuasai Nov 5, 2024
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: 2 additions & 1 deletion dlc_developer_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ notify_test_failures = false

[test]
### On by default
sanity_tests = true
security_sanity_tests = true
functionality_sanity_tests = true
safety_check_test = false
ecr_scan_allowlist_feature = false
ecs_tests = true
Expand Down
8 changes: 6 additions & 2 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ def is_sm_benchmark_test_enabled():
return parse_dlc_developer_configs("test", "sagemaker_benchmark_tests")


def is_sanity_test_enabled():
return parse_dlc_developer_configs("test", "sanity_tests")
def is_security_sanity_test_enabled():
return parse_dlc_developer_configs("test", "security_sanity_tests")


def is_functionality_sanity_test_enabled():
return parse_dlc_developer_configs("test", "functionality_sanity_tests")


def is_sm_local_test_enabled():
Expand Down
3 changes: 2 additions & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
SAGEMAKER_EFA_TESTS = "sagemaker-efa"
SAGEMAKER_RC_TESTS = "sagemaker-rc"
SAGEMAKER_BENCHMARK_TESTS = "sagemaker-benchmark"
SANITY_TESTS = "sanity"
SECURITY_SANITY_TESTS = "security-sanity"
FUNCTIONALITY_SANITY_TESTS = "functionality-sanity"
EC2_TESTS = "ec2"
EC2_BENCHMARK_TESTS = "ec2-benchmark"
ECS_TESTS = "ecs"
Expand Down
3 changes: 2 additions & 1 deletion src/prepare_dlc_dev_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@


VALID_TEST_TYPES = [
"sanity_tests",
"security_sanity_tests",
"functionality_sanity_tests",
"ec2_tests",
"ecs_tests",
"eks_tests",
Expand Down
2 changes: 1 addition & 1 deletion src/send_test_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_dlc_images(build_context):
with open(test_env_file) as test_env:
test_images = json.load(test_env)
for dlc_test_type, images in test_images.items():
if dlc_test_type == "sanity":
if "sanity" in dlc_test_type:
return " ".join(images)
raise RuntimeError(f"Cannot find any images for in {test_images}")

Expand Down
9 changes: 7 additions & 2 deletions src/start_testbuilds.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ def is_test_job_enabled(test_type):
return True
if test_type == constants.EKS_TESTS and config.is_eks_test_enabled():
return True
if test_type == constants.SANITY_TESTS and config.is_sanity_test_enabled():
if test_type == constants.SECURITY_SANITY_TESTS and config.is_security_sanity_test_enabled():
return True
if (
test_type == constants.FUNCTIONALITY_SANITY_TESTS
and config.is_functionality_sanity_test_enabled()
):
return True

return False
Expand Down Expand Up @@ -244,7 +249,7 @@ def main():
pr_test_job = f"dlc-pr-{test_type}-test"
images_str = " ".join(images)
# Maintaining separate codebuild project for graviton sanity test
if "graviton" in images_str and test_type == "sanity":
if "graviton" in images_str and "sanity" in test_type:
pr_test_job += "-graviton"
if is_test_job_enabled(test_type) and is_test_job_implemented_for_framework(
images_str, test_type
Expand Down
3 changes: 2 additions & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def fetch_dlc_images_for_test_jobs(images, use_latest_additional_tag=False):
"eks": [],
"ec2": [],
"ec2-benchmark": [],
"sanity": [],
"security-sanity": [],
"functionality-sanity": [],
"autopr": [],
}

Expand Down
47 changes: 46 additions & 1 deletion test/dlc_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
get_ecr_repo_name,
UBUNTU_HOME_DIR,
NightlyFeatureLabel,
is_mainline_context,
is_pr_context,
)
from test.test_utils.imageutils import are_image_labels_matched, are_fixture_labels_enabled
from test.test_utils.test_reporting import TestReportGenerator
Expand Down Expand Up @@ -1029,6 +1031,49 @@ def _validate_pytorch_framework_version(request, image_uri, test_name, skip_dict
return False


@pytest.fixture(scope="session")
def telemetry():
"""
Telemetry tests are run in ec2 job in PR context but will run in its own job in MAINLINE context.
This fixture ensures that only telemetry tests are run in the `telemetry` job in the MAINLINE context.
"""
is_telemetry_test_job = os.getenv("TEST_TYPE") == "telemetry"
if is_mainline_context() and not is_telemetry_test_job:
pytest.skip(
f"Test in not running in telemetry job in the pipeline context, Skipping current test."
)


@pytest.fixture(scope="session")
def security_sanity():
"""
Skip test if job type is not `security_sanity` in either PR or Pipeline contexts.
Otherwise, sanity tests can run as usual in Canary/Deep Canary contexts.
Each sanity tests should only have either `security_sanity` or `functionality_sanity` fixtures.
Both should not be used at the same time. If neither are used, the test will run in both jobs.
"""
is_security_sanity_test_job = os.getenv("TEST_TYPE") == "security_sanity"
if (is_pr_context() or is_mainline_context()) and not is_security_sanity_test_job:
pytest.skip(
f"Test in not running in `security_sanity` test type within the pipeline context, Skipping current test."
)


@pytest.fixture(scope="session")
def functionality_sanity():
"""
Skip test if job type is not `functionality_sanity` in either PR or Pipeline contexts.
Otherwise, sanity tests can run as usual in Canary/Deep Canary contexts.
Each sanity tests should only have either `security_sanity` or `functionality_sanity` fixtures.
Both should not be used at the same time. If neither are used, the test will run in both jobs.
"""
is_functionality_sanity_test_job = os.getenv("TEST_TYPE") == "functionality_sanity"
if (is_pr_context() or is_mainline_context()) and not is_functionality_sanity_test_job:
pytest.skip(
f"Test in not running in `functionality_sanity` test type within the pipeline context, Skipping current test."
)


@pytest.fixture(scope="session")
def dlc_images(request):
return request.config.getoption("--images")
Expand Down Expand Up @@ -1630,7 +1675,7 @@ def pytest_generate_tests(metafunc):
if (
"stabilityai" not in metafunc.fixturenames
and "stabilityai" in image
and os.getenv("TEST_TYPE") != "sanity"
and "sanity" not in os.getenv("TEST_TYPE")
):
LOGGER.info(
f"Skipping test, as this function is not marked as 'stabilityai'"
Expand Down
Loading
Loading