|
1 | 1 | package sentry
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "encoding/json" |
4 | 5 | "fmt"
|
5 | 6 | "io"
|
6 | 7 | "math/rand"
|
@@ -317,29 +318,34 @@ func findPrimeNumber(n int) int {
|
317 | 318 |
|
318 | 319 | func validateProfile(t *testing.T, trace *profileTrace, duration time.Duration) {
|
319 | 320 | var require = require.New(t)
|
| 321 | + var assert = assert.New(t) |
320 | 322 | require.NotNil(trace)
|
321 |
| - require.NotEmpty(trace.Samples) |
322 |
| - require.NotEmpty(trace.Stacks) |
323 |
| - require.NotEmpty(trace.Frames) |
324 |
| - require.NotEmpty(trace.ThreadMetadata) |
| 323 | + assert.NotEmpty(trace.Samples) |
| 324 | + assert.NotEmpty(trace.Stacks) |
| 325 | + assert.NotEmpty(trace.Frames) |
| 326 | + assert.NotEmpty(trace.ThreadMetadata) |
325 | 327 |
|
326 | 328 | for _, sample := range trace.Samples {
|
327 |
| - require.GreaterOrEqual(sample.ElapsedSinceStartNS, uint64(0)) |
328 |
| - require.GreaterOrEqual(uint64(duration.Nanoseconds()), sample.ElapsedSinceStartNS) |
329 |
| - require.GreaterOrEqual(sample.StackID, 0) |
330 |
| - require.Less(sample.StackID, len(trace.Stacks)) |
331 |
| - require.Contains(trace.ThreadMetadata, sample.ThreadID) |
| 329 | + assert.GreaterOrEqual(sample.ElapsedSinceStartNS, uint64(0)) |
| 330 | + assert.GreaterOrEqual(uint64(duration.Nanoseconds()), sample.ElapsedSinceStartNS) |
| 331 | + assert.GreaterOrEqual(sample.StackID, 0) |
| 332 | + assert.Less(sample.StackID, len(trace.Stacks)) |
| 333 | + assert.Contains(trace.ThreadMetadata, sample.ThreadID) |
332 | 334 | }
|
333 | 335 |
|
334 | 336 | for _, thread := range trace.ThreadMetadata {
|
335 |
| - require.NotEmpty(thread.Name) |
| 337 | + assert.NotEmpty(thread.Name) |
336 | 338 | }
|
337 | 339 |
|
338 |
| - for _, frame := range trace.Frames { |
339 |
| - require.NotEmpty(frame.Function) |
340 |
| - require.NotContains(frame.Function, " ") // Space in the function name is likely a parsing error |
341 |
| - require.Greater(len(frame.AbsPath)+len(frame.Filename), 0) |
342 |
| - require.Greater(frame.Lineno, 0) |
| 340 | + for i, frame := range trace.Frames { |
| 341 | + if jsonData, err := json.Marshal(frame); err == nil { |
| 342 | + t.Logf("Frame %d: %v", i, string(jsonData)) |
| 343 | + } |
| 344 | + |
| 345 | + assert.NotEmpty(frame.Function) |
| 346 | + assert.NotContains(frame.Function, " ") // Space in the function name is likely a parsing error |
| 347 | + assert.Greater(len(frame.AbsPath)+len(frame.Filename), 0) |
| 348 | + assert.Greater(frame.Lineno, 0) |
343 | 349 | }
|
344 | 350 | }
|
345 | 351 |
|
@@ -423,6 +429,10 @@ func countSamples(profiler *profileRecorder) (value int) {
|
423 | 429 | // we should test the profiler API only, this is trying to reduce a chance of a broken code that may externally work
|
424 | 430 | // but has unbounded memory usage or similar performance issue.
|
425 | 431 | func TestProfilerInternalMaps(t *testing.T) {
|
| 432 | + if testutils.IsCI() && testutils.IsRaceTest() { |
| 433 | + t.Skip("This is too flaky on slow CI when run with other goroutines in parallel " + |
| 434 | + " (there are multiple instances of HTTPTransport.worker() when the whole test suite is run).") |
| 435 | + } |
426 | 436 | var assert = assert.New(t)
|
427 | 437 |
|
428 | 438 | profiler := newProfiler(time.Now())
|
|
0 commit comments