some test funcitons didn't cleanup after themselves.
This commit is contained in:
parent
bc97c6c6be
commit
eb6cdbcb5b
|
@ -39,8 +39,9 @@ func TestBlockMetaMustNeverBeVersion2(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetCompactionFailed(t *testing.T) {
|
func TestSetCompactionFailed(t *testing.T) {
|
||||||
tmpdir, err := ioutil.TempDir("", "test-tsdb")
|
tmpdir, err := ioutil.TempDir("", "test")
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
b := createEmptyBlock(t, tmpdir)
|
b := createEmptyBlock(t, tmpdir)
|
||||||
|
|
||||||
|
|
|
@ -328,6 +328,7 @@ func TestCompactionFailWillCleanUpTempDir(t *testing.T) {
|
||||||
|
|
||||||
tmpdir, err := ioutil.TempDir("", "test")
|
tmpdir, err := ioutil.TempDir("", "test")
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
testutil.NotOk(t, compactor.write(tmpdir, &BlockMeta{}, erringBReader{}))
|
testutil.NotOk(t, compactor.write(tmpdir, &BlockMeta{}, erringBReader{}))
|
||||||
_, err = os.Stat(filepath.Join(tmpdir, BlockMeta{}.ULID.String()) + ".tmp")
|
_, err = os.Stat(filepath.Join(tmpdir, BlockMeta{}.ULID.String()) + ".tmp")
|
||||||
|
|
38
db_test.go
38
db_test.go
|
@ -351,6 +351,7 @@ func TestDB_Snapshot(t *testing.T) {
|
||||||
// create snapshot
|
// create snapshot
|
||||||
snap, err := ioutil.TempDir("", "snap")
|
snap, err := ioutil.TempDir("", "snap")
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
defer os.RemoveAll(snap)
|
||||||
testutil.Ok(t, db.Snapshot(snap))
|
testutil.Ok(t, db.Snapshot(snap))
|
||||||
testutil.Ok(t, db.Close())
|
testutil.Ok(t, db.Close())
|
||||||
|
|
||||||
|
@ -416,6 +417,7 @@ Outer:
|
||||||
// create snapshot
|
// create snapshot
|
||||||
snap, err := ioutil.TempDir("", "snap")
|
snap, err := ioutil.TempDir("", "snap")
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
defer os.RemoveAll(snap)
|
||||||
testutil.Ok(t, db.Snapshot(snap))
|
testutil.Ok(t, db.Snapshot(snap))
|
||||||
testutil.Ok(t, db.Close())
|
testutil.Ok(t, db.Close())
|
||||||
|
|
||||||
|
@ -629,23 +631,21 @@ func TestDB_e2e(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWALFlushedOnDBClose(t *testing.T) {
|
func TestWALFlushedOnDBClose(t *testing.T) {
|
||||||
tmpdir, err := ioutil.TempDir("", "test")
|
db, close := openTestDB(t, nil)
|
||||||
testutil.Ok(t, err)
|
defer close()
|
||||||
defer os.RemoveAll(tmpdir)
|
|
||||||
|
|
||||||
db, err := Open(tmpdir, nil, nil, nil)
|
dirDb := db.Dir()
|
||||||
testutil.Ok(t, err)
|
|
||||||
|
|
||||||
lbls := labels.Labels{labels.Label{Name: "labelname", Value: "labelvalue"}}
|
lbls := labels.Labels{labels.Label{Name: "labelname", Value: "labelvalue"}}
|
||||||
|
|
||||||
app := db.Appender()
|
app := db.Appender()
|
||||||
_, err = app.Add(lbls, 0, 1)
|
_, err := app.Add(lbls, 0, 1)
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
testutil.Ok(t, app.Commit())
|
testutil.Ok(t, app.Commit())
|
||||||
|
|
||||||
testutil.Ok(t, db.Close())
|
testutil.Ok(t, db.Close())
|
||||||
|
|
||||||
db, err = Open(tmpdir, nil, nil, nil)
|
db, err = Open(dirDb, nil, nil, nil)
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
|
@ -688,6 +688,7 @@ func TestTombstoneClean(t *testing.T) {
|
||||||
// create snapshot
|
// create snapshot
|
||||||
snap, err := ioutil.TempDir("", "snap")
|
snap, err := ioutil.TempDir("", "snap")
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
defer os.RemoveAll(snap)
|
||||||
testutil.Ok(t, db.Snapshot(snap))
|
testutil.Ok(t, db.Snapshot(snap))
|
||||||
testutil.Ok(t, db.Close())
|
testutil.Ok(t, db.Close())
|
||||||
|
|
||||||
|
@ -751,16 +752,13 @@ func TestTombstoneClean(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDB_Retention(t *testing.T) {
|
func TestDB_Retention(t *testing.T) {
|
||||||
tmpdir, _ := ioutil.TempDir("", "test")
|
db, close := openTestDB(t, nil)
|
||||||
defer os.RemoveAll(tmpdir)
|
defer close()
|
||||||
|
|
||||||
db, err := Open(tmpdir, nil, nil, nil)
|
|
||||||
testutil.Ok(t, err)
|
|
||||||
|
|
||||||
lbls := labels.Labels{labels.Label{Name: "labelname", Value: "labelvalue"}}
|
lbls := labels.Labels{labels.Label{Name: "labelname", Value: "labelvalue"}}
|
||||||
|
|
||||||
app := db.Appender()
|
app := db.Appender()
|
||||||
_, err = app.Add(lbls, 0, 1)
|
_, err := app.Add(lbls, 0, 1)
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
testutil.Ok(t, app.Commit())
|
testutil.Ok(t, app.Commit())
|
||||||
|
|
||||||
|
@ -768,9 +766,9 @@ func TestDB_Retention(t *testing.T) {
|
||||||
// TODO(gouthamve): Add a method to compact headblock.
|
// TODO(gouthamve): Add a method to compact headblock.
|
||||||
snap, err := ioutil.TempDir("", "snap")
|
snap, err := ioutil.TempDir("", "snap")
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
defer os.RemoveAll(snap)
|
||||||
testutil.Ok(t, db.Snapshot(snap))
|
testutil.Ok(t, db.Snapshot(snap))
|
||||||
testutil.Ok(t, db.Close())
|
testutil.Ok(t, db.Close())
|
||||||
defer os.RemoveAll(snap)
|
|
||||||
|
|
||||||
// reopen DB from snapshot
|
// reopen DB from snapshot
|
||||||
db, err = Open(snap, nil, nil, nil)
|
db, err = Open(snap, nil, nil, nil)
|
||||||
|
@ -786,9 +784,9 @@ func TestDB_Retention(t *testing.T) {
|
||||||
// Snapshot again to create another block.
|
// Snapshot again to create another block.
|
||||||
snap, err = ioutil.TempDir("", "snap")
|
snap, err = ioutil.TempDir("", "snap")
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
defer os.RemoveAll(snap)
|
||||||
testutil.Ok(t, db.Snapshot(snap))
|
testutil.Ok(t, db.Snapshot(snap))
|
||||||
testutil.Ok(t, db.Close())
|
testutil.Ok(t, db.Close())
|
||||||
defer os.RemoveAll(snap)
|
|
||||||
|
|
||||||
// reopen DB from snapshot
|
// reopen DB from snapshot
|
||||||
db, err = Open(snap, nil, nil, &Options{
|
db, err = Open(snap, nil, nil, &Options{
|
||||||
|
@ -809,12 +807,8 @@ func TestDB_Retention(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNotMatcherSelectsLabelsUnsetSeries(t *testing.T) {
|
func TestNotMatcherSelectsLabelsUnsetSeries(t *testing.T) {
|
||||||
tmpdir, _ := ioutil.TempDir("", "test")
|
db, close := openTestDB(t, nil)
|
||||||
defer os.RemoveAll(tmpdir)
|
defer close()
|
||||||
|
|
||||||
db, err := Open(tmpdir, nil, nil, nil)
|
|
||||||
testutil.Ok(t, err)
|
|
||||||
defer db.Close()
|
|
||||||
|
|
||||||
labelpairs := []labels.Labels{
|
labelpairs := []labels.Labels{
|
||||||
labels.FromStrings("a", "abcd", "b", "abcde"),
|
labels.FromStrings("a", "abcd", "b", "abcde"),
|
||||||
|
@ -823,7 +817,7 @@ func TestNotMatcherSelectsLabelsUnsetSeries(t *testing.T) {
|
||||||
|
|
||||||
app := db.Appender()
|
app := db.Appender()
|
||||||
for _, lbls := range labelpairs {
|
for _, lbls := range labelpairs {
|
||||||
_, err = app.Add(lbls, 0, 1)
|
_, err := app.Add(lbls, 0, 1)
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
}
|
}
|
||||||
testutil.Ok(t, app.Commit())
|
testutil.Ok(t, app.Commit())
|
||||||
|
|
|
@ -78,7 +78,7 @@ func TestSegmentWAL_Truncate(t *testing.T) {
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "test_wal_log_truncate")
|
dir, err := ioutil.TempDir("", "test_wal_log_truncate")
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
// defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
w, err := OpenSegmentWAL(dir, nil, 0, nil)
|
w, err := OpenSegmentWAL(dir, nil, 0, nil)
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
|
Loading…
Reference in New Issue