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 dc65c10222 Refactor topologies queue update tests (#6979)
dc65c10222 is described below

commit dc65c10222b9acbee23556cf4212e4815df49ac2
Author: Eric Holguin <[email protected]>
AuthorDate: Wed Jul 27 13:15:37 2022 -0600

    Refactor topologies queue update tests (#6979)
---
 .../testing/api/v3/topologies_queue_update_test.go | 195 +++++++++++---------
 .../testing/api/v4/topologies_queue_update_test.go | 200 +++++++++++----------
 2 files changed, 211 insertions(+), 184 deletions(-)

diff --git a/traffic_ops/testing/api/v3/topologies_queue_update_test.go 
b/traffic_ops/testing/api/v3/topologies_queue_update_test.go
index 7287d16cc8..68f8487c52 100644
--- a/traffic_ops/testing/api/v3/topologies_queue_update_test.go
+++ b/traffic_ops/testing/api/v3/topologies_queue_update_test.go
@@ -20,112 +20,129 @@ package v3
  */
 
 import (
+       "encoding/json"
        "net/http"
        "net/url"
        "strconv"
        "testing"
 
        "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"
 )
 
-type topologiesQueueUpdateTestCase struct {
-       Description string
-       tc.TopologiesQueueUpdateRequest
-}
-
 func TestTopologiesQueueUpdate(t *testing.T) {
-       WithObjs(t, []TCObj{CDNs, Types, Tenants, Users, Parameters, Profiles, 
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies, 
DeliveryServices}, func() {
-               const topologyName = "mso-topology"
-               cdnId, dsId := getCdnIdAndDsId(t)
-               InvalidCDNIDIsRejected(t, topologyName)
-               InvalidActionIsRejected(t, topologyName, cdnId)
-               NonexistentTopologyIsRejected(t, cdnId)
-               UpdatesAreQueued(t, topologyName, cdnId, dsId)
-       })
-}
+       WithObjs(t, []TCObj{CDNs, Types, Tenants, Users, Parameters, Profiles, 
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies, 
ServiceCategories, DeliveryServices}, func() {
 
-func getCdnIdAndDsId(t *testing.T) (int64, int) {
-       xmlId := "ds-top"
-       params := url.Values{}
-       params.Set("xmlId", xmlId)
-       dses, _, err := TOSession.GetDeliveryServicesV30WithHdr(nil, params)
-       if err != nil {
-               t.Fatalf("unable to get deliveryservice %s: %s", xmlId, err)
-       }
-       if len(dses) < 1 {
-               t.Fatalf("deliveryservice with xmlId %s not found!", xmlId)
-       }
-       ds := dses[0]
-       return int64(*ds.CDNID), *ds.ID
-}
+               methodTests := utils.V3TestCase{
+                       "POST": {
+                               "OK when VALID REQUEST": {
+                                       ClientSession: TOSession,
+                                       RequestParams: url.Values{"name": 
{"mso-topology"}},
+                                       RequestBody: map[string]interface{}{
+                                               "action": "queue",
+                                               "cdnId":  GetCDNID(t, "cdn1")(),
+                                       },
+                                       Expectations: 
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
+                                               
validateTopologiesQueueUpdateFields(map[string]interface{}{"Action": "queue", 
"CDNID": int64(GetCDNID(t, "cdn1")()), "Topology": 
tc.TopologyName("mso-topology")}),
+                                               
validateServerUpdatesAreQueued("ds-top")),
+                               },
+                               "BAD REQUEST when INVALID CDNID": {
+                                       ClientSession: TOSession,
+                                       RequestParams: url.Values{"name": 
{"mso-topology"}},
+                                       RequestBody: map[string]interface{}{
+                                               "action": "queue",
+                                               "cdnId":  -1,
+                                       },
+                                       Expectations: 
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+                               },
+                               "BAD REQUEST when INVALID ACTION": {
+                                       ClientSession: TOSession,
+                                       RequestParams: url.Values{"name": 
{"mso-topology"}},
+                                       RequestBody: map[string]interface{}{
+                                               "action": "requeue",
+                                               "cdnId":  GetCDNID(t, "cdn1")(),
+                                       },
+                                       Expectations: 
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+                               },
+                               "BAD REQUEST when TOPOLOGY DOESNT EXIST": {
+                                       ClientSession: TOSession,
+                                       RequestParams: url.Values{"name": 
{"nonexistent"}},
+                                       RequestBody: map[string]interface{}{
+                                               "action": "queue",
+                                               "cdnId":  GetCDNID(t, "cdn1")(),
+                                       },
+                                       Expectations: 
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+                               },
+                       },
+               }
 
-func InvalidCDNIDIsRejected(t *testing.T, topologyName tc.TopologyName) {
-       testCase := topologiesQueueUpdateTestCase{
-               Description:                  "invalid CDN ID",
-               TopologiesQueueUpdateRequest: 
tc.TopologiesQueueUpdateRequest{Action: "queue", CDNID: -1},
-       }
-       _, reqInf, _ := TOSession.TopologiesQueueUpdate(topologyName, 
testCase.TopologiesQueueUpdateRequest)
-       if reqInf.StatusCode != http.StatusBadRequest {
-               t.Fatalf("expected status code %d for request with %s, got 
status code %d", http.StatusBadRequest, testCase.Description, reqInf.StatusCode)
-       }
-}
+               for method, testCases := range methodTests {
+                       t.Run(method, func(t *testing.T) {
+                               for name, testCase := range testCases {
+                                       topQueueUpdate := 
tc.TopologiesQueueUpdateRequest{}
 
-func InvalidActionIsRejected(t *testing.T, topologyName tc.TopologyName, cdnId 
int64) {
-       testCase := topologiesQueueUpdateTestCase{
-               Description:                  "invalid update action",
-               TopologiesQueueUpdateRequest: 
tc.TopologiesQueueUpdateRequest{Action: "requeue", CDNID: cdnId},
-       }
-       _, reqInf, _ := TOSession.TopologiesQueueUpdate(topologyName, 
testCase.TopologiesQueueUpdateRequest)
-       if reqInf.StatusCode != http.StatusBadRequest {
-               t.Fatalf("expected status code %d for request with %s, got 
status code %d", http.StatusBadRequest, testCase.Description, reqInf.StatusCode)
-       }
+                                       if testCase.RequestBody != nil {
+                                               dat, err := 
json.Marshal(testCase.RequestBody)
+                                               assert.NoError(t, err, "Error 
occurred when marshalling request body: %v", err)
+                                               err = json.Unmarshal(dat, 
&topQueueUpdate)
+                                               assert.NoError(t, err, "Error 
occurred when unmarshalling request body: %v", err)
+                                       }
+
+                                       switch method {
+                                       case "POST":
+                                               t.Run(name, func(t *testing.T) {
+                                                       resp, reqInf, err := 
testCase.ClientSession.TopologiesQueueUpdate(tc.TopologyName(testCase.RequestParams["name"][0]),
 topQueueUpdate)
+                                                       for _, check := range 
testCase.Expectations {
+                                                               check(t, 
reqInf, resp.TopologiesQueueUpdate, resp.Alerts, err)
+                                                       }
+                                               })
+                                       }
+                               }
+                       })
+               }
+
+       })
 }
 
-func NonexistentTopologyIsRejected(t *testing.T, cdnId int64) {
-       const topologyName = "nonexistent"
-       testCase := topologiesQueueUpdateTestCase{
-               Description:                  "nonexistent topology",
-               TopologiesQueueUpdateRequest: 
tc.TopologiesQueueUpdateRequest{Action: "queue", CDNID: cdnId},
-       }
-       _, reqInf, _ := TOSession.TopologiesQueueUpdate(topologyName, 
testCase.TopologiesQueueUpdateRequest)
-       if reqInf.StatusCode != http.StatusBadRequest {
-               t.Fatalf("expected status code %d for request with %s, got 
status code %d", http.StatusBadRequest, testCase.Description, reqInf.StatusCode)
+func validateTopologiesQueueUpdateFields(expectedResp map[string]interface{}) 
utils.CkReqFunc {
+       return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ 
tc.Alerts, _ error) {
+               assert.RequireNotNil(t, resp, "Expected Topologies Queue Update 
response to not be nil.")
+               topQueueUpdateResp := resp.(tc.TopologiesQueueUpdate)
+               for field, expected := range expectedResp {
+                       switch field {
+                       case "Action":
+                               assert.Equal(t, expected, 
topQueueUpdateResp.Action, "Expected Action to be %v, but got %s", expected, 
topQueueUpdateResp.Action)
+                       case "CDNID":
+                               assert.Equal(t, expected, 
topQueueUpdateResp.CDNID, "Expected CDNID to be %v, but got %d", expected, 
topQueueUpdateResp.CDNID)
+                       case "Topology":
+                               assert.Equal(t, expected, 
topQueueUpdateResp.Topology, "Expected Topology to be %v, but got %s", 
expected, topQueueUpdateResp.Topology)
+                       default:
+                               t.Errorf("Expected field: %v, does not exist in 
response", field)
+                       }
+               }
        }
 }
 
-func UpdatesAreQueued(t *testing.T, topologyName tc.TopologyName, cdnId int64, 
dsId int) {
-       const action = "queue"
-       testCase := topologiesQueueUpdateTestCase{
-               Description:                  "invalid update action",
-               TopologiesQueueUpdateRequest: 
tc.TopologiesQueueUpdateRequest{Action: action, CDNID: cdnId},
-       }
-       resp, _, err := TOSession.TopologiesQueueUpdate(topologyName, 
testCase.TopologiesQueueUpdateRequest)
-       if err != nil {
-               t.Fatalf("received error queueing server updates on topology 
%s: %s", topologyName, err)
-       }
-       if resp.Action != action {
-               t.Fatalf("expected action %s, received action %s", action, 
resp.Action)
-       }
-       if resp.CDNID != cdnId {
-               t.Fatalf("expected CDN ID %d, received CDN ID %d", cdnId, 
resp.CDNID)
-       }
-       if topologyName != resp.Topology {
-               t.Fatalf("expected topology %s, received topology %s", 
topologyName, resp.Topology)
-       }
-       params := url.Values{}
-       dsIdString := strconv.Itoa(dsId)
-       params.Set("dsId", dsIdString)
-       serversResponse, _, err := TOSession.GetServersWithHdr(&params, nil)
-       if err != nil {
-               t.Fatalf("getting servers for delivery service with id %s: %s", 
dsIdString, err)
-       }
-       servers := serversResponse.Response
-       for _, server := range servers {
-               if *server.CDNID != int(cdnId) {
-                       continue
-               }
-               if !*server.UpdPending {
-                       t.Fatalf("expected UpdPending = %t for server with 
hostname %s, got UpdPending = %t", true, *server.HostName, *server.UpdPending)
+func validateServerUpdatesAreQueued(topologyDS string) utils.CkReqFunc {
+       return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ 
tc.Alerts, _ error) {
+               assert.RequireNotNil(t, resp, "Expected Topologies Queue Update 
response to not be nil.")
+               topQueueUpdateResp := resp.(tc.TopologiesQueueUpdate)
+
+               params := url.Values{}
+               params.Set("dsId", strconv.Itoa(GetDeliveryServiceId(t, 
topologyDS)()))
+               serversResponse, _, err := TOSession.GetServersWithHdr(&params, 
nil)
+               assert.RequireNoError(t, err, "Expected no error when getting 
servers: %v", err)
+
+               for _, server := range serversResponse.Response {
+                       assert.RequireNotNil(t, server.CDNID, "Expected Server 
CDNID to not be nil.")
+                       assert.RequireNotNil(t, server.HostName, "Expected 
Server HostName to not be nil.")
+                       assert.RequireNotNil(t, server.UpdPending, "Expected 
Server UpdPending to not be nil.")
+                       if *server.CDNID != int(topQueueUpdateResp.CDNID) {
+                               continue
+                       }
+                       assert.Equal(t, true, *server.UpdPending, "Expected 
Server %s Update Pending flag to be set to true.", *server.HostName)
                }
        }
 }
diff --git a/traffic_ops/testing/api/v4/topologies_queue_update_test.go 
b/traffic_ops/testing/api/v4/topologies_queue_update_test.go
index e6cdcefaa8..b40ae71406 100644
--- a/traffic_ops/testing/api/v4/topologies_queue_update_test.go
+++ b/traffic_ops/testing/api/v4/topologies_queue_update_test.go
@@ -20,120 +20,130 @@ package v4
  */
 
 import (
+       "encoding/json"
        "net/http"
+       "net/url"
        "strconv"
        "testing"
 
        "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"
 )
 
-type topologiesQueueUpdateTestCase struct {
-       Description string
-       tc.TopologiesQueueUpdateRequest
-}
-
 func TestTopologiesQueueUpdate(t *testing.T) {
        WithObjs(t, []TCObj{CDNs, Types, Tenants, Users, Parameters, Profiles, 
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies, 
ServiceCategories, DeliveryServices}, func() {
-               const topologyName = "mso-topology"
-               cdnID, dsID := getCDNIDAndDSID(t)
-               InvalidCDNIDIsRejected(t, topologyName)
-               InvalidActionIsRejected(t, topologyName, cdnID)
-               NonexistentTopologyIsRejected(t, cdnID)
-               UpdatesAreQueued(t, topologyName, cdnID, dsID)
-       })
-}
 
-func getCDNIDAndDSID(t *testing.T) (int64, int) {
-       xmlID := "ds-top"
-       opts := client.NewRequestOptions()
-       opts.QueryParameters.Set("xmlId", xmlID)
-       dses, _, err := TOSession.GetDeliveryServices(opts)
-       if err != nil {
-               t.Fatalf("unable to get Delivery Service '%s': %v - alerts: 
%+v", xmlID, err, dses.Alerts)
-       }
-       if len(dses.Response) < 1 {
-               t.Fatalf("deliveryservice with xmlId '%s' not found!", xmlID)
-       }
-       ds := dses.Response[0]
-       if ds.CDNID == nil || ds.ID == nil {
-               t.Fatalf("Traffic Ops returned a representation of a Delivery 
Service that had null or undefined CDN ID and/or ID")
-       }
-       return int64(*ds.CDNID), *ds.ID
-}
+               methodTests := utils.V4TestCase{
+                       "POST": {
+                               "OK when VALID REQUEST": {
+                                       ClientSession: TOSession,
+                                       RequestOpts:   
client.RequestOptions{QueryParameters: url.Values{"name": {"mso-topology"}}},
+                                       RequestBody: map[string]interface{}{
+                                               "action": "queue",
+                                               "cdnId":  GetCDNID(t, "cdn1")(),
+                                       },
+                                       Expectations: 
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
+                                               
validateTopologiesQueueUpdateFields(map[string]interface{}{"Action": "queue", 
"CDNID": int64(GetCDNID(t, "cdn1")()), "Topology": 
tc.TopologyName("mso-topology")}),
+                                               
validateServerUpdatesAreQueued("ds-top")),
+                               },
+                               "BAD REQUEST when INVALID CDNID": {
+                                       ClientSession: TOSession,
+                                       RequestOpts:   
client.RequestOptions{QueryParameters: url.Values{"name": {"mso-topology"}}},
+                                       RequestBody: map[string]interface{}{
+                                               "action": "queue",
+                                               "cdnId":  -1,
+                                       },
+                                       Expectations: 
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+                               },
+                               "BAD REQUEST when INVALID ACTION": {
+                                       ClientSession: TOSession,
+                                       RequestOpts:   
client.RequestOptions{QueryParameters: url.Values{"name": {"mso-topology"}}},
+                                       RequestBody: map[string]interface{}{
+                                               "action": "requeue",
+                                               "cdnId":  GetCDNID(t, "cdn1")(),
+                                       },
+                                       Expectations: 
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+                               },
+                               "BAD REQUEST when TOPOLOGY DOESNT EXIST": {
+                                       ClientSession: TOSession,
+                                       RequestOpts:   
client.RequestOptions{QueryParameters: url.Values{"name": {"nonexistent"}}},
+                                       RequestBody: map[string]interface{}{
+                                               "action": "queue",
+                                               "cdnId":  GetCDNID(t, "cdn1")(),
+                                       },
+                                       Expectations: 
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+                               },
+                       },
+               }
 
-func InvalidCDNIDIsRejected(t *testing.T, topologyName string) {
-       testCase := topologiesQueueUpdateTestCase{
-               Description:                  "invalid CDN ID",
-               TopologiesQueueUpdateRequest: 
tc.TopologiesQueueUpdateRequest{Action: "queue", CDNID: -1},
-       }
-       _, reqInf, _ := TOSession.TopologiesQueueUpdate(topologyName, 
testCase.TopologiesQueueUpdateRequest, client.RequestOptions{})
-       if reqInf.StatusCode != http.StatusBadRequest {
-               t.Fatalf("expected status code %d for request with %s, got 
status code %d", http.StatusBadRequest, testCase.Description, reqInf.StatusCode)
-       }
-}
+               for method, testCases := range methodTests {
+                       t.Run(method, func(t *testing.T) {
+                               for name, testCase := range testCases {
+                                       topQueueUpdate := 
tc.TopologiesQueueUpdateRequest{}
 
-func InvalidActionIsRejected(t *testing.T, topologyName string, cdnID int64) {
-       testCase := topologiesQueueUpdateTestCase{
-               Description:                  "invalid update action",
-               TopologiesQueueUpdateRequest: 
tc.TopologiesQueueUpdateRequest{Action: "requeue", CDNID: cdnID},
-       }
-       _, reqInf, _ := TOSession.TopologiesQueueUpdate(topologyName, 
testCase.TopologiesQueueUpdateRequest, client.RequestOptions{})
-       if reqInf.StatusCode != http.StatusBadRequest {
-               t.Fatalf("expected status code %d for request with %s, got 
status code %d", http.StatusBadRequest, testCase.Description, reqInf.StatusCode)
-       }
+                                       if testCase.RequestBody != nil {
+                                               dat, err := 
json.Marshal(testCase.RequestBody)
+                                               assert.NoError(t, err, "Error 
occurred when marshalling request body: %v", err)
+                                               err = json.Unmarshal(dat, 
&topQueueUpdate)
+                                               assert.NoError(t, err, "Error 
occurred when unmarshalling request body: %v", err)
+                                       }
+
+                                       switch method {
+                                       case "POST":
+                                               t.Run(name, func(t *testing.T) {
+                                                       resp, reqInf, err := 
testCase.ClientSession.TopologiesQueueUpdate(testCase.RequestOpts.QueryParameters["name"][0],
 topQueueUpdate, testCase.RequestOpts)
+                                                       for _, check := range 
testCase.Expectations {
+                                                               check(t, 
reqInf, resp.TopologiesQueueUpdate, resp.Alerts, err)
+                                                       }
+                                               })
+                                       }
+                               }
+                       })
+               }
+
+       })
 }
 
-func NonexistentTopologyIsRejected(t *testing.T, cdnID int64) {
-       const topologyName = "nonexistent"
-       testCase := topologiesQueueUpdateTestCase{
-               Description:                  "nonexistent topology",
-               TopologiesQueueUpdateRequest: 
tc.TopologiesQueueUpdateRequest{Action: "queue", CDNID: cdnID},
-       }
-       _, reqInf, _ := TOSession.TopologiesQueueUpdate(topologyName, 
testCase.TopologiesQueueUpdateRequest, client.RequestOptions{})
-       if reqInf.StatusCode != http.StatusBadRequest {
-               t.Fatalf("expected status code %d for request with %s, got 
status code %d", http.StatusBadRequest, testCase.Description, reqInf.StatusCode)
+func validateTopologiesQueueUpdateFields(expectedResp map[string]interface{}) 
utils.CkReqFunc {
+       return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ 
tc.Alerts, _ error) {
+               assert.RequireNotNil(t, resp, "Expected Topologies Queue Update 
response to not be nil.")
+               topQueueUpdateResp := resp.(tc.TopologiesQueueUpdate)
+               for field, expected := range expectedResp {
+                       switch field {
+                       case "Action":
+                               assert.Equal(t, expected, 
topQueueUpdateResp.Action, "Expected Action to be %v, but got %s", expected, 
topQueueUpdateResp.Action)
+                       case "CDNID":
+                               assert.Equal(t, expected, 
topQueueUpdateResp.CDNID, "Expected CDNID to be %v, but got %d", expected, 
topQueueUpdateResp.CDNID)
+                       case "Topology":
+                               assert.Equal(t, expected, 
topQueueUpdateResp.Topology, "Expected Topology to be %v, but got %s", 
expected, topQueueUpdateResp.Topology)
+                       default:
+                               t.Errorf("Expected field: %v, does not exist in 
response", field)
+                       }
+               }
        }
 }
 
-func UpdatesAreQueued(t *testing.T, topologyName string, cdnID int64, dsID 
int) {
-       const action = "queue"
-       testCase := topologiesQueueUpdateTestCase{
-               Description:                  "invalid update action",
-               TopologiesQueueUpdateRequest: 
tc.TopologiesQueueUpdateRequest{Action: action, CDNID: cdnID},
-       }
-       resp, _, err := TOSession.TopologiesQueueUpdate(topologyName, 
testCase.TopologiesQueueUpdateRequest, client.RequestOptions{})
-       if err != nil {
-               t.Fatalf("received error queueing server updates on Topology 
'%s': %v - alerts: %+v", topologyName, err, resp.Alerts)
-       }
-       if resp.Action != action {
-               t.Fatalf("expected action %s, received action %s", action, 
resp.Action)
-       }
-       if resp.CDNID != cdnID {
-               t.Fatalf("expected CDN ID %d, received CDN ID %d", cdnID, 
resp.CDNID)
-       }
-       if topologyName != string(resp.Topology) {
-               t.Fatalf("expected topology %s, received topology %s", 
topologyName, resp.Topology)
-       }
+func validateServerUpdatesAreQueued(topologyDS string) utils.CkReqFunc {
+       return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ 
tc.Alerts, _ error) {
+               assert.RequireNotNil(t, resp, "Expected Topologies Queue Update 
response to not be nil.")
+               topQueueUpdateResp := resp.(tc.TopologiesQueueUpdate)
 
-       opts := client.NewRequestOptions()
-       dsIDString := strconv.Itoa(dsID)
-       opts.QueryParameters.Set("dsId", dsIDString)
-       serversResponse, _, err := TOSession.GetServers(opts)
-       if err != nil {
-               t.Fatalf("getting servers for Delivery Service with id %d: %v - 
alerts: %+v", dsID, err, serversResponse.Alerts)
-       }
-       servers := serversResponse.Response
-       for _, server := range servers {
-               if server.CDNID == nil || server.HostName == nil || 
server.UpdPending == nil {
-                       t.Error("Traffic Ops returned a representation of a 
server with null or undefined CDN ID and/or HostName and/or Update Pending 
flag")
-                       continue
-               }
-               if *server.CDNID != int(cdnID) {
-                       continue
-               }
-               if !*server.UpdPending {
-                       t.Fatalf("expected UpdPending = %t for server with 
hostname %s, got UpdPending = %t", true, *server.HostName, *server.UpdPending)
+               opts := client.NewRequestOptions()
+               opts.QueryParameters.Set("dsId", 
strconv.Itoa(GetDeliveryServiceId(t, topologyDS)()))
+               serversResponse, _, err := TOSession.GetServers(opts)
+               assert.RequireNoError(t, err, "Expected no error when getting 
servers: %v", err)
+
+               for _, server := range serversResponse.Response {
+                       assert.RequireNotNil(t, server.CDNID, "Expected Server 
CDNID to not be nil.")
+                       assert.RequireNotNil(t, server.HostName, "Expected 
Server HostName to not be nil.")
+                       assert.RequireNotNil(t, server.UpdPending, "Expected 
Server UpdPending to not be nil.")
+                       if *server.CDNID != int(topQueueUpdateResp.CDNID) {
+                               continue
+                       }
+                       assert.Equal(t, true, *server.UpdPending, "Expected 
Server %s Update Pending flag to be set to true.", *server.HostName)
                }
        }
 }

Reply via email to