Skip to content
This repository was archived by the owner on Aug 13, 2019. It is now read-only.

Commit 6c5bd84

Browse files
committed
Fix circular import
Signed-off-by: obitech <[email protected]>
1 parent 84ce645 commit 6c5bd84

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

cmd/tsdb/main_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017 The Prometheus Authors
1+
// Copyright 2019 The Prometheus Authors
22
// Licensed under the Apache License, Version 2.0 (the "License");
33
// you may not use this file except in compliance with the License.
44
// You may obtain a copy of the License at
@@ -23,7 +23,7 @@ import (
2323
"text/tabwriter"
2424

2525
"github.com/prometheus/tsdb"
26-
"github.com/prometheus/tsdb/testutil"
26+
testutildb "github.com/prometheus/tsdb/testutil/db"
2727
)
2828

2929
func createTestRODBWithBlock(t *testing.T) (*tsdb.DBReadOnly, func()) {
@@ -36,7 +36,7 @@ func createTestRODBWithBlock(t *testing.T) (*tsdb.DBReadOnly, func()) {
3636
safeDBOptions := *tsdb.DefaultOptions
3737
safeDBOptions.RetentionDuration = 0
3838

39-
testutil.CreateBlock(nil, tmpdir, testutil.GenSeries(1, 1, 0, 1))
39+
testutildb.CreateBlock(nil, tmpdir, testutildb.GenSeries(1, 1, 0, 1))
4040
db, err := tsdb.Open(tmpdir, nil, nil, &safeDBOptions)
4141
if err != nil {
4242
os.RemoveAll(tmpdir)

testutil/db.go renamed to testutil/db/db.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
package testutil
1+
// Copyright 2019 The Prometheus Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
package db
215

316
import (
417
"context"
5-
"io/ioutil"
618
"math/rand"
719
"os"
820
"path/filepath"
@@ -11,43 +23,31 @@ import (
1123
"testing"
1224

1325
"github.com/go-kit/kit/log"
26+
1427
"github.com/prometheus/tsdb"
1528
"github.com/prometheus/tsdb/labels"
29+
"github.com/prometheus/tsdb/testutil"
1630
"github.com/prometheus/tsdb/tsdbutil"
1731
)
1832

19-
// OpenTestDB opens a test Database
20-
func OpenTestDB(t testing.TB, opts *tsdb.Options) (db *tsdb.DB, close func()) {
21-
tmpdir, err := ioutil.TempDir("", "test")
22-
Ok(t, err)
23-
24-
db, err = tsdb.Open(tmpdir, nil, nil, opts)
25-
Ok(t, err)
26-
27-
// Do not close the test database by default as it will deadlock on test failures.
28-
return db, func() {
29-
Ok(t, os.RemoveAll(tmpdir))
30-
}
31-
}
32-
3333
// CreateBlock creates a block with given set of series and returns its dir.
3434
func CreateBlock(tb testing.TB, dir string, series []tsdb.Series) string {
3535
head := createHead(tb, series)
3636
compactor, err := tsdb.NewLeveledCompactor(context.Background(), nil, log.NewNopLogger(), []int64{1000000}, nil)
37-
Ok(tb, err)
37+
testutil.Ok(tb, err)
3838

39-
Ok(tb, os.MkdirAll(dir, 0777))
39+
testutil.Ok(tb, os.MkdirAll(dir, 0777))
4040

4141
// Add +1 millisecond to block maxt because block intervals are half-open: [b.MinTime, b.MaxTime).
4242
// Because of this block intervals are always +1 than the total samples it includes.
4343
ulid, err := compactor.Write(dir, head, head.MinTime(), head.MaxTime()+1, nil)
44-
Ok(tb, err)
44+
testutil.Ok(tb, err)
4545
return filepath.Join(dir, ulid.String())
4646
}
4747

4848
func createHead(tb testing.TB, series []tsdb.Series) *tsdb.Head {
4949
head, err := tsdb.NewHead(nil, nil, nil, 2*60*60*1000)
50-
Ok(tb, err)
50+
testutil.Ok(tb, err)
5151
defer head.Close()
5252

5353
app := head.Appender()
@@ -63,12 +63,12 @@ func createHead(tb testing.TB, series []tsdb.Series) *tsdb.Head {
6363
}
6464
}
6565
ref, err = app.Add(s.Labels(), t, v)
66-
Ok(tb, err)
66+
testutil.Ok(tb, err)
6767
}
68-
Ok(tb, it.Err())
68+
testutil.Ok(tb, it.Err())
6969
}
7070
err = app.Commit()
71-
Ok(tb, err)
71+
testutil.Ok(tb, err)
7272
return head
7373
}
7474

0 commit comments

Comments
 (0)