Skip to content

Commit 21bb70d

Browse files
authored
fix(contrib/aws/datadog-lambda): sort the logs to compare (#4677)
### What does this PR do? This PR sorts the logs generated by `contrib/aws/datadog-lambda-go/test/integration_tests/run_integration_tests.sh` when running Lambda Integration tests. ### Motivation Avoid flakiness in the scheduled runs. ### Reviewer's Checklist <!-- * Authors can use this list as a reference to ensure that there are no problems during the review but the signing off is to be done by the reviewer(s). --> - [ ] Changed code has unit tests for its functionality at or near 100% coverage. - [ ] [System-Tests](https://github.com/DataDog/system-tests/) covering this feature have been added and enabled with the va.b.c-dev version tag. - [ ] There is a benchmark for any new code, or changes to existing code. - [ ] If this interacts with the agent in a new way, a system test has been added. - [ ] New code is free of linting errors. You can check this by running `make lint` locally. - [ ] New code doesn't break existing tests. You can check this by running `make test` locally. - [ ] Add an appropriate team label so this PR gets put in the right place for the release notes. - [ ] All generated files are up to date. You can check this by running `make generate` locally. - [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running `make fix-modules` locally. Unsure? Have a question? Request a review!
1 parent d6dc3b9 commit 21bb70d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

contrib/aws/datadog-lambda-go/test/integration_tests/run_integration_tests.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,9 @@ for function_name in "${LAMBDA_HANDLERS[@]}"; do
189189
echo "Overwriting log snapshot for $function_snapshot_path"
190190
echo "$logs" >$function_snapshot_path
191191
else
192-
# Compare new logs to snapshots
193-
diff_output=$(echo "$logs" | diff - $function_snapshot_path)
192+
# Compare new logs to snapshots (sort both sides to avoid flaky failures
193+
# from non-deterministic log ordering in Lambda/CloudWatch)
194+
diff_output=$(diff <(echo "$logs" | sort) <(sort $function_snapshot_path))
194195
if [ $? -eq 1 ]; then
195196
echo "Failed: Mismatch found between new $function_name logs (first) and snapshot (second):"
196197
echo "$diff_output"

0 commit comments

Comments
 (0)