MCPcopy Index your code
hub / github.com/prometheus/prometheus / TestCompactBlockMetas

Function TestCompactBlockMetas

tsdb/compact_test.go:1935–1968  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1933}
1934
1935func TestCompactBlockMetas(t *testing.T) {
1936 parent1 := ulid.MustNew(100, nil)
1937 parent2 := ulid.MustNew(200, nil)
1938 parent3 := ulid.MustNew(300, nil)
1939 parent4 := ulid.MustNew(400, nil)
1940
1941 input := []*BlockMeta{
1942 {ULID: parent1, MinTime: 1000, MaxTime: 2000, Compaction: BlockMetaCompaction{Level: 2, Sources: []ulid.ULID{ulid.MustNew(1, nil), ulid.MustNew(10, nil)}}},
1943 {ULID: parent2, MinTime: 200, MaxTime: 500, Compaction: BlockMetaCompaction{Level: 1}},
1944 {ULID: parent3, MinTime: 500, MaxTime: 2500, Compaction: BlockMetaCompaction{Level: 3, Sources: []ulid.ULID{ulid.MustNew(5, nil), ulid.MustNew(6, nil)}}},
1945 {ULID: parent4, MinTime: 100, MaxTime: 900, Compaction: BlockMetaCompaction{Level: 1}},
1946 }
1947
1948 outUlid := ulid.MustNew(1000, nil)
1949 output := CompactBlockMetas(outUlid, input...)
1950
1951 expected := &BlockMeta{
1952 ULID: outUlid,
1953 MinTime: 100,
1954 MaxTime: 2500,
1955 Stats: BlockStats{},
1956 Compaction: BlockMetaCompaction{
1957 Level: 4,
1958 Sources: []ulid.ULID{ulid.MustNew(1, nil), ulid.MustNew(5, nil), ulid.MustNew(6, nil), ulid.MustNew(10, nil)},
1959 Parents: []BlockDesc{
1960 {ULID: parent1, MinTime: 1000, MaxTime: 2000},
1961 {ULID: parent2, MinTime: 200, MaxTime: 500},
1962 {ULID: parent3, MinTime: 500, MaxTime: 2500},
1963 {ULID: parent4, MinTime: 100, MaxTime: 900},
1964 },
1965 },
1966 }
1967 require.Equal(t, expected, output)
1968}
1969
1970func TestCompactEmptyResultBlockWithTombstone(t *testing.T) {
1971 ctx := context.Background()

Callers

nothing calls this directly

Calls 1

CompactBlockMetasFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…