-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test cleanup. Add sz test, restore commented out and fix e2e
Signed-off-by: Joe Elliott <number101010@gmail.com>
- Loading branch information
1 parent
17a581f
commit d8b73f9
Showing
4 changed files
with
70 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
modules/generator/processor/localblocks/livetraces_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package localblocks | ||
|
||
import ( | ||
"math/rand/v2" | ||
"testing" | ||
"time" | ||
|
||
"github.com/grafana/tempo/pkg/util/test" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestLiveTracesSizesAndLen(t *testing.T) { | ||
lt := newLiveTraces() | ||
|
||
expectedSz := uint64(0) | ||
expectedLen := uint64(0) | ||
|
||
for i := 0; i < 100; i++ { | ||
id := test.ValidTraceID(nil) | ||
tr := test.MakeTrace(rand.IntN(5)+1, id) | ||
|
||
cutTime := time.Now() | ||
|
||
// add some traces and confirm size/len | ||
expectedLen++ | ||
for _, rs := range tr.ResourceSpans { | ||
expectedSz += uint64(rs.Size()) | ||
lt.Push(id, rs, 0) | ||
} | ||
|
||
require.Equal(t, expectedSz, lt.Size()) | ||
require.Equal(t, expectedLen, lt.Len()) | ||
|
||
// cut some traces and confirm size/len | ||
cutTraces := lt.CutIdle(cutTime, false) | ||
for _, tr := range cutTraces { | ||
for _, rs := range tr.Batches { | ||
expectedSz -= uint64(rs.Size()) | ||
} | ||
expectedLen-- | ||
} | ||
|
||
require.Equal(t, expectedSz, lt.Size()) | ||
require.Equal(t, expectedLen, lt.Len()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters