Skip to content

Commit 734b7bf

Browse files
committed
test: ✅ Add unit tests for SELinux usecase
1 parent 4bcd920 commit 734b7bf

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/unit/sagemaker/local/test_local_image.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from mock import patch, Mock, MagicMock
3131

3232
import sagemaker
33-
from sagemaker.local.image import _SageMakerContainer, _aws_credentials
33+
from sagemaker.local.image import _SageMakerContainer, _Volume, _aws_credentials
3434

3535
REGION = "us-west-2"
3636
BUCKET_NAME = "mybucket"
@@ -567,6 +567,26 @@ def test_train_local_intermediate_output(get_data_source_instance, tmpdir, sagem
567567
assert "%s:/opt/ml/output/intermediate" % intermediate_folder_path in volumes
568568

569569

570+
@patch("platform.system", Mock(return_value="Linux"))
571+
@patch("sagemaker.local.image.SELINUX_ENABLED", Mock(return_value=True))
572+
def test_container_selinux_has_label(tmpdir, sagemaker_session):
573+
instance_count = 1
574+
image = "my-image"
575+
volume = _Volume(str(tmpdir), "/opt/ml/model")
576+
577+
assert volume.map.endswith(":z")
578+
579+
580+
@patch("platform.system", Mock(return_value="Darwin"))
581+
@patch("sagemaker.local.image.SELINUX_ENABLED", Mock(return_value=True))
582+
def test_container_has_selinux_no_label(tmpdir, sagemaker_session, monkeypatch):
583+
instance_count = 1
584+
image = "my-image"
585+
volume = _Volume(str(tmpdir), "/opt/ml/model")
586+
587+
assert not volume.map.endswith(":z")
588+
589+
570590
def test_container_has_gpu_support(tmpdir, sagemaker_session):
571591
instance_count = 1
572592
image = "my-image"

0 commit comments

Comments
 (0)