99import requests
1010
1111SLEEP_TIME = 2
12- DEFUALT_1P_ENTRYPOINT = "/lambda-entrypoint.sh"
12+ DEFAULT_1P_ENTRYPOINT = "/lambda-entrypoint.sh"
1313
1414class TestEndToEnd (TestCase ):
1515
@@ -36,7 +36,7 @@ def tearDownClass(cls):
3636
3737
3838 def test_env_var_with_eqaul_sign (self ):
39- 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"
39+ 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 } { DEFAULT_1P_ENTRYPOINT } main.check_env_var_handler"
4040
4141 Popen (cmd .split (' ' )).communicate ()
4242
@@ -47,7 +47,7 @@ def test_env_var_with_eqaul_sign(self):
4747 self .assertEqual (b'"4=4"' , r .content )
4848
4949 def test_two_invokes (self ):
50- 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"
50+ 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 } { DEFAULT_1P_ENTRYPOINT } main.success_handler"
5151
5252 Popen (cmd .split (' ' )).communicate ()
5353
@@ -61,9 +61,31 @@ def test_two_invokes(self):
6161 r = requests .post ("http://localhost:9000/2015-03-31/functions/function/invocations" , json = {})
6262 self .assertEqual (b'"My lambda ran succesfully"' , r .content )
6363
64+ def test_lambda_function_arn_exists (self ):
65+ 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 } { DEFAULT_1P_ENTRYPOINT } main.assert_lambda_arn_in_context"
66+
67+ Popen (cmd .split (' ' )).communicate ()
68+
69+ # sleep 1s to give enough time for the endpoint to be up to curl
70+ time .sleep (SLEEP_TIME )
71+
72+ r = requests .post ("http://localhost:9000/2015-03-31/functions/function/invocations" , json = {})
73+ self .assertEqual (b'"My lambda ran succesfully"' , r .content )
74+
75+ def test_lambda_function_arn_exists_with_defining_custom_name (self ):
76+ cmd = f"docker run --name testing --env AWS_LAMBDA_FUNCTION_NAME=MyCoolName -d -v { self .path_to_binary } :/local-lambda-runtime-server -p 9000:8080 --entrypoint /local-lambda-runtime-server/aws-lambda-rie { self .image_name } { DEFAULT_1P_ENTRYPOINT } main.assert_lambda_arn_in_context"
77+
78+ Popen (cmd .split (' ' )).communicate ()
79+
80+ # sleep 1s to give enough time for the endpoint to be up to curl
81+ time .sleep (SLEEP_TIME )
82+
83+ r = requests .post ("http://localhost:9000/2015-03-31/functions/function/invocations" , json = {})
84+ self .assertEqual (b'"My lambda ran succesfully"' , r .content )
85+
6486
6587 def test_timeout_invoke (self ):
66- 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"
88+ 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 } { DEFAULT_1P_ENTRYPOINT } main.sleep_handler"
6789
6890 Popen (cmd .split (' ' )).communicate ()
6991
@@ -74,7 +96,7 @@ def test_timeout_invoke(self):
7496 self .assertEqual (b"Task timed out after 1.00 seconds" , r .content )
7597
7698 def test_exception_returned (self ):
77- 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"
99+ 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 } { DEFAULT_1P_ENTRYPOINT } main.exception_handler"
78100
79101 Popen (cmd .split (' ' )).communicate ()
80102
@@ -108,7 +130,7 @@ def tearDownClass(cls):
108130 Popen (f"docker rmi { cls .image_name } " .split (' ' )).communicate ()
109131
110132 def test_invoke_with_pre_runtime_api_runtime (self ):
111- 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"
133+ 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 } { DEFAULT_1P_ENTRYPOINT } main.success_handler"
112134
113135 Popen (cmd .split (' ' )).communicate ()
114136
@@ -119,7 +141,7 @@ def test_invoke_with_pre_runtime_api_runtime(self):
119141 self .assertEqual (b'"My lambda ran succesfully"' , r .content )
120142
121143 def test_function_name_is_overriden (self ):
122- 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"
144+ 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 } { DEFAULT_1P_ENTRYPOINT } main.assert_env_var_is_overwritten"
123145
124146 Popen (cmd .split (' ' )).communicate ()
125147
0 commit comments