Skip to content

Commit

Permalink
Squash
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Artoul committed Jul 24, 2018
1 parent c096772 commit 8a33ff2
Show file tree
Hide file tree
Showing 25 changed files with 1,257 additions and 264 deletions.
3 changes: 2 additions & 1 deletion src/dbnode/integration/commitlog_bootstrap_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ func writeCommitLogDataBase(
}

// ensure commit log is flushing frequently
require.Equal(t, defaultIntegrationTestFlushInterval, opts.FlushInterval())
require.Equal(
t, defaultIntegrationTestFlushInterval, opts.FlushInterval())

var (
seriesLookup = newCommitLogSeriesStates(data)
Expand Down
9 changes: 0 additions & 9 deletions src/dbnode/integration/disk_cleanup_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ package integration

import (
"errors"
"os"
"testing"
"time"

Expand Down Expand Up @@ -83,14 +82,6 @@ func writeIndexFileSetFiles(t *testing.T, storageOpts storage.Options, md namesp
}
}

func writeCommitLogs(t *testing.T, filePathPrefix string, fileTimes []time.Time) {
for _, start := range fileTimes {
commitLogFile, _ := fs.NextCommitLogsFile(filePathPrefix, start)
_, err := os.Create(commitLogFile)
require.NoError(t, err)
}
}

type cleanupTimesCommitLog struct {
filePathPrefix string
times []time.Time
Expand Down
17 changes: 16 additions & 1 deletion src/dbnode/integration/disk_cleanup_multi_ns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import (
"testing"
"time"

"github.com/m3db/m3db/src/dbnode/integration/generate"
"github.com/m3db/m3db/src/dbnode/retention"
"github.com/m3db/m3db/src/dbnode/storage/namespace"
xtime "github.com/m3db/m3x/time"

"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -133,7 +135,20 @@ func TestDiskCleanupMultipleNamespace(t *testing.T) {

log.Infof("creating commit log and fileset files")
shard := uint32(0)
writeCommitLogs(t, filePathPrefix, commitLogTimes)
for _, clTime := range commitLogTimes {
// Need to generate valid commit log files otherwise cleanup will fail.
data := map[xtime.UnixNano]generate.SeriesBlock{
xtime.ToUnixNano(clTime): nil,
}
writeCommitLogDataSpecifiedTS(
t,
testSetup,
testSetup.storageOpts.CommitLogOptions().SetFlushInterval(defaultIntegrationTestFlushInterval),
data,
ns1.ID(),
clTime,
)
}
writeDataFileSetFiles(t, testSetup.storageOpts, ns1, shard, ns1Times)
writeDataFileSetFiles(t, testSetup.storageOpts, ns2, shard, ns2Times)

Expand Down
18 changes: 17 additions & 1 deletion src/dbnode/integration/disk_cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import (
"testing"
"time"

"github.com/m3db/m3db/src/dbnode/integration/generate"
"github.com/m3db/m3x/ident"
xtime "github.com/m3db/m3x/time"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -65,7 +68,20 @@ func TestDiskCleanup(t *testing.T) {
fileTimes[i] = now.Add(time.Duration(i) * blockSize)
}
writeDataFileSetFiles(t, testSetup.storageOpts, md, shard, fileTimes)
writeCommitLogs(t, filePathPrefix, fileTimes)
for _, clTime := range fileTimes {
// Need to generate valid commit log files otherwise cleanup will fail.
data := map[xtime.UnixNano]generate.SeriesBlock{
xtime.ToUnixNano(clTime): nil,
}
writeCommitLogDataSpecifiedTS(
t,
testSetup,
testSetup.storageOpts.CommitLogOptions().SetFlushInterval(defaultIntegrationTestFlushInterval),
data,
ident.StringID("some-ns"),
clTime,
)
}

// Move now forward by retentionPeriod + 2 * blockSize so fileset files
// and commit logs at now will be deleted
Expand Down
13 changes: 13 additions & 0 deletions src/dbnode/integration/fs_commitlog_mixed_mode_read_write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,19 @@ func (d dataPointsInTimeOrder) toSeriesMap(blockSize time.Duration) generate.Ser
return nil
}

// before returns a slice of the dataPointsInTimeOrder that are before the
// specified time t.
func (d dataPointsInTimeOrder) before(t time.Time) dataPointsInTimeOrder {
var i int
for i = range d {
if !d[i].time.Before(t) {
break
}
}

return d[:i]
}

type idGen struct {
baseID string
}
Expand Down
Loading

0 comments on commit 8a33ff2

Please sign in to comment.