Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion tests/integration/local/invoke/test_integrations_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ def test_function_exception(self):
stack_trace_lines = [
"[ERROR] Exception: Lambda is raising an exception",
"Traceback (most recent call last):",
'\xa0\xa0File "/var/task/main.py", line 51, in raise_exception',
'\xa0\xa0File "/var/task/main.py", line 65, in raise_exception',
'\xa0\xa0\xa0\xa0raise Exception("Lambda is raising an exception")',
]

Expand Down
11 changes: 11 additions & 0 deletions tests/integration/local/start_api/test_start_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,17 @@ def test_invalid_lambda_json_body_response(self):
self.assertEqual(response.json(), {"message": "Internal server error"})
self.assertEqual(response.raw.version, 11)


class TestMultiTenantStartApi(StartApiIntegBaseClass):
"""
Test multi-tenant Lambda functions with start-api
"""

template_path = "/testdata/start_api/template-http-api-multi-tenant.yaml"

def setUp(self):
self.url = "http://127.0.0.1:{}".format(self.port)

@pytest.mark.flaky(reruns=3)
@pytest.mark.timeout(timeout=600, method="thread")
def test_multi_tenant_function_http_api_with_tenant_id(self):
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/remote/invoke/test_remote_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ def test_invoke_response_json_output_format(self):
self.assertEqual(response_payload, {"message": "Hello world"})
self.assertEqual(remote_invoke_result_stdout["StatusCode"], 200)


@pytest.mark.xdist_group(name="sam_remote_invoke_multi_tenant")
class TestMultiTenantRemoteInvoke(RemoteInvokeIntegBase):
template = Path("template-multi-tenant.yaml")

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.stack_name = f"{cls.__name__}-{uuid.uuid4().hex}"
cls.create_resources_and_boto_clients()

def test_multi_tenant_function_with_tenant_id(self):
command_list = self.get_command_list(
stack_name=self.stack_name,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Resources:
MultiTenantFunction:
Type: AWS::Serverless::Function
Properties:
Handler: lambda-fns/main.multi_tenant_handler
Runtime: python3.9
CodeUri: .
Timeout: 600
TenancyConfig:
TenantIsolationMode: PER_TENANT
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,4 @@ Resources:
Properties:
Handler: main.default_handler
Runtime: python3.9
CodeUri: ./lambda-fns

MultiTenantFunction:
Type: AWS::Serverless::Function
Properties:
Handler: main.multi_tenant_handler
Runtime: python3.9
CodeUri: ./lambda-fns
TenancyConfig:
TenantIsolationMode: PER_TENANT
CodeUri: ./lambda-fns
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Resources:
MultiTenantApiFunction:
Type: AWS::Serverless::Function
Properties:
Handler: main.multi_tenant_handler
Runtime: python3.9
CodeUri: .
Timeout: 600
TenancyConfig:
TenantIsolationMode: PER_TENANT
Events:
HttpApi:
Type: HttpApi
Properties:
Path: /multi-tenant-http
Method: get
15 changes: 0 additions & 15 deletions tests/integration/testdata/start_api/template-http-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -359,18 +359,3 @@ Resources:
Properties:
Method: GET
Path: /multipleheadersoverridesheaders
MultiTenantApiFunction:
Type: AWS::Serverless::Function
Properties:
Handler: main.multi_tenant_handler
Runtime: python3.9
CodeUri: .
Timeout: 600
TenancyConfig:
TenantIsolationMode: PER_TENANT
Events:
HttpApi:
Type: HttpApi
Properties:
Path: /multi-tenant-http
Method: get
31 changes: 31 additions & 0 deletions tests/integration/testdata/start_api/template-multi-tenant.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Globals:
Api:
Cors:
AllowMethods: "'*'"
AllowHeaders: "'*'"
AllowOrigin: "'*'"

Resources:
MultiTenantApiFunction:
Type: AWS::Serverless::Function
Properties:
Handler: main.multi_tenant_handler
Runtime: python3.9
CodeUri: .
Timeout: 600
TenancyConfig:
TenantIsolationMode: PER_TENANT
Events:
RestApi:
Type: Api
Properties:
Path: /multi-tenant-rest
Method: get
HttpApi:
Type: HttpApi
Properties:
Path: /multi-tenant-http
Method: get
21 changes: 0 additions & 21 deletions tests/integration/testdata/start_api/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,24 +301,3 @@ Resources:
Properties:
Path: /sleepfortensecondszipped
Method: get

MultiTenantApiFunction:
Type: AWS::Serverless::Function
Properties:
Handler: main.multi_tenant_handler
Runtime: python3.9
CodeUri: .
Timeout: 600
TenancyConfig:
TenantIsolationMode: PER_TENANT
Events:
RestApi:
Type: Api
Properties:
Path: /multi-tenant-rest
Method: get
HttpApi:
Type: HttpApi
Properties:
Path: /multi-tenant-http
Method: get
Loading