Skip to content

Commit

Permalink
Fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
justinjc committed Jun 14, 2019
1 parent 5507f80 commit 9567db8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
16 changes: 5 additions & 11 deletions src/cmd/tools/dtest/util/seed/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,12 @@ func (t *fileInfoExtractor) visit(fPath string, f os.FileInfo, err error) error
t.shards[uint32(shardNum)] = struct{}{}

name := f.Name()
first := strings.Index(name, "-")
if first == -1 {
return fmt.Errorf("unable to find '-' in %v", name)
nameSplit := strings.Split(name, "-")
if len(nameSplit) < 2 {
return fmt.Errorf("unable to parse time from %v", name)
}
last := strings.LastIndex(name, "-")
if last == -1 {
return fmt.Errorf("unable to find '-' in %v", name)
}
if first == last {
return fmt.Errorf("found only single '-' in %v", name)
}
num, parseErr := strconv.ParseInt(name[first+1:last], 10, 64)

num, parseErr := strconv.ParseInt(nameSplit[1], 10, 64)
if parseErr != nil {
return err
}
Expand Down
14 changes: 7 additions & 7 deletions src/dbnode/persist/fs/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,6 @@ func forEachInfoFile(
t := matched[i].ID.BlockStart
volume := matched[i].ID.VolumeIndex

isLegacy := false
if volume == 0 {
isLegacy, err = isFirstVolumeLegacy(dir, t, checkpointFileSuffix)
if err != nil {
continue
}
}
var (
checkpointFilePath string
digestsFilePath string
Expand All @@ -649,6 +642,13 @@ func forEachInfoFile(
case persist.FileSetFlushType:
switch args.contentType {
case persist.FileSetDataContentType:
isLegacy := false
if volume == 0 {
isLegacy, err = isFirstVolumeLegacy(dir, t, checkpointFileSuffix)
if err != nil {
continue
}
}
checkpointFilePath = dataFilesetPathFromTimeAndIndex(dir, t, volume, checkpointFileSuffix, isLegacy)
digestsFilePath = dataFilesetPathFromTimeAndIndex(dir, t, volume, digestFileSuffix, isLegacy)
infoFilePath = dataFilesetPathFromTimeAndIndex(dir, t, volume, infoFileSuffix, isLegacy)
Expand Down
6 changes: 3 additions & 3 deletions src/dbnode/persist/fs/index_lookup_prop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func TestIndexLookupWriteRead(t *testing.T) {
}

// Read the summaries file into memory
summariesFilePath := filesetPathFromTimeLegacy(
shardDirPath, testWriterStart, summariesFileSuffix)
summariesFilePath := dataFilesetPathFromTimeAndIndex(
shardDirPath, testWriterStart, 0, summariesFileSuffix, false)
summariesFile, err := os.Open(summariesFilePath)
if err != nil {
return false, fmt.Errorf("err opening summaries file: %v, ", err)
Expand Down Expand Up @@ -254,7 +254,7 @@ func genTagIdent() gopter.Gen {
}

func readIndexFileOffsets(shardDirPath string, numEntries int, start time.Time) (map[string]int64, error) {
indexFilePath := filesetPathFromTimeLegacy(shardDirPath, start, indexFileSuffix)
indexFilePath := dataFilesetPathFromTimeAndIndex(shardDirPath, start, 0, indexFileSuffix, false)
buf, err := ioutil.ReadFile(indexFilePath)
if err != nil {
return nil, fmt.Errorf("err reading index file: %v, ", err)
Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/storage/bootstrap/bootstrapper/fs/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import (
"sync"
"time"

"github.com/m3db/m3/src/dbnode/namespace"
"github.com/m3db/m3/src/dbnode/persist"
"github.com/m3db/m3/src/dbnode/persist/fs"
"github.com/m3db/m3/src/dbnode/retention"
"github.com/m3db/m3/src/dbnode/storage/block"
"github.com/m3db/m3/src/dbnode/storage/bootstrap"
"github.com/m3db/m3/src/dbnode/storage/bootstrap/result"
"github.com/m3db/m3/src/dbnode/storage/index/convert"
"github.com/m3db/m3/src/dbnode/namespace"
"github.com/m3db/m3/src/dbnode/storage/series"
"github.com/m3db/m3/src/dbnode/ts"
"github.com/m3db/m3/src/m3ninx/index/segment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import (
"time"

"github.com/m3db/m3/src/dbnode/digest"
"github.com/m3db/m3/src/dbnode/namespace"
"github.com/m3db/m3/src/dbnode/persist/fs"
"github.com/m3db/m3/src/dbnode/retention"
"github.com/m3db/m3/src/dbnode/storage/bootstrap"
"github.com/m3db/m3/src/dbnode/storage/bootstrap/result"
"github.com/m3db/m3/src/dbnode/namespace"
"github.com/m3db/m3/src/dbnode/storage/series"
"github.com/m3db/m3/src/x/checked"
"github.com/m3db/m3/src/x/context"
Expand Down Expand Up @@ -107,19 +107,19 @@ func createTempDir(t *testing.T) string {

func writeInfoFile(t *testing.T, prefix string, namespace ident.ID, shard uint32, start time.Time, data []byte) {
shardDir := fs.ShardDataDirPath(prefix, namespace, shard)
filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-info.db", xtime.ToNanoseconds(start)))
filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-0-info.db", xtime.ToNanoseconds(start)))
writeFile(t, filePath, data)
}

func writeDataFile(t *testing.T, prefix string, namespace ident.ID, shard uint32, start time.Time, data []byte) {
shardDir := fs.ShardDataDirPath(prefix, namespace, shard)
filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-data.db", xtime.ToNanoseconds(start)))
filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-0-data.db", xtime.ToNanoseconds(start)))
writeFile(t, filePath, data)
}

func writeDigestFile(t *testing.T, prefix string, namespace ident.ID, shard uint32, start time.Time, data []byte) {
shardDir := fs.ShardDataDirPath(prefix, namespace, shard)
filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-digest.db", xtime.ToNanoseconds(start)))
filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-0-digest.db", xtime.ToNanoseconds(start)))
writeFile(t, filePath, data)
}

Expand Down

0 comments on commit 9567db8

Please sign in to comment.