"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tsdb/block_test.go" between
prometheus-2.15.1.tar.gz and prometheus-2.15.2.tar.gz

About: Prometheus is a monitoring system, alerting toolkit and time series database.

block_test.go  (prometheus-2.15.1):block_test.go  (prometheus-2.15.2)
skipping to change at line 200 skipping to change at line 200
// Apply corruption function. // Apply corruption function.
test.corrFunc(f) test.corrFunc(f)
testutil.Ok(t, f.Close()) testutil.Ok(t, f.Close())
// Check open err. // Check open err.
b, err := OpenBlock(nil, blockDir, nil) b, err := OpenBlock(nil, blockDir, nil)
if test.openErr != nil { if test.openErr != nil {
testutil.Equals(t, test.openErr.Error(), err.Erro r()) testutil.Equals(t, test.openErr.Error(), err.Erro r())
return return
} }
defer func() { testutil.Ok(t, b.Close()) }()
querier, err := NewBlockQuerier(b, 0, 1) querier, err := NewBlockQuerier(b, 0, 1)
testutil.Ok(t, err) testutil.Ok(t, err)
defer func() { testutil.Ok(t, querier.Close()) }()
set, err := querier.Select(labels.MustNewMatcher(labels.M atchEqual, "a", "b")) set, err := querier.Select(labels.MustNewMatcher(labels.M atchEqual, "a", "b"))
testutil.Ok(t, err) testutil.Ok(t, err)
// Check query err. // Check query err.
testutil.Equals(t, false, set.Next()) testutil.Equals(t, false, set.Next())
testutil.Equals(t, test.queryErr.Error(), set.Err().Error ()) testutil.Equals(t, test.queryErr.Error(), set.Err().Error ())
}) })
} }
} }
skipping to change at line 268 skipping to change at line 270
}() }()
expAfterCompact := blockAfterCompact.Size() expAfterCompact := blockAfterCompact.Size()
actAfterCompact, err := fileutil.DirSize(blockAfterCompact.Dir()) actAfterCompact, err := fileutil.DirSize(blockAfterCompact.Dir())
testutil.Ok(t, err) testutil.Ok(t, err)
testutil.Assert(t, actAfterDelete > actAfterCompact, "after a del ete and compaction the block size should be smaller %v,%v", actAfterDelete, actA fterCompact) testutil.Assert(t, actAfterDelete > actAfterCompact, "after a del ete and compaction the block size should be smaller %v,%v", actAfterDelete, actA fterCompact)
testutil.Equals(t, expAfterCompact, actAfterCompact, "after a del ete and compaction reported block size doesn't match actual disk size") testutil.Equals(t, expAfterCompact, actAfterCompact, "after a del ete and compaction reported block size doesn't match actual disk size")
} }
} }
func TestReadIndexFormatV1(t *testing.T) { func TestReadIndexFormatV1(t *testing.T) {
/* The block here was produced at commit /* The block here was produced at the commit
07ef80820ef1250db82f9544f3fcf7f0f63ccee0 with: 706602daed1487f7849990678b4ece4599745905 used in 2.0.0 with:
db, _ := Open("v1db", nil, nil, nil) db, _ := Open("v1db", nil, nil, nil)
app := db.Appender() app := db.Appender()
app.Add(labels.FromStrings("foo", "bar"), 1, 2) app.Add(labels.FromStrings("foo", "bar"), 1, 2)
app.Add(labels.FromStrings("foo", "baz"), 3, 4) app.Add(labels.FromStrings("foo", "baz"), 3, 4)
app.Add(labels.FromStrings("foo", "meh"), 1000*3600*4, 4) // Not in the b app.Add(labels.FromStrings("foo", "meh"), 1000*3600*4, 4) // Not in th
lock. e block.
app.Commit() // Make sure we've enough values for the lack of sorting of postings o
db.compact() ffsets to show up.
db.Close() for i := 0; i < 100; i++ {
app.Add(labels.FromStrings("bar", strconv.FormatInt(int64(i), 10)),
0, 0)
}
app.Commit()
db.compact()
db.Close()
*/ */
blockDir := filepath.Join("testdata", "index_format_v1") blockDir := filepath.Join("testdata", "index_format_v1")
block, err := OpenBlock(nil, blockDir, nil) block, err := OpenBlock(nil, blockDir, nil)
testutil.Ok(t, err) testutil.Ok(t, err)
q, err := NewBlockQuerier(block, 0, 1000) q, err := NewBlockQuerier(block, 0, 1000)
testutil.Ok(t, err) testutil.Ok(t, err)
testutil.Equals(t, query(t, q, labels.MustNewMatcher(labels.MatchEqual, " foo", "bar")), testutil.Equals(t, query(t, q, labels.MustNewMatcher(labels.MatchEqual, " foo", "bar")),
map[string][]tsdbutil.Sample{`{foo="bar"}`: []tsdbutil.Sample{sam ple{t: 1, v: 2}}}) map[string][]tsdbutil.Sample{`{foo="bar"}`: []tsdbutil.Sample{sam ple{t: 1, v: 2}}})
q, err = NewBlockQuerier(block, 0, 1000) q, err = NewBlockQuerier(block, 0, 1000)
testutil.Ok(t, err) testutil.Ok(t, err)
testutil.Equals(t, query(t, q, labels.MustNewMatcher(labels.MatchNotRegex p, "foo", "^.$")), testutil.Equals(t, query(t, q, labels.MustNewMatcher(labels.MatchNotRegex p, "foo", "^.?$")),
map[string][]tsdbutil.Sample{ map[string][]tsdbutil.Sample{
`{foo="bar"}`: []tsdbutil.Sample{sample{t: 1, v: 2}}, `{foo="bar"}`: []tsdbutil.Sample{sample{t: 1, v: 2}},
`{foo="baz"}`: []tsdbutil.Sample{sample{t: 3, v: 4}}, `{foo="baz"}`: []tsdbutil.Sample{sample{t: 3, v: 4}},
}) })
} }
// createBlock creates a block with given set of series and returns its dir. // createBlock creates a block with given set of series and returns its dir.
func createBlock(tb testing.TB, dir string, series []Series) string { func createBlock(tb testing.TB, dir string, series []Series) string {
return createBlockFromHead(tb, dir, createHead(tb, series)) return createBlockFromHead(tb, dir, createHead(tb, series))
} }
 End of changes. 4 change blocks. 
12 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)