You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/05/29 14:36:27 UTC

[GitHub] dewrich commented on a change in pull request #2124: Add TO Go deliveryservices routes

dewrich commented on a change in pull request #2124: Add TO Go deliveryservices routes
URL: https://github.com/apache/incubator-trafficcontrol/pull/2124#discussion_r191449225
 
 

 ##########
 File path: traffic_ops/testing/api/v13/deliveryservices_test.go
 ##########
 @@ -0,0 +1,296 @@
+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 (
+	"strconv"
+
+	"github.com/apache/incubator-trafficcontrol/lib/go-log"
+	"github.com/apache/incubator-trafficcontrol/lib/go-tc"
+	"testing"
+)
+
+func TestDeliveryServices(t *testing.T) {
+	CreateTestCDNs(t)
+	CreateTestTypes(t)
+	CreateTestProfiles(t)
+	CreateTestStatuses(t)
+	CreateTestDivisions(t)
+	CreateTestRegions(t)
+	CreateTestPhysLocations(t)
+	CreateTestCacheGroups(t)
+	CreateTestServers(t)
+	CreateTestDeliveryServices(t)
+	UpdateTestDeliveryServices(t)
+	GetTestDeliveryServices(t)
+	DeleteTestDeliveryServices(t)
+	DeleteTestServers(t)
+	DeleteTestCacheGroups(t)
+	DeleteTestPhysLocations(t)
+	DeleteTestRegions(t)
+	DeleteTestDivisions(t)
+	DeleteTestStatuses(t)
+	DeleteTestProfiles(t)
+	DeleteTestTypes(t)
+	DeleteTestCDNs(t)
+}
+
+func CreateTestDeliveryServices(t *testing.T) {
+	log.Debugln("CreateTestDeliveryServices")
+
+	// TODO delete on DS delete
+	pl := tc.Parameter{
+		ConfigFile: "remap.config",
+		Name:       "location",
+		Value:      "/remap/config/location/parameter/",
+	}
+	_, _, err := TOSession.CreateParameter(pl)
+	if err != nil {
+		t.Fatalf("cannot create parameter: %v\n", err)
+	}
+	for _, ds := range testData.DeliveryServices {
+		respCDNs, _, err := TOSession.GetCDNByName(ds.CDNName)
+		if err != nil {
+			t.Fatalf("cannot GET CDN - %v\n", err)
+		}
+		if len(respCDNs) < 1 {
+			t.Fatalf("cannot GET CDN - no CDNs\n")
+		}
+		ds.CDNID = respCDNs[0].ID
+
+		respTypes, _, err := TOSession.GetTypeByName(ds.Type)
+		if err != nil {
+			t.Fatalf("cannot GET Type by name: %v\n", err)
+		}
+		if len(respTypes) < 1 {
+			t.Fatalf("cannot GET Type - no Types\n")
+		}
+		ds.TypeID = respTypes[0].ID
+
+		if ds.ProfileName != "" {
+			respProfiles, _, err := TOSession.GetProfileByName(ds.ProfileName)
+			if err != nil {
+				t.Fatalf("cannot GET Profile by name: %v\n", err)
+			}
+			if len(respProfiles) < 1 {
+				t.Fatalf("cannot GET Profile - no Profiles\n")
+			}
+			ds.ProfileID = respProfiles[0].ID
+		}
+
+		// respTenants, _, err := TOSession.GetTenantByName(ds.Tenant)
+		// if err != nil {
+		// 	t.Errorf("cannot GET Division by name: EDGE - %v\n", err)
+		// }
+		// if len(respTenants) < 1 {
+		// 	t.Fatalf("cannot GET Tenant - no Tenants\n")
+		// }
+		respTenants, _, err := TOSession.Tenants()
+		if err != nil {
+			t.Fatalf("cannot GET tenants: %v\n", err)
+		}
+		if len(respTenants) < 1 {
+			t.Fatalf("cannot GET tenants: no tenants returned from Traffic Ops\n")
+		}
+		ds.TenantID = respTenants[0].ID
+
+		_, err = TOSession.CreateDeliveryService(&ds)
+		if err != nil {
+			t.Fatalf("could not CREATE delivery service '%s': %v\n", ds.XMLID, err)
+		}
+	}
+
+	// GET EDGE1 profile
+
+	// respCDNs, _, err := TOSession.GetCDNByName("cdn2")
 
 Review comment:
   Should these comments be cleaned up?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services