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

Function TestMultipleItems

pkg/flushqueues/exclusivequeues_test.go:85–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

83}
84
85func TestMultipleItems(t *testing.T) {
86 gauge := prometheus.NewGauge(prometheus.GaugeOpts{
87 Namespace: "test",
88 Name: "testersons",
89 })
90
91 totalItems := 10
92 q := New[mockOp](gauge)
93
94 // add stuff to the queue and confirm the length matches expected
95 for i := 0; i < totalItems; i++ {
96 op := mockOp{
97 key: uuid.New().String(),
98 }
99
100 err := q.Enqueue(op)
101 assert.NoError(t, err)
102
103 length, err := test.GetGaugeValue(gauge)
104 assert.NoError(t, err)
105 assert.Equal(t, i+1, int(length))
106 }
107
108 // dequeue all items
109 for i := 0; i < totalItems; i++ {
110 op := q.Dequeue()
111 assert.NotNil(t, op)
112
113 length, err := test.GetGaugeValue(gauge)
114 assert.NoError(t, err)
115 assert.Equal(t, totalItems-(i+1), int(length))
116 }
117}
118
119func TestExclusiveQueueLocks(t *testing.T) {
120 gauge := prometheus.NewGauge(prometheus.GaugeOpts{

Callers

nothing calls this directly

Calls 6

GetGaugeValueFunction · 0.92
NewGaugeMethod · 0.65
StringMethod · 0.45
EnqueueMethod · 0.45
EqualMethod · 0.45
DequeueMethod · 0.45

Tested by

no test coverage detected