Skip to content

Commit 17114df

Browse files
authored
chore(test): update skip condition for LMI test (#8562)
* chore(test): update skip condition for LMI test * update skip message * remove additional : * fix make pr
1 parent 1edba25 commit 17114df

7 files changed

Lines changed: 30 additions & 41 deletions

File tree

tests/integration/deploy/test_deploy_command.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,16 +1756,16 @@ def test_deploy_with_valid_config_capabilities_string(self, template_file, confi
17561756
deploy_process_execute = self.run_command(deploy_command_list)
17571757
self.assertEqual(deploy_process_execute.process.returncode, 0)
17581758

1759-
@skipIf(SKIP_LMI_TESTS, "Skip LMI tests when running on canary")
1759+
@skipIf(
1760+
SKIP_LMI_TESTS,
1761+
'Skip LMI tests because required environment variables not set: "LMI_SUBNET_ID", "LMI_SECURITY_GROUP_ID"',
1762+
)
17601763
def test_deploy_lmi_function(self):
17611764
"""Test deployment of LMI (Lambda Managed Infrastructure) functions with capacity providers."""
17621765
# Validate LMI environment variables are set
17631766
lmi_subnet_id = os.environ.get("LMI_SUBNET_ID")
17641767
lmi_security_group_id = os.environ.get("LMI_SECURITY_GROUP_ID")
17651768

1766-
self.assertTrue(lmi_subnet_id, "LMI_SUBNET_ID environment variable must be set")
1767-
self.assertTrue(lmi_security_group_id, "LMI_SECURITY_GROUP_ID environment variable must be set")
1768-
17691769
template_path = self.test_data_path.joinpath("lmi_function", "template.yaml")
17701770
stack_name = self._method_to_stack_name(self.id())
17711771
self.stacks.append({"name": stack_name})

tests/integration/remote/invoke/test_lambda_invoke_response_stream.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,17 @@ def test_invoke_different_boto_options(self):
105105
self.assertEqual(response_event_stream, expected_output_result)
106106

107107

108-
@skipIf(SKIP_LMI_TESTS, "Skip LMI tests when running on canary")
108+
@skipIf(
109+
SKIP_LMI_TESTS,
110+
'Skip LMI tests because required environment variables not set: "LMI_SUBNET_ID", "LMI_SECURITY_GROUP_ID"',
111+
)
109112
class TestInvokeResponseStreamingCapacityProvider(RemoteInvokeIntegBase):
110113
template = Path("template-lambda-response-capacity-provider-stream-fn.yaml")
111114

112115
@classmethod
113116
def setUpClass(cls):
114-
if SKIP_LMI_TESTS:
115-
raise SkipTest("Skip LMI tests when running on canary")
116117
super().setUpClass()
117118
cls.stack_name = f"{cls.__name__}-{uuid.uuid4().hex}"
118-
# LMI is Lambda Managed Instance
119-
assert os.environ.get("LMI_SUBNET_ID"), "LMI_SUBNET_ID environment variable must be set"
120-
assert os.environ.get("LMI_SECURITY_GROUP_ID"), "LMI_SECURITY_GROUP_ID environment variable must be set"
121119

122120
# Read LMI infrastructure from environment variables
123121
cls.parameter_overrides = {

tests/integration/remote/invoke/test_remote_invoke.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,17 @@
1717
SQS_WAIT_TIME_SECONDS = 20
1818

1919

20-
@skipIf(SKIP_LMI_TESTS, "Skip LMI tests when running on canary")
20+
@skipIf(
21+
SKIP_LMI_TESTS,
22+
'Skip LMI tests because required environment variables not set: "LMI_SUBNET_ID", "LMI_SECURITY_GROUP_ID"',
23+
)
2124
class TestingInvokeWithCapacityProvider(RemoteInvokeIntegBase):
2225
template = Path("template-single-lambda-capacity-provider.yaml")
2326

2427
@classmethod
2528
def setUpClass(cls):
26-
if SKIP_LMI_TESTS:
27-
raise SkipTest("Skip LMI tests when running on canary")
2829
super().setUpClass()
2930
cls.stack_name = f"{cls.__name__}-{uuid.uuid4().hex}"
30-
# LMI is Lambda Managed Instance
31-
assert os.environ.get("LMI_SUBNET_ID"), "LMI_SUBNET_ID environment variable must be set"
32-
assert os.environ.get("LMI_SECURITY_GROUP_ID"), "LMI_SECURITY_GROUP_ID environment variable must be set"
3331

3432
# Read LMI infrastructure from environment variables
3533
cls.parameter_overrides = {

tests/integration/sync/test_sync_code.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import uuid
1010
from pathlib import Path
1111
from typing import Dict
12-
from unittest import skipIf, SkipTest
12+
from unittest import skipIf
1313

1414

1515
import pytest
@@ -803,7 +803,10 @@ def test_skip_build(self):
803803
]
804804
)
805805
@pytest.mark.timeout(300)
806-
@skipIf(SKIP_LMI_TESTS, "Skip LMI tests when running on canary")
806+
@skipIf(
807+
SKIP_LMI_TESTS,
808+
'Skip LMI tests because required environment variables not set: "LMI_SUBNET_ID", "LMI_SECURITY_GROUP_ID"',
809+
)
807810
class TestSyncCodeLMI(TestSyncCodeBase):
808811
"""Test sync code operations with Lambda Managed Instance functions"""
809812

@@ -812,12 +815,7 @@ class TestSyncCodeLMI(TestSyncCodeBase):
812815

813816
@classmethod
814817
def setUpClass(cls) -> None:
815-
if SKIP_LMI_TESTS:
816-
raise SkipTest("Skip LMI tests when running on canary")
817818
super().setUpClass()
818-
# Validate LMI environment variables are set
819-
assert os.environ.get("LMI_SUBNET_ID"), "LMI_SUBNET_ID environment variable must be set"
820-
assert os.environ.get("LMI_SECURITY_GROUP_ID"), "LMI_SECURITY_GROUP_ID environment variable must be set"
821819

822820
# Read LMI infrastructure from environment variables
823821
cls.parameter_overrides = {

tests/integration/sync/test_sync_infra.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,10 @@ def test_sync_infra_esbuild(self, template_file):
587587
self.assertEqual(lambda_response.get("message"), "hello world")
588588

589589

590-
@skipIf(SKIP_LMI_TESTS, "Skip LMI tests when running on canary")
590+
@skipIf(
591+
SKIP_LMI_TESTS,
592+
'Skip LMI tests because required environment variables not set: "LMI_SUBNET_ID", "LMI_SECURITY_GROUP_ID"',
593+
)
591594
@parameterized_class(
592595
[
593596
{"dependency_layer": True},
@@ -603,13 +606,7 @@ class TestSyncInfraLMI(SyncIntegBase):
603606

604607
@classmethod
605608
def setUpClass(cls) -> None:
606-
if SKIP_LMI_TESTS:
607-
raise SkipTest("Skip LMI tests when running on canary")
608609
super().setUpClass()
609-
# Validate LMI environment variables are set
610-
assert os.environ.get("LMI_SUBNET_ID"), "LMI_SUBNET_ID environment variable must be set"
611-
assert os.environ.get("LMI_SECURITY_GROUP_ID"), "LMI_SECURITY_GROUP_ID environment variable must be set"
612-
613610
# Read LMI infrastructure from environment variables
614611
cls.parameter_overrides = {
615612
"SubnetId": os.environ.get("LMI_SUBNET_ID", ""),

tests/integration/sync/test_sync_watch.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,10 @@ def test_sync_watch_code_excludes(self):
869869
self.assertEqual(lambda_response.get("message"), "hello world")
870870

871871

872-
@skipIf(SKIP_LMI_TESTS, "Skip LMI tests when running on canary")
872+
@skipIf(
873+
SKIP_LMI_TESTS,
874+
'Skip LMI tests because required environment variables not set: "LMI_SUBNET_ID", "LMI_SECURITY_GROUP_ID"',
875+
)
873876
@parameterized_class([{"dependency_layer": True}, {"dependency_layer": False}])
874877
@pytest.mark.timeout(600) # 10 minutes timeout for LMI operations
875878
class TestSyncWatchCodeLMI(TestSyncWatchBase):
@@ -880,13 +883,6 @@ class TestSyncWatchCodeLMI(TestSyncWatchBase):
880883

881884
@classmethod
882885
def setUpClass(cls) -> None:
883-
# Skip the entire class if LMI tests should be skipped
884-
if SKIP_LMI_TESTS:
885-
raise SkipTest("Skip LMI tests when running on canary")
886-
887-
# Validate LMI environment variables are set
888-
assert os.environ.get("LMI_SUBNET_ID"), "LMI_SUBNET_ID environment variable must be set"
889-
assert os.environ.get("LMI_SECURITY_GROUP_ID"), "LMI_SECURITY_GROUP_ID environment variable must be set"
890886

891887
cls.template_before = str(Path("code", "before", "template-lmi-with-publish.yaml"))
892888
cls.parameter_overrides = {

tests/testing_utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
# Tests require docker suffers from Docker Hub request limit
4141
SKIP_DOCKER_TESTS = RUNNING_ON_CI and not RUN_BY_CANARY
4242

43-
# SKIP_LMI_TESTS = RUNNING_ON_CI and not RUN_BY_CANARY
44-
# SKIP LMI until test resource is deployed
45-
SKIP_LMI_TESTS = True
43+
44+
# SKIP LMI unless test resource is deployed in the test accounts
45+
# Check if required environment variables are available
46+
SKIP_LMI_TESTS = not all(os.environ.get(var) for var in ["LMI_SUBNET_ID", "LMI_SECURITY_GROUP_ID"])
47+
4648

4749
# Set to True temporarily if the integration tests require updated build images
4850
# Build images aren't published until after the CLI is released

0 commit comments

Comments
 (0)