Skip to content

Commit

Permalink
Updated TSDB with fixes.
Browse files Browse the repository at this point in the history
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
  • Loading branch information
bwplotka committed Aug 7, 2020
1 parent 76edd0f commit 8249066
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/rules/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func (m *Manager) Stop() {
mgr.Stop()
}
}

func (m *Manager) protoRuleGroups() []*rulespb.RuleGroup {

rg := m.RuleGroups()
res := make([]*rulespb.RuleGroup, 0, len(rg))
for _, g := range rg {
Expand Down
13 changes: 9 additions & 4 deletions pkg/rules/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ func (n nopQueryable) Querier(_ context.Context, _, _ int64) (storage.Querier, e
return storage.NoopQuerier(), nil
}

type nopQueryable struct{}

func (n nopQueryable) Querier(_ context.Context, _, _ int64) (storage.Querier, error) {
return storage.NoopQuerier(), nil
}

// Regression test against https://github.com/thanos-io/thanos/issues/1779.
func TestRun(t *testing.T) {
func TestRun_Subqueries(t *testing.T) {
dir, err := ioutil.TempDir("", "test_rule_run")
testutil.Ok(t, err)
defer func() { testutil.Ok(t, os.RemoveAll(dir)) }()
Expand Down Expand Up @@ -84,17 +90,16 @@ groups:
},
labels.FromStrings("replica", "1"),
)
testutil.Ok(t, thanosRuleMgr.Update(10*time.Second, []string{filepath.Join(dir, "rule.yaml")}))
testutil.Ok(t, thanosRuleMgr.Update(1*time.Second, []string{filepath.Join(dir, "rule.yaml")}))

thanosRuleMgr.Run()
defer thanosRuleMgr.Stop()

select {
case <-time.After(2 * time.Minute):
case <-time.After(1 * time.Minute):
t.Fatal("timeout while waiting on rule manager query evaluation")
case <-queryDone:
}

testutil.Equals(t, "rate(some_metric[1h:5m] offset 1d)", query)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/store/storepb/testutil/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func CreateHeadWithSeries(t testing.TB, j int, opts HeadGenOptions) (*tsdb.Head,
testutil.Ok(t, err)
}

h, err := tsdb.NewHead(nil, nil, w, 10000000, tsdbDir, nil, tsdb.DefaultStripeSize, nil)
h, err := tsdb.NewHead(nil, nil, w, tsdb.DefaultBlockDuration, tsdbDir, nil, tsdb.DefaultStripeSize, nil)
testutil.Ok(t, err)

app := h.Appender(context.Background())
Expand Down
1 change: 0 additions & 1 deletion pkg/store/tsdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ func TestTSDBStore_LabelValues(t *testing.T) {
}

tsdbStore := NewTSDBStore(nil, nil, db, component.Rule, labels.FromStrings("region", "eu-west"))

now := time.Now()
head := db.Head()
for _, tc := range []struct {
Expand Down

0 comments on commit 8249066

Please sign in to comment.