forked from aws-controllers-k8s/sagemaker-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_data_quality_job_definition.py
75 lines (66 loc) · 2.68 KB
/
test_data_quality_job_definition.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You 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/
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""Integration tests for the SageMaker DataQualityJobDefinition API.
"""
import pytest
import logging
import botocore
import time
from e2e import service_marker, assert_tags_in_sync
from e2e.common.fixtures import (
xgboost_churn_data_quality_job_definition,
xgboost_churn_endpoint,
)
from e2e.common import config as cfg
from acktest.k8s import resource as k8s
from e2e import delete_custom_resource
# Access variable so it is loaded as a fixture
_accessed = xgboost_churn_data_quality_job_definition, xgboost_churn_endpoint
def describe_sagemaker_data_quality_job_definition(
sagemaker_client, job_definition_name
):
try:
return sagemaker_client.describe_data_quality_job_definition(
JobDefinitionName=job_definition_name
)
except botocore.exceptions.ClientError as error:
logging.error(
f"Could not find Data Quality Job Definition with name {job_definition_name}. Error {error}"
)
return None
@service_marker
@pytest.mark.canary
class TestDataQualityJobDefinition:
def test_smoke(self, sagemaker_client, xgboost_churn_data_quality_job_definition):
(reference, resource) = xgboost_churn_data_quality_job_definition
assert k8s.get_resource_exists(reference)
job_definition_name = resource["spec"].get("jobDefinitionName")
job_definition_desc = describe_sagemaker_data_quality_job_definition(
sagemaker_client, job_definition_name
)
job_definition_arn = job_definition_desc["JobDefinitionArn"]
assert k8s.get_resource_arn(resource) == job_definition_arn
# random sleep before we check for tags to reduce test flakyness
time.sleep(cfg.TAG_DELAY_SLEEP)
resource_tags = resource["spec"].get("tags", None)
assert_tags_in_sync(job_definition_arn, resource_tags)
# Delete the k8s resource.
assert delete_custom_resource(
reference, cfg.DELETE_WAIT_PERIOD, cfg.DELETE_WAIT_LENGTH
)
assert (
describe_sagemaker_data_quality_job_definition(
sagemaker_client, job_definition_name
)
is None
)