diff --git a/tests/integration/local/invoke/test_integrations_cli.py b/tests/integration/local/invoke/test_integrations_cli.py index ab9b4074f6..3e4c63f64f 100644 --- a/tests/integration/local/invoke/test_integrations_cli.py +++ b/tests/integration/local/invoke/test_integrations_cli.py @@ -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")', ] diff --git a/tests/integration/local/start_api/test_start_api.py b/tests/integration/local/start_api/test_start_api.py index 1e75594f10..18a784380a 100644 --- a/tests/integration/local/start_api/test_start_api.py +++ b/tests/integration/local/start_api/test_start_api.py @@ -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): diff --git a/tests/integration/remote/invoke/test_remote_invoke.py b/tests/integration/remote/invoke/test_remote_invoke.py index a1eb3581ea..3db2847407 100644 --- a/tests/integration/remote/invoke/test_remote_invoke.py +++ b/tests/integration/remote/invoke/test_remote_invoke.py @@ -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, diff --git a/tests/integration/testdata/remote_invoke/template-multi-tenant.yaml b/tests/integration/testdata/remote_invoke/template-multi-tenant.yaml new file mode 100644 index 0000000000..ad9b615d27 --- /dev/null +++ b/tests/integration/testdata/remote_invoke/template-multi-tenant.yaml @@ -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 diff --git a/tests/integration/testdata/remote_invoke/template-single-lambda.yaml b/tests/integration/testdata/remote_invoke/template-single-lambda.yaml index 27e47e54aa..7ca9b259db 100644 --- a/tests/integration/testdata/remote_invoke/template-single-lambda.yaml +++ b/tests/integration/testdata/remote_invoke/template-single-lambda.yaml @@ -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 \ No newline at end of file + CodeUri: ./lambda-fns \ No newline at end of file diff --git a/tests/integration/testdata/start_api/template-http-api-multi-tenant.yaml b/tests/integration/testdata/start_api/template-http-api-multi-tenant.yaml new file mode 100644 index 0000000000..fba102e77c --- /dev/null +++ b/tests/integration/testdata/start_api/template-http-api-multi-tenant.yaml @@ -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 diff --git a/tests/integration/testdata/start_api/template-http-api.yaml b/tests/integration/testdata/start_api/template-http-api.yaml index f604180368..6dca43b6f2 100644 --- a/tests/integration/testdata/start_api/template-http-api.yaml +++ b/tests/integration/testdata/start_api/template-http-api.yaml @@ -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 diff --git a/tests/integration/testdata/start_api/template-multi-tenant.yaml b/tests/integration/testdata/start_api/template-multi-tenant.yaml new file mode 100644 index 0000000000..154fdc6131 --- /dev/null +++ b/tests/integration/testdata/start_api/template-multi-tenant.yaml @@ -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 diff --git a/tests/integration/testdata/start_api/template.yaml b/tests/integration/testdata/start_api/template.yaml index b340315aa0..bd26c21c0b 100644 --- a/tests/integration/testdata/start_api/template.yaml +++ b/tests/integration/testdata/start_api/template.yaml @@ -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