Skip to content

test(tracer): streamline e2e test structure #3031

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

Merged
merged 5 commits into from
Sep 9, 2024

Conversation

dreamorosi
Copy link
Contributor

Summary

Changes

Please provide a summary of what's being changed

This PR simplifies the end to end test structure for the Tracer integration tests by reducing the amount of duplication and overlap between test cases.

The new structure, while still with some room for improvement, tries to address the main code paths & features for each instrumentation method and selectively uses some shared features in each one of them.

In addition to the changes above, I also simplified how values are passed from the test to the AWS Lambda functions ran as part of the tests. Before the change, the values were shared like this:

flowchart TD
    A[constants.ts] -->|imports values| B[test file]
    B -->|deploys w/ env variables| C[lambda function]
    C -->|reads env vars| D[function uses values]
    B -->|asserts that values as expected| D
Loading

after the change:

flowchart TD
    A[constants.ts] -->|imports values| B[test file]
    A -->|imports values| C[lambda function uses values]
    B -->|asserts that values as expected| C
Loading

While the change doesn't appear significant in its diagram representation, importing the values directly in both the tests and the function allows us to remove a considerable amount of boilerplate code needed to pass and parse environment variables on both sides.

The PR also improves the X-Ray trace utilities in packages/testing to retry loading the trace data when certain subsegments are not present when the trace is first loaded.

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: closes #3028


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.

@dreamorosi dreamorosi self-assigned this Sep 6, 2024
@dreamorosi dreamorosi requested a review from a team September 6, 2024 10:52
@dreamorosi dreamorosi requested a review from a team as a code owner September 6, 2024 10:52
@boring-cyborg boring-cyborg bot added dependencies Changes that touch dependencies, e.g. Dependabot, etc. tests PRs that add or change tests labels Sep 6, 2024
@pull-request-size pull-request-size bot added the size/XXL PRs with 1K+ LOC, largely documentation related label Sep 6, 2024
@dreamorosi
Copy link
Contributor Author

dreamorosi commented Sep 6, 2024

I've run the integration tests ~10 times over the past few hours and the flakiness on the Tracer tests is greatly reduced, as well as the runtime for these tests.

There have been some transient failures in other areas (Logger & Idempotency) which consistently disappear on the next retry. I'll work on these at some point in the future but for the sake of keeping this PR focused, I'm working only on Tracer.

Also, as mentioned in the PR description, there's still some duplication which we will address in the future. For now I wanted mainly to make sure the tests pass more or less consistently, which wasn't the case after the latest changes.

@dreamorosi dreamorosi requested a review from am29d September 6, 2024 12:07
Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

Hi @dreamorosi! Awesome work refactoring these tests and testing what's important, I mean: handler, standalone function, SDK tracer, HTTP tracer, coldStart, annotation and others.

My only question about the tests in general is the use of for and logic inside these loops. I don't know if you can break it down into more small tests to test specific things like "first invocation with coldstart", "second invocation" and so on. You already have the data, so if possible, you should be more specific and reduce the cognitive load to understand the test.

Marking this PR as "Request Changes" to hear from you if we can change anything or if we merge this PR as is.

Copy link

sonarqubecloud bot commented Sep 9, 2024

@dreamorosi
Copy link
Contributor Author

Hey @leandrodamascena, thank you for the review & the useful suggestion.

I've broken down the tests and ran them again (green): https://github.com/aws-powertools/powertools-lambda-typescript/actions/runs/10775415657

Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

APPROVED!

@dreamorosi dreamorosi merged commit abe27ab into main Sep 9, 2024
11 checks passed
@dreamorosi dreamorosi deleted the test/tracer_simplify_e2e branch September 9, 2024 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Changes that touch dependencies, e.g. Dependabot, etc. size/XXL PRs with 1K+ LOC, largely documentation related tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maintenance: streamline tracer e2e tests
2 participants