Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,73 +28,6 @@ def stack_name(self):
"""Generate a unique stack name for testing."""
return f"hyperpod-test-stack-{str(uuid.uuid4())[:8]}"

def test_create_stack(self, stack_name):
"""Test creating a CloudFormation stack using HpClusterStack."""
# Create a minimal stack configuration
cluster_stack = HpClusterStack(
stage="gamma",
resource_name_prefix=f"hyperpod-test-{str(uuid.uuid4())[:8]}",
eks_cluster_name="test-eks-cluster",
create_eks_cluster_stack=True,
create_vpc_stack=False,
create_private_subnet_stack=False,
create_security_group_stack=False,
create_s3_bucket_stack=True,
create_s3_endpoint_stack=False,
create_life_cycle_script_stack=False,
create_sagemaker_iam_role_stack=False,
create_helm_chart_stack=False,
create_hyperpod_cluster_stack=False,
create_fsx_stack=False,
)

cf_client = create_boto3_client('cloudformation')
stack_exists = False

try:
# Create the stack (Did not need the name of the stack so fixed this.)
cluster_stack.create(region ="us-west-2")

# Wait for stack to be created (with timeout)
# max_attempts = 10
# for attempt in range(max_attempts):
# try:
# response = cf_client.describe_stacks(StackName=stack_name)
# stack_exists = True
# print(f"Stack found after {attempt + 1} attempts")
# break
# except Exception as e:
# if "does not exist" in str(e):
# print(f"Waiting for stack to be created (attempt {attempt + 1}/{max_attempts})")
# time.sleep(3) # Wait before retrying
# else:
# raise

# # Verify the stack was created
# assert stack_exists, f"Stack {stack_name} was not created within the timeout period"
#
# # Get the latest stack information
# response = cf_client.describe_stacks(StackName=stack_name)
# assert len(response['Stacks']) == 1
# assert response['Stacks'][0]['StackName'] == stack_name
# assert response['Stacks'][0]['StackStatus'] in [
# 'CREATE_IN_PROGRESS',
# 'CREATE_COMPLETE'
# ]
#
# # Verify tags were applied
# stack_tags = response['Stacks'][0]['Tags']
# assert any(tag['Key'] == 'Environment' and tag['Value'] == 'Test' for tag in stack_tags)
# assert any(tag['Key'] == 'Project' and tag['Value'] == 'HyperPod' for tag in stack_tags)
#
finally:
# Clean up - delete the stack if it exists
if stack_exists:
try:
cf_client.delete_stack(StackName=stack_name)
print(f"Stack {stack_name} deletion initiated")
except Exception as e:
print(f"Error deleting stack: {e}")

@pytest.mark.dependency(name="list_stacks")
def test_list_stacks(self):
Expand Down
Loading