diff --git a/README.md b/README.md index 7dacf629fb..b4f254d42c 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Project Status - \[x\] `nodejs4.3` - \[x\] `nodejs6.10` - \[x\] `nodejs8.10` + - \[x\] `nodejs10.x` - \[x\] `java8` - \[x\] `python2.7` - \[x\] `python3.6` @@ -91,6 +92,7 @@ Project Status - \[x\] `nodejs4.3` - \[x\] `nodejs6.10` - \[x\] `nodejs8.10` + - \[x\] `nodejs10.x` - \[x\] `java8` - \[x\] `python2.7` - \[x\] `python3.6` diff --git a/samcli/commands/build/command.py b/samcli/commands/build/command.py index 6a95e65744..f80dca0d83 100644 --- a/samcli/commands/build/command.py +++ b/samcli/commands/build/command.py @@ -33,7 +33,7 @@ Supported Runtimes ------------------ 1. Python 2.7, 3.6, 3.7 using PIP\n -2. Nodejs 8.10, 6.10 using NPM\n +2. Nodejs 10.x, 8.10, 6.10 using NPM\n 3. Ruby 2.5 using Bundler\n 4. Java 8 using Gradle\n 5. Dotnetcore2.0 and 2.1 using Dotnet CLI (without --use-container flag)\n diff --git a/samcli/commands/init/__init__.py b/samcli/commands/init/__init__.py index e015a08df5..90cf870900 100644 --- a/samcli/commands/init/__init__.py +++ b/samcli/commands/init/__init__.py @@ -103,7 +103,9 @@ def do_cli(ctx, location, runtime, dependency_manager, output_dir, name, no_inpu """.format(output_dir=output_dir, name=name) no_build_step_required = ( - "python", "python3.7", "python3.6", "python2.7", "nodejs", "nodejs4.3", "nodejs6.10", "nodejs8.10", "ruby2.5") + "python", "python3.7", "python3.6", "python2.7", "nodejs", + "nodejs4.3", "nodejs6.10", "nodejs8.10", "nodejs10.x", "ruby2.5" + ) next_step_msg = no_build_msg if runtime in no_build_step_required else build_msg try: diff --git a/samcli/commands/local/invoke/cli.py b/samcli/commands/local/invoke/cli.py index 071a5d5143..50c96e4d2a 100644 --- a/samcli/commands/local/invoke/cli.py +++ b/samcli/commands/local/invoke/cli.py @@ -14,7 +14,7 @@ from samcli.commands.validate.lib.exceptions import InvalidSamDocumentException from samcli.commands.local.lib.exceptions import OverridesNotWellDefinedError from samcli.local.docker.manager import DockerImagePullFailedException -from samcli.local.docker.lambda_container import DebuggingNotSupported +from samcli.local.docker.lambda_debug_entrypoint import DebuggingNotSupported LOG = logging.getLogger(__name__) diff --git a/samcli/commands/local/start_api/cli.py b/samcli/commands/local/start_api/cli.py index 1a24c34908..b4928de7e6 100644 --- a/samcli/commands/local/start_api/cli.py +++ b/samcli/commands/local/start_api/cli.py @@ -13,7 +13,7 @@ from samcli.commands.local.lib.local_api_service import LocalApiService from samcli.commands.validate.lib.exceptions import InvalidSamDocumentException from samcli.commands.local.lib.exceptions import OverridesNotWellDefinedError -from samcli.local.docker.lambda_container import DebuggingNotSupported +from samcli.local.docker.lambda_debug_entrypoint import DebuggingNotSupported LOG = logging.getLogger(__name__) diff --git a/samcli/commands/local/start_lambda/cli.py b/samcli/commands/local/start_lambda/cli.py index 6e7705d3b2..b27c479151 100644 --- a/samcli/commands/local/start_lambda/cli.py +++ b/samcli/commands/local/start_lambda/cli.py @@ -13,7 +13,7 @@ from samcli.commands.local.lib.local_lambda_service import LocalLambdaService from samcli.commands.validate.lib.exceptions import InvalidSamDocumentException from samcli.commands.local.lib.exceptions import OverridesNotWellDefinedError -from samcli.local.docker.lambda_container import DebuggingNotSupported +from samcli.local.docker.lambda_debug_entrypoint import DebuggingNotSupported LOG = logging.getLogger(__name__) diff --git a/samcli/lib/build/workflow_config.py b/samcli/lib/build/workflow_config.py index 28fe8e217e..475e036594 100644 --- a/samcli/lib/build/workflow_config.py +++ b/samcli/lib/build/workflow_config.py @@ -98,6 +98,7 @@ def get_workflow_config(runtime, code_dir, project_dir): "nodejs4.3": BasicWorkflowSelector(NODEJS_NPM_CONFIG), "nodejs6.10": BasicWorkflowSelector(NODEJS_NPM_CONFIG), "nodejs8.10": BasicWorkflowSelector(NODEJS_NPM_CONFIG), + "nodejs10.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG), "ruby2.5": BasicWorkflowSelector(RUBY_BUNDLER_CONFIG), "dotnetcore2.0": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG), "dotnetcore2.1": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG), diff --git a/samcli/local/common/runtime_template.py b/samcli/local/common/runtime_template.py index 528732801b..ef67fe93ea 100644 --- a/samcli/local/common/runtime_template.py +++ b/samcli/local/common/runtime_template.py @@ -32,7 +32,7 @@ ], "nodejs": [ { - "runtimes": ["nodejs8.10"], + "runtimes": ["nodejs8.10", "nodejs10.x"], "dependency_manager": "npm", "init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs"), "build": True diff --git a/samcli/local/docker/lambda_container.py b/samcli/local/docker/lambda_container.py index 1ebb9806d0..a3bffa7f55 100644 --- a/samcli/local/docker/lambda_container.py +++ b/samcli/local/docker/lambda_container.py @@ -2,8 +2,8 @@ Represents Lambda runtime containers. """ import logging -import json +from samcli.local.docker.lambda_debug_entrypoint import LambdaDebugEntryPoint from .container import Container from .lambda_image import Runtime @@ -25,6 +25,9 @@ class LambdaContainer(Container): _DEBUGGER_VOLUME_MOUNT_PATH = "/tmp/lambci_debug_files" _DEFAULT_CONTAINER_DBG_GO_PATH = _DEBUGGER_VOLUME_MOUNT_PATH + "/dlv" + # Options for selecting debug entry point + _DEBUG_ENTRYPOINT_OPTIONS = {"delvePath": _DEFAULT_CONTAINER_DBG_GO_PATH} + # This is the dictionary that represents where the debugger_path arg is mounted in docker to as readonly. _DEBUGGER_VOLUME_MOUNT = {"bind": _DEBUGGER_VOLUME_MOUNT_PATH, "mode": "ro"} @@ -174,10 +177,6 @@ def _get_entry_point(runtime, debug_options=None): # pylint: disable=too-many-b if not debug_options: return None - if runtime not in LambdaContainer._supported_runtimes(): - raise DebuggingNotSupported( - "Debugging is not currently supported for {}".format(runtime)) - debug_port = debug_options.debug_port debug_args_list = [] @@ -186,130 +185,7 @@ def _get_entry_point(runtime, debug_options=None): # pylint: disable=too-many-b # configs from: https://github.com/lambci/docker-lambda # to which we add the extra debug mode options - entrypoint = None - if runtime == Runtime.java8.value: - - entrypoint = ["/usr/bin/java"] \ - + debug_args_list \ - + [ - "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,address=" + str(debug_port), - "-XX:MaxHeapSize=2834432k", - "-XX:MaxMetaspaceSize=163840k", - "-XX:ReservedCodeCacheSize=81920k", - "-XX:+UseSerialGC", - # "-Xshare:on", doesn't work in conjunction with the debug options - "-XX:-TieredCompilation", - "-Djava.net.preferIPv4Stack=true", - "-jar", - "/var/runtime/lib/LambdaJavaRTEntry-1.0.jar", - ] - - elif runtime in (Runtime.dotnetcore20.value, Runtime.dotnetcore21.value): - entrypoint = ["/var/lang/bin/dotnet"] \ - + debug_args_list \ - + [ - "/var/runtime/MockBootstraps.dll", - "--debugger-spin-wait" - ] - - elif runtime == Runtime.go1x.value: - entrypoint = ["/var/runtime/aws-lambda-go"] \ - + debug_args_list \ - + [ - "-debug=true", - "-delvePort=" + str(debug_port), - "-delvePath=" + LambdaContainer._DEFAULT_CONTAINER_DBG_GO_PATH, - ] - - elif runtime == Runtime.nodejs.value: - - entrypoint = ["/usr/bin/node"] \ - + debug_args_list \ - + [ - "--debug-brk=" + str(debug_port), - "--nolazy", - "--max-old-space-size=1229", - "--max-new-space-size=153", - "--max-executable-size=153", - "--expose-gc", - "/var/runtime/node_modules/awslambda/bin/awslambda", - ] - - elif runtime == Runtime.nodejs43.value: - - entrypoint = ["/usr/local/lib64/node-v4.3.x/bin/node"] \ - + debug_args_list \ - + [ - "--debug-brk=" + str(debug_port), - "--nolazy", - "--max-old-space-size=2547", - "--max-semi-space-size=150", - "--max-executable-size=160", - "--expose-gc", - "/var/runtime/node_modules/awslambda/index.js", - ] - - elif runtime == Runtime.nodejs610.value: - - entrypoint = ["/var/lang/bin/node"] \ - + debug_args_list \ - + [ - "--debug-brk=" + str(debug_port), - "--nolazy", - "--max-old-space-size=2547", - "--max-semi-space-size=150", - "--max-executable-size=160", - "--expose-gc", - "/var/runtime/node_modules/awslambda/index.js", - ] - - elif runtime == Runtime.nodejs810.value: - - entrypoint = ["/var/lang/bin/node"] \ - + debug_args_list \ - + [ - # Node8 requires the host to be explicitly set in order to bind to localhost - # instead of 127.0.0.1. https://github.com/nodejs/node/issues/11591#issuecomment-283110138 - "--inspect-brk=0.0.0.0:" + str(debug_port), - "--nolazy", - "--expose-gc", - "--max-semi-space-size=150", - "--max-old-space-size=2707", - "/var/runtime/node_modules/awslambda/index.js", - ] - - elif runtime == Runtime.python27.value: - - entrypoint = ["/usr/bin/python2.7"] \ - + debug_args_list \ - + [ - "/var/runtime/awslambda/bootstrap.py" - ] - - elif runtime == Runtime.python36.value: - - entrypoint = ["/var/lang/bin/python3.6"] \ - + debug_args_list \ - + [ - "/var/runtime/awslambda/bootstrap.py" - ] - - elif runtime == Runtime.python37.value: - entrypoint = ["/var/rapid/init", - "--bootstrap", - "/var/lang/bin/python3.7", - "--bootstrap-args", - json.dumps(debug_args_list + ["/var/runtime/bootstrap"]) - ] - - return entrypoint - - @staticmethod - def _supported_runtimes(): - return {Runtime.java8.value, Runtime.dotnetcore20.value, Runtime.dotnetcore21.value, Runtime.go1x.value, - Runtime.nodejs.value, Runtime.nodejs43.value, Runtime.nodejs610.value, Runtime.nodejs810.value, - Runtime.python27.value, Runtime.python36.value, Runtime.python37.value} - - -class DebuggingNotSupported(Exception): - pass + return LambdaDebugEntryPoint.get_entry_point(debug_port=debug_port, + debug_args_list=debug_args_list, + runtime=runtime, + options=LambdaContainer._DEBUG_ENTRYPOINT_OPTIONS) diff --git a/samcli/local/docker/lambda_debug_entrypoint.py b/samcli/local/docker/lambda_debug_entrypoint.py new file mode 100644 index 0000000000..f382adfa7c --- /dev/null +++ b/samcli/local/docker/lambda_debug_entrypoint.py @@ -0,0 +1,148 @@ +""" +Represents Lambda debug entrypoints. +""" + +import json + +from samcli.local.docker.lambda_image import Runtime + + +class DebuggingNotSupported(Exception): + pass + + +class LambdaDebugEntryPoint(object): + + @staticmethod + def get_entry_point(debug_port, debug_args_list, runtime, options): + + entrypoint_mapping = { + Runtime.java8.value: + ["/usr/bin/java"] + + debug_args_list + + [ + "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,address=" + str(debug_port), + "-XX:MaxHeapSize=2834432k", + "-XX:MaxMetaspaceSize=163840k", + "-XX:ReservedCodeCacheSize=81920k", + "-XX:+UseSerialGC", + # "-Xshare:on", doesn't work in conjunction with the debug options + "-XX:-TieredCompilation", + "-Djava.net.preferIPv4Stack=true", + "-jar", + "/var/runtime/lib/LambdaJavaRTEntry-1.0.jar" + ], + + Runtime.dotnetcore20.value: + ["/var/lang/bin/dotnet"] + \ + debug_args_list + \ + [ + "/var/runtime/MockBootstraps.dll", + "--debugger-spin-wait" + ], + + Runtime.dotnetcore21.value: + ["/var/lang/bin/dotnet"] + \ + debug_args_list + \ + [ + "/var/runtime/MockBootstraps.dll", + "--debugger-spin-wait" + ], + Runtime.go1x.value: + ["/var/runtime/aws-lambda-go"] + \ + debug_args_list + \ + [ + "-debug=true", + "-delvePort=" + str(debug_port), + "-delvePath=" + options.get("delvePath"), + ], + Runtime.nodejs.value: + ["/usr/bin/node"] + \ + debug_args_list + \ + [ + "--debug-brk=" + str(debug_port), + "--nolazy", + "--max-old-space-size=1229", + "--max-new-space-size=153", + "--max-executable-size=153", + "--expose-gc", + "/var/runtime/node_modules/awslambda/bin/awslambda", + ], + Runtime.nodejs43.value: + ["/usr/local/lib64/node-v4.3.x/bin/node"] + \ + debug_args_list + \ + [ + "--debug-brk=" + str(debug_port), + "--nolazy", + "--max-old-space-size=2547", + "--max-semi-space-size=150", + "--max-executable-size=160", + "--expose-gc", + "/var/runtime/node_modules/awslambda/index.js", + ], + Runtime.nodejs610.value: + ["/var/lang/bin/node"] + \ + debug_args_list + \ + [ + "--debug-brk=" + str(debug_port), + "--nolazy", + "--max-old-space-size=2547", + "--max-semi-space-size=150", + "--max-executable-size=160", + "--expose-gc", + "/var/runtime/node_modules/awslambda/index.js", + ], + Runtime.nodejs810.value: + ["/var/lang/bin/node"] + \ + debug_args_list + \ + [ + # Node8 requires the host to be explicitly set in order to bind to localhost + # instead of 127.0.0.1. https://github.com/nodejs/node/issues/11591#issuecomment-283110138 + "--inspect-brk=0.0.0.0:" + str(debug_port), + "--nolazy", + "--expose-gc", + "--max-semi-space-size=150", + "--max-old-space-size=2707", + "/var/runtime/node_modules/awslambda/index.js", + ], + Runtime.nodejs10x.value: + ["/var/rapid/init", + "--bootstrap", + "/var/lang/bin/node", + "--bootstrap-args", + json.dumps(debug_args_list + + [ + "--inspect-brk=0.0.0.0:" + str(debug_port), + "--nolazy", + "--expose-gc", + "--max-http-header-size", + "81920", + "/var/runtime/index.js" + ] + ) + ], + Runtime.python27.value: + ["/usr/bin/python2.7"] + \ + debug_args_list + \ + [ + "/var/runtime/awslambda/bootstrap.py" + ], + Runtime.python36.value: + ["/var/lang/bin/python3.6"] + + debug_args_list + \ + [ + "/var/runtime/awslambda/bootstrap.py" + ], + Runtime.python37.value: + ["/var/rapid/init", + "--bootstrap", + "/var/lang/bin/python3.7", + "--bootstrap-args", + json.dumps(debug_args_list + ["/var/runtime/bootstrap"]) + ] + } + try: + return entrypoint_mapping[runtime] + except KeyError: + raise DebuggingNotSupported( + "Debugging is not currently supported for {}".format(runtime)) diff --git a/samcli/local/docker/lambda_image.py b/samcli/local/docker/lambda_image.py index 05c70980a1..9afc9d341f 100644 --- a/samcli/local/docker/lambda_image.py +++ b/samcli/local/docker/lambda_image.py @@ -25,6 +25,7 @@ class Runtime(Enum): nodejs43 = "nodejs4.3" nodejs610 = "nodejs6.10" nodejs810 = "nodejs8.10" + nodejs10x = "nodejs10.x" python27 = "python2.7" python36 = "python3.6" python37 = "python3.7" diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/README.md b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/README.md index 614a9a5b7a..9222daa182 100644 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/README.md +++ b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/README.md @@ -10,6 +10,7 @@ A cookiecutter template to create a NodeJS Hello world boilerplate using [Server Generate a boilerplate template in your current project directory using the following syntax: +* **NodeJS 10**: `sam init --runtime nodejs10.x` * **NodeJS 8**: `sam init --runtime nodejs8.10` > **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default) diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/cookiecutter.json b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/cookiecutter.json index 1462701ea8..60b6c69147 100644 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/cookiecutter.json +++ b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/cookiecutter.json @@ -1,4 +1,4 @@ { "project_name": "Name of the project", - "runtime": "nodejs8.10" + "runtime": "nodejs10.x" } \ No newline at end of file diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/README.md b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/README.md index ee97f83fbf..29c6a66896 100644 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/README.md +++ b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/README.md @@ -18,7 +18,12 @@ This is a sample template for {{ cookiecutter.project_name }} - Below is a brief ## Requirements * AWS CLI already configured with Administrator permission -* [NodeJS 8.10+ installed](https://nodejs.org/en/download/) +{%- if cookiecutter.runtime == 'nodejs8.10' %} +* [NodeJS 8.10+ installed](https://nodejs.org/en/download/releases/) +{%- else %} +* [NodeJS 10.10+ installed](https://nodejs.org/en/download/releases/) +{%- endif %} + * [Docker installed](https://www.docker.com/community-edition) ## Setup process diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/hello-world/package.json b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/hello-world/package.json index 6e5abce643..8f876665cc 100644 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/hello-world/package.json +++ b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/hello-world/package.json @@ -13,7 +13,7 @@ "test": "mocha tests/unit/" }, "devDependencies": { - "chai": "^4.1.2", - "mocha": "^5.1.1" + "chai": "^4.2.0", + "mocha": "^6.1.4" } } diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/template.yaml b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/template.yaml index a39cebc63c..3ffdbf536b 100644 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/template.yaml +++ b/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/{{cookiecutter.project_name}}/template.yaml @@ -16,7 +16,11 @@ Resources: Properties: CodeUri: hello-world/ Handler: app.lambdaHandler - Runtime: nodejs8.10 + {%- if cookiecutter.runtime == 'nodejs8.10' %} + Runtime: {{ cookiecutter.runtime }} + {%- else %} + Runtime: nodejs10.x + {%- endif %} Events: HelloWorld: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api diff --git a/tests/integration/buildcmd/test_build_cmd.py b/tests/integration/buildcmd/test_build_cmd.py index c180c32be2..0ca79efb5a 100644 --- a/tests/integration/buildcmd/test_build_cmd.py +++ b/tests/integration/buildcmd/test_build_cmd.py @@ -121,9 +121,11 @@ class TestBuildCommand_NodeFunctions(BuildIntegBase): ("nodejs4.3", False), ("nodejs6.10", False), ("nodejs8.10", False), + ("nodejs10.x", False), ("nodejs4.3", "use_container"), ("nodejs6.10", "use_container"), - ("nodejs8.10", "use_container") + ("nodejs8.10", "use_container"), + ("nodejs10.x", "use_container") ]) def test_with_default_package_json(self, runtime, use_container): overrides = {"Runtime": runtime, "CodeUri": "Node", "Handler": "ignored"} diff --git a/tests/unit/commands/local/invoke/test_cli.py b/tests/unit/commands/local/invoke/test_cli.py index b4fdf459e8..8f6b514b36 100644 --- a/tests/unit/commands/local/invoke/test_cli.py +++ b/tests/unit/commands/local/invoke/test_cli.py @@ -13,7 +13,7 @@ from samcli.commands.local.invoke.cli import do_cli as invoke_cli, _get_event as invoke_cli_get_event from samcli.commands.local.lib.exceptions import OverridesNotWellDefinedError from samcli.local.docker.manager import DockerImagePullFailedException -from samcli.local.docker.lambda_container import DebuggingNotSupported +from samcli.local.docker.lambda_debug_entrypoint import DebuggingNotSupported STDIN_FILE_NAME = "-" diff --git a/tests/unit/commands/local/start_api/test_cli.py b/tests/unit/commands/local/start_api/test_cli.py index 13e2e02560..8dbb129ddb 100644 --- a/tests/unit/commands/local/start_api/test_cli.py +++ b/tests/unit/commands/local/start_api/test_cli.py @@ -12,7 +12,7 @@ from samcli.commands.exceptions import UserException from samcli.commands.validate.lib.exceptions import InvalidSamDocumentException from samcli.commands.local.lib.exceptions import OverridesNotWellDefinedError -from samcli.local.docker.lambda_container import DebuggingNotSupported +from samcli.local.docker.lambda_debug_entrypoint import DebuggingNotSupported class TestCli(TestCase): diff --git a/tests/unit/commands/local/start_lambda/test_cli.py b/tests/unit/commands/local/start_lambda/test_cli.py index cc22295abb..3656f8245c 100644 --- a/tests/unit/commands/local/start_lambda/test_cli.py +++ b/tests/unit/commands/local/start_lambda/test_cli.py @@ -8,7 +8,7 @@ from samcli.commands.local.cli_common.user_exceptions import UserException from samcli.commands.validate.lib.exceptions import InvalidSamDocumentException from samcli.commands.local.lib.exceptions import OverridesNotWellDefinedError -from samcli.local.docker.lambda_container import DebuggingNotSupported +from samcli.local.docker.lambda_debug_entrypoint import DebuggingNotSupported class TestCli(TestCase): diff --git a/tests/unit/local/docker/test_lambda_container.py b/tests/unit/local/docker/test_lambda_container.py index 31df5d7b46..963e268a0b 100644 --- a/tests/unit/local/docker/test_lambda_container.py +++ b/tests/unit/local/docker/test_lambda_container.py @@ -7,7 +7,8 @@ from parameterized import parameterized, param from samcli.commands.local.lib.debug_context import DebugContext -from samcli.local.docker.lambda_container import LambdaContainer, Runtime, DebuggingNotSupported +from samcli.local.docker.lambda_container import LambdaContainer, Runtime +from samcli.local.docker.lambda_debug_entrypoint import DebuggingNotSupported RUNTIMES_WITH_ENTRYPOINT = [Runtime.java8.value, Runtime.dotnetcore20.value, @@ -20,6 +21,10 @@ Runtime.python36.value, Runtime.python27.value] +RUNTIMES_WITH_BOOTSTRAP_ENTRYPOINT = [Runtime.nodejs10x.value, + Runtime.python37.value] + + ALL_RUNTIMES = [r for r in Runtime] @@ -145,7 +150,7 @@ def test_must_provide_entrypoint_for_certain_runtimes_only(self, runtime): with self.assertRaises(DebuggingNotSupported): LambdaContainer._get_entry_point(runtime, self.debug_options) - @parameterized.expand([param(r) for r in RUNTIMES_WITH_ENTRYPOINT]) + @parameterized.expand([param(r) for r in set(RUNTIMES_WITH_ENTRYPOINT)]) def test_debug_arg_must_be_split_by_spaces_and_appended_to_entrypoint(self, runtime): """ Debug args list is appended starting at second position in the array @@ -156,6 +161,17 @@ def test_debug_arg_must_be_split_by_spaces_and_appended_to_entrypoint(self, runt self.assertEquals(actual, expected_debug_args) + @parameterized.expand([param(r) for r in set(RUNTIMES_WITH_BOOTSTRAP_ENTRYPOINT)]) + def test_debug_arg_must_be_split_by_spaces_and_appended_to_bootstrap_based_entrypoint(self, runtime): + """ + Debug args list is appended as arguments to bootstrap-args, which is past the fourth position in the array + """ + expected_debug_args = ["a=b", "c=d", "e=f"] + result = LambdaContainer._get_entry_point(runtime, self.debug_options) + actual = result[4:5][0] + + self.assertTrue(all(debug_arg in actual for debug_arg in expected_debug_args)) + @parameterized.expand([param(r) for r in RUNTIMES_WITH_ENTRYPOINT]) def test_must_provide_entrypoint_even_without_debug_args(self, runtime): debug_options = DebugContext(debug_port=1235, debug_args=None)