use a global indexFilename constant

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
This commit is contained in:
Krasi Georgiev 2019-01-29 10:32:32 +02:00
parent b521559c3b
commit 53c18e7a41
5 changed files with 11 additions and 9 deletions

View File

@ -282,7 +282,7 @@ func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (*Block, error
if err != nil {
return nil, err
}
ir, err := index.NewFileReader(filepath.Join(dir, "index"))
ir, err := index.NewFileReader(filepath.Join(dir, indexFilename))
if err != nil {
return nil, err
}

View File

@ -45,6 +45,8 @@ const (
FormatV2 = 2
labelNameSeperator = "\xff"
indexFilename = "index"
)
type indexWriterSeries struct {

View File

@ -151,7 +151,7 @@ func TestIndexRW_Create_Open(t *testing.T) {
testutil.Ok(t, err)
defer os.RemoveAll(dir)
fn := filepath.Join(dir, "index")
fn := filepath.Join(dir, indexFilename)
// An empty index must still result in a readable file.
iw, err := NewWriter(fn)
@ -177,7 +177,7 @@ func TestIndexRW_Postings(t *testing.T) {
testutil.Ok(t, err)
defer os.RemoveAll(dir)
fn := filepath.Join(dir, "index")
fn := filepath.Join(dir, indexFilename)
iw, err := NewWriter(fn)
testutil.Ok(t, err)
@ -271,7 +271,7 @@ func TestPersistence_index_e2e(t *testing.T) {
})
}
iw, err := NewWriter(filepath.Join(dir, "index"))
iw, err := NewWriter(filepath.Join(dir, indexFilename))
testutil.Ok(t, err)
testutil.Ok(t, iw.AddSymbols(symbols))
@ -331,7 +331,7 @@ func TestPersistence_index_e2e(t *testing.T) {
err = iw.Close()
testutil.Ok(t, err)
ir, err := NewFileReader(filepath.Join(dir, "index"))
ir, err := NewFileReader(filepath.Join(dir, indexFilename))
testutil.Ok(t, err)
for p := range mi.postings {

View File

@ -64,7 +64,7 @@ func repairBadIndexVersion(logger log.Logger, dir string) error {
if err != nil {
return wrapErr(err, d)
}
broken, err := os.Open(filepath.Join(d, "index"))
broken, err := os.Open(filepath.Join(d, indexFilename))
if err != nil {
return wrapErr(err, d)
}

View File

@ -30,7 +30,7 @@ func TestRepairBadIndexVersion(t *testing.T) {
// at a broken revision.
//
// func main() {
// w, err := index.NewWriter("index")
// w, err := index.NewWriter(indexFilename)
// if err != nil {
// panic(err)
// }
@ -72,7 +72,7 @@ func TestRepairBadIndexVersion(t *testing.T) {
os.MkdirAll(filepath.Join(dbDir, "chunks"), 0777)
defer os.RemoveAll(filepath.Join(dbDir, "chunks"))
r, err := index.NewFileReader(filepath.Join(dbDir, "index"))
r, err := index.NewFileReader(filepath.Join(dbDir, indexFilename))
testutil.Ok(t, err)
p, err := r.Postings("b", "1")
testutil.Ok(t, err)
@ -95,7 +95,7 @@ func TestRepairBadIndexVersion(t *testing.T) {
testutil.Ok(t, err)
db.Close()
r, err = index.NewFileReader(filepath.Join(tmpDbDir, "index"))
r, err = index.NewFileReader(filepath.Join(tmpDbDir, indexFilename))
testutil.Ok(t, err)
p, err = r.Postings("b", "1")
testutil.Ok(t, err)