Alerting: Detach condition validator from condition evaluator (#91150)

* Detach validator from evaluator

* Drop unnecessary interface and type
This commit is contained in:
Alexander Weaver
2024-07-30 10:55:37 -05:00
committed by GitHub
parent cf55ac5813
commit 4c71cadd5f
7 changed files with 84 additions and 46 deletions
+4 -3
View File
@@ -591,10 +591,11 @@ func TestValidate(t *testing.T) {
pluginsStore: store,
})
evaluator := NewEvaluatorFactory(setting.UnifiedAlertingSettings{}, cacheService, expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil, featuremgmt.WithFeatures(), nil, tracing.InitializeTracerForTest()), store)
expressions := expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil, featuremgmt.WithFeatures(), nil, tracing.InitializeTracerForTest())
validator := NewConditionValidator(cacheService, expressions, store)
evalCtx := NewContext(context.Background(), u)
err := evaluator.Validate(evalCtx, condition)
err := validator.Validate(evalCtx, condition)
if testCase.error {
require.Error(t, err)
} else {
@@ -709,7 +710,7 @@ func TestCreate_HysteresisCommand(t *testing.T) {
cache: cacheService,
pluginsStore: store,
})
evaluator := NewEvaluatorFactory(setting.UnifiedAlertingSettings{}, cacheService, expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil, featuremgmt.WithFeatures(featuremgmt.FlagRecoveryThreshold), nil, tracing.InitializeTracerForTest()), store)
evaluator := NewEvaluatorFactory(setting.UnifiedAlertingSettings{}, cacheService, expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil, featuremgmt.WithFeatures(featuremgmt.FlagRecoveryThreshold), nil, tracing.InitializeTracerForTest()))
evalCtx := NewContextWithPreviousResults(context.Background(), u, testCase.reader)
eval, err := evaluator.Create(evalCtx, condition)