From 540f2062ecb62e9abd5d7fc898200fe12cdd73f7 Mon Sep 17 00:00:00 2001 From: shane Date: Tue, 29 Oct 2024 11:14:10 -0500 Subject: [PATCH 1/5] LEAF-4487 - moving the test over here from the old x-test dir --- API-tests/largeFormQuery_test.go | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 API-tests/largeFormQuery_test.go diff --git a/API-tests/largeFormQuery_test.go b/API-tests/largeFormQuery_test.go new file mode 100644 index 00000000..b95287c5 --- /dev/null +++ b/API-tests/largeFormQuery_test.go @@ -0,0 +1,46 @@ +package main + +import ( + "encoding/json" + "io" + "strings" + "testing" +) + +func TestLargeFormQuery_SmallQuery(t *testing.T) { + url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":["status","initiatorName"],"sort":{},"limit":10000,"getData":["9","8","10","4","5","7","3","6","2"]}&x-filterData=recordID,title,stepTitle,lastStatus,lastName,firstName` + + url = strings.Replace(url, " ", "%20", -1) + res, _ := client.Get(url) + b, _ := io.ReadAll(res.Body) + + var formQueryResponse FormQueryResponse + _ = json.Unmarshal(b, &formQueryResponse) + + if _, exists := formQueryResponse[958]; !exists { + t.Errorf("Record 958 should be readable") + } + + if v, ok := res.Header["Leaf_large_queries"]; ok && (len(v) != 1 || v[0] != "pass_onto_large_query_server") { + t.Errorf("bad headers: %v", res.Header) + } +} + +func TestLargeFormQuery_LargeQuery(t *testing.T) { + url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":["status","initiatorName"],"sort":{},"getData":["9","8","10","4","5","7","3","6","2"]}&x-filterData=recordID,title,stepTitle,lastStatus,lastName,firstName` + + url = strings.Replace(url, " ", "%20", -1) + res, _ := client.Get(url) + b, _ := io.ReadAll(res.Body) + + var formQueryResponse FormQueryResponse + _ = json.Unmarshal(b, &formQueryResponse) + + if _, exists := formQueryResponse[958]; !exists { + t.Errorf("Record 958 should be readable") + } + + if v, ok := res.Header["Leaf_large_queries"]; ok && (len(v) != 1 || v[0] != "process_ran_on_large_query_server") { + t.Errorf("bad headers: %v", res.Header) + } +} From 094343dec62c2454762332d7b2ec7a5dca037a73 Mon Sep 17 00:00:00 2001 From: shane Date: Mon, 2 Dec 2024 09:27:01 -0600 Subject: [PATCH 2/5] LEAF-4487 - large query move test into form query and make test fail when large query server/code is not in use --- API-tests/formQuery_test.go | 49 ++++++++++++++++++++++++++++---- API-tests/largeFormQuery_test.go | 46 ------------------------------ 2 files changed, 43 insertions(+), 52 deletions(-) delete mode 100644 API-tests/largeFormQuery_test.go diff --git a/API-tests/formQuery_test.go b/API-tests/formQuery_test.go index e3476738..47636b91 100644 --- a/API-tests/formQuery_test.go +++ b/API-tests/formQuery_test.go @@ -208,15 +208,14 @@ func TestFormQuery_FindTwoSteps(t *testing.T) { } } - /* post a new employee to an orgchart format question and then confirm expected values on orgchart property */ func TestFormQuery_Employee_Format__Orgchart_Has_Expected_Values(t *testing.T) { mock_orgchart_employee := FormQuery_Orgchart_Employee{ - FirstName: "Ramon", - LastName: "Watsica", + FirstName: "Ramon", + LastName: "Watsica", MiddleName: "Yundt", - Email: "Ramon.Watsica@fake-email.com", - UserName: "vtrycxbethany", + Email: "Ramon.Watsica@fake-email.com", + UserName: "vtrycxbethany", } postData := url.Values{} @@ -243,7 +242,7 @@ func TestFormQuery_Employee_Format__Orgchart_Has_Expected_Values(t *testing.T) { recData := formRes[11].S1 dataInterface := recData["id8_orgchart"] - orgchart := dataInterface.(map[string]interface {}) + orgchart := dataInterface.(map[string]interface{}) b, _ := json.Marshal(orgchart) var org_emp FormQuery_Orgchart_Employee @@ -278,3 +277,41 @@ func TestFormQuery_Employee_Format__Orgchart_Has_Expected_Values(t *testing.T) { t.Errorf("userName got = %v, want = %v", got, want) } } + +func TestLargeFormQuery_SmallQuery(t *testing.T) { + url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":["status","initiatorName"],"sort":{},"limit":10000,"getData":["9","8","10","4","5","7","3","6","2"]}&x-filterData=recordID,title,stepTitle,lastStatus,lastName,firstName` + + url = strings.Replace(url, " ", "%20", -1) + res, _ := client.Get(url) + b, _ := io.ReadAll(res.Body) + + var formQueryResponse FormQueryResponse + _ = json.Unmarshal(b, &formQueryResponse) + + if _, exists := formQueryResponse[958]; !exists { + t.Errorf("Record 958 should be readable") + } + + if v, ok := res.Header["Leaf_large_queries"]; ok && v[0] != "pass_onto_large_query_server" { + t.Errorf("bad headers: %v", res.Header) + } +} + +func TestLargeFormQuery_LargeQuery(t *testing.T) { + url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":["status","initiatorName"],"sort":{},"getData":["9","8","10","4","5","7","3","6","2"]}&x-filterData=recordID,title,stepTitle,lastStatus,lastName,firstName` + + url = strings.Replace(url, " ", "%20", -1) + res, _ := client.Get(url) + b, _ := io.ReadAll(res.Body) + + var formQueryResponse FormQueryResponse + _ = json.Unmarshal(b, &formQueryResponse) + + if _, exists := formQueryResponse[958]; !exists { + t.Errorf("Record 958 should be readable") + } + + if v, ok := res.Header["Leaf_large_queries"]; ok && v[0] != "process_ran_on_large_query_server" { + t.Errorf("bad headers: %v", res.Header) + } +} diff --git a/API-tests/largeFormQuery_test.go b/API-tests/largeFormQuery_test.go deleted file mode 100644 index b95287c5..00000000 --- a/API-tests/largeFormQuery_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package main - -import ( - "encoding/json" - "io" - "strings" - "testing" -) - -func TestLargeFormQuery_SmallQuery(t *testing.T) { - url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":["status","initiatorName"],"sort":{},"limit":10000,"getData":["9","8","10","4","5","7","3","6","2"]}&x-filterData=recordID,title,stepTitle,lastStatus,lastName,firstName` - - url = strings.Replace(url, " ", "%20", -1) - res, _ := client.Get(url) - b, _ := io.ReadAll(res.Body) - - var formQueryResponse FormQueryResponse - _ = json.Unmarshal(b, &formQueryResponse) - - if _, exists := formQueryResponse[958]; !exists { - t.Errorf("Record 958 should be readable") - } - - if v, ok := res.Header["Leaf_large_queries"]; ok && (len(v) != 1 || v[0] != "pass_onto_large_query_server") { - t.Errorf("bad headers: %v", res.Header) - } -} - -func TestLargeFormQuery_LargeQuery(t *testing.T) { - url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":["status","initiatorName"],"sort":{},"getData":["9","8","10","4","5","7","3","6","2"]}&x-filterData=recordID,title,stepTitle,lastStatus,lastName,firstName` - - url = strings.Replace(url, " ", "%20", -1) - res, _ := client.Get(url) - b, _ := io.ReadAll(res.Body) - - var formQueryResponse FormQueryResponse - _ = json.Unmarshal(b, &formQueryResponse) - - if _, exists := formQueryResponse[958]; !exists { - t.Errorf("Record 958 should be readable") - } - - if v, ok := res.Header["Leaf_large_queries"]; ok && (len(v) != 1 || v[0] != "process_ran_on_large_query_server") { - t.Errorf("bad headers: %v", res.Header) - } -} From 72a6e5f023edcd2cc063c272d34f1487b58da617 Mon Sep 17 00:00:00 2001 From: shane Date: Mon, 2 Dec 2024 10:08:25 -0600 Subject: [PATCH 3/5] LEAF-4487 - adjustment to the query to make it only pass when using the correct docker config and code, previus iterations allowed for passage if not run on the proper version since at the time we were unsure how the testing process would function --- API-tests/formQuery_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/API-tests/formQuery_test.go b/API-tests/formQuery_test.go index 47636b91..a3593ea2 100644 --- a/API-tests/formQuery_test.go +++ b/API-tests/formQuery_test.go @@ -292,7 +292,7 @@ func TestLargeFormQuery_SmallQuery(t *testing.T) { t.Errorf("Record 958 should be readable") } - if v, ok := res.Header["Leaf_large_queries"]; ok && v[0] != "pass_onto_large_query_server" { + if res.Header.Get("Leaf_large_queries") != "pass_onto_large_query_server" { t.Errorf("bad headers: %v", res.Header) } } @@ -311,7 +311,8 @@ func TestLargeFormQuery_LargeQuery(t *testing.T) { t.Errorf("Record 958 should be readable") } - if v, ok := res.Header["Leaf_large_queries"]; ok && v[0] != "process_ran_on_large_query_server" { + if res.Header.Get("Leaf_large_queries") != "process_ran_on_large_query_server" { t.Errorf("bad headers: %v", res.Header) } + } From 58ffd3464e039e66a3a5a00f2c170170da3042c7 Mon Sep 17 00:00:00 2001 From: shane Date: Thu, 5 Dec 2024 10:19:24 -0600 Subject: [PATCH 4/5] LEAF-4487 - add in the tests for the differing variations. --- API-tests/formQuery_test.go | 63 +++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/API-tests/formQuery_test.go b/API-tests/formQuery_test.go index a3593ea2..cf489c51 100644 --- a/API-tests/formQuery_test.go +++ b/API-tests/formQuery_test.go @@ -292,12 +292,31 @@ func TestLargeFormQuery_SmallQuery(t *testing.T) { t.Errorf("Record 958 should be readable") } - if res.Header.Get("Leaf_large_queries") != "pass_onto_large_query_server" { + if res.Header.Get("Leaf_large_queries") != "process_ran_on_api_server" { t.Errorf("bad headers: %v", res.Header) } } -func TestLargeFormQuery_LargeQuery(t *testing.T) { +func TestLargeFormQuery_SmallQuery_Indi_lt10_Limit1001(t *testing.T) { + url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":[],"sort":{},"getData":["9","8","10","4","5","7","3","6"],"limit":1001}&x-filterData=recordID,title` + + url = strings.Replace(url, " ", "%20", -1) + res, _ := client.Get(url) + b, _ := io.ReadAll(res.Body) + + var formQueryResponse FormQueryResponse + _ = json.Unmarshal(b, &formQueryResponse) + + if _, exists := formQueryResponse[958]; !exists { + t.Errorf("Record 958 should be readable") + } + + if res.Header.Get("Leaf_large_queries") != "process_ran_on_api_server" { + t.Errorf("bad headers: %v", res.Header) + } +} + +func TestLargeFormQuery_LargeQuery_NoLimit(t *testing.T) { url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":["status","initiatorName"],"sort":{},"getData":["9","8","10","4","5","7","3","6","2"]}&x-filterData=recordID,title,stepTitle,lastStatus,lastName,firstName` url = strings.Replace(url, " ", "%20", -1) @@ -316,3 +335,43 @@ func TestLargeFormQuery_LargeQuery(t *testing.T) { } } + +func TestLargeFormQuery_LargeQuery_LimitGT110000(t *testing.T) { + url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":["status","initiatorName"],"sort":{},"getData":["9","8","10","4","5","7","3","6","2"],"limit":10001}&x-filterData=recordID,title,stepTitle,lastStatus,lastName,firstName` + + url = strings.Replace(url, " ", "%20", -1) + res, _ := client.Get(url) + b, _ := io.ReadAll(res.Body) + + var formQueryResponse FormQueryResponse + _ = json.Unmarshal(b, &formQueryResponse) + + if _, exists := formQueryResponse[958]; !exists { + t.Errorf("Record 958 should be readable") + } + + if res.Header.Get("Leaf_large_queries") != "process_ran_on_large_query_server" { + t.Errorf("bad headers: %v", res.Header) + } + +} + +func TestLargeFormQuery_LargeQuery_Indi_10_Limit1001(t *testing.T) { + url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":[],"sort":{},"getData":["9","8","10","4","5","7","3","6","2","-7","-5","-6","-2","-1","-4","14","15","12","1"],"limit":1001}&x-filterData=recordID,title` + + url = strings.Replace(url, " ", "%20", -1) + res, _ := client.Get(url) + b, _ := io.ReadAll(res.Body) + + var formQueryResponse FormQueryResponse + _ = json.Unmarshal(b, &formQueryResponse) + + if _, exists := formQueryResponse[958]; !exists { + t.Errorf("Record 958 should be readable") + } + + if res.Header.Get("Leaf_large_queries") != "process_ran_on_large_query_server" { + t.Errorf("bad headers: %v", res.Header) + } + +} From 395ec39c517e13d24ff74b2047f04ca7d246d1cf Mon Sep 17 00:00:00 2001 From: shane Date: Tue, 10 Dec 2024 10:11:49 -0600 Subject: [PATCH 5/5] LEAF-4487 - switch over to different headers and values --- API-tests/formQuery_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/API-tests/formQuery_test.go b/API-tests/formQuery_test.go index cf489c51..04c828db 100644 --- a/API-tests/formQuery_test.go +++ b/API-tests/formQuery_test.go @@ -292,7 +292,7 @@ func TestLargeFormQuery_SmallQuery(t *testing.T) { t.Errorf("Record 958 should be readable") } - if res.Header.Get("Leaf_large_queries") != "process_ran_on_api_server" { + if res.Header.Get("LEAF_Is_Large_Query") != "false" { t.Errorf("bad headers: %v", res.Header) } } @@ -311,7 +311,7 @@ func TestLargeFormQuery_SmallQuery_Indi_lt10_Limit1001(t *testing.T) { t.Errorf("Record 958 should be readable") } - if res.Header.Get("Leaf_large_queries") != "process_ran_on_api_server" { + if res.Header.Get("LEAF_Is_Large_Query") != "false" { t.Errorf("bad headers: %v", res.Header) } } @@ -330,7 +330,7 @@ func TestLargeFormQuery_LargeQuery_NoLimit(t *testing.T) { t.Errorf("Record 958 should be readable") } - if res.Header.Get("Leaf_large_queries") != "process_ran_on_large_query_server" { + if res.Header.Get("LEAF_Is_Large_Query") != "true" { t.Errorf("bad headers: %v", res.Header) } @@ -350,7 +350,7 @@ func TestLargeFormQuery_LargeQuery_LimitGT110000(t *testing.T) { t.Errorf("Record 958 should be readable") } - if res.Header.Get("Leaf_large_queries") != "process_ran_on_large_query_server" { + if res.Header.Get("LEAF_Is_Large_Query") != "true" { t.Errorf("bad headers: %v", res.Header) } @@ -370,7 +370,7 @@ func TestLargeFormQuery_LargeQuery_Indi_10_Limit1001(t *testing.T) { t.Errorf("Record 958 should be readable") } - if res.Header.Get("Leaf_large_queries") != "process_ran_on_large_query_server" { + if res.Header.Get("LEAF_Is_Large_Query") != "true" { t.Errorf("bad headers: %v", res.Header) }