Skip to content

Commit b4444a9

Browse files
committed
fix sanity and security tests
1 parent e24c955 commit b4444a9

File tree

7 files changed

+70
-58
lines changed

7 files changed

+70
-58
lines changed

sglang/x86_64/gpu/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ RUN dpkg -l | grep -E "cuda|nvidia|libnv" | awk '{print $2}' | xargs apt-mark ho
9494
&& apt-get upgrade -y \
9595
&& apt-get clean
9696

97+
RUN rm -rf /tmp/*
98+
9799
COPY sagemaker_entrypoint.sh /usr/local/bin/sagemaker_entrypoint.sh
98100
RUN chmod +x /usr/local/bin/sagemaker_entrypoint.sh
99101

test/dlc_tests/sanity/test_anaconda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_repo_anaconda_not_present(image):
1515

1616
# First check to see if image has conda installed, if not, skip test since no packages installed from conda present
1717
conda_present = test_utils.run_cmd_on_container(
18-
container_name, ctx, 'find . -name conda -not -path "**/.github/*" -ignore_readdir_race'
18+
container_name, ctx, 'find . -name conda -not -path "**/.github/*" -not -path "**/.oh-my-zsh/*" -ignore_readdir_race'
1919
).stdout.strip()
2020
if not conda_present:
2121
pytest.skip(f"Image {image} does not have conda installed, skipping test.")

test/dlc_tests/sanity/test_boottime_container_security.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import pytest
2-
32
from invoke import run
43

54

65
@pytest.mark.usefixtures("sagemaker", "security_sanity")
76
@pytest.mark.model("N/A")
87
@pytest.mark.canary("Run security test regularly on production images")
98
def test_security(image):
10-
if "vllm" in image:
9+
upstream_types = ["vllm"]
10+
if any(t in image for t in upstream_types):
1111
pytest.skip(
12-
"vLLM images do not require pip check as they are managed by vLLM devs. Skipping test."
12+
f"{', '.join(upstream_types)} images do not require boot time security check as they are managed by upstream devs. Skipping test."
1313
)
1414
repo_name, image_tag = image.split("/")[-1].split(":")
1515
container_name = f"{repo_name}-{image_tag}-security"

test/dlc_tests/sanity/test_dlc_labels.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ def test_dlc_major_version_label(image, region):
3131
@pytest.mark.integration("dlc_labels")
3232
@pytest.mark.model("N/A")
3333
def test_dlc_standard_labels(image, region):
34-
if "vllm" in image:
34+
upstream_types = ["vllm", "sglang"]
35+
if any(t in image for t in upstream_types):
3536
pytest.skip(
36-
"vLLM images do not require test_dlc_standard_labels check as they are managed by vLLM devs. Skipping test."
37+
f"{', '.join(upstream_types)} images do not require test_dlc_standard_labels check as they are managed by upstream devs. Skipping test."
3738
)
39+
3840
customer_type_label_prefix = "ec2" if test_utils.is_ec2_image(image) else "sagemaker"
3941

4042
framework, fw_version = test_utils.get_framework_and_version_from_tag(image)

test/dlc_tests/sanity/test_ecr_scan.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,12 @@ def test_ecr_enhanced_scan(image, ecr_client, sts_client, region):
435435
:param sts_client: boto3 Client for STS
436436
:param region: str Name of region where test is executed
437437
"""
438-
if "vllm" in image:
438+
upstream_types = ["vllm", "sglang"]
439+
if any(t in image for t in upstream_types):
439440
pytest.skip(
440-
"vLLM images do not require test_ecr_enhanced_scan check as they are managed by vLLM devs. Skipping test."
441+
f"{', '.join(upstream_types)} images do not require test_ecr_enhanced_scan check as they are managed by upstream devs. Skipping test."
441442
)
443+
442444
LOGGER.info(f"Running test_ecr_enhanced_scan for image {image}")
443445
image = conduct_preprocessing_of_images_before_running_ecr_scans(
444446
image, ecr_client, sts_client, region

test/dlc_tests/sanity/test_pre_release.py

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,55 @@
1+
import filecmp
2+
import json
13
import os
24
import re
35
import subprocess
4-
import botocore
5-
import boto3
6-
import json
76
import time
8-
9-
from packaging.version import Version
10-
from packaging.specifiers import SpecifierSet
11-
12-
import pytest
13-
import requests
14-
import filecmp
15-
16-
from urllib3.util.retry import Retry
17-
from invoke.context import Context
18-
from botocore.exceptions import ClientError
19-
20-
from src.buildspec import Buildspec
21-
import src.utils as src_utils
227
from test.test_utils import (
23-
LOGGER,
8+
AL2023_BASE_DLAMI_ARM64_US_WEST_2,
249
CONTAINER_TESTS_PREFIX,
10+
LOGGER,
11+
DockerImagePullException,
2512
ec2,
13+
execute_env_variables_test,
14+
get_account_id_from_image_uri,
15+
get_all_the_tags_of_an_image_from_ecr,
16+
get_buildspec_path,
2617
get_container_name,
18+
get_cuda_version_from_tag,
2719
get_framework_and_version_from_tag,
28-
get_neuron_sdk_version_from_tag,
20+
get_image_spec_from_buildspec,
21+
get_installed_python_packages_using_image_uri,
22+
get_installed_python_packages_with_version,
23+
get_labels_from_ecr_image,
2924
get_neuron_release_manifest,
25+
get_neuron_sdk_version_from_tag,
26+
get_python_version_from_image_uri,
27+
get_pytorch_version_from_autogluon_image,
28+
get_region_from_image_uri,
29+
get_repository_and_tag_from_image_uri,
30+
get_repository_local_path,
3031
is_canary_context,
3132
is_dlc_cicd_context,
33+
is_nightly_context,
34+
login_to_ecr_registry,
3235
run_cmd_on_container,
3336
start_container,
3437
stop_and_remove_container,
35-
get_repository_local_path,
36-
get_repository_and_tag_from_image_uri,
37-
get_python_version_from_image_uri,
38-
get_pytorch_version_from_autogluon_image,
39-
get_cuda_version_from_tag,
40-
get_labels_from_ecr_image,
41-
get_buildspec_path,
42-
get_all_the_tags_of_an_image_from_ecr,
43-
is_nightly_context,
44-
execute_env_variables_test,
45-
AL2023_BASE_DLAMI_ARM64_US_WEST_2,
46-
get_installed_python_packages_with_version,
47-
login_to_ecr_registry,
48-
get_account_id_from_image_uri,
49-
get_region_from_image_uri,
50-
DockerImagePullException,
51-
get_installed_python_packages_with_version,
52-
get_installed_python_packages_using_image_uri,
53-
get_image_spec_from_buildspec,
5438
)
5539

40+
import boto3
41+
import botocore
42+
import pytest
43+
import requests
44+
from botocore.exceptions import ClientError
45+
from invoke.context import Context
46+
from packaging.specifiers import SpecifierSet
47+
from packaging.version import Version
48+
from urllib3.util.retry import Retry
49+
50+
import src.utils as src_utils
51+
from src.buildspec import Buildspec
52+
5653

5754
def tail_n_lines(fname, n):
5855
try:
@@ -112,9 +109,10 @@ def test_stray_files(image):
112109
113110
:param image: ECR image URI
114111
"""
115-
if "vllm" in image:
112+
upstream_types = ["vllm", "sglang"]
113+
if any(t in image for t in upstream_types):
116114
pytest.skip(
117-
"vLLM images do not require pip check as they are managed by vLLM devs. Skipping test."
115+
f"{', '.join(upstream_types)} images do not require pip check as they are managed by upstream devs. Skipping test."
118116
)
119117

120118
ctx = Context()
@@ -585,9 +583,10 @@ def test_pip_check(image):
585583
586584
:param image: ECR image URI
587585
"""
588-
if "vllm" in image:
586+
upstream_types = ["vllm", "sglang"]
587+
if any(t in image for t in upstream_types):
589588
pytest.skip(
590-
"vLLM images do not require pip check as they are managed by vLLM devs. Skipping test."
589+
f"{', '.join(upstream_types)} images do not require pip check as they are managed by upstream devs. Skipping test."
591590
)
592591

593592
allowed_exceptions = []
@@ -733,9 +732,10 @@ def test_cuda_paths(gpu):
733732
:param gpu: gpu image uris
734733
"""
735734
image = gpu
736-
if "base" in image or "vllm" in image:
735+
general_types = ["base", "vllm", "sglang"]
736+
if any(t in image for t in general_types):
737737
pytest.skip(
738-
"Base/vLLM DLC doesn't have the same directory structure and buildspec as other images"
738+
f"{', '.join(general_types)} DLC doesn't have the same directory structure and buildspec as other images"
739739
)
740740
if "example" in image:
741741
pytest.skip("Skipping Example Dockerfiles which are not explicitly tied to a cuda version")
@@ -1070,8 +1070,9 @@ def test_license_file(image):
10701070
"""
10711071
Check that license file within the container is readable and valid
10721072
"""
1073-
if "base" in image or "vllm" in image:
1074-
pytest.skip("Base DLC has doesn't embed license.txt. Skipping test.")
1073+
general_types = ["base", "vllm", "sglang"]
1074+
if any(t in image for t in general_types):
1075+
pytest.skip(f"{', '.join(general_types)} DLC doesn't embed license.txt. Skipping test.")
10751076

10761077
framework, version = get_framework_and_version_from_tag(image)
10771078

@@ -1194,8 +1195,10 @@ def test_core_package_version(image):
11941195
In this test, we ensure that if a core_packages.json file exists for an image, the packages installed in the image
11951196
satisfy the version constraints specified in the core_packages.json file.
11961197
"""
1197-
if "base" in image or "vllm" in image:
1198-
pytest.skip("Base/vLLM images do not have core packages. Skipping test.")
1198+
general_types = ["base", "vllm", "sglang"]
1199+
if any(t in image for t in general_types):
1200+
pytest.skip(f"{', '.join(general_types)} images do not have core packages. Skipping test.")
1201+
11991202
core_packages_path = src_utils.get_core_packages_path(image)
12001203
if not os.path.exists(core_packages_path):
12011204
pytest.skip(f"Core packages file {core_packages_path} does not exist for {image}")

test/dlc_tests/sanity/test_safety_report_file.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,13 @@ def test_safety_file_exists_and_is_valid(image):
7373
pytest.skip(
7474
"Base images do not require safety file as there isn't much python libs in it. Skipping test."
7575
)
76-
if "vllm" in image:
76+
77+
upstream_types = ["vllm", "sglang"]
78+
if any(t in image for t in upstream_types):
7779
pytest.skip(
78-
"vllm images do not require safety file as they are managed by vLLM devs. Skipping test."
80+
f"{', '.join(upstream_types)} images do not require safety file as they are managed by upstream devs. Skipping test."
7981
)
82+
8083
repo_name, image_tag = image.split("/")[-1].split(":")
8184
# Make sure this container name doesn't conflict with the safety check test container name
8285
container_name = f"{repo_name}-{image_tag}-safety-file"

0 commit comments

Comments
 (0)