mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Update package tsdb/index tests for new labels.Labels type
Note in one cases we needed an extra copy of labels in case they change. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
d3d96ec887
commit
a5bdff414b
|
@ -68,14 +68,14 @@ func (m mockIndex) AddSeries(ref storage.SeriesRef, l labels.Labels, chunks ...c
|
||||||
if _, ok := m.series[ref]; ok {
|
if _, ok := m.series[ref]; ok {
|
||||||
return errors.Errorf("series with reference %d already added", ref)
|
return errors.Errorf("series with reference %d already added", ref)
|
||||||
}
|
}
|
||||||
for _, lbl := range l {
|
l.Range(func(lbl labels.Label) {
|
||||||
m.symbols[lbl.Name] = struct{}{}
|
m.symbols[lbl.Name] = struct{}{}
|
||||||
m.symbols[lbl.Value] = struct{}{}
|
m.symbols[lbl.Value] = struct{}{}
|
||||||
if _, ok := m.postings[lbl]; !ok {
|
if _, ok := m.postings[lbl]; !ok {
|
||||||
m.postings[lbl] = []storage.SeriesRef{}
|
m.postings[lbl] = []storage.SeriesRef{}
|
||||||
}
|
}
|
||||||
m.postings[lbl] = append(m.postings[lbl], ref)
|
m.postings[lbl] = append(m.postings[lbl], ref)
|
||||||
}
|
})
|
||||||
m.postings[allPostingsKey] = append(m.postings[allPostingsKey], ref)
|
m.postings[allPostingsKey] = append(m.postings[allPostingsKey], ref)
|
||||||
|
|
||||||
s := series{l: l}
|
s := series{l: l}
|
||||||
|
@ -129,7 +129,7 @@ func (m mockIndex) Series(ref storage.SeriesRef, builder *labels.ScratchBuilder,
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("not found")
|
return errors.New("not found")
|
||||||
}
|
}
|
||||||
*lset = append((*lset)[:0], s.l...)
|
lset.CopyFrom(s.l)
|
||||||
*chks = append((*chks)[:0], s.chunks...)
|
*chks = append((*chks)[:0], s.chunks...)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -322,7 +322,7 @@ func TestPostingsMany(t *testing.T) {
|
||||||
var metas []chunks.Meta
|
var metas []chunks.Meta
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
require.NoError(t, ir.Series(it.At(), &builder, &lbls, &metas))
|
require.NoError(t, ir.Series(it.At(), &builder, &lbls, &metas))
|
||||||
got = append(got, lbls.Get("i"))
|
got = append(got, lbls.Copy().Get("i"))
|
||||||
}
|
}
|
||||||
require.NoError(t, it.Err())
|
require.NoError(t, it.Err())
|
||||||
exp := []string{}
|
exp := []string{}
|
||||||
|
@ -346,10 +346,10 @@ func TestPersistence_index_e2e(t *testing.T) {
|
||||||
|
|
||||||
symbols := map[string]struct{}{}
|
symbols := map[string]struct{}{}
|
||||||
for _, lset := range lbls {
|
for _, lset := range lbls {
|
||||||
for _, l := range lset {
|
lset.Range(func(l labels.Label) {
|
||||||
symbols[l.Name] = struct{}{}
|
symbols[l.Name] = struct{}{}
|
||||||
symbols[l.Value] = struct{}{}
|
symbols[l.Value] = struct{}{}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var input indexWriterSeriesSlice
|
var input indexWriterSeriesSlice
|
||||||
|
@ -397,14 +397,14 @@ func TestPersistence_index_e2e(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, mi.AddSeries(storage.SeriesRef(i), s.labels, s.chunks...))
|
require.NoError(t, mi.AddSeries(storage.SeriesRef(i), s.labels, s.chunks...))
|
||||||
|
|
||||||
for _, l := range s.labels {
|
s.labels.Range(func(l labels.Label) {
|
||||||
valset, ok := values[l.Name]
|
valset, ok := values[l.Name]
|
||||||
if !ok {
|
if !ok {
|
||||||
valset = map[string]struct{}{}
|
valset = map[string]struct{}{}
|
||||||
values[l.Name] = valset
|
values[l.Name] = valset
|
||||||
}
|
}
|
||||||
valset[l.Value] = struct{}{}
|
valset[l.Value] = struct{}{}
|
||||||
}
|
})
|
||||||
postings.Add(storage.SeriesRef(i), s.labels)
|
postings.Add(storage.SeriesRef(i), s.labels)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue