-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[test] Refactor integration tests to directly write/read ptrace.Traces
#7812
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Manik Mehta <[email protected]>
Signed-off-by: Manik Mehta <[email protected]>
|
Currently fixing the ES tests |
Signed-off-by: Manik Mehta <[email protected]>
Signed-off-by: Manik Mehta <[email protected]>
Signed-off-by: Manik Mehta <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7812 +/- ##
==========================================
- Coverage 95.53% 95.52% -0.02%
==========================================
Files 307 307
Lines 15911 15911
==========================================
- Hits 15201 15199 -2
- Misses 558 559 +1
- Partials 152 153 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Metrics Comparison SummaryTotal changes across all snapshots: 32 Detailed changes per snapshotsummary_metrics_snapshot_cassandra📊 Metrics Diff SummaryTotal Changes: 0
summary_metrics_snapshot_badger📊 Metrics Diff SummaryTotal Changes: 32
❌ Removed Metrics
View diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleView diff sampleTotal Changes: 0
|
Signed-off-by: Manik Mehta <[email protected]>
|
Majority of tests are passing, except kafka. Working on it!. @yurishkuro Please can you review it! |
Signed-off-by: Manik Mehta <[email protected]>
|
Want to ask about kafka, do kafka also assigns one span per resource span? Like ES/OS? Also I can't understand the encoding part, how is kafka tested? i mean to ask how it is different from other storage tests? |
| return 0 | ||
| } | ||
|
|
||
| func checkSize(t *testing.T, expected *model.Trace, actual *model.Trace) { |
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.
no need to check size, ptracetest.CompareTraces checks for us
| ptracetest.IgnoreSpansOrder(), | ||
| } | ||
| if err := ptracetest.CompareTraces(expected, actual, options...); err != nil { | ||
| t.Logf("Actual trace and expected traces are not equal: %v", err) |
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.
no need of pretty diff, CompareTraces gives first point of difference as error
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.
have you tried comparing JSON strigns instead? I think it's nice to get a full dump of diffs, not the first breaking point.
Example:
import (
"github.com/hexops/gotextdiff"
"github.com/hexops/gotextdiff/myers"
"github.com/hexops/gotextdiff/span"
)
func DiffStrings(want, got string) string {
edits := myers.ComputeEdits(span.URIFromPath("want.json"), want, got)
diff := gotextdiff.ToUnified("want.json", "got.json", want, edits)
return fmt.Sprint(diff)
}
| return bytes.Compare(aAttrs[:], bAttrs[:]) | ||
| } | ||
|
|
||
| func compareTimestamps(a, b pcommon.Timestamp) int { |
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.
we could directly subtract the timestamps but that would require unnecessary and risky conversion of uint64 to int
| t.Log(err) | ||
| return false | ||
| } | ||
| if len(expected) != len(traces) { |
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.
We don't know the number of traces which reader will give in one slice, so this check becomes useless
|
Another problem is that for |
Signed-off-by: Manik Mehta <[email protected]>
| } | ||
| } | ||
| } | ||
| return assert.ObjectsAreEqualValues(expected, actual) |
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.
I thought ObjectsAreEqualValues does not work for ptrace objects
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.
yes, but they never compare ptrace objects in tests, only operations, services, dependency link etc
yurishkuro
left a comment
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.
similar comments in different functions, please address comprehensively
Signed-off-by: Manik Mehta <[email protected]>
This issue seemed to be fixed now! I think |
|
@yurishkuro The OTLP Json encoding test for large trace is failing with this log (I incremented number of traces from 200 to 8000 in |
Are you generating more verbose traces which exceeded the message limit? There should be settings in both Kafka broker and exporter about max message size. Alternatively we can use a smaller batch in the collector config, there's no reason to send all 1000 spans as a single message |
|
|
I remember there was an outstanding ticket in upstream OTEL contrib about Kafka exporter not respecting max batch size / message size, i.e. the batch processor can make the message bigger by aggregating multiple |
yes, the issue is still there! |
Signed-off-by: Manik Mehta <[email protected]>
| _ io.Closer = (*traceWriter)(nil) | ||
|
|
||
| MaxChunkSize = 35 // max chunk size otel kafka export can handle safely. | ||
| MaxChunkSize = 5 // max chunk size otel kafka export can handle safely. |
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.
reducing to this has passed the tests
|
@yurishkuro Please review |
| loadAndParseJSONPB(t, fileName, &trace) | ||
| return &trace | ||
| // getNormalisedTraces normalise traces and assign one resource span to one span | ||
| func getNormalisedTraces(td ptrace.Traces) ptrace.Traces { |
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.
use usually use American spelling
| func getNormalisedTraces(td ptrace.Traces) ptrace.Traces { | |
| func getNormalizedTraces(td ptrace.Traces) ptrace.Traces { |
I am not clear why this function is needed.
| require.NoError(t, err, "Not expecting error when unmarshaling fixture %s", path) | ||
| } | ||
|
|
||
| func correctTimeForTraces(trace ptrace.Traces) { |
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.
add comments
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.
and move to dates.go with dates_test.go
| ptracetest.IgnoreSpansOrder(), | ||
| } | ||
| if err := ptracetest.CompareTraces(expected, actual, options...); err != nil { | ||
| t.Logf("Actual trace and expected traces are not equal: %v", err) |
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.
have you tried comparing JSON strigns instead? I think it's nice to get a full dump of diffs, not the first breaking point.
Example:
import (
"github.com/hexops/gotextdiff"
"github.com/hexops/gotextdiff/myers"
"github.com/hexops/gotextdiff/span"
)
func DiffStrings(want, got string) string {
edits := myers.ComputeEdits(span.URIFromPath("want.json"), want, got)
diff := gotextdiff.ToUnified("want.json", "got.json", want, edits)
return fmt.Sprint(diff)
}
Which problem is this PR solving?
Description of the changes
ptrace.Tracesdirectly.How was this change tested?
Checklist
jaeger:make lint testjaeger-ui:npm run lintandnpm run test