Skip to content

Commit

Permalink
tests: add integ test for sagemaker-studio module (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonLuttenberger authored Jul 17, 2024
1 parent 49c9146 commit e3c4c66
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### **Changed**

- add integration tests for `sagemaker-studio`
- bump ecr module version to 1.10.0 to consume auto-delete images feature

## v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions modules/sagemaker/sagemaker-studio/deployspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ deploy:
phases:
install:
commands:
- npm install -g aws-cdk@2.128.0
- npm install -g aws-cdk@2.149.0
- pip install -r requirements.txt
- apt-get install gettext-base
build:
Expand All @@ -28,7 +28,7 @@ destroy:
phases:
install:
commands:
- npm install -g aws-cdk@2.128.0
- npm install -g aws-cdk@2.149.0
- pip install -r requirements.txt
build:
commands:
Expand Down
65 changes: 65 additions & 0 deletions modules/sagemaker/sagemaker-studio/integ/integ_studio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import json
import os
import sys
from typing import Dict, List

import aws_cdk as cdk
import boto3
from aws_cdk import cloud_assembly_schema as cas
from aws_cdk import integ_tests_alpha as integration

sys.path.append("../")

import stack # noqa: E402

app = cdk.App()


def get_module_dependencies(resource_keys: List[str]) -> Dict[str, str]:
ssm = boto3.client("ssm", region_name="us-east-1")
dependencies = {}
try:
for key in resource_keys:
dependencies[key] = ssm.get_parameter(Name=f"/module-integration-tests/{key}")["Parameter"]["Value"]
except Exception as e:
print(f"issue getting dependencies: {e}")
return dependencies


dependencies = get_module_dependencies(
# Add any required resource identifiers here
resource_keys=["vpc-id", "vpc-private-subnets"]
)

studio_stack = stack.SagemakerStudioStack(
app,
"sagemaker-studio-integ-stack",
vpc_id=dependencies["vpc-id"],
subnet_ids=json.loads(dependencies["vpc-private-subnets"]),
studio_domain_name="test-domain",
studio_bucket_name="test-bucket",
data_science_users=["ds-user-1"],
lead_data_science_users=["lead-ds-user-1"],
app_image_config_name=None,
image_name=None,
enable_custom_sagemaker_projects=False,
enable_domain_resource_isolation=True,
auth_mode="IAM",
env=cdk.Environment(account=os.getenv("CDK_DEFAULT_ACCOUNT"), region="us-east-1"),
)

integration.IntegTest(
app,
"Integration Tests SageMaker Studio Module",
test_cases=[
studio_stack,
],
diff_assets=True,
stack_update_workflow=True,
enable_lookups=True,
cdk_command_options=cas.CdkCommands(
deploy=cas.DeployCommand(args=cas.DeployOptions(require_approval=cas.RequireApproval.NEVER, json=True)),
destroy=cas.DestroyCommand(args=cas.DestroyOptions(force=True)),
),
)
app.synth()
11 changes: 6 additions & 5 deletions modules/sagemaker/sagemaker-studio/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
aws-cdk-lib==2.128.0
aws_cdk.aws_lambda_python_alpha==2.128.0a0
cdk-nag==2.28.40
pydantic~=2.7.1
pydantic-settings~=2.2.1
aws-cdk-lib~=2.149.0
aws_cdk.aws_lambda_python_alpha~=2.149.0a0
aws_cdk.integ-tests-alpha~=2.149.0a0
cdk-nag~=2.28.160
pydantic~=2.8.2
pydantic-settings~=2.3.4

0 comments on commit e3c4c66

Please sign in to comment.