Skip to content

Conversation

jlvoiseux
Copy link
Contributor

@jlvoiseux jlvoiseux commented Mar 1, 2022

Motivation

The goal of these tests is to ease the refactor of the extension following the recent code reviews. They can also be used to solve some of the current issues. For example :

The core idea is to combine a mock Lambda API backend with a mock APM server to enable the recreation of several scenarios.

Limitations

  • Since Address partial list of code review comments #132 is not merged yet, TestFlush panics. Same for TestSeveralTransactions, as the related issue is not yet solved.
  • Another limitation is the fact that due to the concurrent nature of the processes tested, the aforementioned failing tests might sometimes pass.

@github-actions github-actions bot added the aws-λ-extension AWS Lambda Extension label Mar 1, 2022
@ghost
Copy link

ghost commented Mar 1, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-03-15T15:31:14.363+0000

  • Duration: 7 min 46 sec

Test stats 🧪

Test Results
Failed 0
Passed 168
Skipped 6
Total 174

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@jlvoiseux jlvoiseux marked this pull request as ready for review March 9, 2022 12:11
@jlvoiseux jlvoiseux requested a review from estolfo March 9, 2022 12:16
Copy link
Contributor

@estolfo estolfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great, thanks for building this test framework! I'm just wondering if there's some way we can add an assertion to the tests or if it makes sense to have the absence of a panic indicate that the test passes.

// Flush any APM data, in case waiting for the agentDone or runtimeDone signals
// timed out, the agent data wasn't available yet, and we got to the next non-shutdown event
extension.FlushAPMData(client, agentDataChannel, config)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you move this block to after the Shutdown event check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When writing my tests, I found myself in the following situation :

Test setup :

  • APM Server configured to be very slow (approx 3 seconds to respond).
  • APM Agent Data channel filled with data
  • SendStrategy configured to background

Behavior :
The extension starts sending data from the loaded channel to the slow APM server. It is then interrupted due to the current event being finished. A shutdown event is then received, and we start flushing APM data. The issue is that this takes a tremendous time if the APM Agent data channel is full and if the response time of the Server is large, even if the SendStrategy is set to background.

An alternative solution would be to put the flush statement above the Shutdown, but to only run FlushAPMData if the SendStrategy is SyncFlush

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. I think we might want to remove this flush anyway: with syncFlush, we'll flush at the end of an invocation so there won't be anything to flush upon a new function invocation. With background, we'll just continue receiving from the channel in the go routine when the extension starts its work for a new function invocation.

@jlvoiseux
Copy link
Contributor Author

Regarding success/failure assertions, it really depends on the specific test. Explicitly stating an assertion for each test will increase clarity, even if it is just the absence of panic. I will make a proposal for each of them.

@jlvoiseux jlvoiseux changed the title Add unit tests for main.go Add unit tests for main.go and handle APM server edge behaviors Mar 9, 2022
@jlvoiseux
Copy link
Contributor Author

I added success/failure assertions in 41a8039. For most tests, I check if the extension does not panic and if APM data is correctly sent to the APM server.

Copy link
Contributor

@estolfo estolfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@jlvoiseux jlvoiseux requested a review from estolfo March 15, 2022 12:14
Copy link
Contributor

@estolfo estolfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two minor comments then I think we can merge this. Thanks for your work on this!

@jlvoiseux
Copy link
Contributor Author

@estolfo Thank you for the review ! Your two suggestions have been addressed in 0f58cb5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws-λ-extension AWS Lambda Extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants