Skip to content

test: unskip sm-core integ tests#5856

Open
lucasjia-aws wants to merge 9 commits into
aws:masterfrom
lucasjia-aws:unskip-integ-tests-core
Open

test: unskip sm-core integ tests#5856
lucasjia-aws wants to merge 9 commits into
aws:masterfrom
lucasjia-aws:unskip-integ-tests-core

Conversation

@lucasjia-aws
Copy link
Copy Markdown
Collaborator

@lucasjia-aws lucasjia-aws commented May 14, 2026

Description

This PR audits and unskips integration tests in sagemaker-core as part of COE AI4 (skipped test audit). Each previously-skipped test was investigated for necessity, root cause of skip, and fixed where possible.

Summary of Changes

Test Status Commit Fix Description
test_retrieve_image_uri_intelligent_default Fixed & Unskipped 28c168e3, 533f3c6a, b17f7b7f Fixed 3 bugs in ImageRetriever: (1) replaced ineffective locals() assignment with args dict, (2) added missing PYTHON_SDK in config path, (3) used PascalCase (_to_pascal_case) for config key lookup. Updated expected image version from 3.0.0 to 3.2.0.
test_advanced_job_setting Fixed & Unskipped a1e0e17e Ported kms_utils.py from SageMakerHulkPythonSDK with get_or_create_kms_key utility, adapted for sagemaker-core import paths. Uncommented the import in test file.
test_decorator_with_spark_job Conditionally Skipped 6aa560bc Fixed test code bugs (set→dict, attribute→string). Added @pytest.mark.skipif for Python != 3.9 or 3.12 -- SageMaker Spark image only available for Python 3.9 and 3.12
test_decorator_auto_capture Unskipped (passes) 5a914837 Was unnecessarily skipped. Passes in CI without changes.

Tests that remain skipped (with justification)

Test Reason
test_decorator_with_spark_job Spark container (sagemaker-spark-processing:3.3-cpu-py39-v1) does not have a working pip in PATH. SDK auto-injects pip install sagemaker-feature-store-pyspark as a pre-exec command which fails. Requires Spark container image update. Conditionally skipped with @pytest.mark.skipif so it auto-enables when run on py39 with a fixed container.

Testing

  • Ran full sagemaker-core integ test suite via CodeBuild
  • Individually verified test_decorator_with_spark_job on py39 and py312 to confirm root cause
  • Verified CI role has required KMS permissions for test_advanced_job_setting

@lucasjia-aws lucasjia-aws force-pushed the unskip-integ-tests-core branch from 4147d4a to 076b890 Compare May 14, 2026 18:32
@lucasjia-aws lucasjia-aws force-pushed the unskip-integ-tests-core branch from 67d18ca to 24fcdac Compare May 15, 2026 22:07
@lucasjia-aws lucasjia-aws force-pushed the unskip-integ-tests-core branch from 24fcdac to b17f7b7 Compare May 18, 2026 21:06
@lucasjia-aws lucasjia-aws force-pushed the unskip-integ-tests-core branch from c8108c7 to 6aa560b Compare May 19, 2026 16:44
aviruthen
aviruthen previously approved these changes May 20, 2026
from tests.integ.s3_utils import assert_s3_files_exist

# from tests.integ.kms_utils import get_or_create_kms_key # TODO: provide KMS utils
from tests.integ.kms_utils import get_or_create_kms_key
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're creating a kms key, it should be cleaned up (ie deleted) after test ends.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently it uses a fixed alias (SageMakerTestKMSKey) and reuses the same key across test runs — it only creates a new key if one doesn't already exist under that alias. This is the same pattern used in
kms_utils.py (which I ported this from), where the key persists in the CI account and is shared across all integ tests that need KMS.

The reason for this design: KMS keys have a mandatory 7-day minimum deletion window (schedule_key_deletion(PendingWindowInDays=7)), so creating and deleting a key per test run isn't practical. The persistent shared key approach avoids accumulating orphaned keys and unnecessary costs.

# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Can we rename this file so it indicates this file only to help with integ tests? Current name makes it sound like its a part of sm-core.

Also, can you check if the codebase does not already have util functions to get/create kms keys. Most like there isn't so you're good.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point — I'll rename it to integ_test_kms_helpers.py.

Confirmed there's no existing KMS utility anywhere in sagemaker-core. This was ported from
kms_utils.py which is the canonical implementation used across the old SDK's integ tests. When sagemaker-core was split out, this test helper seems like wasn't carried over.

…ineffective locals() assignment with args dict
…ced_job_setting

- Add tests/integ/kms_utils.py with get_or_create_kms_key utility ported
  from SageMakerHulkPythonSDK, adapted for sagemaker-core import paths
- Uncomment kms_utils import in test_decorator.py to fix NameError in
  s3_kms_key fixture
… fix test bugs

- Add skipif for Python versions without Spark image (only 3.9/3.12 supported)
- Fix Properties set literal to dict: {"spark.app.name": "remote-spark-test"}
- Fix spark.conf.get() to use string key instead of attribute reference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants