diff --git a/tests/integration/buildcmd/test_build_cmd.py b/tests/integration/buildcmd/test_build_cmd.py index d21d3a9f0f1..d1e25a1969c 100644 --- a/tests/integration/buildcmd/test_build_cmd.py +++ b/tests/integration/buildcmd/test_build_cmd.py @@ -1588,6 +1588,13 @@ def test_nested_build(self, use_container, cached, parallel): ) +@parameterized_class( + ("template", "use_base_dir"), + [ + (os.path.join("deep-nested", "template.yaml"), False), + (os.path.join("base-dir", "template", "template.yaml"), "use_base_dir"), + ], +) class TestBuildWithNestedStacks3Level(NestedBuildIntegBase): """ In this template, it has the same structure as .aws-sam/build @@ -1610,7 +1617,12 @@ def test_nested_build(self): if SKIP_DOCKER_TESTS: self.skipTest(SKIP_DOCKER_MESSAGE) - cmdlist = self.get_command_list(use_container=True, cached=True, parallel=True) + cmdlist = self.get_command_list( + use_container=True, + cached=True, + parallel=True, + base_dir=(os.path.join(self.test_data_path, "base-dir") if self.use_base_dir else None), + ) LOG.info("Running Command: %s", cmdlist) LOG.info(self.working_dir) diff --git a/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/FunctionA/main_a_2.py b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/FunctionA/main_a_2.py new file mode 100644 index 00000000000..c1098a40c28 --- /dev/null +++ b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/FunctionA/main_a_2.py @@ -0,0 +1,8 @@ +import json + + +def handler(event, context): + """ + FunctionA in leaf template + """ + return {"statusCode": 200, "body": json.dumps({"hello": "a2"})} diff --git a/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/FunctionA/requirements.txt b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/FunctionA/requirements.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/MyLayerVersion/__init__.py b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/MyLayerVersion/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/MyLayerVersion/my_layer/__init__.py b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/MyLayerVersion/my_layer/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/MyLayerVersion/my_layer/requirements.txt b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/MyLayerVersion/my_layer/requirements.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/MyLayerVersion/my_layer/simple_python.py b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/MyLayerVersion/my_layer/simple_python.py new file mode 100644 index 00000000000..1998a450d7c --- /dev/null +++ b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/MyLayerVersion/my_layer/simple_python.py @@ -0,0 +1,2 @@ +def layer_ping(): + return "This is a Layer Ping from simple_python" diff --git a/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/template.yaml b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/template.yaml new file mode 100644 index 00000000000..c87a76fc2e0 --- /dev/null +++ b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/ChildStackY/template.yaml @@ -0,0 +1,21 @@ +AWSTemplateFormatVersion : '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: A hello world application. + +Resources: + FunctionA: + Type: AWS::Serverless::Function + Properties: + Handler: main_a_2.handler + Runtime: python3.7 + CodeUri: ChildStackX/ChildStackY/FunctionA + Timeout: 600 + + MyLayerVersion: + Type: AWS::Serverless::LayerVersion + Properties: + LayerName: MyLayer + Description: Layer description + ContentUri: ChildStackX/ChildStackY/MyLayerVersion + CompatibleRuntimes: + - python3.7 \ No newline at end of file diff --git a/tests/integration/testdata/buildcmd/base-dir/ChildStackX/FunctionB/main_b.py b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/FunctionB/main_b.py new file mode 100644 index 00000000000..c879b04a979 --- /dev/null +++ b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/FunctionB/main_b.py @@ -0,0 +1,8 @@ +import json + + +def handler(event, context): + """ + FunctionB in child template + """ + return {"statusCode": 200, "body": json.dumps({"hello": "b"})} diff --git a/tests/integration/testdata/buildcmd/base-dir/ChildStackX/FunctionB/requirements.txt b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/FunctionB/requirements.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/integration/testdata/buildcmd/base-dir/ChildStackX/template.yaml b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/template.yaml new file mode 100644 index 00000000000..14d70104d4d --- /dev/null +++ b/tests/integration/testdata/buildcmd/base-dir/ChildStackX/template.yaml @@ -0,0 +1,17 @@ +AWSTemplateFormatVersion : '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: A hello world application. + +Resources: + FunctionB: + Type: AWS::Serverless::Function + Properties: + Handler: main_b.handler + Runtime: python3.7 + CodeUri: ChildStackX/FunctionB + Timeout: 600 + + ChildStackY: + Type: AWS::Serverless::Application + Properties: + Location: ChildStackY/template.yaml diff --git a/tests/integration/testdata/buildcmd/base-dir/FunctionA/main_a.py b/tests/integration/testdata/buildcmd/base-dir/FunctionA/main_a.py new file mode 100644 index 00000000000..3279b0789b8 --- /dev/null +++ b/tests/integration/testdata/buildcmd/base-dir/FunctionA/main_a.py @@ -0,0 +1,8 @@ +import json + + +def handler(event, context): + """ + FunctionA in root template + """ + return {"statusCode": 200, "body": json.dumps({"hello": "a"})} diff --git a/tests/integration/testdata/buildcmd/base-dir/FunctionA/requirements.txt b/tests/integration/testdata/buildcmd/base-dir/FunctionA/requirements.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/integration/testdata/buildcmd/base-dir/template/template.yaml b/tests/integration/testdata/buildcmd/base-dir/template/template.yaml new file mode 100644 index 00000000000..4dbd1e5de95 --- /dev/null +++ b/tests/integration/testdata/buildcmd/base-dir/template/template.yaml @@ -0,0 +1,17 @@ +AWSTemplateFormatVersion : '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: A hello world application. + +Resources: + FunctionA: + Type: AWS::Serverless::Function + Properties: + Handler: main_a.handler + Runtime: python3.7 + CodeUri: FunctionA + Timeout: 600 + + ChildStackX: + Type: AWS::Serverless::Application + Properties: + Location: ChildStackX/template.yaml