From 7bcddd5f89bc516d35915b4070c51a0d56564d70 Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Wed, 13 Mar 2024 11:13:18 +0000 Subject: [PATCH 01/20] refactoring integration tests for search_metrics --- .../golang/aim/metric/search_test.go | 5747 +++-------------- 1 file changed, 862 insertions(+), 4885 deletions(-) diff --git a/tests/integration/golang/aim/metric/search_test.go b/tests/integration/golang/aim/metric/search_test.go index db4e5dfaa..148c237d8 100644 --- a/tests/integration/golang/aim/metric/search_test.go +++ b/tests/integration/golang/aim/metric/search_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/G-Research/fasttrackml/pkg/api/aim/encoding" - "github.com/G-Research/fasttrackml/pkg/api/aim/request" + "github.com/G-Research/fasttrackml/pkg/api/aim2/api/request" "github.com/G-Research/fasttrackml/pkg/api/mlflow/dao/models" "github.com/G-Research/fasttrackml/pkg/common/db/types" "github.com/G-Research/fasttrackml/tests/integration/golang/helpers" @@ -306,6 +306,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { s.Require().Nil(err) runs := []*models.Run{run1, run2, run3} + contextValue := "\"testkey\":\"testvalue\"" tests := []struct { name string request request.SearchMetricsRequest @@ -314,7 +315,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameOperationEqual", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + }, + }, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -322,223 +327,44 @@ func (s *SearchMetricsTestSuite) Test_Ok() { metric1Run3, }, }, - { - name: "SearchMetricNameOperationNotEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric3")`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric1Run2, - metric2Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameOperationStartsWith", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameOperationEndsWith", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("3"))`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric3Run2, - }, - }, - { - name: "SearchMetricLastOperationEquals", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastOperationNotEquals", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastOperationGreater", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastOperationLess", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastOperationGreaterOrEqual", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastOperationLessOrEqual", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepOperationEquals", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 1)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastStepOperationNotEquals", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 1)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepOperationGreater", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 1)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepOperationLess", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepOperationGreaterOrEqual", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 1)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepOperationLessOrEqual", - request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, { name: "SearchRunArchived", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.archived == True`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.archived == True`, }, }, { name: "SearchRunNotArchived", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.archived == False`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.archived == False`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -554,8 +380,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunActive", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.active == True`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.active == True`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -566,8 +405,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNotActive", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.active == False`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.active == False`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -580,8 +432,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchDurationOperationGreater", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.duration > 0`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.duration > 0`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -594,8 +459,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.duration >= 0`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.duration >= 0`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -611,9 +489,22 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationLess", request: request.SearchMetricsRequest{ + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, Query: fmt.Sprintf( - `((metric.name == "TestMetric1") or (metric.name == "TestMetric2")`+ - `or (metric.name == "TestMetric3")) and run.duration < %d`, + `run.duration < %d`, (run3.EndTime.Int64-run3.StartTime.Int64)/1000, ), }, @@ -626,9 +517,22 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationLessOrEqual", request: request.SearchMetricsRequest{ + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, Query: fmt.Sprintf( - `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and run.duration <= %d`, + `run.duration <= %d`, (run3.EndTime.Int64-run3.StartTime.Int64)/1000, ), }, @@ -643,8 +547,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.duration == 0`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.duration == 0`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -655,8 +572,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationNotEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.duration != 0`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.duration != 0`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -669,8 +599,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationGreater", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.created_at > 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.created_at > 123456789`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -680,8 +623,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.created_at >= 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.created_at >= 123456789`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -694,8 +650,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationNotEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.created_at != 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.created_at != 123456789`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -708,8 +677,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.created_at == 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.created_at == 123456789`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -720,8 +702,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationLess", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.created_at < 222222222`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.created_at < 222222222`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -735,8 +730,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationLessOrEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.created_at <= 222222222`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.created_at <= 222222222`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -752,8 +760,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationGreater", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.finalized_at > 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.finalized_at > 123456789`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -766,8 +787,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.finalized_at >= 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.finalized_at >= 123456789`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -783,8 +817,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationNotEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.finalized_at != 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.finalized_at != 123456789`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -797,8 +844,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.finalized_at == 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.finalized_at == 123456789`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -809,8 +869,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationLess", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.finalized_at < 444444444`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.finalized_at < 444444444`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -821,8 +894,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.finalized_at <= 444444444`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.finalized_at <= 444444444`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -838,8 +924,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunHashOperationEqual", request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`((metric.name == "TestMetric1") or (metric.name == "TestMetric2")`+ - `or (metric.name == "TestMetric3")) and run.hash == "%s"`, run1.ID), + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: fmt.Sprintf(`run.hash == "%s"`, run1.ID), }, metrics: []*models.LatestMetric{ metric1Run1, @@ -850,8 +949,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunHashOperationNotEqual", request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`((metric.name == "TestMetric1") or (metric.name == "TestMetric2")`+ - `or (metric.name == "TestMetric3")) and run.hash != "%s"`, run1.ID), + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: fmt.Sprintf(`run.hash != "%s"`, run1.ID), }, metrics: []*models.LatestMetric{ metric1Run2, @@ -864,8 +976,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationNotEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.name != "TestRun1"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.name != "TestRun1"`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -878,8 +1003,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.name == "TestRun1"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.name == "TestRun1"`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -890,8 +1028,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationIn", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and "Run3" in run.name`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `"Run3" in run.name`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -901,8 +1052,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationNotIn", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and "Run3" not in run.name`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `"Run3" not in run.name`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -916,8 +1080,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationStartsWith", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.name.startswith("Test")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.name.startswith("Test")`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -933,8 +1110,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationStartsWith", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.name.endswith('3')`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.name.endswith('3')`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -944,9 +1134,22 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunExperimentOperationEqual", request: request.SearchMetricsRequest{ + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, Query: fmt.Sprintf( - `((metric.name == "TestMetric1") or (metric.name == "TestMetric2")`+ - `or (metric.name == "TestMetric3")) and run.experiment == "%s"`, + `run.experiment == "%s"`, experiment.Name, ), }, @@ -962,9 +1165,22 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunExperimentOperationNotEqual", request: request.SearchMetricsRequest{ + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, Query: fmt.Sprintf( - `((metric.name == "TestMetric1") or (metric.name == "TestMetric2")`+ - `or (metric.name == "TestMetric3")) and run.experiment != "%s"`, + `run.experiment != "%s"`, experiment.Name, ), }, @@ -976,8 +1192,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunTagOperationEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.tags['mlflow.runName'] == "TestRunTag1"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.tags['mlflow.runName'] == "TestRunTag1"`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -988,8 +1217,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunTagOperationNotEqual", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and run.tags['mlflow.runName'] != "TestRunTag1"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.tags['mlflow.runName'] != "TestRunTag1"`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1002,7 +1244,13 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationRegexpMatchFunction", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and re.match("TestRun1", run.name))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `re.match("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1011,7 +1259,13 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationRegexpSearchFunction", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and re.search("TestRun1", run.name))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `re.search("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1020,7 +1274,13 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationEquals", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.name == "TestRun1")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `run.name == "TestRun1"`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1029,7 +1289,13 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationNotEquals", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.name != "TestRun1")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `run.name != "TestRun1"`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1039,7 +1305,13 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationStartsWith", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.name.startswith("Test"))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `run.name.startswith("Test")`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1050,7 +1322,13 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationEndsWith", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.name.endswith("Run2"))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `run.name.endswith("Run2")`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1059,7 +1337,17 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationNotEqualsAndRegexpMatchFunction", request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and re.match("TestRun1", run.name))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `re.match("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1069,7 +1357,17 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationNotEqualsAndRegexpSearchFunction", request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and re.search("TestRun1", run.name))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `re.search("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1079,7 +1377,17 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationNotEqualsAndEquals", request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.name == "TestRun1")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.name == "TestRun1"`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1089,7 +1397,17 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationNotEqualsAndNotEquals", request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.name != "TestRun1")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.name != "TestRun1"`, }, metrics: []*models.LatestMetric{ metric2Run2, @@ -1100,7 +1418,17 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationNotEqualsAndStartsWith", request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.name.startswith("Test"))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.name.startswith("Test")`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1113,7 +1441,17 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricNameAndRunNameOperationNotEqualsAndEndsWith", request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.name.endswith("Run2"))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `run.name.endswith("Run2")`, }, metrics: []*models.LatestMetric{ metric2Run2, @@ -1121,4756 +1459,397 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationStartsWithAndRegexpMatchFunction", + name: "SearchMetricNameAndRunDurationOperationEqual", request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and re.match("TestRun1", run.name))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `run.duration == 222222`, }, metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, + metric1Run3, }, }, { - name: "SearchMetricNameAndRunNameOperationStartsWithAndRegexpSearchFunction", + name: "SearchMetricNameAndRunDurationOperationNotEqual", request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and re.search("TestRun1", run.name))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `run.duration != 222222`, }, metrics: []*models.LatestMetric{ metric1Run1, - metric2Run1, - metric3Run1, + metric1Run2, }, }, { - name: "SearchMetricNameAndRunNameOperationStartsWithAndEquals", + name: "SearchMetricNameAndRunDurationOperationGreater", request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.name == "TestRun1")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `run.duration > 0`, }, metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, + metric1Run2, + metric1Run3, }, }, { - name: "SearchMetricNameAndRunNameOperationStartsWithAndNotEquals", + name: "SearchMetricNameAndRunDurationOperationGreaterOrEquals", request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.name != "TestRun1")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `run.duration >= 0`, }, metrics: []*models.LatestMetric{ + metric1Run1, metric1Run2, - metric2Run2, - metric3Run2, metric1Run3, - metric2Run3, }, }, { - name: "SearchMetricNameAndRunNameOperationStartsWithAndStartsWith", + name: "SearchMetricNameAndRunDurationOperationLess", request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.name.startswith("Test"))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.duration < 333333)`, }, metrics: []*models.LatestMetric{ metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, metric1Run3, - metric2Run3, }, }, { - name: "SearchMetricNameAndRunNameOperationStartsWithAndEndsWith", + name: "SearchMetricNameAndRunDurationOperationLessOrEquals", request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.name.endswith("Run2"))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `run.duration <= 333333`, }, metrics: []*models.LatestMetric{ + metric1Run1, metric1Run2, - metric2Run2, - metric3Run2, + metric1Run3, }, }, { - name: "SearchMetricNameAndRunNameOperationEndsWithAndRegexpMatchFunction", + name: "SearchMetricNameAndRunHashOperationEquals", request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and re.match("TestRun1", run.name))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: fmt.Sprintf(`(run.hash == "%s")`, run1.ID), }, metrics: []*models.LatestMetric{ - metric2Run1, + metric1Run1, }, }, { - name: "SearchMetricNameAndRunNameOperationEndsWithAndRegexpSearchFunction", + name: "SearchMetricNameAndRunHashOperationNotEquals", request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and re.search("TestRun1", run.name))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: fmt.Sprintf(`(run.hash != "%s")`, run1.ID), }, metrics: []*models.LatestMetric{ - metric2Run1, + metric1Run2, + metric1Run3, }, }, { - name: "SearchMetricNameAndRunNameOperationEndsWithAndEquals", + name: "SearchMetricNameAndRunFinalizedAtOperationGreater", request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.name == "TestRun1")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.finalized_at > 123456789)`, }, metrics: []*models.LatestMetric{ - metric2Run1, + metric1Run2, + metric1Run3, }, }, { - name: "SearchMetricNameAndRunNameOperationEndsWithAndNotEquals", + name: "SearchMetricNameAndRunFinalizedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.name != "TestRun1")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.finalized_at >= 123456789)`, }, metrics: []*models.LatestMetric{ - metric2Run2, - metric2Run3, + metric1Run1, + metric1Run2, + metric1Run3, }, }, { - name: "SearchMetricNameAndRunNameOperationEndsWithAndStartsWith", + name: "SearchMetricNameAndRunFinalizedAtOperationLess", request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.name.startswith("Test"))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.finalized_at < 444444444)`, }, metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - metric2Run3, + metric1Run1, }, }, { - name: "SearchMetricNameAndRunNameOperationEndsWithAndEndsWith", + name: "SearchMetricNameAndRunFinalizedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.name.endswith("Run2"))`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.finalized_at <= 444444444)`, }, metrics: []*models.LatestMetric{ - metric2Run2, + metric1Run1, + metric1Run2, + metric1Run3, }, }, { - name: "SearchMetricNameAndRunDurationOperationEqual", + name: "SearchMetricNameAndRunFinalizedOperationAtEquals", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.duration == 222222)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.finalized_at == 123456789)`, }, metrics: []*models.LatestMetric{ - metric1Run3, + metric1Run1, }, }, { - name: "SearchMetricNameAndRunDurationOperationNotEqual", + name: "SearchMetricNameAndRunFinalizedAtOperationNotEquals", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.duration != 222222)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.finalized_at != 123456789)`, }, metrics: []*models.LatestMetric{ - metric1Run1, metric1Run2, + metric1Run3, }, }, { - name: "SearchMetricNameAndRunDurationOperationGreater", + name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndGreater", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.duration > 0)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `(run.finalized_at > 123456789)`, }, metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, + metric2Run2, + metric3Run2, + metric2Run3, }, }, { - name: "SearchMetricNameAndRunDurationOperationGreaterOrEquals", + name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndGreaterOrEqual", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.duration >= 0)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + PartialContext: nil, + }, + { + Key: "TestMetric3", + PartialContext: nil, + }, + }, + Query: `(run.finalized_at >= 123456789)`, }, metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, + metric2Run1, + metric3Run1, + metric2Run2, + metric3Run2, + metric2Run3, }, }, { - name: "SearchMetricNameAndRunDurationOperationLess", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationGreater", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.duration < 333333)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.created_at > 123456789)`, }, metrics: []*models.LatestMetric{ - metric1Run1, metric1Run3, }, }, { - name: "SearchMetricNameAndRunDurationOperationLessOrEquals", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.duration <= 333333)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.created_at >= 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run1, - metric1Run2, metric1Run3, }, }, { - name: "SearchMetricNameAndRunDurationOperationNotEqualsAndEquals", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationLess", request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.duration == 222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.duration != 222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationNotEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationNotEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationNotEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationNotEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationStartsWithAndEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.duration == 222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationStartsWithAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.duration != 222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationStartsWithAndGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationStartsWithAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationStartsWithAndLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationStartsWithAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationEndsWithAndEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.duration == 222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationEndsWithAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.duration != 222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationEndsWithAndGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationEndsWithAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationEndsWithAndLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunDurationOperationEndsWithAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunHashOperationEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(metric.name == "TestMetric1" and run.hash == "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricNameAndRunHashOperationNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(metric.name == "TestMetric1" and run.hash != "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricNameAndRunHashOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(metric.name != "TestMetric1" and run.hash == "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricNameAndRunHashOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(metric.name != "TestMetric1" and run.hash != "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunHashOperationStartsWithAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(metric.name.startswith("Test") and run.hash == "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricNameAndRunHashOperationStartsWithAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(metric.name.startswith("Test") and run.hash != "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunHashOperationEndsWithAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(metric.name.endswith("Metric2") and run.hash == "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricNameAndRunHashOperationEndsWithAndNotEqual", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(metric.name.endswith("Metric2") and run.hash != "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationGreaterOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationLessOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedOperationAtEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndGreaterOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndLessOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationStartsWithAndGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationStartsWithAndGreaterOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationStartsWithAndLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricNamehAndRunFinalizedAtOperationStartsWithAndLessOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationStartsWithAndEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationStartsWithAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationEndsWithAndGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationEndsWithAndGreaterOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationEndsWithAndLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationEndsWithAndLessOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationEndsWithAndEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricNameAndRunFinalizedAtOperationEndsWithAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.created_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run3, - }, - }, - { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationGreaterOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.created_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - }, - }, - { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationLessOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.created_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1" and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricNameNotEqualsAndRunCreatedAtOperationGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.created_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricNameNotEqualsAndRunCreatedAtOperationGreaterOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.created_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run3, - }, - }, - { - name: "SearchMetricNameNotEqualsAndRunCreatedAtOperationLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricNameNotEqualsAndRunCreatedAtOperationLessOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameNotEqualsAndRunCreatedAtOperationEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.created_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricNameNotEqualsAndRunCreatedAtOperationNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name != "TestMetric1" and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameStartsWithAndRunCreatedAtOperationGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.created_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameStartsWithAndRunCreatedAtOperationGreaterOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.created_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameStartsWithAndRunCreatedAtOperationLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricNameStartsWithAndRunCreatedAtOperationLessOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameStartsWithAndRunCreatedAtOperationEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.created_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricNameStartsWithAndRunCreatedAtOperationNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.startswith("Test") and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricNameEndsWithAndRunCreatedAtOperationNotEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.created_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricNameEndsWithAndRunCreatedAtOperationNotEqualsAndGreaterOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.created_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run3, - }, - }, - { - name: "SearchMetricNameEndsWithAndRunCreatedAtOperationNotEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricNameEndsWithAndRunCreatedAtOperationNotEqualsAndLessOrEqual", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricNameEndsWithAndRunCreatedAtOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.created_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricNameEndsWithAndRunCreatedAtOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(metric.name.endswith("Metric2") and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and re.match("TestRun3", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and re.search("TestRun3", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.name == "TestRun3")`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.name != "TestRun3")`, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.name.endswith("Run2"))`, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationNotEqualsAndRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and re.match("TestRun3", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationNotEqualsAndRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and re.search("TestRun3", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.name == "TestRun3")`, - }, - metrics: []*models.LatestMetric{ - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.name != "TestRun3")`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationNotEqualsAndStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationNotEqualsAndEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.name.endswith("Run3"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterAndRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and re.match("TestRun1", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterAndRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and re.search("TestRun1", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.name == "TestRun1")`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.name != "TestRun1")`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterAndStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterAndEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.name.endswith("Run2"))`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterOrEqualsAndRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and re.match("TestRun1", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterOrEqualsAndRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and re.search("TestRun1", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.name == "TestRun1")`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.name != "TestRun1")`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterOrEqualsAndStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationGreaterOrEqualsAndEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.name.endswith("Run2"))`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessAndRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and re.match("TestRun1", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessAndRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and re.search("TestRun1", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.name == "TestRun1")`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.name != "TestRun1")`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessAndStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessAndEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.name.endswith("Run2"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessOrEqualsAndRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and re.match("TestRun1", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessOrEqualsAndRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and re.search("TestRun1", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.name == "TestRun1")`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.name != "TestRun1")`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessOrEqualsAndStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunNameOperationLessOrEqualsAndEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.name.endswith("Run2"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.duration == 222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.duration != 222222)`, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.duration < 222222)`, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.duration <= 222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.duration == 222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.duration != 222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationNotEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationNotEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationNotEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.duration < 222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationNotEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.duration <= 222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.duration == 222222)`, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.duration != 222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.duration == 222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.duration != 222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationGreaterOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.duration == 222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.duration != 222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.duration == 222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.duration != 222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunDurationOperationLessOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2")`+ - `or (metric.name == "TestMetric3")) and (metric.last == 1.1) and run.hash == "%s")`, - run1.ID, - ), - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2")`+ - `or (metric.name == "TestMetric3")) and (metric.last == 1.1) and run.hash != "%s")`, - run1.ID, - ), - }, - }, - { - name: "SearchMetricLastAndRunHashOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2")`+ - `or (metric.name == "TestMetric3")) and (metric.last != 1.1) and run.hash == "%s")`, - run1.ID, - ), - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last != 1.1) and run.hash != "%s")`, - run1.ID, - ), - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationGreaterAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last > 1.1) and run.hash == "%s")`, - run1.ID), - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationGreaterAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last > 1.1) and run.hash != "%s")`, - run1.ID, - ), - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationGreaterOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last >= 1.1) and run.hash == "%s")`, - run1.ID, - ), - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationGreaterOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last >= 1.1) and run.hash != "%s")`, - run1.ID, - ), - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationLessAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last < 3.1) and run.hash == "%s")`, - run1.ID, - ), - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationLessAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last < 3.1) and run.hash != "%s")`, - run1.ID, - ), - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationLessOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last <= 3.1) and run.hash == "%s")`, - run1.ID, - ), - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunHashOperationLessOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf( - `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last <= 3.1) and run.hash != "%s")`, - run1.ID, - ), - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.1) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.1) and run.finalized_at > 123456789)`, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.1) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.finalized_at < 444444444)`, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationNotEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationNotEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationNotEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationNotEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationGreaterOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunFinalizedAtOperationLessOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.1) and run.created_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.1) and run.created_at > 123456789)`, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.1) and run.created_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.created_at < 222222222)`, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last == 1.6) and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.created_at == 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.created_at != 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationNotEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.created_at > 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationNotEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.created_at >= 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationNotEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationNotEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last != 1.6) and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.created_at == 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.created_at != 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.created_at > 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.created_at >= 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.created_at < 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last > 1.6) and run.created_at <= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.created_at == 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.created_at != 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.created_at > 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.created_at >= 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationGreaterOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last >= 1.6) and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric2Run2, - metric3Run2, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.created_at == 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.created_at != 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.created_at > 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.created_at >= 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last < 1.6) and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.created_at == 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.created_at != 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.created_at > 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.created_at >= 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - }, - }, - { - name: "SearchMetricLastAndRunCreatedAtOperationLessOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last <= 1.6) and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric1Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and re.match("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and re.search("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.name == "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.name != "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.name.endswith("Run2"))`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationNotEqualsAndRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and re.match("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationNotEqualsAndRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and re.search("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.name == "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") or ` + - `(metric.name == "TestMetric3")) and (metric.last_step != 2) and run.name != "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationNotEqualsAndStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationNotEqualsAndEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.name.endswith("Run2"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterAndRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and re.match("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterAndRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and re.search("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.name == "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.name != "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterAndStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterAndEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.name.endswith("Run2"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterOrEqualsAndRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and re.match("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterOrEqualsAndRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and re.search("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.name == "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.name != "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterOrEqualsAndStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationGreaterOrEqualsAndEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.name.endswith("Run2"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessAndRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and re.match("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessAndRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and re.search("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.name == "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.name != "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessAndStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessAndEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.name.endswith("Run2"))`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessOrEqualsAndRegexpMatchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and re.match("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessOrEqualsAndRegexpSearchFunction", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and re.search("TestRun2", run.name))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.name == "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.name != "TestRun2")`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessrOrEqualsAndStartsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.name.startswith("Test"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunNameOperationLessOrEqualsAndEndsWith", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.name.endswith("Run2"))`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.duration == 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.duration != 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.duration == 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.duration != 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationNotEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationNotEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationNotEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationNotEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.duration == 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.duration != 333333)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.duration == 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.duration != 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationGreaterOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.duration == 333333)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.duration != 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.duration == 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.duration != 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.duration > 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.duration >= 0)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.duration < 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunDurationOperationLessOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.duration <= 333333)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.hash == "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.hash != "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.hash == "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.hash != "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationGreaterAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.hash == "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationGreaterAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.hash != "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationGreaterOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.hash == "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationGreaterOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.hash != "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationLessAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.hash == "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationLessAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.hash != "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationLessOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.hash == "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunHashOperationLessOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: fmt.Sprintf(`(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") `+ - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.hash != "%s")`, run1.ID), - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationNotEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationNotEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationNotEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationNotEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationGreaterOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.finalized_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.finalized_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.finalized_at > 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.finalized_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.finalized_at < 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunFinalizedAtOperationLessOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.finalized_at <= 444444444)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.created_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.created_at > 123456789)`, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.created_at >= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.created_at < 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step == 2) and run.created_at <= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationNotEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.created_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationNotEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationNotEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.created_at > 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationNotEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.created_at >= 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationNotEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationNotEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step != 2) and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.created_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.created_at > 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.created_at >= 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step > 2) and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric3Run1, - metric1Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.created_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.created_at > 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterOrEqualsAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.created_at >= 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterOrEqualsAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.created_at < 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationGreaterOrEqualsAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step >= 2) and run.created_at <= 222222222)`, - }, - metrics: []*models.LatestMetric{ - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, - metric2Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.created_at == 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.created_at > 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessAndGreaterOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.created_at >= 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessAndLess", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.created_at < 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessAndLessOrEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step < 3) and run.created_at <= 123456789)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric2Run2, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessOrEqualsAndEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.created_at == 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.created_at < 222222222)`, }, metrics: []*models.LatestMetric{ metric1Run1, - metric2Run1, - metric3Run1, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessOrEqualsAndNotEquals", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.created_at != 123456789)`, - }, - metrics: []*models.LatestMetric{ metric1Run2, - metric2Run2, - metric3Run2, - metric1Run3, }, }, { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessOrEqualsAndGreater", - request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.created_at > 111111111)`, - }, - metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, - metric1Run3, - }, - }, - { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessOrEqualsAndGreaterOrEquals", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.created_at >= 111111111)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.created_at <= 222222222)`, }, metrics: []*models.LatestMetric{ metric1Run1, - metric2Run1, - metric3Run1, metric1Run2, - metric2Run2, - metric3Run2, metric1Run3, }, }, { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessOrEqualsAndLess", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationEquals", request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.created_at < 222222222)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.created_at == 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run1, - metric2Run1, - metric3Run1, - metric1Run2, - metric2Run2, - metric3Run2, }, }, { - name: "SearchMetricLastStepAndRunCreatedAtOperationLessOrEqualsAndLessOrEquals", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationNotEquals", request: request.SearchMetricsRequest{ - Query: `(((metric.name == "TestMetric1") or (metric.name == "TestMetric2") ` + - `or (metric.name == "TestMetric3")) and (metric.last_step <= 3) and run.created_at <= 222222222)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + }, + Query: `(run.created_at != 123456789)`, }, metrics: []*models.LatestMetric{ - metric1Run1, - metric2Run1, - metric3Run1, metric1Run2, - metric2Run2, - metric3Run2, metric1Run3, }, }, { name: "SearchMetricComplexQuery", request: request.SearchMetricsRequest{ - Query: `((metric.name == "TestMetric1") or (metric.name == "TestMetric2")) ` + - `and metric.last_step >= 1 and (run.name.endswith("2") or re.match("TestRun1", run.name)) ` + - `and (metric.last < 1.6) and run.duration > 0`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: nil, + }, + { + Key: "TestMetric2", + PartialContext: nil, + }, + }, + Query: `(run.name.endswith("2") or re.match("TestRun1", run.name) and run.duration > 0)`, }, metrics: []*models.LatestMetric{ metric1Run2, + metric2Run2, }, }, { name: "SearchMetricContext", request: request.SearchMetricsRequest{ - Query: `metric.name == "TestMetric1" and metric.context.testkey == "testvalue"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: &contextValue, + }, + }, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -5879,20 +1858,18 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricContextWithXAxis", request: request.SearchMetricsRequest{ - Query: `metric.name == "TestMetric1" and metric.context.testkey == "testvalue"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + PartialContext: &contextValue, + }, + }, XAxis: `TestMetric2`, }, metrics: []*models.LatestMetric{ metric1Run2, }, }, - { - name: "NegativeSearchMetricContext", - request: request.SearchMetricsRequest{ - Query: `metric.name == "TestMetric1" and metric.context.testkey != "testvalue"`, - }, - metrics: []*models.LatestMetric(nil), - }, } for _, tt := range tests { s.Run(tt.name, func() { From e66a915a79a1b42eb8a6e992bb2448f62533607b Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Wed, 13 Mar 2024 11:20:29 +0000 Subject: [PATCH 02/20] renaming integration tests --- .../golang/aim/metric/search_test.go | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/tests/integration/golang/aim/metric/search_test.go b/tests/integration/golang/aim/metric/search_test.go index 148c237d8..607df98bf 100644 --- a/tests/integration/golang/aim/metric/search_test.go +++ b/tests/integration/golang/aim/metric/search_test.go @@ -313,7 +313,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { metrics []*models.LatestMetric }{ { - name: "SearchMetricNameOperationEqual", + name: "SearchMetric", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1242,7 +1242,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationRegexpMatchFunction", + name: "SearchMetricAndRunNameOperationRegexpMatchFunction", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1257,7 +1257,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationRegexpSearchFunction", + name: "SearchMetricAndRunNameOperationRegexpSearchFunction", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1272,7 +1272,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationEquals", + name: "SearchMetricAndRunNameOperationEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1287,7 +1287,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationNotEquals", + name: "SearchMetricAndRunNameOperationNotEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1303,7 +1303,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationStartsWith", + name: "SearchMetricAndRunNameOperationStartsWith", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1320,7 +1320,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationEndsWith", + name: "SearchMetricAndRunNameOperationEndsWith", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1335,7 +1335,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationNotEqualsAndRegexpMatchFunction", + name: "SearchMetricsAndRunNameOperationRegexpMatchFunction", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1355,7 +1355,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationNotEqualsAndRegexpSearchFunction", + name: "SearchMetricsAndRunNameOperationRegexpSearchFunction", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1375,7 +1375,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationNotEqualsAndEquals", + name: "SearchMetricsAndRunNameOperationdEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1395,7 +1395,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationNotEqualsAndNotEquals", + name: "SearchMetricsAndRunNameOperationNotEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1416,7 +1416,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationNotEqualsAndStartsWith", + name: "SearchMetricsAndRunNameOperationStartsWith", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1439,7 +1439,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunNameOperationNotEqualsAndEndsWith", + name: "SearchMetricsxsAndRunNameOperationEndsWith", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1459,7 +1459,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunDurationOperationEqual", + name: "SearchMetricAndRunDurationOperationEqual", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1474,7 +1474,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunDurationOperationNotEqual", + name: "SearchMetricAndRunDurationOperationNotEqual", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1490,7 +1490,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunDurationOperationGreater", + name: "SearchMetricAndRunDurationOperationGreater", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1506,7 +1506,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunDurationOperationGreaterOrEquals", + name: "SearchMetricAndRunDurationOperationGreaterOrEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1523,7 +1523,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunDurationOperationLess", + name: "SearchMetricAndRunDurationOperationLess", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1539,7 +1539,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunDurationOperationLessOrEquals", + name: "SearchMetricAndRunDurationOperationLessOrEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1556,7 +1556,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunHashOperationEquals", + name: "SearchMetricAndRunHashOperationEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1571,7 +1571,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunHashOperationNotEquals", + name: "SearchMetricsAndRunHashOperationNotEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1587,7 +1587,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunFinalizedAtOperationGreater", + name: "SearchMetricAndRunFinalizedAtOperationGreater", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1603,7 +1603,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunFinalizedAtOperationGreaterOrEqual", + name: "SearchMetricAndRunFinalizedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1620,7 +1620,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunFinalizedAtOperationLess", + name: "SearchMetricAndRunFinalizedAtOperationLess", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1635,7 +1635,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunFinalizedAtOperationLessOrEqual", + name: "SearchMetricAndRunFinalizedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1652,7 +1652,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunFinalizedOperationAtEquals", + name: "SearchMetricAndRunFinalizedOperationAtEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1667,7 +1667,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunFinalizedAtOperationNotEquals", + name: "SearchMetricAndRunFinalizedAtOperationNotEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1683,7 +1683,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndGreater", + name: "SearchMetricAndRunFinalizedAtOperationNotEqualsAndGreater", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1704,7 +1704,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndGreaterOrEqual", + name: "SearchMetricsAndRunFinalizedAtOperationNotEqualsAndGreaterOrEqual", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1727,7 +1727,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationGreater", + name: "SearchMetricEqualsAndRunCreatedAtOperationGreater", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1742,7 +1742,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationGreaterOrEqual", + name: "SearchMetricEqualsAndRunCreatedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1758,7 +1758,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationLess", + name: "SearchMetricEqualsAndRunCreatedAtOperationLess", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1774,7 +1774,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationLessOrEqual", + name: "SearchMetricEqualsAndRunCreatedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1791,7 +1791,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationEquals", + name: "SearchMetricEqualsAndRunCreatedAtOperationEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { @@ -1806,7 +1806,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricNameEqualsAndRunCreatedAtOperationNotEquals", + name: "SearchMetricEqualsAndRunCreatedAtOperationNotEquals", request: request.SearchMetricsRequest{ Metrics: []request.MetricTuple{ { From df2e4a4f857962c1627a55ef50672db0be5b3cad Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Wed, 13 Mar 2024 12:33:34 +0000 Subject: [PATCH 03/20] wip removing .metric support --- pkg/api/aim2/api/request/run.go | 15 ++++++-- pkg/api/aim2/dao/repositories/metric.go | 17 ++++++++- pkg/api/aim2/query/query.go | 49 ------------------------- 3 files changed, 26 insertions(+), 55 deletions(-) diff --git a/pkg/api/aim2/api/request/run.go b/pkg/api/aim2/api/request/run.go index 048436d8c..14d428da1 100644 --- a/pkg/api/aim2/api/request/run.go +++ b/pkg/api/aim2/api/request/run.go @@ -49,13 +49,20 @@ type SearchRunsRequest struct { ExcludeTraces bool `query:"exclude_traces"` } +// MetricTuple represents a metric with key and partial context. +type MetricTuple struct { + Key string `query:"metric"` + PartialContext *string `query:"context"` +} + // SearchMetricsRequest is a request struct for `GET /runs/search/metric` endpoint. type SearchMetricsRequest struct { BaseSearchRequest - Query string `query:"q"` - Steps int `query:"p"` - XAxis string `query:"x_axis"` - SkipSystem bool `query:"skip_system"` + Metrics []MetricTuple `query:"m"` + Query string `query:"q"` + Steps int `query:"p"` + XAxis string `query:"x_axis"` + SkipSystem bool `query:"skip_system"` } // SearchAlignedMetricsRequest is a request struct for `GET /runs/search/metric/align` endpoint. diff --git a/pkg/api/aim2/dao/repositories/metric.go b/pkg/api/aim2/dao/repositories/metric.go index 228bbc550..b2ac4c836 100644 --- a/pkg/api/aim2/dao/repositories/metric.go +++ b/pkg/api/aim2/dao/repositories/metric.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "fmt" + "strings" "github.com/gofiber/fiber/v2" "github.com/rotisserie/eris" @@ -103,7 +104,7 @@ func (r MetricRepository) SearchMetrics( return nil, 0, nil, err } - if !pq.IsMetricSelected() { + if req.Metrics == nil || len(req.Metrics) == 0 { return nil, 0, nil, eris.New("No metrics are selected") } @@ -169,6 +170,17 @@ func (r MetricRepository) SearchMetrics( result[r.ID] = SearchResult{int64(r.RowNum), run} } + var metricsSlice []string + var metricsContextsSlice []string + for _, metricTuple := range req.Metrics { + if metricTuple.PartialContext == nil { + metricsSlice = append(metricsSlice, metricTuple.Key) + } else { + cleanContext := strings.ReplaceAll(*metricTuple.PartialContext, `"`, `"`) + metricsContextsSlice = append(metricsContextsSlice, fmt.Sprintf("%s-{%s}", metricTuple.Key, cleanContext)) + } + } + tx := r.db.WithContext(ctx). Select(` metrics.*, @@ -192,7 +204,8 @@ func (r MetricRepository) SearchMetrics( namespaceID, ). Joins("LEFT JOIN latest_metrics USING(run_uuid)"). - Joins("LEFT JOIN contexts ON latest_metrics.context_id = contexts.id")), + Joins("LEFT JOIN contexts ON latest_metrics.context_id = contexts.id"). + Where("CONCAT(latest_metrics.key, '-', contexts.json) IN ? OR latest_metrics.key IN ?", metricsContextsSlice, metricsSlice)), ). Where("MOD(metrics.iter + 1 + runmetrics.interval / 2, runmetrics.interval) < 1"). Order("runmetrics.row_num DESC"). diff --git a/pkg/api/aim2/query/query.go b/pkg/api/aim2/query/query.go index de00c49b4..e57777a0d 100644 --- a/pkg/api/aim2/query/query.go +++ b/pkg/api/aim2/query/query.go @@ -187,10 +187,6 @@ func (pq *parsedQuery) Filter(tx *gorm.DB) *gorm.DB { return tx } -func (pq *parsedQuery) IsMetricSelected() bool { - return pq.metricSelected -} - func (pq *parsedQuery) parseNode(node ast.Expr) (any, error) { ret, err := pq._parseNode(node) if err != nil && !errors.Is(err, SyntaxError{}) { @@ -644,51 +640,6 @@ func (pq *parsedQuery) parseName(node *ast.Name) (any, error) { } }, ), nil - case "metric": - table, ok := pq.qp.Tables["metrics"] - if !ok { - return nil, errors.New("unsupported name identifier 'metric'") - } - return attributeGetter( - func(attr string) (any, error) { - switch attr { - case "name": - pq.metricSelected = true - return clause.Column{ - Table: table, - Name: "key", - }, nil - case "last": - return clause.Column{ - Table: table, - Name: "value", - }, nil - case "last_step": - return clause.Column{ - Table: table, - Name: "last_iter", - }, nil - case "first_step": - return 0, nil - case "context": - return attributeGetter( - func(contextKey string) (any, error) { - // Add a WHERE clause for the context key - return Json{ - Column: clause.Column{ - Table: TableContexts, - Name: "json", - }, - JsonPath: contextKey, - Dialector: pq.qp.Dialector, - }, nil - }, - ), nil - default: - return nil, fmt.Errorf("unsupported metrics attribute %q", attr) - } - }, - ), nil case "re": return attributeGetter( func(attr string) (any, error) { From 3755278aa1878446ed1a149f09e3051f2317a47e Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Fri, 15 Mar 2024 09:45:32 +0000 Subject: [PATCH 04/20] adapt tests --- .../golang/aim/metric/search_test.go | 964 ++++-------------- 1 file changed, 193 insertions(+), 771 deletions(-) diff --git a/tests/integration/golang/aim/metric/search_test.go b/tests/integration/golang/aim/metric/search_test.go index 607df98bf..45b8acadb 100644 --- a/tests/integration/golang/aim/metric/search_test.go +++ b/tests/integration/golang/aim/metric/search_test.go @@ -306,7 +306,6 @@ func (s *SearchMetricsTestSuite) Test_Ok() { s.Require().Nil(err) runs := []*models.Run{run1, run2, run3} - contextValue := "\"testkey\":\"testvalue\"" tests := []struct { name string request request.SearchMetricsRequest @@ -315,11 +314,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetric", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - }, - }, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -330,39 +325,18 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunArchived", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.archived == True`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.archived == True`, }, }, { name: "SearchRunNotArchived", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.archived == False`, }, @@ -380,21 +354,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunActive", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.active == True`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.active == True`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -405,19 +366,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNotActive", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.active == False`, }, @@ -432,19 +385,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchDurationOperationGreater", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.duration > 0`, }, @@ -459,19 +404,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.duration >= 0`, }, @@ -489,20 +426,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationLess", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, Query: fmt.Sprintf( `run.duration < %d`, (run3.EndTime.Int64-run3.StartTime.Int64)/1000, @@ -517,20 +441,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationLessOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, Query: fmt.Sprintf( `run.duration <= %d`, (run3.EndTime.Int64-run3.StartTime.Int64)/1000, @@ -547,21 +458,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.duration == 0`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.duration == 0`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -572,19 +470,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationNotEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.duration != 0`, }, @@ -599,21 +489,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationGreater", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.created_at > 123456789`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.created_at > 123456789`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -623,21 +500,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.created_at >= 123456789`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.created_at >= 123456789`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -650,19 +514,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationNotEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.created_at != 123456789`, }, @@ -677,21 +533,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.created_at == 123456789`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.created_at == 123456789`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -702,19 +545,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationLess", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.created_at < 222222222`, }, @@ -730,19 +565,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationLessOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.created_at <= 222222222`, }, @@ -760,19 +587,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationGreater", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.finalized_at > 123456789`, }, @@ -787,19 +606,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.finalized_at >= 123456789`, }, @@ -817,19 +628,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationNotEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.finalized_at != 123456789`, }, @@ -844,21 +647,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.finalized_at == 123456789`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.finalized_at == 123456789`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -869,21 +659,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationLess", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.finalized_at < 444444444`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.finalized_at < 444444444`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -894,19 +671,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.finalized_at <= 444444444`, }, @@ -924,21 +693,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunHashOperationEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: fmt.Sprintf(`run.hash == "%s"`, run1.ID), + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: fmt.Sprintf(`run.hash == "%s"`, run1.ID), }, metrics: []*models.LatestMetric{ metric1Run1, @@ -949,19 +705,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunHashOperationNotEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: fmt.Sprintf(`run.hash != "%s"`, run1.ID), }, @@ -976,19 +724,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationNotEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.name != "TestRun1"`, }, @@ -1003,21 +743,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.name == "TestRun1"`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.name == "TestRun1"`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1028,21 +755,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationIn", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `"Run3" in run.name`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `"Run3" in run.name`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -1052,19 +766,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationNotIn", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `"Run3" not in run.name`, }, @@ -1080,19 +786,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationStartsWith", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.name.startswith("Test")`, }, @@ -1110,21 +808,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationStartsWith", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.name.endswith('3')`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.name.endswith('3')`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -1134,19 +819,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunExperimentOperationEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: fmt.Sprintf( `run.experiment == "%s"`, @@ -1165,20 +842,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunExperimentOperationNotEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, Query: fmt.Sprintf( `run.experiment != "%s"`, experiment.Name, @@ -1192,21 +856,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunTagOperationEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.tags['mlflow.runName'] == "TestRunTag1"`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.tags['mlflow.runName'] == "TestRunTag1"`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1217,19 +868,11 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunTagOperationNotEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, + MetricsWithContext: []string{ + "TestMetric1-{}", + "TestMetric2-{}", + "TestMetric3-{}", + `TestMetric1-{"testkey":"testvalue"}`, }, Query: `run.tags['mlflow.runName'] != "TestRunTag1"`, }, @@ -1244,13 +887,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunNameOperationRegexpMatchFunction", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `re.match("TestRun1", run.name)`, + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: `re.match("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1259,13 +897,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunNameOperationRegexpSearchFunction", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `re.search("TestRun1", run.name)`, + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: `re.search("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1274,13 +907,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunNameOperationEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `run.name == "TestRun1"`, + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: `run.name == "TestRun1"`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1289,13 +917,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunNameOperationNotEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `run.name != "TestRun1"`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `run.name != "TestRun1"`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1305,13 +928,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunNameOperationStartsWith", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `run.name.startswith("Test")`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `run.name.startswith("Test")`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1322,13 +940,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunNameOperationEndsWith", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `run.name.endswith("Run2")`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `run.name.endswith("Run2")`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1337,17 +950,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricsAndRunNameOperationRegexpMatchFunction", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `re.match("TestRun1", run.name)`, + MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, + Query: `re.match("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1357,17 +961,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricsAndRunNameOperationRegexpSearchFunction", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `re.search("TestRun1", run.name)`, + MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, + Query: `re.search("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1377,17 +972,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricsAndRunNameOperationdEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.name == "TestRun1"`, + MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.name == "TestRun1"`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1397,17 +983,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricsAndRunNameOperationNotEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.name != "TestRun1"`, + MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.name != "TestRun1"`, }, metrics: []*models.LatestMetric{ metric2Run2, @@ -1418,17 +995,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricsAndRunNameOperationStartsWith", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.name.startswith("Test")`, + MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.name.startswith("Test")`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1441,17 +1009,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricsxsAndRunNameOperationEndsWith", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `run.name.endswith("Run2")`, + MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, + Query: `run.name.endswith("Run2")`, }, metrics: []*models.LatestMetric{ metric2Run2, @@ -1461,13 +1020,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunDurationOperationEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `run.duration == 222222`, + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: `run.duration == 222222`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -1476,13 +1030,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunDurationOperationNotEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `run.duration != 222222`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `run.duration != 222222`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1492,13 +1041,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunDurationOperationGreater", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `run.duration > 0`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `run.duration > 0`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1508,13 +1052,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunDurationOperationGreaterOrEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `run.duration >= 0`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `run.duration >= 0`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1525,13 +1064,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunDurationOperationLess", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.duration < 333333)`, + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: `(run.duration < 333333)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1541,13 +1075,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunDurationOperationLessOrEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `run.duration <= 333333`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `run.duration <= 333333`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1558,13 +1087,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunHashOperationEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: fmt.Sprintf(`(run.hash == "%s")`, run1.ID), + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: fmt.Sprintf(`(run.hash == "%s")`, run1.ID), }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1573,13 +1097,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricsAndRunHashOperationNotEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: fmt.Sprintf(`(run.hash != "%s")`, run1.ID), + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: fmt.Sprintf(`(run.hash != "%s")`, run1.ID), }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1589,13 +1108,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunFinalizedAtOperationGreater", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.finalized_at > 123456789)`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `(run.finalized_at > 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1605,13 +1119,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunFinalizedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.finalized_at >= 123456789)`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `(run.finalized_at >= 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1622,13 +1131,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunFinalizedAtOperationLess", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.finalized_at < 444444444)`, + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: `(run.finalized_at < 444444444)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1637,13 +1141,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunFinalizedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.finalized_at <= 444444444)`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `(run.finalized_at <= 444444444)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1654,13 +1153,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunFinalizedOperationAtEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.finalized_at == 123456789)`, + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: `(run.finalized_at == 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1669,13 +1163,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunFinalizedAtOperationNotEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.finalized_at != 123456789)`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `(run.finalized_at != 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1685,17 +1174,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricAndRunFinalizedAtOperationNotEqualsAndGreater", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `(run.finalized_at > 123456789)`, + MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, + Query: `(run.finalized_at > 123456789)`, }, metrics: []*models.LatestMetric{ metric2Run2, @@ -1706,17 +1186,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricsAndRunFinalizedAtOperationNotEqualsAndGreaterOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric2", - PartialContext: nil, - }, - { - Key: "TestMetric3", - PartialContext: nil, - }, - }, - Query: `(run.finalized_at >= 123456789)`, + MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, + Query: `(run.finalized_at >= 123456789)`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1729,13 +1200,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricEqualsAndRunCreatedAtOperationGreater", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.created_at > 123456789)`, + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: `(run.created_at > 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -1744,13 +1210,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricEqualsAndRunCreatedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.created_at >= 123456789)`, + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: `(run.created_at >= 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1760,13 +1221,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricEqualsAndRunCreatedAtOperationLess", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.created_at < 222222222)`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `(run.created_at < 222222222)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1776,13 +1232,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricEqualsAndRunCreatedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.created_at <= 222222222)`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `(run.created_at <= 222222222)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1793,13 +1244,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricEqualsAndRunCreatedAtOperationEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.created_at == 123456789)`, + MetricsWithContext: []string{"TestMetric1-{}"}, + Query: `(run.created_at == 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1808,13 +1254,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricEqualsAndRunCreatedAtOperationNotEquals", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - }, - Query: `(run.created_at != 123456789)`, + MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `(run.created_at != 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1824,17 +1265,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricComplexQuery", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: nil, - }, - { - Key: "TestMetric2", - PartialContext: nil, - }, - }, - Query: `(run.name.endswith("2") or re.match("TestRun1", run.name) and run.duration > 0)`, + MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Query: `(run.name.endswith("2") or re.match("TestRun1", run.name) and run.duration > 0)`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1844,12 +1276,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricContext", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: &contextValue, - }, - }, + MetricsWithContext: []string{`TestMetric1-{"testkey":"testvalue"}`}, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1858,13 +1285,8 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricContextWithXAxis", request: request.SearchMetricsRequest{ - Metrics: []request.MetricTuple{ - { - Key: "TestMetric1", - PartialContext: &contextValue, - }, - }, - XAxis: `TestMetric2`, + MetricsWithContext: []string{`TestMetric1-{"testkey":"testvalue"}`}, + XAxis: `TestMetric2`, }, metrics: []*models.LatestMetric{ metric1Run2, From 78600c92ad67b4aa683711b42cf10bf60b15c724 Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Fri, 15 Mar 2024 09:47:06 +0000 Subject: [PATCH 05/20] change metric-context format for searchmetric endpoint --- pkg/api/aim2/api/request/run.go | 16 +++----- pkg/api/aim2/dao/repositories/metric.go | 16 +------- pkg/api/aim2/query/query.go | 49 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 25 deletions(-) diff --git a/pkg/api/aim2/api/request/run.go b/pkg/api/aim2/api/request/run.go index 14d428da1..163115e90 100644 --- a/pkg/api/aim2/api/request/run.go +++ b/pkg/api/aim2/api/request/run.go @@ -49,20 +49,14 @@ type SearchRunsRequest struct { ExcludeTraces bool `query:"exclude_traces"` } -// MetricTuple represents a metric with key and partial context. -type MetricTuple struct { - Key string `query:"metric"` - PartialContext *string `query:"context"` -} - // SearchMetricsRequest is a request struct for `GET /runs/search/metric` endpoint. type SearchMetricsRequest struct { BaseSearchRequest - Metrics []MetricTuple `query:"m"` - Query string `query:"q"` - Steps int `query:"p"` - XAxis string `query:"x_axis"` - SkipSystem bool `query:"skip_system"` + MetricsWithContext []string `query:"m"` + Query string `query:"q"` + Steps int `query:"p"` + XAxis string `query:"x_axis"` + SkipSystem bool `query:"skip_system"` } // SearchAlignedMetricsRequest is a request struct for `GET /runs/search/metric/align` endpoint. diff --git a/pkg/api/aim2/dao/repositories/metric.go b/pkg/api/aim2/dao/repositories/metric.go index b2ac4c836..52caa089c 100644 --- a/pkg/api/aim2/dao/repositories/metric.go +++ b/pkg/api/aim2/dao/repositories/metric.go @@ -4,7 +4,6 @@ import ( "context" "database/sql" "fmt" - "strings" "github.com/gofiber/fiber/v2" "github.com/rotisserie/eris" @@ -104,7 +103,7 @@ func (r MetricRepository) SearchMetrics( return nil, 0, nil, err } - if req.Metrics == nil || len(req.Metrics) == 0 { + if req.MetricsWithContext == nil || len(req.MetricsWithContext) == 0 { return nil, 0, nil, eris.New("No metrics are selected") } @@ -170,17 +169,6 @@ func (r MetricRepository) SearchMetrics( result[r.ID] = SearchResult{int64(r.RowNum), run} } - var metricsSlice []string - var metricsContextsSlice []string - for _, metricTuple := range req.Metrics { - if metricTuple.PartialContext == nil { - metricsSlice = append(metricsSlice, metricTuple.Key) - } else { - cleanContext := strings.ReplaceAll(*metricTuple.PartialContext, `"`, `"`) - metricsContextsSlice = append(metricsContextsSlice, fmt.Sprintf("%s-{%s}", metricTuple.Key, cleanContext)) - } - } - tx := r.db.WithContext(ctx). Select(` metrics.*, @@ -205,7 +193,7 @@ func (r MetricRepository) SearchMetrics( ). Joins("LEFT JOIN latest_metrics USING(run_uuid)"). Joins("LEFT JOIN contexts ON latest_metrics.context_id = contexts.id"). - Where("CONCAT(latest_metrics.key, '-', contexts.json) IN ? OR latest_metrics.key IN ?", metricsContextsSlice, metricsSlice)), + Where("CONCAT(latest_metrics.key, '-', contexts.json) IN ?", req.MetricsWithContext)), ). Where("MOD(metrics.iter + 1 + runmetrics.interval / 2, runmetrics.interval) < 1"). Order("runmetrics.row_num DESC"). diff --git a/pkg/api/aim2/query/query.go b/pkg/api/aim2/query/query.go index e57777a0d..34bc8ec76 100644 --- a/pkg/api/aim2/query/query.go +++ b/pkg/api/aim2/query/query.go @@ -187,6 +187,10 @@ func (pq *parsedQuery) Filter(tx *gorm.DB) *gorm.DB { return tx } +func (pq *parsedQuery) IsMetricSelected() bool { + return true +} + func (pq *parsedQuery) parseNode(node ast.Expr) (any, error) { ret, err := pq._parseNode(node) if err != nil && !errors.Is(err, SyntaxError{}) { @@ -640,6 +644,51 @@ func (pq *parsedQuery) parseName(node *ast.Name) (any, error) { } }, ), nil + case "metric": + table, ok := pq.qp.Tables["metrics"] + if !ok { + return nil, errors.New("unsupported name identifier 'metric'") + } + return attributeGetter( + func(attr string) (any, error) { + switch attr { + case "name": + pq.metricSelected = true + return clause.Column{ + Table: table, + Name: "key", + }, nil + case "last": + return clause.Column{ + Table: table, + Name: "value", + }, nil + case "last_step": + return clause.Column{ + Table: table, + Name: "last_iter", + }, nil + case "first_step": + return 0, nil + case "context": + return attributeGetter( + func(contextKey string) (any, error) { + // Add a WHERE clause for the context key + return Json{ + Column: clause.Column{ + Table: TableContexts, + Name: "json", + }, + JsonPath: contextKey, + Dialector: pq.qp.Dialector, + }, nil + }, + ), nil + default: + return nil, fmt.Errorf("unsupported metrics attribute %q", attr) + } + }, + ), nil case "re": return attributeGetter( func(attr string) (any, error) { From e31d594d11e94fbebebd40ff2b901e32a2d2a374 Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Fri, 15 Mar 2024 10:22:22 +0000 Subject: [PATCH 06/20] removing support of metric. --- pkg/api/aim2/controller/runs_test.go | 101 --------------------------- pkg/api/aim2/query/query.go | 50 ------------- 2 files changed, 151 deletions(-) delete mode 100644 pkg/api/aim2/controller/runs_test.go diff --git a/pkg/api/aim2/controller/runs_test.go b/pkg/api/aim2/controller/runs_test.go deleted file mode 100644 index e94dba56c..000000000 --- a/pkg/api/aim2/controller/runs_test.go +++ /dev/null @@ -1,101 +0,0 @@ -package controller - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/G-Research/fasttrackml/pkg/api/aim/query" -) - -func Test_isMetricSelected(t *testing.T) { - dialectors := []string{ - "sqlite3", - "postgres", - } - for _, dialector := range dialectors { - qp := query.QueryParser{ - Default: query.DefaultExpression{ - Contains: "run.archived", - Expression: "not run.archived", - }, - Tables: map[string]string{ - "runs": "runs", - "experiments": "experiments", - "metrics": "latest_metrics", - }, - TzOffset: 0, - Dialector: dialector, - } - - tests := []struct { - name string - query string - wantResult bool - }{ - { - name: "QueryWithMetricName", - query: `(run.active == True) and ((metric.name == "accuracy"))`, - wantResult: true, - }, - { - name: "QueryWithMetricNameNoSpaces", - query: `(run.active == True) and ((metric.name=="accuracy"))`, - wantResult: true, - }, - { - name: "QueryWithStringSyntax", - query: `(run.active == True) and (metric.name.startswith("acc"))`, - wantResult: true, - }, - { - name: "QueryWithInSyntax", - query: `(run.active == True) and ("accuracy" in metric.name)`, - wantResult: true, - }, - { - name: "QueryWithMetricNameAtEnd", - query: `(run.active == True) and "accuracy" in metric.name`, - wantResult: true, - }, - { - name: "QueryWithoutMetricName", - query: `(run.active == True)`, - wantResult: false, - }, - { - name: "QueryWithTrickyDictKey", - query: `(run.active == True) and (run.tags["metric.name"] == "foo")`, - wantResult: false, - }, - { - name: "QueryWithTrickyDictKeyAndMetricName", - query: `(run.active == True) and (run.tags["mymetric.name"] == "foo") and (metric.name == "accuracy")`, - wantResult: true, - }, - { - name: "QueryWithRegexMatchMetricName", - query: `(run.active == True) and re.match("accuracy", metric.name)`, - wantResult: true, - }, - { - name: "QueryWithRegexSearchMetricName", - query: `(run.active == True) and re.search("accuracy", metric.name)`, - wantResult: true, - }, - { - name: "QueryWithRegexSearchAndNoMetricName", - query: `(run.active == True) and re.search("accuracy", run.tags["metric.name"])`, - wantResult: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - pq, err := qp.Parse(tt.query) - require.Nil(t, err) - assert.Equal(t, tt.wantResult, pq.IsMetricSelected()) - }) - } - } -} diff --git a/pkg/api/aim2/query/query.go b/pkg/api/aim2/query/query.go index 34bc8ec76..5ada83922 100644 --- a/pkg/api/aim2/query/query.go +++ b/pkg/api/aim2/query/query.go @@ -35,7 +35,6 @@ type QueryParser struct { type ParsedQuery interface { Filter(*gorm.DB) *gorm.DB - IsMetricSelected() bool } type parsedQuery struct { @@ -187,10 +186,6 @@ func (pq *parsedQuery) Filter(tx *gorm.DB) *gorm.DB { return tx } -func (pq *parsedQuery) IsMetricSelected() bool { - return true -} - func (pq *parsedQuery) parseNode(node ast.Expr) (any, error) { ret, err := pq._parseNode(node) if err != nil && !errors.Is(err, SyntaxError{}) { @@ -644,51 +639,6 @@ func (pq *parsedQuery) parseName(node *ast.Name) (any, error) { } }, ), nil - case "metric": - table, ok := pq.qp.Tables["metrics"] - if !ok { - return nil, errors.New("unsupported name identifier 'metric'") - } - return attributeGetter( - func(attr string) (any, error) { - switch attr { - case "name": - pq.metricSelected = true - return clause.Column{ - Table: table, - Name: "key", - }, nil - case "last": - return clause.Column{ - Table: table, - Name: "value", - }, nil - case "last_step": - return clause.Column{ - Table: table, - Name: "last_iter", - }, nil - case "first_step": - return 0, nil - case "context": - return attributeGetter( - func(contextKey string) (any, error) { - // Add a WHERE clause for the context key - return Json{ - Column: clause.Column{ - Table: TableContexts, - Name: "json", - }, - JsonPath: contextKey, - Dialector: pq.qp.Dialector, - }, nil - }, - ), nil - default: - return nil, fmt.Errorf("unsupported metrics attribute %q", attr) - } - }, - ), nil case "re": return attributeGetter( func(attr string) (any, error) { From 21b223556c5eabd5d9bea6a46e9c53f3677e78d0 Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Fri, 15 Mar 2024 12:56:16 +0000 Subject: [PATCH 07/20] set FML_RUN_ORIGINAL_AIM_SERVICE to false --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 101a38348..73da5e8f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -171,7 +171,7 @@ jobs: env: DOCKER_BUILDKIT: 1 FML_DATABASE_BACKEND: ${{ matrix.database-backend }} - FML_RUN_ORIGINAL_AIM_SERVICE: true + FML_RUN_ORIGINAL_AIM_SERVICE: false - name: Run Integration Tests (Aim Refactor) run: make container-test From 16818848c5927673f0bbb3eda0910d1b0f9c3873 Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Mon, 18 Mar 2024 11:40:51 +0000 Subject: [PATCH 08/20] adapt query_test --- pkg/api/aim2/query/query_test.go | 178 ------------------------------- 1 file changed, 178 deletions(-) diff --git a/pkg/api/aim2/query/query_test.go b/pkg/api/aim2/query/query_test.go index f10b10e51..626945ab7 100644 --- a/pkg/api/aim2/query/query_test.go +++ b/pkg/api/aim2/query/query_test.go @@ -122,22 +122,6 @@ func (s *QueryTestSuite) TestPostgresDialector_Ok() { `WHERE "metrics_0"."value" < $2 AND "runs"."lifecycle_stage" <> $3`, expectedVars: []interface{}{"my_metric", -1.0, models.LifecycleStageDeleted}, }, - { - name: "TestMetricContext", - query: `metric.context.key1 == 'value1'`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE "contexts"."json"#>>$1 = $2 AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"{key1}", "value1", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextNegative", - query: `metric.context.key1 != 'value1'`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE "contexts"."json"#>>$1 <> $2 AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"{key1}", "value1", models.LifecycleStageDeleted}, - }, { name: "TestMetricContextSliceTuple", query: `run.metrics["my_metric", {"key1": "value1"}].last < -1`, @@ -158,75 +142,6 @@ func (s *QueryTestSuite) TestPostgresDialector_Ok() { `AND ("metrics_0"."value" < $4 AND "runs"."lifecycle_stage" <> $5)`, expectedVars: []interface{}{"my_metric", "{key1}", "value1", -1, models.LifecycleStageDeleted}, }, - { - name: "TestMetricCompound", - query: `run.metrics["my_metric"].last < -1 and metric.context.key1 == "value1"`, - expectedSQL: `SELECT "run_uuid" FROM "runs" ` + - `LEFT JOIN latest_metrics metrics_0 ON runs.run_uuid = metrics_0.run_uuid AND metrics_0.key = $1 ` + - `WHERE ("metrics_0"."value" < $2 AND "contexts"."json"#>>$3 = $4) ` + - `AND "runs"."lifecycle_stage" <> $5`, - expectedVars: []interface{}{"my_metric", -1, "{key1}", "value1", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextArray", - query: `metric.context.key1 == [1,2,3]`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE "contexts"."json"#>>$1 = '[1, 2, 3]' AND "runs"."lifecycle_stage" <> $2`, - expectedVars: []interface{}{"{key1}", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextObject", - query: `metric.context.key1 == {"subkey": "val"}`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE "contexts"."json"#>>$1 = '{"subkey": "val"}' AND "runs"."lifecycle_stage" <> $2`, - expectedVars: []interface{}{"{key1}", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextObject2", - query: `metric.context.key1 == {"subkey": "val", "subkey2": "val"}`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE "contexts"."json"#>>$1 = '{"subkey": "val", "subkey2": "val"}' AND "runs"."lifecycle_stage" <> $2`, - expectedVars: []interface{}{"{key1}", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextIn", - query: `"val1" in metric.context.key1`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE "contexts"."json"#>>$1 LIKE $2 ` + - `AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"{key1}", "%val1%", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextNotIn", - query: `"val1" not in metric.context.key1`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE "contexts"."json"#>>$1 NOT LIKE $2 ` + - `AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"{key1}", "%val1%", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextStartsWith", - query: `metric.context.key1.startswith("va")`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE "contexts"."json"#>>$1 LIKE $2 ` + - `AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"{key1}", "va%", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextEndsWith", - query: `metric.context.key1.endswith("va")`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE "contexts"."json"#>>$1 LIKE $2 ` + - `AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"{key1}", "%va", models.LifecycleStageDeleted}, - }, } for _, tt := range tests { @@ -350,23 +265,6 @@ func (s *QueryTestSuite) TestSqliteDialector_Ok() { `WHERE "metrics_0"."value" < $2 AND "runs"."lifecycle_stage" <> $3`, expectedVars: []interface{}{"my_metric", -1.0, models.LifecycleStageDeleted}, }, - { - name: "TestMetricContext", - query: `metric.context.key1 == 'value1'`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - - `WHERE IFNULL("contexts"."json", JSON('{}'))->>$1 = $2 AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"$.key1", "value1", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextNegative", - query: `metric.context.key1 != 'value1'`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE IFNULL("contexts"."json", JSON('{}'))->>$1 <> $2 AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"$.key1", "value1", models.LifecycleStageDeleted}, - }, { name: "TestMetricKeySlice", query: `run.metrics["key1"].last < -1`, @@ -395,77 +293,6 @@ func (s *QueryTestSuite) TestSqliteDialector_Ok() { `AND ("metrics_0"."value" < $4 AND "runs"."lifecycle_stage" <> $5)`, expectedVars: []interface{}{"my_metric", "$.key1", "value1", -1, models.LifecycleStageDeleted}, }, - { - name: "TestMetricCompound", - query: `run.metrics["my_metric"].last < -1 and metric.context.key1 == "value1"`, - expectedSQL: `SELECT "run_uuid" FROM "runs" ` + - `LEFT JOIN latest_metrics metrics_0 ON runs.run_uuid = metrics_0.run_uuid AND metrics_0.key = $1 ` + - `WHERE ("metrics_0"."value" < $2 AND IFNULL("contexts"."json", JSON('{}'))->>$3 = $4) ` + - `AND "runs"."lifecycle_stage" <> $5`, - expectedVars: []interface{}{"my_metric", -1, "$.key1", "value1", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextArray", - query: `metric.context.key1 == [1,2,3]`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE IFNULL("contexts"."json", JSON('{}'))->>$1 = '[1,2,3]' AND "runs"."lifecycle_stage" <> $2`, - expectedVars: []interface{}{"$.key1", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextObject", - query: `metric.context.key1 == {"subkey": "val"}`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE IFNULL("contexts"."json", JSON('{}'))->>$1 = '{"subkey":"val"}' ` + - `AND "runs"."lifecycle_stage" <> $2`, - expectedVars: []interface{}{"$.key1", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextObject2", - query: `metric.context.key1 == {"subkey": "val", "subkey2": "val"}`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE IFNULL("contexts"."json", JSON('{}'))->>$1 = '{"subkey":"val","subkey2":"val"}' ` + - `AND "runs"."lifecycle_stage" <> $2`, - expectedVars: []interface{}{"$.key1", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextIn", - query: `"val1" in metric.context.key1`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE IFNULL("contexts"."json", JSON('{}'))->>$1 LIKE $2 ` + - `AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"$.key1", "%val1%", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextNotIn", - query: `"val1" not in metric.context.key1`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE IFNULL("contexts"."json", JSON('{}'))->>$1 NOT LIKE $2 ` + - `AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"$.key1", "%val1%", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextStartsWith", - query: `metric.context.key1.startswith("va")`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE IFNULL("contexts"."json", JSON('{}'))->>$1 LIKE $2 ` + - `AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"$.key1", "va%", models.LifecycleStageDeleted}, - }, - { - name: "TestMetricContextEndsWith", - query: `metric.context.key1.endswith("va")`, - selectMetrics: true, - expectedSQL: `SELECT ID FROM "metrics" ` + - `WHERE IFNULL("contexts"."json", JSON('{}'))->>$1 LIKE $2 ` + - `AND "runs"."lifecycle_stage" <> $3`, - expectedVars: []interface{}{"$.key1", "%va", models.LifecycleStageDeleted}, - }, } for _, tt := range tests { @@ -508,11 +335,6 @@ func (s *QueryTestSuite) Test_Error() { query string expectedError error }{ - { - name: "TestMetricContextNested", - query: `metric.context.parent.nested == 'value1'`, - expectedError: SyntaxError{}, - }, { name: "TestMetricContextSubscriptTupleWrongOrder", query: `run.metrics[{"key1": "value1"}, "my_metric"].last < -1`, From fc7126249cf6e9bf1db531be1d4c2ebfd5b78d6b Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Mon, 18 Mar 2024 11:44:04 +0000 Subject: [PATCH 09/20] enable aim2 tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73da5e8f5..101a38348 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -171,7 +171,7 @@ jobs: env: DOCKER_BUILDKIT: 1 FML_DATABASE_BACKEND: ${{ matrix.database-backend }} - FML_RUN_ORIGINAL_AIM_SERVICE: false + FML_RUN_ORIGINAL_AIM_SERVICE: true - name: Run Integration Tests (Aim Refactor) run: make container-test From e3c160610031a9b81859d6d86ba4eb09339ca851 Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Mon, 18 Mar 2024 12:04:15 +0000 Subject: [PATCH 10/20] run TestSearchMetrics only against aim2 package --- tests/integration/golang/aim/metric/search_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/integration/golang/aim/metric/search_test.go b/tests/integration/golang/aim/metric/search_test.go index 45b8acadb..0a004ba40 100644 --- a/tests/integration/golang/aim/metric/search_test.go +++ b/tests/integration/golang/aim/metric/search_test.go @@ -5,6 +5,7 @@ import ( "context" "database/sql" "fmt" + "os" "testing" "github.com/google/uuid" @@ -22,7 +23,10 @@ type SearchMetricsTestSuite struct { } func TestSearchMetricsTestSuite(t *testing.T) { - suite.Run(t, new(SearchMetricsTestSuite)) + flag, ok := os.LookupEnv("FML_RUN_ORIGINAL_AIM_SERVICE") + if ok && flag == "true" { + suite.Run(t, new(SearchMetricsTestSuite)) + } } func (s *SearchMetricsTestSuite) Test_Ok() { From 126092be261e2608497a7572497fbfe9de6789d6 Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Mon, 18 Mar 2024 12:04:46 +0000 Subject: [PATCH 11/20] run TestSearchMetrics only against aim2 package --- tests/integration/golang/aim/metric/search_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/golang/aim/metric/search_test.go b/tests/integration/golang/aim/metric/search_test.go index 0a004ba40..68e97ca6b 100644 --- a/tests/integration/golang/aim/metric/search_test.go +++ b/tests/integration/golang/aim/metric/search_test.go @@ -24,7 +24,7 @@ type SearchMetricsTestSuite struct { func TestSearchMetricsTestSuite(t *testing.T) { flag, ok := os.LookupEnv("FML_RUN_ORIGINAL_AIM_SERVICE") - if ok && flag == "true" { + if !ok || flag == "false" { suite.Run(t, new(SearchMetricsTestSuite)) } } From 9322fc5436d1d5a3b7d3764bc3bf82aeb5eee6fe Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Mon, 18 Mar 2024 12:21:10 +0000 Subject: [PATCH 12/20] adapt flows metric_test --- tests/integration/golang/aim/namespace/flows/metric_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/golang/aim/namespace/flows/metric_test.go b/tests/integration/golang/aim/namespace/flows/metric_test.go index 30cbf8dd3..00dad8b07 100644 --- a/tests/integration/golang/aim/namespace/flows/metric_test.go +++ b/tests/integration/golang/aim/namespace/flows/metric_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/G-Research/fasttrackml/pkg/api/aim/encoding" - "github.com/G-Research/fasttrackml/pkg/api/aim/request" + "github.com/G-Research/fasttrackml/pkg/api/aim2/api/request" "github.com/G-Research/fasttrackml/pkg/api/mlflow/common" "github.com/G-Research/fasttrackml/pkg/api/mlflow/dao/models" "github.com/G-Research/fasttrackml/tests/integration/golang/helpers" @@ -238,12 +238,12 @@ func (s *MetricFlowTestSuite) testRunFlow( ) { // test `GET /runs/search/metric` endpoint. s.searchMetricsAndCompare(namespace1Code, request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric1")`, + MetricsWithContext: []string{`TestMetric1-{"key":"value"}`}, }, []*models.Run{run1}, []*models.LatestMetric{ metric1Run1, }) s.searchMetricsAndCompare(namespace2Code, request.SearchMetricsRequest{ - Query: `(metric.name == "TestMetric2")`, + MetricsWithContext: []string{`TestMetric2-{"key":"value"}`}, }, []*models.Run{run2}, []*models.LatestMetric{ metric1Run2, }) From 84495d42590da00b67d7cb42f6ec771582bfee78 Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Mon, 18 Mar 2024 12:40:38 +0000 Subject: [PATCH 13/20] run flow tests only over aim2 --- .../golang/aim/namespace/flows/metric_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/integration/golang/aim/namespace/flows/metric_test.go b/tests/integration/golang/aim/namespace/flows/metric_test.go index 00dad8b07..151adba36 100644 --- a/tests/integration/golang/aim/namespace/flows/metric_test.go +++ b/tests/integration/golang/aim/namespace/flows/metric_test.go @@ -6,6 +6,7 @@ import ( "database/sql" "fmt" "net/http" + "os" "testing" "github.com/stretchr/testify/suite" @@ -26,12 +27,15 @@ type MetricFlowTestSuite struct { // - `GET /runs/search/metric` // - `GET /runs/search/metric/align` func TestMetricTestSuite(t *testing.T) { - suite.Run(t, &MetricFlowTestSuite{ - helpers.BaseTestSuite{ - ResetOnSubTest: true, - SkipCreateDefaultNamespace: true, - }, - }) + flag, ok := os.LookupEnv("FML_RUN_ORIGINAL_AIM_SERVICE") + if !ok || flag == "false" { + suite.Run(t, &MetricFlowTestSuite{ + helpers.BaseTestSuite{ + ResetOnSubTest: true, + SkipCreateDefaultNamespace: true, + }, + }) + } } func (s *MetricFlowTestSuite) Test_Ok() { From 3caa11009e5fff0dce9c383490c2080c05e251cb Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Tue, 19 Mar 2024 11:38:39 +0000 Subject: [PATCH 14/20] change query --- pkg/api/aim2/dao/repositories/metric.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/aim2/dao/repositories/metric.go b/pkg/api/aim2/dao/repositories/metric.go index 52caa089c..b94d2dc3c 100644 --- a/pkg/api/aim2/dao/repositories/metric.go +++ b/pkg/api/aim2/dao/repositories/metric.go @@ -193,7 +193,7 @@ func (r MetricRepository) SearchMetrics( ). Joins("LEFT JOIN latest_metrics USING(run_uuid)"). Joins("LEFT JOIN contexts ON latest_metrics.context_id = contexts.id"). - Where("CONCAT(latest_metrics.key, '-', contexts.json) IN ?", req.MetricsWithContext)), + Where("(latest_metrics.key || '-' || contexts.json) IN ?", req.MetricsWithContext)), ). Where("MOD(metrics.iter + 1 + runmetrics.interval / 2, runmetrics.interval) < 1"). Order("runmetrics.row_num DESC"). From d6fe608b0774ff5036490c104f94063719c79dbd Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Tue, 19 Mar 2024 12:09:36 +0000 Subject: [PATCH 15/20] restore where clause --- pkg/api/aim2/dao/repositories/metric.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/aim2/dao/repositories/metric.go b/pkg/api/aim2/dao/repositories/metric.go index b94d2dc3c..52caa089c 100644 --- a/pkg/api/aim2/dao/repositories/metric.go +++ b/pkg/api/aim2/dao/repositories/metric.go @@ -193,7 +193,7 @@ func (r MetricRepository) SearchMetrics( ). Joins("LEFT JOIN latest_metrics USING(run_uuid)"). Joins("LEFT JOIN contexts ON latest_metrics.context_id = contexts.id"). - Where("(latest_metrics.key || '-' || contexts.json) IN ?", req.MetricsWithContext)), + Where("CONCAT(latest_metrics.key, '-', contexts.json) IN ?", req.MetricsWithContext)), ). Where("MOD(metrics.iter + 1 + runmetrics.interval / 2, runmetrics.interval) < 1"). Order("runmetrics.row_num DESC"). From a9b3d31f77e7cfdfa3cddf3a67e30f04cfe164ac Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Wed, 20 Mar 2024 10:10:23 +0000 Subject: [PATCH 16/20] split psql and sql query building --- pkg/api/aim2/dao/repositories/metric.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/api/aim2/dao/repositories/metric.go b/pkg/api/aim2/dao/repositories/metric.go index 52caa089c..886ca0b04 100644 --- a/pkg/api/aim2/dao/repositories/metric.go +++ b/pkg/api/aim2/dao/repositories/metric.go @@ -169,6 +169,13 @@ func (r MetricRepository) SearchMetrics( result[r.ID] = SearchResult{int64(r.RowNum), run} } + var contextJson string + if r.db.Dialector.Name() == "postgres" { + contextJson = "REPLACE(contexts.json::text, ': ', ':')" + } else { + contextJson = "contexts.json" + } + tx := r.db.WithContext(ctx). Select(` metrics.*, @@ -183,7 +190,7 @@ func (r MetricRepository) SearchMetrics( "runs.row_num", "latest_metrics.key", "latest_metrics.context_id", - "contexts.json AS context_json", + fmt.Sprintf("%s AS context_json", contextJson), fmt.Sprintf("(latest_metrics.last_iter + 1)/ %f AS interval", float32(req.Steps)), ). Table("runs"). @@ -193,7 +200,7 @@ func (r MetricRepository) SearchMetrics( ). Joins("LEFT JOIN latest_metrics USING(run_uuid)"). Joins("LEFT JOIN contexts ON latest_metrics.context_id = contexts.id"). - Where("CONCAT(latest_metrics.key, '-', contexts.json) IN ?", req.MetricsWithContext)), + Where(fmt.Sprintf("CONCAT(latest_metrics.key, '-', %s) IN ?", contextJson), req.MetricsWithContext)), ). Where("MOD(metrics.iter + 1 + runmetrics.interval / 2, runmetrics.interval) < 1"). Order("runmetrics.row_num DESC"). From 9e1564927282b6dcb038e952f46585503ad0296d Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Wed, 20 Mar 2024 13:11:32 +0000 Subject: [PATCH 17/20] using struct for metric context tuple --- pkg/api/aim2/api/request/run.go | 16 +- pkg/api/aim2/dao/repositories/helpers.go | 14 + pkg/api/aim2/dao/repositories/metric.go | 75 +- .../golang/aim/metric/search_test.go | 1179 +++++++++++++---- 4 files changed, 1022 insertions(+), 262 deletions(-) diff --git a/pkg/api/aim2/api/request/run.go b/pkg/api/aim2/api/request/run.go index 163115e90..06da48310 100644 --- a/pkg/api/aim2/api/request/run.go +++ b/pkg/api/aim2/api/request/run.go @@ -49,14 +49,20 @@ type SearchRunsRequest struct { ExcludeTraces bool `query:"exclude_traces"` } +// MetricTuple represents a metric with key and context. +type MetricTuple struct { + Key string `query:"metric"` + Context string `query:"context"` +} + // SearchMetricsRequest is a request struct for `GET /runs/search/metric` endpoint. type SearchMetricsRequest struct { BaseSearchRequest - MetricsWithContext []string `query:"m"` - Query string `query:"q"` - Steps int `query:"p"` - XAxis string `query:"x_axis"` - SkipSystem bool `query:"skip_system"` + Metrics []MetricTuple `query:"m"` + Query string `query:"q"` + Steps int `query:"p"` + XAxis string `query:"x_axis"` + SkipSystem bool `query:"skip_system"` } // SearchAlignedMetricsRequest is a request struct for `GET /runs/search/metric/align` endpoint. diff --git a/pkg/api/aim2/dao/repositories/helpers.go b/pkg/api/aim2/dao/repositories/helpers.go index bb51255bd..06e205838 100644 --- a/pkg/api/aim2/dao/repositories/helpers.go +++ b/pkg/api/aim2/dao/repositories/helpers.go @@ -1,7 +1,9 @@ package repositories import ( + "encoding/json" "fmt" + "reflect" "strings" "gorm.io/driver/postgres" @@ -68,3 +70,15 @@ func BuildJsonCondition( sql = strings.Repeat(conditionTemplate+" AND ", len(jsonPathValueMap)-1) + conditionTemplate return sql, args } + +// CompareJson compares two json objects. +func CompareJson(json1, json2 []byte) bool { + var j, j2 interface{} + if err := json.Unmarshal(json1, &j); err != nil { + return false + } + if err := json.Unmarshal(json2, &j2); err != nil { + return false + } + return reflect.DeepEqual(j2, j) +} diff --git a/pkg/api/aim2/dao/repositories/metric.go b/pkg/api/aim2/dao/repositories/metric.go index 886ca0b04..83c203c8b 100644 --- a/pkg/api/aim2/dao/repositories/metric.go +++ b/pkg/api/aim2/dao/repositories/metric.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "fmt" + "strings" "github.com/gofiber/fiber/v2" "github.com/rotisserie/eris" @@ -12,6 +13,7 @@ import ( "github.com/G-Research/fasttrackml/pkg/api/aim2/api/request" "github.com/G-Research/fasttrackml/pkg/api/aim2/dao/models" "github.com/G-Research/fasttrackml/pkg/api/aim2/query" + "github.com/G-Research/fasttrackml/pkg/common/api" "github.com/G-Research/fasttrackml/pkg/common/db/types" ) @@ -103,7 +105,7 @@ func (r MetricRepository) SearchMetrics( return nil, 0, nil, err } - if req.MetricsWithContext == nil || len(req.MetricsWithContext) == 0 { + if req.Metrics == nil || len(req.Metrics) == 0 { return nil, 0, nil, eris.New("No metrics are selected") } @@ -169,38 +171,61 @@ func (r MetricRepository) SearchMetrics( result[r.ID] = SearchResult{int64(r.RowNum), run} } - var contextJson string - if r.db.Dialector.Name() == "postgres" { - contextJson = "REPLACE(contexts.json::text, ': ', ':')" - } else { - contextJson = "contexts.json" + values, contextsMap := []any{}, map[string]types.JSONB{} + for _, r := range req.Metrics { + data := []byte(r.Context) + values, contextsMap[string(data)] = append(values, data), data } + contexts, err := r.GetContextListByContextObjects(ctx, contextsMap) + if err != nil { + return nil, 0, nil, api.NewInternalError("error getting context list: %s", err) + } + + // add context ids to `values` array. + ids := make([]uint, len(values)) + for _, context := range contexts { + for i := 0; i < len(values); i += 1 { + if CompareJson(values[i].([]byte), context.Json) { + ids[i] = context.ID + } + } + } + + var conditions []string + for i, tuple := range req.Metrics { + condition := fmt.Sprintf("(latest_metrics.key = '%s' AND contexts.id = %d)", tuple.Key, ids[i]) + conditions = append(conditions, condition) + } + tuplesConditions := strings.Join(conditions, " OR ") + + subQuery := r.db.WithContext(ctx). + Select( + "runs.run_uuid", + "runs.row_num", + "latest_metrics.key", + "latest_metrics.context_id", + "contexts.json AS context_json", + fmt.Sprintf("(latest_metrics.last_iter + 1)/ %f AS interval", float32(req.Steps)), + ). + Table("runs"). + Joins( + "INNER JOIN experiments ON experiments.experiment_id = runs.experiment_id AND experiments.namespace_id = ?", + namespaceID, + ). + Joins("LEFT JOIN latest_metrics USING(run_uuid)"). + Joins("LEFT JOIN contexts ON latest_metrics.context_id = contexts.id"). + Where(tuplesConditions) + tx := r.db.WithContext(ctx). Select(` - metrics.*, - runmetrics.context_json`, + metrics.*, + runmetrics.context_json`, ). Table("metrics"). Joins( "INNER JOIN (?) runmetrics USING(run_uuid, key, context_id)", - pq.Filter(r.db.WithContext(ctx). - Select( - "runs.run_uuid", - "runs.row_num", - "latest_metrics.key", - "latest_metrics.context_id", - fmt.Sprintf("%s AS context_json", contextJson), - fmt.Sprintf("(latest_metrics.last_iter + 1)/ %f AS interval", float32(req.Steps)), - ). - Table("runs"). - Joins( - "INNER JOIN experiments ON experiments.experiment_id = runs.experiment_id AND experiments.namespace_id = ?", - namespaceID, - ). - Joins("LEFT JOIN latest_metrics USING(run_uuid)"). - Joins("LEFT JOIN contexts ON latest_metrics.context_id = contexts.id"). - Where(fmt.Sprintf("CONCAT(latest_metrics.key, '-', %s) IN ?", contextJson), req.MetricsWithContext)), + pq.Filter(subQuery), ). Where("MOD(metrics.iter + 1 + runmetrics.interval / 2, runmetrics.interval) < 1"). Order("runmetrics.row_num DESC"). diff --git a/tests/integration/golang/aim/metric/search_test.go b/tests/integration/golang/aim/metric/search_test.go index 68e97ca6b..35b7ee18e 100644 --- a/tests/integration/golang/aim/metric/search_test.go +++ b/tests/integration/golang/aim/metric/search_test.go @@ -5,7 +5,6 @@ import ( "context" "database/sql" "fmt" - "os" "testing" "github.com/google/uuid" @@ -23,10 +22,7 @@ type SearchMetricsTestSuite struct { } func TestSearchMetricsTestSuite(t *testing.T) { - flag, ok := os.LookupEnv("FML_RUN_ORIGINAL_AIM_SERVICE") - if !ok || flag == "false" { - suite.Run(t, new(SearchMetricsTestSuite)) - } + suite.Run(t, new(SearchMetricsTestSuite)) } func (s *SearchMetricsTestSuite) Test_Ok() { @@ -310,6 +306,7 @@ func (s *SearchMetricsTestSuite) Test_Ok() { s.Require().Nil(err) runs := []*models.Run{run1, run2, run3} + contextValue := "{\"testkey\":\"testvalue\"}" tests := []struct { name string request request.SearchMetricsRequest @@ -318,7 +315,16 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetric", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -329,18 +335,43 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunArchived", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.archived == True`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.archived == True`, }, }, { name: "SearchRunNotArchived", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.archived == False`, }, @@ -358,8 +389,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunActive", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.active == True`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.active == True`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -370,11 +414,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNotActive", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.active == False`, }, @@ -389,11 +445,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchDurationOperationGreater", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.duration > 0`, }, @@ -408,11 +476,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.duration >= 0`, }, @@ -430,7 +510,20 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationLess", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, Query: fmt.Sprintf( `run.duration < %d`, (run3.EndTime.Int64-run3.StartTime.Int64)/1000, @@ -445,7 +538,20 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationLessOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, Query: fmt.Sprintf( `run.duration <= %d`, (run3.EndTime.Int64-run3.StartTime.Int64)/1000, @@ -462,8 +568,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.duration == 0`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.duration == 0`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -474,11 +593,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunDurationOperationNotEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.duration != 0`, }, @@ -493,8 +624,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationGreater", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.created_at > 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.created_at > 123456789`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -504,8 +648,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.created_at >= 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.created_at >= 123456789`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -518,11 +675,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationNotEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.created_at != 123456789`, }, @@ -537,8 +706,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.created_at == 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.created_at == 123456789`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -549,11 +731,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationLess", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.created_at < 222222222`, }, @@ -569,11 +763,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunStartTimeOperationLessOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.created_at <= 222222222`, }, @@ -591,11 +797,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationGreater", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.finalized_at > 123456789`, }, @@ -610,11 +828,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.finalized_at >= 123456789`, }, @@ -632,11 +862,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationNotEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.finalized_at != 123456789`, }, @@ -651,8 +893,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.finalized_at == 123456789`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.finalized_at == 123456789`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -663,8 +918,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationLess", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.finalized_at < 444444444`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.finalized_at < 444444444`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -675,11 +943,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunFinalizedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.finalized_at <= 444444444`, }, @@ -697,8 +977,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunHashOperationEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: fmt.Sprintf(`run.hash == "%s"`, run1.ID), + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: fmt.Sprintf(`run.hash == "%s"`, run1.ID), }, metrics: []*models.LatestMetric{ metric1Run1, @@ -709,11 +1002,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunHashOperationNotEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: fmt.Sprintf(`run.hash != "%s"`, run1.ID), }, @@ -728,11 +1033,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationNotEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.name != "TestRun1"`, }, @@ -747,8 +1064,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.name == "TestRun1"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.name == "TestRun1"`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -759,8 +1089,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationIn", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `"Run3" in run.name`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `"Run3" in run.name`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -770,11 +1113,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationNotIn", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `"Run3" not in run.name`, }, @@ -790,11 +1145,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationStartsWith", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.name.startswith("Test")`, }, @@ -812,8 +1179,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunNameOperationStartsWith", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.name.endswith('3')`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.name.endswith('3')`, }, metrics: []*models.LatestMetric{ metric1Run3, @@ -823,11 +1203,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunExperimentOperationEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: fmt.Sprintf( `run.experiment == "%s"`, @@ -846,7 +1238,20 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunExperimentOperationNotEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, Query: fmt.Sprintf( `run.experiment != "%s"`, experiment.Name, @@ -860,8 +1265,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunTagOperationEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.tags['mlflow.runName'] == "TestRunTag1"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.tags['mlflow.runName'] == "TestRunTag1"`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -872,11 +1290,23 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchRunTagOperationNotEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{ - "TestMetric1-{}", - "TestMetric2-{}", - "TestMetric3-{}", - `TestMetric1-{"testkey":"testvalue"}`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, }, Query: `run.tags['mlflow.runName'] != "TestRunTag1"`, }, @@ -889,40 +1319,64 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunNameOperationRegexpMatchFunction", + name: "SearchMetricNameAndRunNameOperationRegexpMatchFunction", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: `re.match("TestRun1", run.name)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: `re.match("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric1Run1, }, }, { - name: "SearchMetricAndRunNameOperationRegexpSearchFunction", + name: "SearchMetricNameAndRunNameOperationRegexpSearchFunction", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: `re.search("TestRun1", run.name)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: `re.search("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric1Run1, }, }, { - name: "SearchMetricAndRunNameOperationEquals", + name: "SearchMetricNameAndRunNameOperationEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: `run.name == "TestRun1"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: `run.name == "TestRun1"`, }, metrics: []*models.LatestMetric{ metric1Run1, }, }, { - name: "SearchMetricAndRunNameOperationNotEquals", + name: "SearchMetricNameAndRunNameOperationNotEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `run.name != "TestRun1"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `run.name != "TestRun1"`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -930,10 +1384,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunNameOperationStartsWith", + name: "SearchMetricNameAndRunNameOperationStartsWith", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `run.name.startswith("Test")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `run.name.startswith("Test")`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -942,20 +1405,38 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunNameOperationEndsWith", + name: "SearchMetricNameAndRunNameOperationEndsWith", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `run.name.endswith("Run2")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `run.name.endswith("Run2")`, }, metrics: []*models.LatestMetric{ metric1Run2, }, }, { - name: "SearchMetricsAndRunNameOperationRegexpMatchFunction", + name: "SearchMetricNameAndRunNameOperationNotEqualsAndRegexpMatchFunction", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, - Query: `re.match("TestRun1", run.name)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `re.match("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -963,10 +1444,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricsAndRunNameOperationRegexpSearchFunction", + name: "SearchMetricNameAndRunNameOperationNotEqualsAndRegexpSearchFunction", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, - Query: `re.search("TestRun1", run.name)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `re.search("TestRun1", run.name)`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -974,10 +1464,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricsAndRunNameOperationdEquals", + name: "SearchMetricNameAndRunNameOperationNotEqualsAndEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.name == "TestRun1"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.name == "TestRun1"`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -985,10 +1484,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricsAndRunNameOperationNotEquals", + name: "SearchMetricNameAndRunNameOperationNotEqualsAndNotEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.name != "TestRun1"`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.name != "TestRun1"`, }, metrics: []*models.LatestMetric{ metric2Run2, @@ -997,10 +1505,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricsAndRunNameOperationStartsWith", + name: "SearchMetricNameAndRunNameOperationNotEqualsAndStartsWith", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.name.startswith("Test")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.name.startswith("Test")`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1011,10 +1528,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricsxsAndRunNameOperationEndsWith", + name: "SearchMetricNameAndRunNameOperationNotEqualsAndEndsWith", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, - Query: `run.name.endswith("Run2")`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `run.name.endswith("Run2")`, }, metrics: []*models.LatestMetric{ metric2Run2, @@ -1022,20 +1548,34 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunDurationOperationEqual", + name: "SearchMetricNameAndRunDurationOperationEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: `run.duration == 222222`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: `run.duration == 222222`, }, metrics: []*models.LatestMetric{ metric1Run3, }, }, { - name: "SearchMetricAndRunDurationOperationNotEqual", + name: "SearchMetricNameAndRunDurationOperationNotEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `run.duration != 222222`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `run.duration != 222222`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1043,10 +1583,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunDurationOperationGreater", + name: "SearchMetricNameAndRunDurationOperationGreater", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `run.duration > 0`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `run.duration > 0`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1054,10 +1603,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunDurationOperationGreaterOrEquals", + name: "SearchMetricNameAndRunDurationOperationGreaterOrEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `run.duration >= 0`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `run.duration >= 0`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1066,10 +1624,15 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunDurationOperationLess", + name: "SearchMetricNameAndRunDurationOperationLess", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: `(run.duration < 333333)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: `(run.duration < 333333)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1077,10 +1640,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunDurationOperationLessOrEquals", + name: "SearchMetricNameAndRunDurationOperationLessOrEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `run.duration <= 333333`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `run.duration <= 333333`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1089,20 +1661,34 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunHashOperationEquals", + name: "SearchMetricNameAndRunHashOperationEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: fmt.Sprintf(`(run.hash == "%s")`, run1.ID), + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: fmt.Sprintf(`(run.hash == "%s")`, run1.ID), }, metrics: []*models.LatestMetric{ metric1Run1, }, }, { - name: "SearchMetricsAndRunHashOperationNotEquals", + name: "SearchMetricNameAndRunHashOperationNotEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: fmt.Sprintf(`(run.hash != "%s")`, run1.ID), + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: fmt.Sprintf(`(run.hash != "%s")`, run1.ID), }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1110,10 +1696,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunFinalizedAtOperationGreater", + name: "SearchMetricNameAndRunFinalizedAtOperationGreater", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `(run.finalized_at > 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `(run.finalized_at > 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1121,10 +1716,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunFinalizedAtOperationGreaterOrEqual", + name: "SearchMetricNameAndRunFinalizedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `(run.finalized_at >= 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `(run.finalized_at >= 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1133,20 +1737,34 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunFinalizedAtOperationLess", + name: "SearchMetricNameAndRunFinalizedAtOperationLess", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: `(run.finalized_at < 444444444)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: `(run.finalized_at < 444444444)`, }, metrics: []*models.LatestMetric{ metric1Run1, }, }, { - name: "SearchMetricAndRunFinalizedAtOperationLessOrEqual", + name: "SearchMetricNameAndRunFinalizedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `(run.finalized_at <= 444444444)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `(run.finalized_at <= 444444444)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1155,20 +1773,34 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunFinalizedOperationAtEquals", + name: "SearchMetricNameAndRunFinalizedOperationAtEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: `(run.finalized_at == 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: `(run.finalized_at == 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run1, }, }, { - name: "SearchMetricAndRunFinalizedAtOperationNotEquals", + name: "SearchMetricNameAndRunFinalizedAtOperationNotEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `(run.finalized_at != 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `(run.finalized_at != 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1176,10 +1808,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricAndRunFinalizedAtOperationNotEqualsAndGreater", + name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndGreater", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, - Query: `(run.finalized_at > 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `(run.finalized_at > 123456789)`, }, metrics: []*models.LatestMetric{ metric2Run2, @@ -1188,10 +1829,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricsAndRunFinalizedAtOperationNotEqualsAndGreaterOrEqual", + name: "SearchMetricNameAndRunFinalizedAtOperationNotEqualsAndGreaterOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric2-{}", "TestMetric3-{}"}, - Query: `(run.finalized_at >= 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric3", + Context: "{}", + }, + }, + Query: `(run.finalized_at >= 123456789)`, }, metrics: []*models.LatestMetric{ metric2Run1, @@ -1202,20 +1852,30 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricEqualsAndRunCreatedAtOperationGreater", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationGreater", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: `(run.created_at > 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: `(run.created_at > 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run3, }, }, { - name: "SearchMetricEqualsAndRunCreatedAtOperationGreaterOrEqual", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationGreaterOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: `(run.created_at >= 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: `(run.created_at >= 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1223,10 +1883,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricEqualsAndRunCreatedAtOperationLess", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationLess", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `(run.created_at < 222222222)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `(run.created_at < 222222222)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1234,10 +1903,19 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricEqualsAndRunCreatedAtOperationLessOrEqual", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationLessOrEqual", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `(run.created_at <= 222222222)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `(run.created_at <= 222222222)`, }, metrics: []*models.LatestMetric{ metric1Run1, @@ -1246,20 +1924,34 @@ func (s *SearchMetricsTestSuite) Test_Ok() { }, }, { - name: "SearchMetricEqualsAndRunCreatedAtOperationEquals", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}"}, - Query: `(run.created_at == 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + }, + Query: `(run.created_at == 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run1, }, }, { - name: "SearchMetricEqualsAndRunCreatedAtOperationNotEquals", + name: "SearchMetricNameEqualsAndRunCreatedAtOperationNotEquals", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `(run.created_at != 123456789)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `(run.created_at != 123456789)`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1269,8 +1961,21 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricComplexQuery", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{"TestMetric1-{}", "TestMetric2-{}", `TestMetric1-{"testkey":"testvalue"}`}, - Query: `(run.name.endswith("2") or re.match("TestRun1", run.name) and run.duration > 0)`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: "{}", + }, + { + Key: "TestMetric2", + Context: "{}", + }, + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + Query: `(run.name.endswith("2") or re.match("TestRun1", run.name) and run.duration > 0)`, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1280,7 +1985,12 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricContext", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{`TestMetric1-{"testkey":"testvalue"}`}, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: contextValue, + }, + }, }, metrics: []*models.LatestMetric{ metric1Run2, @@ -1289,8 +1999,13 @@ func (s *SearchMetricsTestSuite) Test_Ok() { { name: "SearchMetricContextWithXAxis", request: request.SearchMetricsRequest{ - MetricsWithContext: []string{`TestMetric1-{"testkey":"testvalue"}`}, - XAxis: `TestMetric2`, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: contextValue, + }, + }, + XAxis: `TestMetric2`, }, metrics: []*models.LatestMetric{ metric1Run2, From dab905a2229ea0726af358a24e4817634f60c056 Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Wed, 20 Mar 2024 13:18:01 +0000 Subject: [PATCH 18/20] adapt flow tests --- .../golang/aim/namespace/flows/metric_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/integration/golang/aim/namespace/flows/metric_test.go b/tests/integration/golang/aim/namespace/flows/metric_test.go index 151adba36..6cfded3a3 100644 --- a/tests/integration/golang/aim/namespace/flows/metric_test.go +++ b/tests/integration/golang/aim/namespace/flows/metric_test.go @@ -242,12 +242,22 @@ func (s *MetricFlowTestSuite) testRunFlow( ) { // test `GET /runs/search/metric` endpoint. s.searchMetricsAndCompare(namespace1Code, request.SearchMetricsRequest{ - MetricsWithContext: []string{`TestMetric1-{"key":"value"}`}, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric1", + Context: `{"key":"value"}`, + }, + }, }, []*models.Run{run1}, []*models.LatestMetric{ metric1Run1, }) s.searchMetricsAndCompare(namespace2Code, request.SearchMetricsRequest{ - MetricsWithContext: []string{`TestMetric2-{"key":"value"}`}, + Metrics: []request.MetricTuple{ + { + Key: "TestMetric2", + Context: `{"key":"value"}`, + }, + }, }, []*models.Run{run2}, []*models.LatestMetric{ metric1Run2, }) From c0247ca9190d777a40776171050cb9dae0f25eaa Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Wed, 20 Mar 2024 14:51:50 +0000 Subject: [PATCH 19/20] reuse comparejson function --- .../aim2/{services/run => common}/helpers.go | 2 +- pkg/api/aim2/dao/repositories/helpers.go | 14 -------------- pkg/api/aim2/dao/repositories/metric.go | 17 +++++++++-------- pkg/api/aim2/services/run/service.go | 3 ++- 4 files changed, 12 insertions(+), 24 deletions(-) rename pkg/api/aim2/{services/run => common}/helpers.go (95%) diff --git a/pkg/api/aim2/services/run/helpers.go b/pkg/api/aim2/common/helpers.go similarity index 95% rename from pkg/api/aim2/services/run/helpers.go rename to pkg/api/aim2/common/helpers.go index 4d81e6cfc..a709c8f9a 100644 --- a/pkg/api/aim2/services/run/helpers.go +++ b/pkg/api/aim2/common/helpers.go @@ -1,4 +1,4 @@ -package run +package common import ( "encoding/json" diff --git a/pkg/api/aim2/dao/repositories/helpers.go b/pkg/api/aim2/dao/repositories/helpers.go index 06e205838..bb51255bd 100644 --- a/pkg/api/aim2/dao/repositories/helpers.go +++ b/pkg/api/aim2/dao/repositories/helpers.go @@ -1,9 +1,7 @@ package repositories import ( - "encoding/json" "fmt" - "reflect" "strings" "gorm.io/driver/postgres" @@ -70,15 +68,3 @@ func BuildJsonCondition( sql = strings.Repeat(conditionTemplate+" AND ", len(jsonPathValueMap)-1) + conditionTemplate return sql, args } - -// CompareJson compares two json objects. -func CompareJson(json1, json2 []byte) bool { - var j, j2 interface{} - if err := json.Unmarshal(json1, &j); err != nil { - return false - } - if err := json.Unmarshal(json2, &j2); err != nil { - return false - } - return reflect.DeepEqual(j2, j) -} diff --git a/pkg/api/aim2/dao/repositories/metric.go b/pkg/api/aim2/dao/repositories/metric.go index 83c203c8b..975c81134 100644 --- a/pkg/api/aim2/dao/repositories/metric.go +++ b/pkg/api/aim2/dao/repositories/metric.go @@ -11,6 +11,7 @@ import ( "gorm.io/gorm" "github.com/G-Research/fasttrackml/pkg/api/aim2/api/request" + "github.com/G-Research/fasttrackml/pkg/api/aim2/common" "github.com/G-Research/fasttrackml/pkg/api/aim2/dao/models" "github.com/G-Research/fasttrackml/pkg/api/aim2/query" "github.com/G-Research/fasttrackml/pkg/common/api" @@ -171,9 +172,9 @@ func (r MetricRepository) SearchMetrics( result[r.ID] = SearchResult{int64(r.RowNum), run} } - values, contextsMap := []any{}, map[string]types.JSONB{} + values, contextsMap := []types.JSONB{}, map[string]types.JSONB{} for _, r := range req.Metrics { - data := []byte(r.Context) + data := types.JSONB(r.Context) values, contextsMap[string(data)] = append(values, data), data } @@ -185,19 +186,19 @@ func (r MetricRepository) SearchMetrics( // add context ids to `values` array. ids := make([]uint, len(values)) for _, context := range contexts { - for i := 0; i < len(values); i += 1 { - if CompareJson(values[i].([]byte), context.Json) { + for i := 0; i < len(values); i++ { + if common.CompareJson(values[i], context.Json) { ids[i] = context.ID } } } - var conditions []string + var metricKeyContextConditionSlice []string for i, tuple := range req.Metrics { condition := fmt.Sprintf("(latest_metrics.key = '%s' AND contexts.id = %d)", tuple.Key, ids[i]) - conditions = append(conditions, condition) + metricKeyContextConditionSlice = append(metricKeyContextConditionSlice, condition) } - tuplesConditions := strings.Join(conditions, " OR ") + metricKeyContextCondition := strings.Join(metricKeyContextConditionSlice, " OR ") subQuery := r.db.WithContext(ctx). Select( @@ -215,7 +216,7 @@ func (r MetricRepository) SearchMetrics( ). Joins("LEFT JOIN latest_metrics USING(run_uuid)"). Joins("LEFT JOIN contexts ON latest_metrics.context_id = contexts.id"). - Where(tuplesConditions) + Where(metricKeyContextCondition) tx := r.db.WithContext(ctx). Select(` diff --git a/pkg/api/aim2/services/run/service.go b/pkg/api/aim2/services/run/service.go index 80ce26af9..fc8644477 100644 --- a/pkg/api/aim2/services/run/service.go +++ b/pkg/api/aim2/services/run/service.go @@ -8,6 +8,7 @@ import ( "github.com/rotisserie/eris" "github.com/G-Research/fasttrackml/pkg/api/aim2/api/request" + "github.com/G-Research/fasttrackml/pkg/api/aim2/common" "github.com/G-Research/fasttrackml/pkg/api/aim2/dao/models" "github.com/G-Research/fasttrackml/pkg/api/aim2/dao/repositories" "github.com/G-Research/fasttrackml/pkg/common/api" @@ -144,7 +145,7 @@ func (s Service) SearchAlignedMetrics( // add context ids to `values` array. for _, context := range contexts { for i := 2; i < len(values); i += 4 { - if CompareJson(values[i].([]byte), context.Json) { + if common.CompareJson(values[i].([]byte), context.Json) { values[i] = context.ID } } From c67e081a6524681a25d94d8e313c9e38fe37df29 Mon Sep 17 00:00:00 2001 From: fabio vincenzi Date: Thu, 21 Mar 2024 13:41:10 +0000 Subject: [PATCH 20/20] extract function for findContextIDs --- pkg/api/aim2/dao/repositories/metric.go | 47 +++++++++++++++---------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/pkg/api/aim2/dao/repositories/metric.go b/pkg/api/aim2/dao/repositories/metric.go index 975c81134..6fcc07434 100644 --- a/pkg/api/aim2/dao/repositories/metric.go +++ b/pkg/api/aim2/dao/repositories/metric.go @@ -14,7 +14,6 @@ import ( "github.com/G-Research/fasttrackml/pkg/api/aim2/common" "github.com/G-Research/fasttrackml/pkg/api/aim2/dao/models" "github.com/G-Research/fasttrackml/pkg/api/aim2/query" - "github.com/G-Research/fasttrackml/pkg/common/api" "github.com/G-Research/fasttrackml/pkg/common/db/types" ) @@ -172,25 +171,9 @@ func (r MetricRepository) SearchMetrics( result[r.ID] = SearchResult{int64(r.RowNum), run} } - values, contextsMap := []types.JSONB{}, map[string]types.JSONB{} - for _, r := range req.Metrics { - data := types.JSONB(r.Context) - values, contextsMap[string(data)] = append(values, data), data - } - - contexts, err := r.GetContextListByContextObjects(ctx, contextsMap) + ids, err := r.findContextIDs(ctx, &req) if err != nil { - return nil, 0, nil, api.NewInternalError("error getting context list: %s", err) - } - - // add context ids to `values` array. - ids := make([]uint, len(values)) - for _, context := range contexts { - for i := 0; i < len(values); i++ { - if common.CompareJson(values[i], context.Json) { - ids[i] = context.ID - } - } + return nil, 0, nil, eris.Wrap(err, "error finding context ids") } var metricKeyContextConditionSlice []string @@ -268,3 +251,29 @@ func (r MetricRepository) GetContextListByContextObjects( } return contexts, nil } + +func (r MetricRepository) findContextIDs(ctx context.Context, req *request.SearchMetricsRequest) ([]uint, error) { + contextList := []types.JSONB{} + contextsMap := map[string]types.JSONB{} + for _, r := range req.Metrics { + data := types.JSONB(r.Context) + contextList = append(contextList, data) + contextsMap[string(data)] = data + } + + contexts, err := r.GetContextListByContextObjects(ctx, contextsMap) + if err != nil { + return nil, fmt.Errorf("error getting context list: %w", err) + } + + ids := make([]uint, len(contextList)) + for _, context := range contexts { + for i := 0; i < len(contextList); i++ { + if common.CompareJson(contextList[i], context.Json) { + ids[i] = context.ID + } + } + } + + return ids, nil +}