This is an automated email from the ASF dual-hosted git repository.
ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 2693bac Fixed servercheck filtering for unknown and extra query param
(#5616)
2693bac is described below
commit 2693bac6f7fd4d48a615ab1ce491948592ffdde0
Author: Rima Shah <[email protected]>
AuthorDate: Wed Mar 10 16:52:47 2021 -0700
Fixed servercheck filtering for unknown and extra query param (#5616)
---
CHANGELOG.md | 1 +
traffic_ops/testing/api/v4/serverchecks_test.go | 30 ++++++++++++++++++++++
.../traffic_ops_golang/servercheck/servercheck.go | 6 +++++
3 files changed, 37 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7eb8d47..625a52e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,7 @@ The format is based on [Keep a
Changelog](http://keepachangelog.com/en/1.0.0/).
- Added an endpoint for statuses on asynchronous jobs and applied it to the
ACME renewal endpoint.
### Fixed
+- [#5609](https://github.com/apache/trafficcontrol/issues/5609) - Fixed GET
/servercheck filter for an extra query param.
- [#5565](https://github.com/apache/trafficcontrol/issues/5565) - TO GET
/caches/stats panic converting string to uint64
- [#5558](https://github.com/apache/trafficcontrol/issues/5558) - Fixed `TM
UI` and `/api/cache-statuses` to report aggregate `bandwidth_kbps` correctly.
- [#5288](https://github.com/apache/trafficcontrol/issues/5288) - Fixed the
ability to create and update a server with MTU value >= 1280.
diff --git a/traffic_ops/testing/api/v4/serverchecks_test.go
b/traffic_ops/testing/api/v4/serverchecks_test.go
index ac98454..0b0c687 100644
--- a/traffic_ops/testing/api/v4/serverchecks_test.go
+++ b/traffic_ops/testing/api/v4/serverchecks_test.go
@@ -154,6 +154,21 @@ func GetTestServerChecksWithName(t *testing.T) {
if err != nil {
t.Fatalf("could not GET serverchecks by name (%v): %v (alerts:
%+v)", scResp[0].HostName, err, alerts)
}
+
+ //Add unknown param key
+ params.Add("foo", "car")
+ // Get server checks
+ resp, alerts, _, err := TOSession.GetServersChecks(params, nil)
+ if len(resp) == 0 {
+ t.Fatal("no server checks in response, quitting")
+ }
+ if err != nil {
+ t.Fatalf("could not GET serverchecks by name (%v): %v (alerts:
%+v)", resp[0].HostName, err, alerts)
+ }
+
+ if len(scResp) != len(resp) {
+ t.Fatalf("expected: Both response lengths should be equal, got:
first resp:%v-second resp:%v", len(scResp), len(resp))
+ }
}
func GetTestServerChecksWithID(t *testing.T) {
@@ -176,6 +191,21 @@ func GetTestServerChecksWithID(t *testing.T) {
if err != nil {
t.Fatalf("could not GET serverchecks by id (%v): %v (alerts:
%+v)", scResp[0].ID, err, alerts)
}
+
+ //Add unknown param key
+ params.Add("foo", "car")
+ // Get server checks
+ resp, alerts, _, err := TOSession.GetServersChecks(params, nil)
+ if len(resp) == 0 {
+ t.Fatal("no server checks in response, quitting")
+ }
+ if err != nil {
+ t.Fatalf("could not GET serverchecks by name (%v): %v (alerts:
%+v)", resp[0].HostName, err, alerts)
+ }
+
+ if len(scResp) != len(resp) {
+ t.Fatalf("expected: Both response lengths should be equal, got:
first resp:%v-second resp:%v", len(scResp), len(resp))
+ }
}
// Need to define no-op function as TCObj interface expects a delete function
diff --git a/traffic_ops/traffic_ops_golang/servercheck/servercheck.go
b/traffic_ops/traffic_ops_golang/servercheck/servercheck.go
index 436b55b..ef4d1ea 100644
--- a/traffic_ops/traffic_ops_golang/servercheck/servercheck.go
+++ b/traffic_ops/traffic_ops_golang/servercheck/servercheck.go
@@ -270,6 +270,12 @@ func handleReadServerCheck(inf *api.APIInfo, tx *sql.Tx)
([]tc.GenericServerChec
if ok && ok1 {
whereSI = "WHERE (type.name LIKE 'MID%' OR type.name
LIKE 'EDGE%') AND (server.host_name=:hostName AND server.id=:id)"
whereSC = "WHERE servercheck.server=:id"
+ } else if ok && !ok1 {
+ whereSI = "WHERE (type.name LIKE 'MID%' OR type.name
LIKE 'EDGE%') AND server.id=:id "
+ whereSC = "WHERE servercheck.server=:id"
+ } else if ok1 && !ok {
+ whereSI = "WHERE (type.name LIKE 'MID%' OR type.name
LIKE 'EDGE%') AND server.host_name=:hostName "
+ whereSC = ""
} else {
whereSI = "WHERE type.name LIKE 'MID%' OR type.name
LIKE 'EDGE%' "
whereSC = ""