You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by el...@apache.org on 2018/07/06 17:17:12 UTC
[trafficcontrol] 02/02: Add TO Go ds_matches client funcs, tests
This is an automated email from the ASF dual-hosted git repository.
elsloo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit e2321e53d116a43bfa911fe23e652bf6b7421b17
Author: Robert Butts <ro...@apache.org>
AuthorDate: Sat Jun 30 11:53:15 2018 -0600
Add TO Go ds_matches client funcs, tests
---
lib/go-tc/deliveryservices.go | 4 ++
traffic_ops/client/deliveryservice.go | 10 ++++
traffic_ops/client/v13/deliveryservice.go | 10 ++++
.../testing/api/v13/deliveryservicematches_test.go | 67 ++++++++++++++++++++++
4 files changed, 91 insertions(+)
diff --git a/lib/go-tc/deliveryservices.go b/lib/go-tc/deliveryservices.go
index 519e97b..e9fa6ee 100644
--- a/lib/go-tc/deliveryservices.go
+++ b/lib/go-tc/deliveryservices.go
@@ -533,6 +533,10 @@ type DeliveryServicePatterns struct {
DSName DeliveryServiceName `json:"dsName"`
}
+type DeliveryServiceMatchesResponse struct {
+ Response []DeliveryServicePatterns `json:"response"`
+}
+
// DeliveryServiceRoutingResponse ...
type DeliveryServiceRoutingResponse struct {
Response DeliveryServiceRouting `json:"response"`
diff --git a/traffic_ops/client/deliveryservice.go b/traffic_ops/client/deliveryservice.go
index 6843789..413c31a 100644
--- a/traffic_ops/client/deliveryservice.go
+++ b/traffic_ops/client/deliveryservice.go
@@ -249,3 +249,13 @@ func (to *Session) GetDeliveryServiceSSLKeysByHostname(hostname string) (*tc.Del
return &data.Response, reqInf, nil
}
+
+func (to *Session) GetDeliveryServiceMatches() ([]tc.DeliveryServicePatterns, ReqInf, error) {
+ uri := apiBase + `/deliveryservice_matches`
+ resp := tc.DeliveryServiceMatchesResponse{}
+ reqInf, err := get(to, uri, &resp)
+ if err != nil {
+ return nil, reqInf, err
+ }
+ return resp.Response, reqInf, nil
+}
diff --git a/traffic_ops/client/v13/deliveryservice.go b/traffic_ops/client/v13/deliveryservice.go
index 9f2cfba..a4bee7b 100644
--- a/traffic_ops/client/v13/deliveryservice.go
+++ b/traffic_ops/client/v13/deliveryservice.go
@@ -251,3 +251,13 @@ func (to *Session) GetDeliveryServiceSSLKeysByHostname(hostname string) (*tc.Del
return &data.Response, reqInf, nil
}
+
+func (to *Session) GetDeliveryServiceMatches() ([]tc.DeliveryServicePatterns, ReqInf, error) {
+ uri := apiBase + `/deliveryservice_matches`
+ resp := tc.DeliveryServiceMatchesResponse{}
+ reqInf, err := get(to, uri, &resp)
+ if err != nil {
+ return nil, reqInf, err
+ }
+ return resp.Response, reqInf, nil
+}
diff --git a/traffic_ops/testing/api/v13/deliveryservicematches_test.go b/traffic_ops/testing/api/v13/deliveryservicematches_test.go
new file mode 100644
index 0000000..f1ec759
--- /dev/null
+++ b/traffic_ops/testing/api/v13/deliveryservicematches_test.go
@@ -0,0 +1,67 @@
+package v13
+
+/*
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+import (
+ "github.com/apache/trafficcontrol/lib/go-log"
+ "github.com/apache/trafficcontrol/lib/go-tc"
+ "testing"
+)
+
+func TestDeliveryServiceMatches(t *testing.T) {
+ CreateTestCDNs(t)
+ CreateTestTypes(t)
+ CreateTestProfiles(t)
+ CreateTestStatuses(t)
+ CreateTestDivisions(t)
+ CreateTestRegions(t)
+ CreateTestPhysLocations(t)
+ CreateTestCacheGroups(t)
+ CreateTestServers(t)
+ CreateTestDeliveryServices(t)
+
+ GetTestDeliveryServiceMatches(t)
+
+ DeleteTestDeliveryServices(t)
+ DeleteTestServers(t)
+ DeleteTestCacheGroups(t)
+ DeleteTestPhysLocations(t)
+ DeleteTestRegions(t)
+ DeleteTestDivisions(t)
+ DeleteTestStatuses(t)
+ DeleteTestProfiles(t)
+ DeleteTestTypes(t)
+ DeleteTestCDNs(t)
+}
+
+func GetTestDeliveryServiceMatches(t *testing.T) {
+ log.Debugln("GetTestDeliveryServiceMatches")
+ dsMatches, _, err := TOSession.GetDeliveryServiceMatches()
+ if err != nil {
+ t.Fatalf("cannot GET DeliveryService matches: %v\n", err)
+ }
+
+ dsMatchMap := map[tc.DeliveryServiceName][]string{}
+ for _, ds := range dsMatches {
+ dsMatchMap[ds.DSName] = ds.Patterns
+ }
+
+ for _, ds := range testData.DeliveryServices {
+ if _, ok := dsMatchMap[tc.DeliveryServiceName(ds.XMLID)]; !ok {
+ t.Fatalf("GET DeliveryService matches missing: %v\n", ds.XMLID)
+ }
+ }
+}