From c66347768889f140253ecc7a0f4358bc051aaa01 Mon Sep 17 00:00:00 2001 From: Ganesh Vernekar Date: Mon, 20 Aug 2018 14:51:05 +0200 Subject: [PATCH] Fixed TestUpdate in rules/manager_test.go (#4516) Signed-off-by: Ganesh Vernekar --- rules/manager_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/rules/manager_test.go b/rules/manager_test.go index c54c70bd0..109b0bd3a 100644 --- a/rules/manager_test.go +++ b/rules/manager_test.go @@ -433,11 +433,6 @@ func TestForStateRestore(t *testing.T) { newGroups := make(map[string]*Group) newGroups["default;"] = newGroup - m := NewManager(opts) - m.mtx.Lock() - m.groups = newGroups - m.mtx.Unlock() - restoreTime := baseTime.Add(tst.restoreDuration) // First eval before restoration. newGroup.Eval(suite.Context(), restoreTime) @@ -626,11 +621,18 @@ func TestUpdate(t *testing.T) { expected := map[string]labels.Labels{ "test": labels.FromStrings("name", "value"), } + storage := testutil.NewStorage(t) + defer storage.Close() + engine := promql.NewEngine(nil, nil, 10, 10*time.Second) ruleManager := NewManager(&ManagerOptions{ - Context: context.Background(), - Logger: log.NewNopLogger(), + Appendable: storage, + TSDB: storage, + QueryFunc: EngineQueryFunc(engine, storage), + Context: context.Background(), + Logger: log.NewNopLogger(), }) ruleManager.Run() + defer ruleManager.Stop() err := ruleManager.Update(10*time.Second, files) testutil.Ok(t, err)