MCPcopy
hub / github.com/grafana/tempo / TestDeterministicIDGenerator

Function TestDeterministicIDGenerator

modules/blockbuilder/util/id_test.go:13–37  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestDeterministicIDGenerator(t *testing.T) {
14 ts := time.Now().UnixMilli()
15
16 gen := NewDeterministicIDGenerator(util.FakeTenantID, 0, uint64(ts))
17
18 firstPassIDs := make(map[backend.UUID]struct{})
19 for seq := int64(0); seq < 10; seq++ {
20 id := gen.NewID()
21 firstPassIDs[id] = struct{}{}
22 }
23
24 // Verify that that UUIDs are valid
25 for id := range firstPassIDs {
26 _, err := uuid.Parse(id.String())
27 assert.NoError(t, err)
28 }
29
30 gen = NewDeterministicIDGenerator(util.FakeTenantID, 0, uint64(ts))
31 for seq := int64(0); seq < 10; seq++ {
32 id := gen.NewID()
33 if _, ok := firstPassIDs[id]; !ok {
34 t.Errorf("ID %s not found in first pass IDs", id)
35 }
36 }
37}
38
39func TestDeterministicIDGeneratorWithDifferentTenants(t *testing.T) {
40 ts := time.Now().UnixMilli()

Callers

nothing calls this directly

Calls 5

NewIDMethod · 0.95
NowMethod · 0.65
ParseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected