Skip to content

Commit 6a74e68

Browse files
authored
Fix integ tests (#4)
Co-authored-by: Jacob Fuss <[email protected]>
1 parent 20924a8 commit 6a74e68

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

Diff for: test/integration/local_lambda/end-to-end-test.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
import requests
1010

11+
SLEEP_TIME = 2
12+
DEFUALT_1P_ENTRYPOINT = "/lambda-entrypoint.sh"
13+
1114
class TestEndToEnd(TestCase):
1215

1316
@classmethod
@@ -33,23 +36,23 @@ def tearDownClass(cls):
3336

3437

3538
def test_env_var_with_eqaul_sign(self):
36-
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"
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"
3740

3841
Popen(cmd.split(' ')).communicate()
3942

4043
# sleep 1s to give enough time for the endpoint to be up to curl
41-
time.sleep(1)
44+
time.sleep(SLEEP_TIME)
4245

4346
r = requests.post("http://localhost:9003/2015-03-31/functions/function/invocations", json={})
4447
self.assertEqual(b'"4=4"', r.content)
4548

4649
def test_two_invokes(self):
47-
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"
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"
4851

4952
Popen(cmd.split(' ')).communicate()
5053

5154
# sleep 1s to give enough time for the endpoint to be up to curl
52-
time.sleep(1)
55+
time.sleep(SLEEP_TIME)
5356

5457
r = requests.post("http://localhost:9000/2015-03-31/functions/function/invocations", json={})
5558
self.assertEqual(b'"My lambda ran succesfully"', r.content)
@@ -60,23 +63,23 @@ def test_two_invokes(self):
6063

6164

6265
def test_timeout_invoke(self):
63-
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"
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"
6467

6568
Popen(cmd.split(' ')).communicate()
6669

6770
# sleep 1s to give enough time for the endpoint to be up to curl
68-
time.sleep(1)
71+
time.sleep(SLEEP_TIME)
6972

7073
r = requests.post("http://localhost:9001/2015-03-31/functions/function/invocations", json={})
7174
self.assertEqual(b"Task timed out after 1.00 seconds", r.content)
7275

7376
def test_exception_returned(self):
74-
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"
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"
7578

7679
Popen(cmd.split(' ')).communicate()
7780

7881
# sleep 1s to give enough time for the endpoint to be up to curl
79-
time.sleep(1)
82+
time.sleep(SLEEP_TIME)
8083

8184
r = requests.post("http://localhost:9002/2015-03-31/functions/function/invocations", json={})
8285
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):
105108
Popen(f"docker rmi {cls.image_name}".split(' ')).communicate()
106109

107110
def test_invoke_with_pre_runtime_api_runtime(self):
108-
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"
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"
109112

110113
Popen(cmd.split(' ')).communicate()
111114

112115
# sleep 1s to give enough time for the endpoint to be up to curl
113-
time.sleep(1)
116+
time.sleep(SLEEP_TIME)
114117

115118
r = requests.post("http://localhost:9000/2015-03-31/functions/function/invocations", json={})
116119
self.assertEqual(b'"My lambda ran succesfully"', r.content)
117120

118121
def test_function_name_is_overriden(self):
119-
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"
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"
120123

121124
Popen(cmd.split(' ')).communicate()
122125

123126
# sleep 1s to give enough time for the endpoint to be up to curl
124-
time.sleep(1)
127+
time.sleep(SLEEP_TIME)
125128

126129
r = requests.post("http://localhost:9009/2015-03-31/functions/function/invocations", json={})
127130
self.assertEqual(b'"My lambda ran succesfully"', r.content)

Diff for: test/integration/testdata/Dockerfile-allinone

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.erc.aws/lambda/python:3.8
1+
FROM public.ecr.aws/lambda/python:3.8
22

33
WORKDIR /var/task
44
COPY ./ ./

Diff for: test/integration/testdata/Dockerfile-python36

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.erc.aws/lambda/python:3.8
1+
FROM public.ecr.aws/lambda/python:3.8
22

33
WORKDIR /var/task
44
COPY ./ ./

0 commit comments

Comments
 (0)