diff --git a/test/integration/local_lambda/end-to-end-test.py b/test/integration/local_lambda/end-to-end-test.py index 1bd80bf..64b676e 100644 --- a/test/integration/local_lambda/end-to-end-test.py +++ b/test/integration/local_lambda/end-to-end-test.py @@ -8,6 +8,9 @@ import requests +SLEEP_TIME = 2 +DEFUALT_1P_ENTRYPOINT = "/lambda-entrypoint.sh" + class TestEndToEnd(TestCase): @classmethod @@ -33,23 +36,23 @@ def tearDownClass(cls): def test_env_var_with_eqaul_sign(self): - cmd = f"docker run --name envvarcheck -d -v {self.path_to_binary}:/local-lambda-runtime-server -p 9003:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} /bootstrap-with-handler main.check_env_var_handler" + cmd = f"docker run --name envvarcheck -d -v {self.path_to_binary}:/local-lambda-runtime-server -p 9003:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} {DEFUALT_1P_ENTRYPOINT} main.check_env_var_handler" Popen(cmd.split(' ')).communicate() # sleep 1s to give enough time for the endpoint to be up to curl - time.sleep(1) + time.sleep(SLEEP_TIME) r = requests.post("http://localhost:9003/2015-03-31/functions/function/invocations", json={}) self.assertEqual(b'"4=4"', r.content) def test_two_invokes(self): - cmd = f"docker run --name testing -d -v {self.path_to_binary}:/local-lambda-runtime-server -p 9000:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} /bootstrap-with-handler main.success_handler" + cmd = f"docker run --name testing -d -v {self.path_to_binary}:/local-lambda-runtime-server -p 9000:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} {DEFUALT_1P_ENTRYPOINT} main.success_handler" Popen(cmd.split(' ')).communicate() # sleep 1s to give enough time for the endpoint to be up to curl - time.sleep(1) + time.sleep(SLEEP_TIME) r = requests.post("http://localhost:9000/2015-03-31/functions/function/invocations", json={}) self.assertEqual(b'"My lambda ran succesfully"', r.content) @@ -60,23 +63,23 @@ def test_two_invokes(self): def test_timeout_invoke(self): - cmd = f"docker run --name timeout -d --env AWS_LAMBDA_FUNCTION_TIMEOUT=1 -v {self.path_to_binary}:/local-lambda-runtime-server -p 9001:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} /bootstrap-with-handler main.sleep_handler" + cmd = f"docker run --name timeout -d --env AWS_LAMBDA_FUNCTION_TIMEOUT=1 -v {self.path_to_binary}:/local-lambda-runtime-server -p 9001:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} {DEFUALT_1P_ENTRYPOINT} main.sleep_handler" Popen(cmd.split(' ')).communicate() # sleep 1s to give enough time for the endpoint to be up to curl - time.sleep(1) + time.sleep(SLEEP_TIME) r = requests.post("http://localhost:9001/2015-03-31/functions/function/invocations", json={}) self.assertEqual(b"Task timed out after 1.00 seconds", r.content) def test_exception_returned(self): - cmd = f"docker run --name exception -d -v {self.path_to_binary}:/local-lambda-runtime-server -p 9002:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} /bootstrap-with-handler main.exception_handler" + cmd = f"docker run --name exception -d -v {self.path_to_binary}:/local-lambda-runtime-server -p 9002:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} {DEFUALT_1P_ENTRYPOINT} main.exception_handler" Popen(cmd.split(' ')).communicate() # sleep 1s to give enough time for the endpoint to be up to curl - time.sleep(1) + time.sleep(SLEEP_TIME) r = requests.post("http://localhost:9002/2015-03-31/functions/function/invocations", json={}) self.assertEqual(b'{"errorMessage": "Raising an exception", "errorType": "Exception", "stackTrace": [" File \\"/var/task/main.py\\", line 13, in exception_handler\\n raise Exception(\\"Raising an exception\\")\\n"]}', r.content) @@ -105,23 +108,23 @@ def tearDownClass(cls): Popen(f"docker rmi {cls.image_name}".split(' ')).communicate() def test_invoke_with_pre_runtime_api_runtime(self): - cmd = f"docker run --name testing -d -v {self.path_to_binary}:/local-lambda-runtime-server -p 9000:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} /bootstrap-with-handler main.success_handler" + cmd = f"docker run --name testing -d -v {self.path_to_binary}:/local-lambda-runtime-server -p 9000:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} {DEFUALT_1P_ENTRYPOINT} main.success_handler" Popen(cmd.split(' ')).communicate() # sleep 1s to give enough time for the endpoint to be up to curl - time.sleep(1) + time.sleep(SLEEP_TIME) r = requests.post("http://localhost:9000/2015-03-31/functions/function/invocations", json={}) self.assertEqual(b'"My lambda ran succesfully"', r.content) def test_function_name_is_overriden(self): - cmd = f"docker run --name assert-overwritten -d --env AWS_LAMBDA_FUNCTION_NAME=MyCoolName -v {self.path_to_binary}:/local-lambda-runtime-server -p 9009:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} /bootstrap-with-handler main.assert_env_var_is_overwritten" + cmd = f"docker run --name assert-overwritten -d --env AWS_LAMBDA_FUNCTION_NAME=MyCoolName -v {self.path_to_binary}:/local-lambda-runtime-server -p 9009:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie {self.image_name} {DEFUALT_1P_ENTRYPOINT} main.assert_env_var_is_overwritten" Popen(cmd.split(' ')).communicate() # sleep 1s to give enough time for the endpoint to be up to curl - time.sleep(1) + time.sleep(SLEEP_TIME) r = requests.post("http://localhost:9009/2015-03-31/functions/function/invocations", json={}) self.assertEqual(b'"My lambda ran succesfully"', r.content) diff --git a/test/integration/testdata/Dockerfile-allinone b/test/integration/testdata/Dockerfile-allinone index bcd4f9a..36faf0b 100644 --- a/test/integration/testdata/Dockerfile-allinone +++ b/test/integration/testdata/Dockerfile-allinone @@ -1,4 +1,4 @@ -FROM public.erc.aws/lambda/python:3.8 +FROM public.ecr.aws/lambda/python:3.8 WORKDIR /var/task COPY ./ ./ diff --git a/test/integration/testdata/Dockerfile-python36 b/test/integration/testdata/Dockerfile-python36 index bcd4f9a..36faf0b 100644 --- a/test/integration/testdata/Dockerfile-python36 +++ b/test/integration/testdata/Dockerfile-python36 @@ -1,4 +1,4 @@ -FROM public.erc.aws/lambda/python:3.8 +FROM public.ecr.aws/lambda/python:3.8 WORKDIR /var/task COPY ./ ./