From 5bf67119ad93ea20086f7937f585562344f8096c Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Tue, 13 Sep 2022 18:29:41 +0300 Subject: [PATCH] Increase analyzer search hits maximum size --- analyzers/analyzers.go | 2 +- general_tests/analyzers_doc_it_test.go | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/analyzers/analyzers.go b/analyzers/analyzers.go index d7f0a88be..0f83e21e5 100644 --- a/analyzers/analyzers.go +++ b/analyzers/analyzers.go @@ -154,7 +154,7 @@ func (aS *AnalyzerS) V1StringQuery(ctx *context.Context, args *QueryArgs, reply } else { q = bleve.NewQueryStringQuery(args.HeaderFilters) } - s := bleve.NewSearchRequest(q) + s := bleve.NewSearchRequestOptions(q, utils.AbsoluteMaxInt, 0, false) s.Fields = []string{utils.Meta} // return all fields searchResults, err := aS.db.SearchInContext(ctx, s) if err != nil { diff --git a/general_tests/analyzers_doc_it_test.go b/general_tests/analyzers_doc_it_test.go index 8632c9757..7d3b85c82 100644 --- a/general_tests/analyzers_doc_it_test.go +++ b/general_tests/analyzers_doc_it_test.go @@ -67,7 +67,7 @@ var ( // make queries to the AnalyzerS db using only HeaderFilters testAnzDocQueryWithHeaderFilters, // make queries to the AnalyzerS db using only ContentFilters - // testAnzDocQueryWithContentFiltersFilters, + testAnzDocQueryWithContentFiltersFilters, // make queries to the AnalyzerS db using a combination of both types of filters testAnzDocQuery, testAnzDocKillEngine, @@ -133,7 +133,7 @@ func testAnzDocCoreSStatus(t *testing.T) { func testPopulateTimeVariable(t *testing.T) { time.Sleep(time.Second) - timeVar = time.Now().Format("2006-01-02T15:04:05Z07:00") + timeVar = time.Now().UTC().Format("2006-01-02T15:04:05Z07:00") } func testAnzDocSetAttributeProfiles(t *testing.T) { @@ -502,6 +502,16 @@ func testAnzDocQueryWithHeaderFilters(t *testing.T) { t.Errorf("Unexpected result: %s", utils.ToJSON(result)) } + // Query results for all the request methods except CacheSv1.ReloadCache using HeaderFilters + if err := anzDocRPC.Call(context.Background(), utils.AnalyzerSv1StringQuery, &analyzers.QueryArgs{ + HeaderFilters: `-RequestMethod:"CacheSv1.ReloadCache"`, + ContentFilters: []string{}, + }, &result); err != nil { + t.Error(err) + } else if len(result) != 11 { + t.Errorf("Unexpected result: %s", utils.ToJSON(result)) + } + // Query all results for the requests made to the AdminS service using regular expressions if err := anzDocRPC.Call(context.Background(), utils.AnalyzerSv1StringQuery, &analyzers.QueryArgs{ HeaderFilters: `+RequestMethod:"/AdminSv1.*/"`, @@ -526,12 +536,11 @@ func testAnzDocQueryWithHeaderFilters(t *testing.T) { // Query results for API calls with RequestID smaller or equal to 2 if err := anzDocRPC.Call(context.Background(), utils.AnalyzerSv1StringQuery, &analyzers.QueryArgs{ - HeaderFilters: `+RequestID:<=2`, + HeaderFilters: `+RequestID:<=2 -RequestMethod:"CacheSv1.ReloadCache"`, ContentFilters: []string{}, }, &result); err != nil { t.Error(err) - } else if len(result) != 7 { - fmt.Println(len(result)) + } else if len(result) != 2 { t.Errorf("Unexpected result: %s", utils.ToJSON(result)) } } @@ -624,11 +633,10 @@ func testAnzDocQueryWithContentFiltersFilters(t *testing.T) { // Query results for API calls with with an execution duration longer than 30ms if err := anzDocRPC.Call(context.Background(), utils.AnalyzerSv1StringQuery, &analyzers.QueryArgs{ HeaderFilters: "", - ContentFilters: []string{"*gt:~*hdr.RequestDuration:30ms"}, + ContentFilters: []string{"*gt:~*hdr.RequestDuration:50ms"}, }, &result); err != nil { t.Error(err) - } else if len(result) != 7 { - fmt.Println(len(result)) + } else if len(result) != 1 { t.Errorf("Unexpected result: %s", utils.ToJSON(result)) } }