-
Notifications
You must be signed in to change notification settings - Fork 406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(tests): refactor E2E logger to ease maintenance, writing tests and parallelization #1460
chore(tests): refactor E2E logger to ease maintenance, writing tests and parallelization #1460
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1460 +/- ##
========================================
Coverage 99.89% 99.89%
========================================
Files 123 123
Lines 5496 5497 +1
Branches 629 629
========================================
+ Hits 5490 5491 +1
Misses 2 2
Partials 4 4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Similar to Tracer, I've created a Beforedef test_basic_lambda_contextual_data_logged(execute_lambda: conftest.InfrastructureOutput):
# GIVEN
required_keys = (
"xray_trace_id",
"function_request_id",
"function_arn",
"function_memory_size",
"function_name",
"cold_start",
)
lambda_name = execute_lambda.get_lambda_function_name(cf_output_name="basichandlerarn")
timestamp = execute_lambda.get_lambda_execution_time_timestamp()
cw_client = boto3.client("logs")
# WHEN
filtered_logs = data_fetcher.get_logs(lambda_function_name=lambda_name, start_time=timestamp, log_client=cw_client)
# THEN
assert all(keys in logs.dict(exclude_unset=True) for logs in filtered_logs for keys in required_keys) AfterIt combines all other tests into a single test by making the payload dynamic. def test_basic_lambda_logs_visible(basic_handler_fn, basic_handler_fn_arn):
# GIVEN
message = "logs should be visible with default settings"
custom_key = "order_id"
additional_keys = {custom_key: f"{uuid4()}"}
payload = json.dumps({"message": message, "append_keys": additional_keys})
# WHEN
_, execution_time = data_fetcher.get_lambda_response(lambda_arn=basic_handler_fn_arn, payload=payload)
data_fetcher.get_lambda_response(lambda_arn=basic_handler_fn_arn, payload=payload)
# THEN
logs = data_fetcher.get_logs(function_name=basic_handler_fn, start_time=execution_time)
assert len(logs) == 2
assert len(logs.get_cold_start_log()) == 1
assert len(logs.get_log(key=custom_key)) == 2
assert logs.have_keys(*LOGGER_LAMBDA_CONTEXT_KEYS) is True |
@rubenfonseca @mploski @leandrodamascena could either of you have a pass? It's a lot smaller now that we don't need non-related cleanups |
Issue number: #1441
Summary
This PR refactors Logger E2E test following the new Infrastructure and explicit tests.
Tasks
LoggerStack
and use new infrastructureget_logs
: consistency with other fetcher UXget_logs
: accept date time (consistency) and convert toepoch
int
get_logs
: removelru_cache
due to new dynamic natureget_logs
: acceptfilter_expression
to reduce unwanted logsget_logs
: setfilter_expression
default to standard Logger key to remove start/end/report log eventsget_logs
: arbitrary additional keys should be added toLog
modelget_logs
on whether we could make assertion easierChanges
User experience
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.