This is an automated email from the ASF dual-hosted git repository.
zrhoffman 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 eaa6bb89a0 Refactor Servers ID Delivery Services Tests (#6934)
eaa6bb89a0 is described below
commit eaa6bb89a02be97e4e6e7ceee983bc71ef675214
Author: Eric Holguin <[email protected]>
AuthorDate: Mon Jul 18 10:56:20 2022 -0600
Refactor Servers ID Delivery Services Tests (#6934)
* Refactor servers id deliveryservices tests
* Move servers deliveryservices tests
* Change test name
---
.../testing/api/v3/deliveryserviceservers_test.go | 45 ---
.../api/v3/servers_id_deliveryservices_test.go | 170 +++++++++++
.../servers_to_deliveryservice_assignment_test.go | 305 --------------------
.../testing/api/v4/deliveryserviceservers_test.go | 53 ----
.../api/v4/servers_id_deliveryservices_test.go | 180 ++++++++++++
.../servers_to_deliveryservice_assignment_test.go | 320 ---------------------
6 files changed, 350 insertions(+), 723 deletions(-)
diff --git a/traffic_ops/testing/api/v3/deliveryserviceservers_test.go
b/traffic_ops/testing/api/v3/deliveryserviceservers_test.go
index 6cb5781d37..1f984592bb 100644
--- a/traffic_ops/testing/api/v3/deliveryserviceservers_test.go
+++ b/traffic_ops/testing/api/v3/deliveryserviceservers_test.go
@@ -254,51 +254,6 @@ func TestDeliveryServicesIDServers(t *testing.T) {
})
}
-func TestServersIDDeliveryServices(t *testing.T) {
- WithObjs(t, []TCObj{CDNs, Types, Tenants, Parameters, Profiles,
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies,
ServiceCategories, DeliveryServices, DeliveryServiceServerAssignments}, func() {
- serversIDDSTests := utils.V3TestCase{
- "POST": {
- "BAD REQUEST when REMOVING ONLY EDGE SERVER
ASSIGNMENT": {
- ClientSession: TOSession, RequestBody:
map[string]interface{}{
- "server": GetServerID(t,
"test-ds-server-assignments")(),
- "dsIds":
[]int{GetDeliveryServiceId(t, "test-ds-server-assignments")()},
- "replace": true,
- },
- Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusConflict)),
- },
- },
- }
- for method, testCases := range serversIDDSTests {
- t.Run(method, func(t *testing.T) {
- for name, testCase := range testCases {
-
- var server int
- var replace bool
-
- if testCase.RequestBody != nil {
- if val, ok :=
testCase.RequestBody["server"]; ok {
- server = val.(int)
- }
- if val, ok :=
testCase.RequestBody["replace"]; ok {
- replace = val.(bool)
- }
- }
-
- switch method {
- case "POST":
- t.Run(name, func(t *testing.T) {
- resp, reqInf, err :=
testCase.ClientSession.AssignDeliveryServiceIDsToServerID(server, []int{},
replace)
- for _, check := range
testCase.Expectations {
- check(t,
reqInf, nil, resp, err)
- }
- })
- }
- }
- })
- }
- })
-}
-
func TestDeliveryServicesDSIDServerID(t *testing.T) {
WithObjs(t, []TCObj{CDNs, Types, Tenants, Parameters, Profiles,
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies,
ServiceCategories, DeliveryServices, DeliveryServiceServerAssignments}, func() {
dssDSIDServerIDTests := utils.V3TestCase{
diff --git a/traffic_ops/testing/api/v3/servers_id_deliveryservices_test.go
b/traffic_ops/testing/api/v3/servers_id_deliveryservices_test.go
new file mode 100644
index 0000000000..39437b7286
--- /dev/null
+++ b/traffic_ops/testing/api/v3/servers_id_deliveryservices_test.go
@@ -0,0 +1,170 @@
+package v3
+
+/*
+ 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 (
+ "net/http"
+ "testing"
+ "time"
+
+ "github.com/apache/trafficcontrol/lib/go-rfc"
+ "github.com/apache/trafficcontrol/lib/go-tc"
+ "github.com/apache/trafficcontrol/traffic_ops/testing/api/assert"
+ "github.com/apache/trafficcontrol/traffic_ops/testing/api/utils"
+ "github.com/apache/trafficcontrol/traffic_ops/toclientlib"
+)
+
+func TestServersIDDeliveryServices(t *testing.T) {
+ WithObjs(t, []TCObj{CDNs, Types, Parameters, Profiles, Statuses,
Divisions, Regions, PhysLocations, CacheGroups, Servers, Tenants, Topologies,
ServiceCategories, DeliveryServices, DeliveryServiceServerAssignments}, func() {
+
+ currentTime := time.Now().UTC().Add(-15 * time.Second)
+ tomorrow := currentTime.AddDate(0, 0, 1).Format(time.RFC1123)
+
+ methodTests := utils.V3TestCase{
+ "GET": {
+ "NOT MODIFIED when NO CHANGES made": {
+ EndpointId: GetServerID(t,
"atlanta-edge-14"),
+ ClientSession: TOSession,
+ RequestHeaders:
http.Header{rfc.IfModifiedSince: {tomorrow}},
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusNotModified)),
+ },
+ "OK when VALID request": {
+ EndpointId: GetServerID(t,
"atlanta-edge-14"),
+ ClientSession: TOSession,
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+ },
+ },
+ "POST": {
+ "OK when VALID request": {
+ EndpointId: GetServerID(t,
"atlanta-edge-01"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds":
[]int{GetDeliveryServiceId(t, "ds1")()},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
+
validateServersDeliveryServicesPost(GetServerID(t, "atlanta-edge-01")(),
GetDeliveryServiceId(t, "ds1")())),
+ },
+ "OK when ASSIGNING EDGE to TOPOLOGY BASED
DELIVERY SERVICE": {
+ EndpointId: GetServerID(t,
"atlanta-edge-03"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds":
[]int{GetDeliveryServiceId(t, "top-ds-in-cdn1")()},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
+
validateServersDeliveryServicesPost(GetServerID(t, "atlanta-edge-03")(),
GetDeliveryServiceId(t, "top-ds-in-cdn1")())),
+ },
+ "OK when ASSIGNING ORIGIN to TOPOLOGY BASED
DELIVERY SERVICE": {
+ EndpointId: GetServerID(t,
"denver-mso-org-01"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds":
[]int{GetDeliveryServiceId(t, "ds-top")()},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
+
validateServersDeliveryServicesPost(GetServerID(t, "denver-mso-org-01")(),
GetDeliveryServiceId(t, "ds-top")())),
+ },
+ "CONFLICT when SERVER NOT IN SAME CDN as
DELIVERY SERVICE": {
+ EndpointId: GetServerID(t,
"cdn2-test-edge"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds":
[]int{GetDeliveryServiceId(t, "ds1")()},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusConflict)),
+ },
+ "BAD REQUEST when ORIGIN'S CACHEGROUP IS NOT A
PART OF TOPOLOGY BASED DELIVERY SERVICE": {
+ EndpointId: GetServerID(t,
"denver-mso-org-01"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds":
[]int{GetDeliveryServiceId(t, "ds-top-req-cap")()},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+ },
+ "CONFLICT when REMOVING ONLY EDGE SERVER
ASSIGNMENT": {
+ EndpointId: GetServerID(t,
"test-ds-server-assignments"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds": []int{},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusConflict)),
+ },
+ },
+ }
+
+ for method, testCases := range methodTests {
+ t.Run(method, func(t *testing.T) {
+ for name, testCase := range testCases {
+
+ var dsIds []int
+ var replace bool
+
+ if testCase.RequestBody != nil {
+ if val, ok :=
testCase.RequestBody["dsIds"]; ok {
+ dsIds = val.([]int)
+ }
+ if val, ok :=
testCase.RequestBody["replace"]; ok {
+ replace = val.(bool)
+ }
+ }
+
+ switch method {
+ case "GET":
+ t.Run(name, func(t *testing.T) {
+ resp, reqInf, err :=
testCase.ClientSession.GetServerIDDeliveryServicesWithHdr(testCase.EndpointId(),
testCase.RequestHeaders)
+ for _, check := range
testCase.Expectations {
+ check(t,
reqInf, resp, tc.Alerts{}, err)
+ }
+ })
+ case "POST":
+ t.Run(name, func(t *testing.T) {
+ alerts, reqInf, err :=
testCase.ClientSession.AssignDeliveryServiceIDsToServerID(testCase.EndpointId(),
dsIds, replace)
+ for _, check := range
testCase.Expectations {
+ check(t,
reqInf, nil, alerts, err)
+ }
+ })
+ }
+ }
+ })
+ }
+ })
+}
+
+func validateServersDeliveryServices(expectedDSID int) utils.CkReqFunc {
+ return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _
tc.Alerts, _ error) {
+ assert.RequireNotNil(t, resp, "Expected Server Delivery Service
response to not be nil.")
+ var found bool
+ deliveryServices := resp.([]tc.DeliveryServiceNullable)
+ for _, ds := range deliveryServices {
+ if ds.ID != nil && *ds.ID == expectedDSID {
+ found = true
+ break
+ }
+ }
+ assert.Equal(t, true, found, "Expected to find Delivery Service
ID: %d in response.")
+ }
+}
+
+func validateServersDeliveryServicesPost(serverID int, expectedDSID int)
utils.CkReqFunc {
+ return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _
tc.Alerts, _ error) {
+ serverDeliveryServices, _, err :=
TOSession.GetServerIDDeliveryServicesWithHdr(serverID, nil)
+ assert.RequireNoError(t, err, "Error getting Server Delivery
Services: %v", err)
+ assert.RequireEqual(t, 1, len(serverDeliveryServices),
"Expected one Delivery Service returned Got: %d", len(serverDeliveryServices))
+ validateServersDeliveryServices(expectedDSID)(t,
toclientlib.ReqInf{}, serverDeliveryServices, tc.Alerts{}, nil)
+ }
+}
diff --git
a/traffic_ops/testing/api/v3/servers_to_deliveryservice_assignment_test.go
b/traffic_ops/testing/api/v3/servers_to_deliveryservice_assignment_test.go
deleted file mode 100644
index 4ae11f4d30..0000000000
--- a/traffic_ops/testing/api/v3/servers_to_deliveryservice_assignment_test.go
+++ /dev/null
@@ -1,305 +0,0 @@
-package v3
-
-/*
- 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 (
- "net/http"
- "net/url"
- "testing"
- "time"
-
- "github.com/apache/trafficcontrol/lib/go-rfc"
- "github.com/apache/trafficcontrol/lib/go-tc"
-)
-
-func TestAssignments(t *testing.T) {
- WithObjs(t, []TCObj{CDNs, Types, Parameters, Profiles, Statuses,
Divisions, Regions, PhysLocations, CacheGroups, Servers, Tenants, Topologies,
DeliveryServices}, func() {
- AssignTestDeliveryService(t)
- AssignIncorrectTestDeliveryService(t)
- AssignTopologyBasedDeliveryService(t)
- OriginAssignTopologyBasedDeliveryService(t)
- })
-}
-
-func AssignTestDeliveryService(t *testing.T) {
- if len(testData.Servers) < 1 {
- t.Fatal("Need at least one test server to test delivery service
assignment")
- }
-
- server := testData.Servers[0]
- if server.HostName == nil {
- t.Fatalf("First server had nil hostname: %+v", server)
- }
-
- params := url.Values{}
- params.Add("hostName", *server.HostName)
-
- rs, _, err := TOSession.GetServersWithHdr(¶ms, nil)
- if err != nil {
- t.Fatalf("Failed to fetch server information: %v", err)
- } else if len(rs.Response) == 0 {
- t.Fatalf("Failed to fetch server information: No results
returned!")
- }
- firstServer := rs.Response[0]
- if firstServer.ID == nil {
- t.Fatalf("Server '%s' had nil ID", *server.HostName)
- }
-
- rd, _, err :=
TOSession.GetDeliveryServiceByXMLIDNullableWithHdr(*testData.DeliveryServices[0].XMLID,
nil)
- if err != nil {
- t.Fatalf("Failed to fetch DS information: %v", err)
- } else if len(rd) == 0 {
- t.Fatalf("Failed to fetch DS information: No results returned!")
- }
- firstDS := rd[0]
-
- if firstDS.ID == nil {
- t.Fatal("Fetch DS information returned unknown ID")
- }
- alerts, _, err :=
TOSession.AssignDeliveryServiceIDsToServerID(*firstServer.ID,
[]int{*firstDS.ID}, false)
- if err != nil {
- t.Errorf("Couldn't assign DS '%+v' to server '%+v': %v (alerts:
%v)", firstDS, firstServer, err, alerts)
- }
- t.Logf("alerts: %+v", alerts)
-
- response, _, err :=
TOSession.GetServerIDDeliveryServicesWithHdr(*firstServer.ID, nil)
- t.Logf("response: %+v", response)
- if err != nil {
- t.Fatalf("Couldn't get Delivery Services assigned to Server
'%+v': %v", firstServer, err)
- }
-
- var found bool
- for _, ds := range response {
- if ds.ID != nil && *ds.ID == *firstDS.ID {
- found = true
- break
- }
- }
-
- if !found {
- t.Errorf(`Server/DS assignment not found after "successful"
assignment!`)
- }
-
- currentTime := time.Now().UTC().Add(5 * time.Second)
- time := currentTime.Format(time.RFC1123)
- var header http.Header
- header = make(map[string][]string)
- header.Set(rfc.IfModifiedSince, time)
- _, reqInf, _ :=
TOSession.GetServerIDDeliveryServicesWithHdr(*firstServer.ID, header)
- if reqInf.StatusCode != http.StatusNotModified {
- t.Errorf("Expected a status code of 304, got %v",
reqInf.StatusCode)
- }
-}
-
-func AssignIncorrectTestDeliveryService(t *testing.T) {
- var server *tc.ServerV30
- for _, s := range testData.Servers {
- if s.CDNName != nil && *s.CDNName == "cdn2" {
- server = &s
- break
- }
- }
- if server == nil {
- t.Fatal("Couldn't find a server in CDN 'cdn2'!")
- }
- if server.HostName == nil {
- t.Fatalf("Server found with nil hostname: %+v", *server)
- }
- hostname := *server.HostName
-
- params := url.Values{}
- params.Add("hostName", hostname)
- rs, _, err := TOSession.GetServersWithHdr(¶ms, nil)
- if err != nil {
- t.Fatalf("Failed to fetch server information: %v - %v", err,
rs.Alerts)
- } else if len(rs.Response) == 0 {
- t.Fatalf("Failed to fetch server information: No results
returned!")
- }
- server = &rs.Response[0]
- if server.ID == nil {
- t.Fatalf("Server '%s' has nil ID", hostname)
- }
-
- rd, _, err :=
TOSession.GetDeliveryServiceByXMLIDNullableWithHdr(*testData.DeliveryServices[0].XMLID,
nil)
- if err != nil {
- t.Fatalf("Failed to fetch DS information: %v", err)
- } else if len(rd) == 0 {
- t.Fatalf("Failed to fetch DS information: No results returned!")
- }
- firstDS := rd[0]
-
- if firstDS.ID == nil {
- t.Fatal("Fetch DS information returned unknown ID")
- }
- alerts, _, err :=
TOSession.AssignDeliveryServiceIDsToServerID(*server.ID, []int{*firstDS.ID},
false)
- if err == nil {
- t.Errorf("Expected bad assignment to fail, but it didn't!
(alerts: %v)", alerts)
- }
-
- response, _, err :=
TOSession.GetServerIDDeliveryServicesWithHdr(*server.ID, nil)
- t.Logf("response: %+v", response)
- if err != nil {
- t.Fatalf("Couldn't get Delivery Services assigned to Server
'%+v': %v", *server, err)
- }
-
- var found bool
- for _, ds := range response {
-
- if ds.ID != nil && *ds.ID == *firstDS.ID {
- found = true
- break
- }
- }
-
- if found {
- t.Errorf(`Invalid Server/DS assignment was created!`)
- }
-}
-
-func AssignTopologyBasedDeliveryService(t *testing.T) {
- var server *tc.ServerV30
- for _, s := range testData.Servers {
- if s.CDNName != nil && *s.CDNName == "cdn1" && s.Type ==
string(tc.CacheTypeEdge) {
- server = &s
- break
- }
- }
- if server == nil || server.HostName == nil {
- t.Fatalf("Couldn't find an EDGE server in CDN 'cdn1'!")
- }
-
- params := url.Values{}
- params.Add("hostName", *server.HostName)
- rs, _, err := TOSession.GetServersWithHdr(¶ms, nil)
- if err != nil {
- t.Fatalf("Failed to fetch server information: %v", err)
- } else if len(rs.Response) == 0 {
- t.Fatalf("Failed to fetch server information: No results
returned!")
- }
- server = &rs.Response[0]
- if server.ID == nil {
- t.Fatal("Server had nil ID")
- }
-
- rd, _, err :=
TOSession.GetDeliveryServiceByXMLIDNullableWithHdr("ds-top", nil)
- if err != nil {
- t.Fatalf("Failed to fetch DS information: %v", err)
- } else if len(rd) == 0 {
- t.Fatalf("Failed to fetch DS information: No results returned!")
- }
- firstDS := rd[0]
-
- if firstDS.ID == nil {
- t.Fatal("Fetch DS information returned unknown ID")
- }
- alerts, reqInf, err :=
TOSession.AssignDeliveryServiceIDsToServerID(*server.ID, []int{*firstDS.ID},
false)
- if err != nil {
- t.Errorf("Expected assignment to succeed, but it didn't!
(alerts: %v)", alerts)
- }
- if reqInf.StatusCode >= http.StatusBadRequest {
- t.Fatalf("assigning Topology-based delivery service to server -
expected: non-error status code, actual: %d", reqInf.StatusCode)
- }
-
- response, _, err :=
TOSession.GetServerIDDeliveryServicesWithHdr(*server.ID, nil)
- t.Logf("response: %+v", response)
- if err != nil {
- t.Fatalf("Couldn't get Delivery Services assigned to Server
'%+v': %v", *server, err)
- }
-
- var found bool
- for _, ds := range response {
-
- if ds.ID != nil && *ds.ID == *firstDS.ID {
- found = true
- break
- }
- }
-
- if !found {
- t.Errorf(`Valid Server/DS assignment was not created!`)
- }
-}
-
-func OriginAssignTopologyBasedDeliveryService(t *testing.T) {
- params := url.Values{}
- params.Add("hostName", "denver-mso-org-01")
- rs, _, err := TOSession.GetServersWithHdr(¶ms, nil)
- if err != nil {
- t.Fatalf("Failed to fetch server information: %v", err)
- } else if len(rs.Response) == 0 {
- t.Fatalf("Failed to fetch server information: No results
returned!")
- }
- origin := &rs.Response[0]
- if origin.ID == nil {
- t.Fatal("Server had nil ID")
- }
-
- rd, _, err :=
TOSession.GetDeliveryServiceByXMLIDNullableWithHdr("ds-top-req-cap", nil)
- if err != nil {
- t.Fatalf("Failed to fetch DS information: %v", err)
- } else if len(rd) == 0 {
- t.Fatalf("Failed to fetch DS information: No results returned!")
- }
- firstDS := rd[0]
- if firstDS.ID == nil {
- t.Fatal("Fetch DS information returned unknown ID")
- }
-
- // invalid assignment: ORG server cachegroup does not belong to the
topology
- alerts, reqInf, err :=
TOSession.AssignDeliveryServiceIDsToServerID(*origin.ID, []int{*firstDS.ID},
true)
- if err == nil {
- t.Errorf("Expected assigning ORG server to topology-based
delivery service where the ORG server does not belong to the topology to fail,
but it didn't! (alerts: %v)", alerts)
- }
- if reqInf.StatusCode < http.StatusBadRequest || reqInf.StatusCode >=
http.StatusInternalServerError {
- t.Fatalf("assigning Topology-based delivery service to ORG
server that does not belong to the topology - expected: 400-level status code,
actual: %d", reqInf.StatusCode)
- }
-
- // valid assignment ORG server cachegroup belongs to the topology
- rd, _, err =
TOSession.GetDeliveryServiceByXMLIDNullableWithHdr("ds-top", nil)
- if err != nil {
- t.Fatalf("Failed to fetch DS information: %v", err)
- } else if len(rd) == 0 {
- t.Fatalf("Failed to fetch DS information: No results returned!")
- }
- firstDS = rd[0]
- if firstDS.ID == nil {
- t.Fatal("Fetch DS information returned unknown ID")
- }
-
- alerts, reqInf, err =
TOSession.AssignDeliveryServiceIDsToServerID(*origin.ID, []int{*firstDS.ID},
true)
- if err != nil {
- t.Errorf("Expected assigning ORG server to topology-based
delivery service where the ORG server belongs to the topology to succeed, but
it didn't! (alerts: %v, err: %v)", alerts, err)
- }
- if reqInf.StatusCode < http.StatusOK || reqInf.StatusCode >=
http.StatusMultipleChoices {
- t.Fatalf("assigning Topology-based delivery service to ORG
server that belongs to the topology - expected: 200-level status code, actual:
%d", reqInf.StatusCode)
- }
-
- response, _, err :=
TOSession.GetServerIDDeliveryServicesWithHdr(*origin.ID, nil)
- if err != nil {
- t.Fatalf("Couldn't get Delivery Services assigned to Server
'%+v': %v", *origin, err)
- }
- var found bool
- for _, ds := range response {
-
- if ds.ID != nil && *ds.ID == *firstDS.ID {
- found = true
- break
- }
- }
-
- if !found {
- t.Errorf(`Valid Server/DS assignment was not created!`)
- }
-}
diff --git a/traffic_ops/testing/api/v4/deliveryserviceservers_test.go
b/traffic_ops/testing/api/v4/deliveryserviceservers_test.go
index fc5e715fd5..119a2af169 100644
--- a/traffic_ops/testing/api/v4/deliveryserviceservers_test.go
+++ b/traffic_ops/testing/api/v4/deliveryserviceservers_test.go
@@ -282,59 +282,6 @@ func TestDeliveryServicesIDServers(t *testing.T) {
})
}
-func TestServersIDDeliveryServices(t *testing.T) {
- WithObjs(t, []TCObj{CDNs, Types, Tenants, Parameters, Profiles,
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies,
ServiceCategories, DeliveryServices, DeliveryServiceServerAssignments}, func() {
- serversIDDSTests := utils.V4TestCase{
- "POST": {
- "BAD REQUEST when REMOVING ONLY EDGE SERVER
ASSIGNMENT": {
- ClientSession: TOSession, RequestBody:
map[string]interface{}{
- "server": GetServerID(t,
"test-mso-org-01")(),
- "dsIds":
[]int{GetDeliveryServiceId(t, "test-ds-server-assignments")()},
- "replace": true,
- },
- Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusConflict)),
- },
- "BAD REQUEST when REMOVING ONLY ORIGIN SERVER
ASSIGNMENT": {
- ClientSession: TOSession, RequestBody:
map[string]interface{}{
- "server": GetServerID(t,
"test-ds-server-assignments")(),
- "dsIds":
[]int{GetDeliveryServiceId(t, "test-ds-server-assignments")()},
- "replace": true,
- },
- Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusConflict)),
- },
- },
- }
- for method, testCases := range serversIDDSTests {
- t.Run(method, func(t *testing.T) {
- for name, testCase := range testCases {
-
- var server int
- var replace bool
-
- if testCase.RequestBody != nil {
- if val, ok :=
testCase.RequestBody["server"]; ok {
- server = val.(int)
- }
- if val, ok :=
testCase.RequestBody["replace"]; ok {
- replace = val.(bool)
- }
- }
-
- switch method {
- case "POST":
- t.Run(name, func(t *testing.T) {
- resp, reqInf, err :=
testCase.ClientSession.AssignDeliveryServiceIDsToServerID(server, []int{},
replace, testCase.RequestOpts)
- for _, check := range
testCase.Expectations {
- check(t,
reqInf, nil, resp, err)
- }
- })
- }
- }
- })
- }
- })
-}
-
func TestDeliveryServicesDSIDServerID(t *testing.T) {
WithObjs(t, []TCObj{CDNs, Types, Tenants, Parameters, Profiles,
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies,
ServiceCategories, DeliveryServices, DeliveryServiceServerAssignments}, func() {
dssDSIDServerIDTests := utils.V4TestCase{
diff --git a/traffic_ops/testing/api/v4/servers_id_deliveryservices_test.go
b/traffic_ops/testing/api/v4/servers_id_deliveryservices_test.go
new file mode 100644
index 0000000000..4e159cc17e
--- /dev/null
+++ b/traffic_ops/testing/api/v4/servers_id_deliveryservices_test.go
@@ -0,0 +1,180 @@
+package v4
+
+/*
+ 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 (
+ "net/http"
+ "testing"
+ "time"
+
+ "github.com/apache/trafficcontrol/lib/go-rfc"
+ "github.com/apache/trafficcontrol/lib/go-tc"
+ "github.com/apache/trafficcontrol/traffic_ops/testing/api/assert"
+ "github.com/apache/trafficcontrol/traffic_ops/testing/api/utils"
+ "github.com/apache/trafficcontrol/traffic_ops/toclientlib"
+ client "github.com/apache/trafficcontrol/traffic_ops/v4-client"
+)
+
+func TestServersIDDeliveryServices(t *testing.T) {
+ WithObjs(t, []TCObj{CDNs, Types, Parameters, Profiles, Statuses,
Divisions, Regions, PhysLocations, CacheGroups, Servers, Tenants, Topologies,
ServiceCategories, DeliveryServices, DeliveryServiceServerAssignments}, func() {
+
+ currentTime := time.Now().UTC().Add(-15 * time.Second)
+ tomorrow := currentTime.AddDate(0, 0, 1).Format(time.RFC1123)
+
+ methodTests := utils.V4TestCase{
+ "GET": {
+ "NOT MODIFIED when NO CHANGES made": {
+ EndpointId: GetServerID(t,
"atlanta-edge-14"),
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{Header: http.Header{rfc.IfModifiedSince: {tomorrow}}},
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusNotModified)),
+ },
+ "OK when VALID request": {
+ EndpointId: GetServerID(t,
"atlanta-edge-14"),
+ ClientSession: TOSession,
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+ },
+ },
+ "POST": {
+ "OK when VALID request": {
+ EndpointId: GetServerID(t,
"atlanta-edge-01"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds":
[]int{GetDeliveryServiceId(t, "ds1")()},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
+
validateServersDeliveryServicesPost(GetServerID(t, "atlanta-edge-01")(),
GetDeliveryServiceId(t, "ds1")())),
+ },
+ "OK when ASSIGNING EDGE to TOPOLOGY BASED
DELIVERY SERVICE": {
+ EndpointId: GetServerID(t,
"atlanta-edge-03"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds":
[]int{GetDeliveryServiceId(t, "top-ds-in-cdn1")()},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
+
validateServersDeliveryServicesPost(GetServerID(t, "atlanta-edge-03")(),
GetDeliveryServiceId(t, "top-ds-in-cdn1")())),
+ },
+ "OK when ASSIGNING ORIGIN to TOPOLOGY BASED
DELIVERY SERVICE": {
+ EndpointId: GetServerID(t,
"denver-mso-org-01"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds":
[]int{GetDeliveryServiceId(t, "ds-top")()},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
+
validateServersDeliveryServicesPost(GetServerID(t, "denver-mso-org-01")(),
GetDeliveryServiceId(t, "ds-top")())),
+ },
+ "CONFLICT when SERVER NOT IN SAME CDN as
DELIVERY SERVICE": {
+ EndpointId: GetServerID(t,
"cdn2-test-edge"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds":
[]int{GetDeliveryServiceId(t, "ds1")()},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusConflict)),
+ },
+ "BAD REQUEST when ORIGIN'S CACHEGROUP IS NOT A
PART OF TOPOLOGY BASED DELIVERY SERVICE": {
+ EndpointId: GetServerID(t,
"denver-mso-org-01"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds":
[]int{GetDeliveryServiceId(t, "ds-top-req-cap")()},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+ },
+ "CONFLICT when REMOVING ONLY EDGE SERVER
ASSIGNMENT": {
+ EndpointId: GetServerID(t,
"test-ds-server-assignments"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds": []int{},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusConflict)),
+ },
+ "CONFLICT when REMOVING ONLY ORIGIN SERVER
ASSIGNMENT": {
+ EndpointId: GetServerID(t,
"test-mso-org-01"),
+ ClientSession: TOSession,
+ RequestBody: map[string]interface{}{
+ "dsIds": []int{},
+ "replace": true,
+ },
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusConflict)),
+ },
+ },
+ }
+
+ for method, testCases := range methodTests {
+ t.Run(method, func(t *testing.T) {
+ for name, testCase := range testCases {
+
+ var dsIds []int
+ var replace bool
+
+ if testCase.RequestBody != nil {
+ if val, ok :=
testCase.RequestBody["dsIds"]; ok {
+ dsIds = val.([]int)
+ }
+ if val, ok :=
testCase.RequestBody["replace"]; ok {
+ replace = val.(bool)
+ }
+ }
+
+ switch method {
+ case "GET":
+ t.Run(name, func(t *testing.T) {
+ resp, reqInf, err :=
testCase.ClientSession.GetServerIDDeliveryServices(testCase.EndpointId(),
testCase.RequestOpts)
+ for _, check := range
testCase.Expectations {
+ check(t,
reqInf, resp.Response, resp.Alerts, err)
+ }
+ })
+ case "POST":
+ t.Run(name, func(t *testing.T) {
+ alerts, reqInf, err :=
testCase.ClientSession.AssignDeliveryServiceIDsToServerID(testCase.EndpointId(),
dsIds, replace, testCase.RequestOpts)
+ for _, check := range
testCase.Expectations {
+ check(t,
reqInf, nil, alerts, err)
+ }
+ })
+ }
+ }
+ })
+ }
+ })
+}
+
+func validateServersDeliveryServices(expectedDSID int) utils.CkReqFunc {
+ return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _
tc.Alerts, _ error) {
+ assert.RequireNotNil(t, resp, "Expected Server Delivery Service
response to not be nil.")
+ var found bool
+ deliveryServices := resp.([]tc.DeliveryServiceV40)
+ for _, ds := range deliveryServices {
+ if ds.ID != nil && *ds.ID == expectedDSID {
+ found = true
+ break
+ }
+ }
+ assert.Equal(t, true, found, "Expected to find Delivery Service
ID: %d in response.")
+ }
+}
+
+func validateServersDeliveryServicesPost(serverID int, expectedDSID int)
utils.CkReqFunc {
+ return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _
tc.Alerts, _ error) {
+ serverDeliveryServices, _, err :=
TOSession.GetServerIDDeliveryServices(serverID, client.RequestOptions{})
+ assert.RequireNoError(t, err, "Error getting Server Delivery
Services: %v - alerts: %+v", err, serverDeliveryServices.Alerts)
+ assert.RequireEqual(t, 1, len(serverDeliveryServices.Response),
"Expected one Delivery Service returned Got: %d",
len(serverDeliveryServices.Response))
+ validateServersDeliveryServices(expectedDSID)(t,
toclientlib.ReqInf{}, serverDeliveryServices.Response, tc.Alerts{}, nil)
+ }
+}
diff --git
a/traffic_ops/testing/api/v4/servers_to_deliveryservice_assignment_test.go
b/traffic_ops/testing/api/v4/servers_to_deliveryservice_assignment_test.go
deleted file mode 100644
index 30330b6ac0..0000000000
--- a/traffic_ops/testing/api/v4/servers_to_deliveryservice_assignment_test.go
+++ /dev/null
@@ -1,320 +0,0 @@
-package v4
-
-/*
- 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 (
- "net/http"
- "testing"
- "time"
-
- "github.com/apache/trafficcontrol/lib/go-rfc"
- "github.com/apache/trafficcontrol/lib/go-tc"
- client "github.com/apache/trafficcontrol/traffic_ops/v4-client"
-)
-
-func TestAssignments(t *testing.T) {
- WithObjs(t, []TCObj{CDNs, Types, Parameters, Profiles, Statuses,
Divisions, Regions, PhysLocations, CacheGroups, Servers, Tenants, Topologies,
ServiceCategories, DeliveryServices}, func() {
- AssignTestDeliveryService(t)
- AssignIncorrectTestDeliveryService(t)
- AssignTopologyBasedDeliveryService(t)
- OriginAssignTopologyBasedDeliveryService(t)
- })
-}
-
-func AssignTestDeliveryService(t *testing.T) {
- if len(testData.Servers) < 1 || len(testData.DeliveryServices) < 1 {
- t.Fatal("Need at least one test server and one Delivery Service
to test Delivery Service assignment")
- }
-
- server := testData.Servers[0]
- if server.HostName == nil {
- t.Fatalf("First server had nil hostname: %+v", server)
- }
-
- opts := client.NewRequestOptions()
- opts.QueryParameters.Add("hostName", *server.HostName)
- rs, _, err := TOSession.GetServers(opts)
- if err != nil {
- t.Fatalf("Failed to fetch server information: %v - alerts:
%+v", err, rs.Alerts)
- } else if len(rs.Response) == 0 {
- t.Fatalf("Failed to fetch server information: No results
returned!")
- }
- firstServer := rs.Response[0]
- if firstServer.ID == nil {
- t.Fatalf("Server '%s' had nil ID", *server.HostName)
- }
-
- if testData.DeliveryServices[0].XMLID == nil {
- t.Fatal("Found Delivery Service in testing data with null or
undefined XMLID")
- }
-
- opts.QueryParameters.Del("hostName")
- opts.QueryParameters.Set("xmlId", *testData.DeliveryServices[0].XMLID)
- rd, _, err := TOSession.GetDeliveryServices(opts)
- if err != nil {
- t.Fatalf("Failed to fetch DS information: %v - alerts: %+v",
err, rd.Alerts)
- } else if len(rd.Response) == 0 {
- t.Fatalf("Failed to fetch DS information: No results returned!")
- }
- firstDS := rd.Response[0]
-
- if firstDS.ID == nil {
- t.Fatal("Fetch DS information returned unknown ID")
- }
- alerts, _, err :=
TOSession.AssignDeliveryServiceIDsToServerID(*firstServer.ID,
[]int{*firstDS.ID}, false, client.RequestOptions{})
- if err != nil {
- t.Errorf("Couldn't assign DS '%+v' to server '%+v': %v -
alerts: %+v", firstDS, firstServer, err, alerts.Alerts)
- }
-
- response, _, err :=
TOSession.GetServerIDDeliveryServices(*firstServer.ID, client.RequestOptions{})
- if err != nil {
- t.Fatalf("Couldn't get Delivery Services assigned to Server
'%+v': %v - alerts: %+v", firstServer, err, response.Alerts)
- }
-
- var found bool
- for _, ds := range response.Response {
- if ds.ID != nil && *ds.ID == *firstDS.ID {
- found = true
- break
- }
- }
-
- if !found {
- t.Error(`Server/DS assignment not found after "successful"
assignment!`)
- }
-
- currentTime := time.Now().UTC().Add(5 * time.Second)
- time := currentTime.Format(time.RFC1123)
-
- opts.Header.Set(rfc.IfModifiedSince, time)
- opts.QueryParameters.Del("xmlId")
- _, reqInf, _ := TOSession.GetServerIDDeliveryServices(*firstServer.ID,
opts)
- if reqInf.StatusCode != http.StatusNotModified {
- t.Errorf("Expected a status code of 304, got %d",
reqInf.StatusCode)
- }
-}
-
-func AssignIncorrectTestDeliveryService(t *testing.T) {
- var server *tc.ServerV4
- for _, s := range testData.Servers {
- if s.CDNName != nil && *s.CDNName == "cdn2" {
- server = &s
- break
- }
- }
- if server == nil {
- t.Fatal("Couldn't find a server in CDN 'cdn2'!")
- }
- if server.HostName == nil {
- t.Fatalf("Server found with nil hostname: %+v", *server)
- }
- hostname := *server.HostName
-
- opts := client.NewRequestOptions()
- opts.QueryParameters.Add("hostName", hostname)
- rs, _, err := TOSession.GetServers(opts)
- if err != nil {
- t.Fatalf("Failed to fetch server information: %v - alerts:
%+v", err, rs.Alerts)
- } else if len(rs.Response) == 0 {
- t.Fatal("Failed to fetch server information: No results
returned!")
- }
- server = &rs.Response[0]
- if server.ID == nil {
- t.Fatalf("Server '%s' has nil ID", hostname)
- }
-
- if len(testData.DeliveryServices) < 1 {
- t.Fatal("Need at least one Delivery Service to test assignment
of servers to Delivery Services")
- }
- if testData.DeliveryServices[0].XMLID == nil {
- t.Fatal("Delivery Service selected for testing had null or
undefined XMLID")
- }
-
- opts = client.NewRequestOptions()
- opts.QueryParameters.Set("xmlId", *testData.DeliveryServices[0].XMLID)
- rd, _, err := TOSession.GetDeliveryServices(opts)
- if err != nil {
- t.Fatalf("Failed to fetch DS information: %v - alerts: %+v",
err, rd.Alerts)
- } else if len(rd.Response) == 0 {
- t.Fatalf("Failed to fetch DS information: No results returned!")
- }
- firstDS := rd.Response[0]
-
- if firstDS.ID == nil {
- t.Fatal("Fetch DS information returned unknown ID")
- }
- alerts, _, err :=
TOSession.AssignDeliveryServiceIDsToServerID(*server.ID, []int{*firstDS.ID},
false, client.RequestOptions{})
- if err == nil {
- t.Errorf("Expected bad assignment to fail, but it didn't:
alerts: %v", alerts.Alerts)
- }
-
- response, _, err := TOSession.GetServerIDDeliveryServices(*server.ID,
client.RequestOptions{})
- if err != nil {
- t.Fatalf("Couldn't get Delivery Services assigned to Server
'%+v': %v - alerts: %+v", *server, err, response.Alerts)
- }
-
- var found bool
- for _, ds := range response.Response {
-
- if ds.ID != nil && *ds.ID == *firstDS.ID {
- found = true
- break
- }
- }
-
- if found {
- t.Errorf(`Invalid Server/DS assignment was created!`)
- }
-}
-
-func AssignTopologyBasedDeliveryService(t *testing.T) {
- var server *tc.ServerV4
- for _, s := range testData.Servers {
- if s.CDNName != nil && *s.CDNName == "cdn1" && s.Type ==
string(tc.CacheTypeEdge) {
- server = &s
- break
- }
- }
- if server == nil || server.HostName == nil {
- t.Fatalf("Couldn't find an EDGE server in CDN 'cdn1' with a
non-nil Host Name")
- }
-
- opts := client.NewRequestOptions()
- opts.QueryParameters.Add("hostName", *server.HostName)
- rs, _, err := TOSession.GetServers(opts)
- if err != nil {
- t.Fatalf("Failed to fetch server information: %v - alerts:
%+v", err, rs.Alerts)
- } else if len(rs.Response) == 0 {
- t.Fatalf("Failed to fetch server information: No results
returned!")
- }
- server = &rs.Response[0]
- if server.ID == nil {
- t.Fatal("Server had nil ID")
- }
-
- opts.QueryParameters.Del("hostName")
- opts.QueryParameters.Set("xmlId", "ds-top")
- rd, _, err := TOSession.GetDeliveryServices(opts)
- if err != nil {
- t.Fatalf("Failed to fetch DS information: %v - alerts: %+v",
err, rd.Alerts)
- } else if len(rd.Response) == 0 {
- t.Fatalf("Failed to fetch DS information: No results returned!")
- }
- firstDS := rd.Response[0]
-
- if firstDS.ID == nil {
- t.Fatal("Fetch DS information returned unknown ID")
- }
- alerts, reqInf, err :=
TOSession.AssignDeliveryServiceIDsToServerID(*server.ID, []int{*firstDS.ID},
false, client.RequestOptions{})
- if err != nil {
- t.Errorf("Expected assignment to succeed, but it didn't!
(alerts: %v)", alerts)
- }
- if reqInf.StatusCode >= http.StatusBadRequest {
- t.Fatalf("assigning Topology-based delivery service to server -
expected: non-error status code, actual: %d", reqInf.StatusCode)
- }
-
- response, _, err := TOSession.GetServerIDDeliveryServices(*server.ID,
client.RequestOptions{})
- if err != nil {
- t.Fatalf("Couldn't get Delivery Services assigned to Server
'%+v': %v - alerts: %+v", *server, err, response.Alerts)
- }
-
- var found bool
- for _, ds := range response.Response {
-
- if ds.ID != nil && *ds.ID == *firstDS.ID {
- found = true
- break
- }
- }
-
- if !found {
- t.Error(`Valid Server/DS assignment was not created!`)
- }
-}
-
-func OriginAssignTopologyBasedDeliveryService(t *testing.T) {
- opts := client.NewRequestOptions()
- opts.QueryParameters.Add("hostName", "denver-mso-org-01")
- rs, _, err := TOSession.GetServers(opts)
- if err != nil {
- t.Fatalf("Failed to fetch server information: %v - alerts:
%+v", err, rs.Alerts)
- } else if len(rs.Response) == 0 {
- t.Fatalf("Failed to fetch server information: No results
returned!")
- }
- origin := &rs.Response[0]
- if origin.ID == nil {
- t.Fatal("Server had nil ID")
- }
-
- opts.QueryParameters.Del("hostName")
- opts.QueryParameters.Set("xmlId", "ds-top-req-cap")
- rd, _, err := TOSession.GetDeliveryServices(opts)
- if err != nil {
- t.Fatalf("Failed to fetch DS information: %v - alerts: %+v",
err, rd.Alerts)
- } else if len(rd.Response) == 0 {
- t.Fatalf("Failed to fetch DS information: No results returned!")
- }
- firstDS := rd.Response[0]
- if firstDS.ID == nil {
- t.Fatal("Fetch DS information returned unknown ID")
- }
-
- // invalid assignment: ORG server cachegroup does not belong to the
topology
- alerts, reqInf, err :=
TOSession.AssignDeliveryServiceIDsToServerID(*origin.ID, []int{*firstDS.ID},
true, client.RequestOptions{})
- if err == nil {
- t.Errorf("Expected assigning ORG server to topology-based
delivery service where the ORG server does not belong to the topology to fail,
but it didn't: alerts: %+v", alerts.Alerts)
- }
- if reqInf.StatusCode < http.StatusBadRequest || reqInf.StatusCode >=
http.StatusInternalServerError {
- t.Fatalf("assigning Topology-based delivery service to ORG
server that does not belong to the topology - expected: 400-level status code,
actual: %d", reqInf.StatusCode)
- }
-
- // valid assignment ORG server cachegroup belongs to the topology
- opts.QueryParameters.Set("xmlId", "ds-top")
- rd, _, err = TOSession.GetDeliveryServices(opts)
- if err != nil {
- t.Fatalf("Failed to fetch DS information: %v - alerts: %+v",
err, rd.Alerts)
- } else if len(rd.Response) == 0 {
- t.Fatalf("Failed to fetch DS information: No results returned!")
- }
- firstDS = rd.Response[0]
- if firstDS.ID == nil {
- t.Fatal("Fetch DS information returned unknown ID")
- }
-
- alerts, reqInf, err =
TOSession.AssignDeliveryServiceIDsToServerID(*origin.ID, []int{*firstDS.ID},
true, opts)
- if err != nil {
- t.Errorf("Expected assigning ORG server to topology-based
delivery service where the ORG server belongs to the topology to succeed, but
it didn't! (alerts: %v, err: %v)", alerts, err)
- }
- if reqInf.StatusCode < http.StatusOK || reqInf.StatusCode >=
http.StatusMultipleChoices {
- t.Fatalf("assigning Topology-based delivery service to ORG
server that belongs to the topology - expected: 200-level status code, actual:
%d", reqInf.StatusCode)
- }
-
- response, _, err := TOSession.GetServerIDDeliveryServices(*origin.ID,
client.RequestOptions{})
- if err != nil {
- t.Fatalf("Couldn't get Delivery Services assigned to Server
'%+v': %v", *origin, err)
- }
- var found bool
- for _, ds := range response.Response {
-
- if ds.ID != nil && *ds.ID == *firstDS.ID {
- found = true
- break
- }
- }
-
- if !found {
- t.Errorf(`Valid Server/DS assignment was not created!`)
- }
-}