-
Notifications
You must be signed in to change notification settings - Fork 45
Add integration tests #48
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff!
# Return value snapshot file format is snapshots/return_values/{handler}_{runtime}_{input-event} | ||
snapshot_path="./snapshots/return_values/${function_name}_${input_event_name}.json" | ||
|
||
return_value=$(serverless invoke -f $function_name --path "./input_events/$input_event_file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The invoke with return value is a neat trick
raw_logs=$(serverless logs -f $function_name --startTime $script_start_time) | ||
|
||
# Replace invocation-specific data like timestamps and IDs with XXXX to normalize logs across executions | ||
logs=$( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also pretty cool trick
What does this PR do?
These integration tests do the following:
To run integration tests for new changes to the layer:
BUILD_LAYERS=true DD_API_KEY=XXXX aws-vault exec sandbox-account-admin -- ./scripts/run_integration_tests
To regenerate snapshots:
UPDATE_SNAPSHOTS=true DD_API_KEY=XXXX aws-vault exec sandbox-account-admin -- ./scripts/run_integration_tests
This PR also makes a change to the layer itself to hook into the existing request patching so that if env var
DD_INTEGRATION_TEST=true
, each HTTP request will be logged in this format:HTTP GET https://ip-ranges.datadoghq.com/ Headers: ["x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:2", "x-datadog-trace-id:XXXX"] Data: {}
so that we can see in the snapshot tests if any HTTP requests have changed.
This is the first step of the integration tests so we are only running them locally for now. In the future we will integrate these tests into our CI.
Testing Guidelines
I've run this many times locally and it is working as expected without being flaky.
Additional Notes
Anything else we should know when reviewing?