9
9
import requests
10
10
11
11
SLEEP_TIME = 2
12
- DEFUALT_1P_ENTRYPOINT = "/lambda-entrypoint.sh"
12
+ DEFAULT_1P_ENTRYPOINT = "/lambda-entrypoint.sh"
13
13
14
14
class TestEndToEnd (TestCase ):
15
15
@@ -36,7 +36,7 @@ def tearDownClass(cls):
36
36
37
37
38
38
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"
40
40
41
41
Popen (cmd .split (' ' )).communicate ()
42
42
@@ -47,7 +47,7 @@ def test_env_var_with_eqaul_sign(self):
47
47
self .assertEqual (b'"4=4"' , r .content )
48
48
49
49
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"
51
51
52
52
Popen (cmd .split (' ' )).communicate ()
53
53
@@ -61,9 +61,31 @@ def test_two_invokes(self):
61
61
r = requests .post ("http://localhost:9000/2015-03-31/functions/function/invocations" , json = {})
62
62
self .assertEqual (b'"My lambda ran succesfully"' , r .content )
63
63
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
+
64
86
65
87
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"
67
89
68
90
Popen (cmd .split (' ' )).communicate ()
69
91
@@ -74,7 +96,7 @@ def test_timeout_invoke(self):
74
96
self .assertEqual (b"Task timed out after 1.00 seconds" , r .content )
75
97
76
98
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"
78
100
79
101
Popen (cmd .split (' ' )).communicate ()
80
102
@@ -108,7 +130,7 @@ def tearDownClass(cls):
108
130
Popen (f"docker rmi { cls .image_name } " .split (' ' )).communicate ()
109
131
110
132
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"
112
134
113
135
Popen (cmd .split (' ' )).communicate ()
114
136
@@ -119,7 +141,7 @@ def test_invoke_with_pre_runtime_api_runtime(self):
119
141
self .assertEqual (b'"My lambda ran succesfully"' , r .content )
120
142
121
143
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"
123
145
124
146
Popen (cmd .split (' ' )).communicate ()
125
147
0 commit comments