Skip to content

Commit

Permalink
fix nit, naming
Browse files Browse the repository at this point in the history
  • Loading branch information
roger-zhangg committed Apr 19, 2024
1 parent d78aea8 commit 6e0c33e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/integ-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
go-tests:
runs-on: ubuntu-latest
environment:
name: prod
name: integ-tests
steps:
- uses: actions/checkout@v4
- name: run go tests
run: make tests-with-docker
integ-tests-x86:
runs-on: ubuntu-latest
environment:
name: prod
name: integ-tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -28,7 +28,7 @@ jobs:
integ-tests-arm64:
runs-on: ubuntu-latest
environment:
name: prod
name: integ-tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -39,7 +39,7 @@ jobs:
integ-tests-old:
runs-on: ubuntu-latest
environment:
name: prod
name: integ-tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ prep-python:
.venv/bin/pip install requests parameterized

exec-python-e2e-test:
TEST_ARCH=${TEST_ARCH} TEST_PORT=${TEST_PORT} .venv/bin/python3 test/integration/local_lambda/test_end_to_end.py
.venv/bin/python3 test/integration/local_lambda/test_end_to_end.py

integ-tests:
make prep-python
Expand Down
52 changes: 26 additions & 26 deletions test/integration/local_lambda/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def test_env_var_with_equal_sign(self):
def test_two_invokes(self):
image, rie, image_name = self.tagged_name("twoinvokes")

cmd = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.success_handler"
params = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.success_handler"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

self.assertEqual(b'"My lambda ran succesfully"', r.content)
Expand All @@ -115,9 +115,9 @@ def test_two_invokes(self):
def test_lambda_function_arn_exists(self):
image, rie, image_name = self.tagged_name("arnexists")

cmd = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.assert_lambda_arn_in_context"
params = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.assert_lambda_arn_in_context"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

self.assertEqual(b'"My lambda ran succesfully"', r.content)
Expand All @@ -126,9 +126,9 @@ def test_lambda_function_arn_exists(self):
def test_lambda_function_arn_exists_with_defining_custom_name(self):
image, rie, image_name = self.tagged_name("customname")

cmd = f"--name {image} --env AWS_LAMBDA_FUNCTION_NAME=MyCoolName -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.assert_lambda_arn_in_context"
params = f"--name {image} --env AWS_LAMBDA_FUNCTION_NAME=MyCoolName -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.assert_lambda_arn_in_context"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

self.assertEqual(b'"My lambda ran succesfully"', r.content)
Expand All @@ -137,9 +137,9 @@ def test_lambda_function_arn_exists_with_defining_custom_name(self):
def test_timeout_invoke(self):
image, rie, image_name = self.tagged_name("timeout")

cmd = f"--name {image} -d --env AWS_LAMBDA_FUNCTION_TIMEOUT=1 -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.sleep_handler"
params = f"--name {image} -d --env AWS_LAMBDA_FUNCTION_TIMEOUT=1 -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.sleep_handler"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

self.assertEqual(b"Task timed out after 1.00 seconds", r.content)
Expand All @@ -148,25 +148,25 @@ def test_timeout_invoke(self):
def test_exception_returned(self):
image, rie, image_name = self.tagged_name("exception")

cmd = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.exception_handler"
params = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.exception_handler"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

# Except the 3 fields assrted below, there's another field `request_id` included start from python3.12 runtime.
# We should ignore asserting the field `request_id` for it is in a UUID like format and chages everytime
# We should ignore asserting the field `request_id` for it is in a UUID like format and changes everytime
result = r.json()
self.assertEqual(result["errorMessage"],"Raising an exception")
self.assertEqual(result["errorType"],"Exception")
self.assertEqual(result["stackTrace"],[" File \"/var/task/main.py\", line 13, in exception_handler\n raise Exception(\"Raising an exception\")\n"])
self.assertEqual(result["errorMessage"], "Raising an exception")
self.assertEqual(result["errorType"], "Exception")
self.assertEqual(result["stackTrace"], [" File \"/var/task/main.py\", line 13, in exception_handler\n raise Exception(\"Raising an exception\")\n"])


def test_context_get_remaining_time_in_three_seconds(self):
image, rie, image_name = self.tagged_name("remaining_time_in_three_seconds")

cmd = f"--name {image} -d --env AWS_LAMBDA_FUNCTION_TIMEOUT=3 -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.check_remaining_time_handler"
params = f"--name {image} -d --env AWS_LAMBDA_FUNCTION_TIMEOUT=3 -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.check_remaining_time_handler"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

# Execution time is not decided, 1.0s ~ 3.0s is a good estimation
Expand All @@ -177,9 +177,9 @@ def test_context_get_remaining_time_in_three_seconds(self):
def test_context_get_remaining_time_in_ten_seconds(self):
image, rie, image_name = self.tagged_name("remaining_time_in_ten_seconds")

cmd = f"--name {image} -d --env AWS_LAMBDA_FUNCTION_TIMEOUT=10 -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.check_remaining_time_handler"
params = f"--name {image} -d --env AWS_LAMBDA_FUNCTION_TIMEOUT=10 -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.check_remaining_time_handler"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

# Execution time is not decided, 8.0s ~ 10.0s is a good estimation
Expand All @@ -190,9 +190,9 @@ def test_context_get_remaining_time_in_ten_seconds(self):
def test_context_get_remaining_time_in_default_deadline(self):
image, rie, image_name = self.tagged_name("remaining_time_in_default_deadline")

cmd = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.check_remaining_time_handler"
params = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.check_remaining_time_handler"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

# Executation time is not decided, 298.0s ~ 300.0s is a good estimation
Expand All @@ -203,9 +203,9 @@ def test_context_get_remaining_time_in_default_deadline(self):
def test_invoke_with_pre_runtime_api_runtime(self):
image, rie, image_name = self.tagged_name("pre-runtime-api")

cmd = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.success_handler"
params = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.success_handler"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

self.assertEqual(b'"My lambda ran succesfully"', r.content)
Expand All @@ -214,9 +214,9 @@ def test_invoke_with_pre_runtime_api_runtime(self):
def test_function_name_is_overriden(self):
image, rie, image_name = self.tagged_name("assert-overwritten")

cmd = f"--name {image} -d --env AWS_LAMBDA_FUNCTION_NAME=MyCoolName -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.assert_env_var_is_overwritten"
params = f"--name {image} -d --env AWS_LAMBDA_FUNCTION_NAME=MyCoolName -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8080 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.assert_env_var_is_overwritten"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

self.assertEqual(b'"My lambda ran succesfully"', r.content)
Expand All @@ -226,9 +226,9 @@ def test_port_override(self):
image, rie, image_name = self.tagged_name("port_override")

# Use port 8081 inside the container instead of 8080
cmd = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8081 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.success_handler --runtime-interface-emulator-address 0.0.0.0:8081"
params = f"--name {image} -d -v {self.path_to_binary}:/local-lambda-runtime-server -p {self.PORT}:8081 --entrypoint /local-lambda-runtime-server/{rie} {image_name} {DEFAULT_1P_ENTRYPOINT} main.success_handler --runtime-interface-emulator-address 0.0.0.0:8081"

with self.create_container(cmd, image):
with self.create_container(params, image):
r = self.invoke_function()

self.assertEqual(b'"My lambda ran succesfully"', r.content)
Expand Down

0 comments on commit 6e0c33e

Please sign in to comment.