Skip to content

tests: refactor away need for test/instrumentation-specific mocks#2319

Merged
trentm merged 2 commits intomasterfrom
trentm/test-refactor-no-instr-mock-agent
Sep 7, 2021
Merged

tests: refactor away need for test/instrumentation-specific mocks#2319
trentm merged 2 commits intomasterfrom
trentm/test-refactor-no-instr-mock-agent

Conversation

@trentm
Copy link
Copy Markdown
Member

@trentm trentm commented Sep 7, 2021

Drop the need for the mocks _agent.js and _instrumentation.js under
test/instrumentation that reach into Agent internal implementation
details. This will help coming re-work of some Instrumentation
internal implementation details.

This depends on #2316 going in first (for the added
"test/_capturing_transport.js").

Drop the need for the mocks _agent.js and _instrumentation.js under
test/instrumentation that reach into Agent internal implementation
details. This will help coming re-work of some Instrumentation
internal implementation details.
@trentm trentm self-assigned this Sep 7, 2021
@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Sep 7, 2021
@ghost
Copy link
Copy Markdown

ghost commented Sep 7, 2021

💚 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: 2021-09-07T23:07:45.102+0000

  • Duration: 20 min 20 sec

  • Commit: 6a63c13

Test stats 🧪

Test Results
Failed 0
Passed 20
Skipped 0
Total 20

Trends 🧪

Image of Build Times

Image of Tests

@trentm trentm marked this pull request as ready for review September 7, 2021 21:17
@trentm trentm requested a review from astorm September 7, 2021 21:18
Copy link
Copy Markdown
Contributor

@astorm astorm left a comment

Choose a reason for hiding this comment

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

Overall this look good -- as in it does the thing and moves us away from the mock agent. Also, no noticeable perf. regressions in the time these particular new tests take to run. Approving.

One thing to note -- the npx tape test/instrumentation/transaction.test.js has a different number of assertions on this branch when compared to master (140 on master, 136 on this branch) I did not dig deeply into it but my presumption is these are assertions lost due to how mockInstrumentation worked. Not a deal break, just an observation in case this wasn't expected.

@trentm
Copy link
Copy Markdown
Member Author

trentm commented Sep 7, 2021

the npx tape test/instrumentation/transaction.test.js has a different number of assertions on this branch when compared to master (140 on master, 136 on this branch)

We add two assertions near the top, e.g. here is one added assertion: https://github.com/elastic/apm-agent-nodejs/pull/2319/files#diff-115ec49fff221477451b17e1fca2a5208448489ccbb84c4eb7b53c6c4016f3caR189-R203

Then for six replacements of mockInstrumentation, we drop a t.pass('should end the transaction') assertion, e.g. here: https://github.com/elastic/apm-agent-nodejs/pull/2319/files#diff-115ec49fff221477451b17e1fca2a5208448489ccbb84c4eb7b53c6c4016f3caR356-R357
Those are safe to drop because the subsequent assertions on agent._transport.transactions[0] ensures the transaction was ended and sent.

Thanks for the review.

@trentm trentm merged commit 666092c into master Sep 7, 2021
@trentm trentm deleted the trentm/test-refactor-no-instr-mock-agent branch September 7, 2021 23:40
dgieselaar pushed a commit to dgieselaar/apm-agent-nodejs that referenced this pull request Sep 10, 2021
…astic#2319)

Drop the need for the mocks _agent.js and _instrumentation.js under
test/instrumentation that reach into Agent internal implementation
details. This will help coming re-work of some Instrumentation
internal implementation details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-nodejs Make available for APM Agents project planning.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants