Skip to content
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

[fix] Fix test expectations for translator to avoid depending on order #6404

Merged
merged 2 commits into from
Dec 25, 2024

Conversation

mahadzaryab1
Copy link
Collaborator

Description of the changes

  • The output of ProtoToTraces is not guaranteed to be in order which was causing flaky test failures in translator_test.go. This PR changes the test expectations to not depend on the return order of ProtoToTraces.

How was this change tested?

  • CI

Checklist

@mahadzaryab1 mahadzaryab1 added the changelog:ci Change related to continuous integration / testing label Dec 25, 2024
@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner December 25, 2024 16:14
@dosubot dosubot bot added the bug label Dec 25, 2024
@yurishkuro
Copy link
Member

The output of ProtoToTraces is not guaranteed to be in order

can you elaborate what this means?

Copy link

codecov bot commented Dec 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.27%. Comparing base (1677650) to head (7c1e34c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6404      +/-   ##
==========================================
- Coverage   96.29%   96.27%   -0.02%     
==========================================
  Files         367      367              
  Lines       20978    20978              
==========================================
- Hits        20200    20197       -3     
- Misses        595      597       +2     
- Partials      183      184       +1     
Flag Coverage Δ
badger_v1 8.94% <ø> (ø)
badger_v2 1.83% <ø> (ø)
cassandra-4.x-v1-manual 14.87% <ø> (ø)
cassandra-4.x-v2-auto 1.77% <ø> (ø)
cassandra-4.x-v2-manual 1.77% <ø> (ø)
cassandra-5.x-v1-manual 14.87% <ø> (ø)
cassandra-5.x-v2-auto 1.77% <ø> (ø)
cassandra-5.x-v2-manual 1.77% <ø> (ø)
elasticsearch-6.x-v1 18.56% <ø> (ø)
elasticsearch-7.x-v1 18.63% <ø> (ø)
elasticsearch-8.x-v1 18.78% <ø> (-0.01%) ⬇️
elasticsearch-8.x-v2 1.83% <ø> (ø)
grpc_v1 10.61% <ø> (ø)
grpc_v2 8.10% <ø> (ø)
kafka-v1 9.30% <ø> (ø)
kafka-v2 1.83% <ø> (ø)
memory_v2 1.83% <ø> (ø)
opensearch-1.x-v1 18.68% <ø> (ø)
opensearch-2.x-v1 18.67% <ø> (-0.01%) ⬇️
opensearch-2.x-v2 1.83% <ø> (ø)
tailsampling-processor 0.46% <ø> (ø)
unittests 95.13% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mahadzaryab1
Copy link
Collaborator Author

mahadzaryab1 commented Dec 25, 2024

The output of ProtoToTraces is not guaranteed to be in order

can you elaborate what this means?

If we pass in batch1,batch2 - there's no guarantee that resources.At(0) == batch1. They can be in either order. I think its because this function maintains a map which it then iterates over to create the new set of batches to operate on.

assert.Equal(t, 2, ss1.Spans().Len())
spanMap := make(map[string]ptrace.Span)

for i := 0; i < traces.ResourceSpans().Len(); i++ {
Copy link
Member

Choose a reason for hiding this comment

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

considering how often we seem to be doing this I would create a helper

package jptrace

func SpanMap[K](tr ptrace.Traces, keyFn func (ptrace.Span) K) map[K]ptrace.Span

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sounds good - can do in a follow-up PR

@mahadzaryab1 mahadzaryab1 enabled auto-merge (squash) December 25, 2024 16:34
@mahadzaryab1 mahadzaryab1 merged commit 354cbca into jaegertracing:main Dec 25, 2024
54 checks passed
Manik2708 pushed a commit to Manik2708/jaeger that referenced this pull request Jan 5, 2025
jaegertracing#6404)

## Description of the changes
- The output of `ProtoToTraces` is not guaranteed to be in order which
was causing flaky test failures in `translator_test.go`. This PR changes
the test expectations to not depend on the return order of
`ProtoToTraces`.

## How was this change tested?
- CI

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

Signed-off-by: Mahad Zaryab <[email protected]>
@mahadzaryab1 mahadzaryab1 deleted the fix-flaky-unit-test branch January 6, 2025 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug changelog:ci Change related to continuous integration / testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants