You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by zr...@apache.org on 2022/04/29 16:16:34 UTC

[trafficcontrol] branch master updated: Refactor Delivery Service Requests (#6758)

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 498dad6c98 Refactor Delivery Service Requests (#6758)
498dad6c98 is described below

commit 498dad6c983accbb085ff5f76551d4567097b826
Author: Eric Holguin <14...@users.noreply.github.com>
AuthorDate: Fri Apr 29 10:16:28 2022 -0600

    Refactor Delivery Service Requests (#6758)
    
    * Updated prereqs for ds requests tests
    
    * Refactor tests
    
    * all fields start on newline
    
    * Added assert
    
    * Readd resetDS functionality
---
 .../api/v3/deliveryservice_requests_test.go        | 625 +++++++-------
 traffic_ops/testing/api/v3/tc-fixtures.json        |  49 +-
 .../api/v4/deliveryservice_requests_test.go        | 925 +++++++--------------
 traffic_ops/testing/api/v4/tc-fixtures.json        |  64 +-
 4 files changed, 615 insertions(+), 1048 deletions(-)

diff --git a/traffic_ops/testing/api/v3/deliveryservice_requests_test.go b/traffic_ops/testing/api/v3/deliveryservice_requests_test.go
index 11cc733ee4..df323a44a4 100644
--- a/traffic_ops/testing/api/v3/deliveryservice_requests_test.go
+++ b/traffic_ops/testing/api/v3/deliveryservice_requests_test.go
@@ -16,366 +16,327 @@ package v3
 */
 
 import (
+	"encoding/json"
 	"net/http"
+	"net/url"
 	"strings"
 	"testing"
 	"time"
 
 	"github.com/apache/trafficcontrol/lib/go-rfc"
-	tc "github.com/apache/trafficcontrol/lib/go-tc"
-)
-
-const (
-	dsrGood      = 0
-	dsrBadTenant = 1
-	dsrRequired  = 2
-	dsrDraft     = 3
+	"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 TestDeliveryServiceRequests(t *testing.T) {
 	WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants, DeliveryServiceRequests}, func() {
-		GetTestDeliveryServiceRequestsIMS(t)
-		GetTestDeliveryServiceRequests(t)
-		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)
-		header.Set(rfc.IfUnmodifiedSince, time)
-		UpdateTestDeliveryServiceRequests(t)
-		UpdateTestDeliveryServiceRequestsWithHeaders(t, header)
-		GetTestDeliveryServiceRequestsIMSAfterChange(t, header)
-		header = make(map[string][]string)
-		etag := rfc.ETag(currentTime)
-		header.Set(rfc.IfMatch, etag)
-		UpdateTestDeliveryServiceRequestsWithHeaders(t, header)
-	})
-}
-
-func UpdateTestDeliveryServiceRequestsWithHeaders(t *testing.T, header http.Header) {
-	// Retrieve the DeliveryServiceRequest by name so we can get the id for the Update
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	resp, _, err := TOSession.GetDeliveryServiceRequestByXMLIDWithHdr(dsr.DeliveryService.XMLID, header)
-	if err != nil {
-		t.Errorf("cannot GET DeliveryServiceRequest by name: %v - %v", dsr.DeliveryService.XMLID, err)
-	}
-	if len(resp) == 0 {
-		t.Fatal("Length of GET DeliveryServiceRequest is 0")
-	}
-	respDSR := resp[0]
-	respDSR.DeliveryService.DisplayName = "new display name"
-
-	_, reqInf, err := TOSession.UpdateDeliveryServiceRequestByIDWithHdr(respDSR.ID, respDSR, header)
-	if err == nil {
-		t.Errorf("Expected error about precondition failed, but got none")
-	}
-	if reqInf.StatusCode != http.StatusPreconditionFailed {
-		t.Errorf("Expected status code 412, got %v", reqInf.StatusCode)
-	}
-}
-
-func GetTestDeliveryServiceRequestsIMSAfterChange(t *testing.T, header http.Header) {
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	_, reqInf, err := TOSession.GetDeliveryServiceRequestByXMLIDWithHdr(dsr.DeliveryService.XMLID, header)
-	if err != nil {
-		t.Fatalf("Expected no error, but got %v", err.Error())
-	}
-	if reqInf.StatusCode != http.StatusOK {
-		t.Fatalf("Expected 200 status code, got %v", reqInf.StatusCode)
-	}
-	currentTime := time.Now().UTC()
-	currentTime = currentTime.Add(1 * time.Second)
-	timeStr := currentTime.Format(time.RFC1123)
-	header.Set(rfc.IfModifiedSince, timeStr)
-	_, reqInf, err = TOSession.GetDeliveryServiceRequestByXMLIDWithHdr(dsr.DeliveryService.XMLID, header)
-	if err != nil {
-		t.Fatalf("Expected no error, but got %v", err.Error())
-	}
-	if reqInf.StatusCode != http.StatusNotModified {
-		t.Fatalf("Expected 304 status code, got %v", reqInf.StatusCode)
-	}
-}
-
-func CreateTestDeliveryServiceRequests(t *testing.T) {
-	t.Log("CreateTestDeliveryServiceRequests")
-
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	respDSR, _, err := TOSession.CreateDeliveryServiceRequest(dsr)
-	t.Log("Response: ", respDSR)
-	if err != nil {
-		t.Errorf("could not CREATE DeliveryServiceRequests: %v", err)
-	}
-
-}
 
-func TestDeliveryServiceRequestRequired(t *testing.T) {
-	WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants}, func() {
-		dsr := testData.DeliveryServiceRequests[dsrRequired]
-		_, _, err := TOSession.CreateDeliveryServiceRequest(dsr)
-		if err == nil {
-			t.Error("expected: validation error, actual: nil")
+		currentTime := time.Now().UTC().Add(-15 * time.Second)
+		currentTimeRFC := currentTime.Format(time.RFC1123)
+		tomorrow := currentTime.AddDate(0, 0, 1).Format(time.RFC1123)
+
+		methodTests := utils.V3TestCase{
+			"GET": {
+				"NOT MODIFIED when NO CHANGES made": {
+					ClientSession:  TOSession,
+					RequestHeaders: http.Header{rfc.IfModifiedSince: {tomorrow}},
+					Expectations:   utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusNotModified)),
+				},
+				"OK when VALID XMLID parameter": {
+					ClientSession: TOSession,
+					RequestParams: url.Values{"xmlId": {"test-ds1"}},
+					Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK), utils.ResponseLengthGreaterOrEqual(1),
+						validateGetDSRequestFields(map[string]interface{}{"XMLID": "test-ds1"})),
+				},
+			},
+			"PUT": {
+				"OK when VALID request": {
+					EndpointId:    GetDeliveryServiceRequestId(t, "test-ds1"),
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"deliveryService": generateDeliveryService(t, map[string]interface{}{
+							"displayName": "NEW DISPLAY NAME",
+							"tenantId":    GetTenantId(t, "tenant1"),
+							"xmlId":       "test-ds1",
+						}),
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+				},
+				"OK when UPDATING STATUS FROM DRAFT TO SUBMITTED": {
+					EndpointId:    GetDeliveryServiceRequestId(t, "test-ds1"),
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"deliveryService": generateDeliveryService(t, map[string]interface{}{
+							"tenantId": GetTenantId(t, "tenant1"),
+							"xmlId":    "test-ds1",
+						}),
+						"status": "submitted",
+					},
+					Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+				},
+				"PRECONDITION FAILED when updating with IF-UNMODIFIED-SINCE Header": {
+					EndpointId:     GetDeliveryServiceRequestId(t, "test-ds1"),
+					ClientSession:  TOSession,
+					RequestHeaders: http.Header{rfc.IfUnmodifiedSince: {currentTimeRFC}},
+					RequestBody:    map[string]interface{}{},
+					Expectations:   utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusPreconditionFailed)),
+				},
+				"PRECONDITION FAILED when updating with IFMATCH ETAG Header": {
+					EndpointId:     GetDeliveryServiceRequestId(t, "test-ds1"),
+					ClientSession:  TOSession,
+					RequestBody:    map[string]interface{}{},
+					RequestHeaders: http.Header{rfc.IfMatch: {rfc.ETag(currentTime)}},
+					Expectations:   utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusPreconditionFailed)),
+				},
+			},
+			"POST": {
+				"OK when VALID request": {
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"deliveryService": generateDeliveryService(t, map[string]interface{}{
+							"ccrDnsTtl":          30,
+							"deepCachingType":    "NEVER",
+							"initialDispersion":  3,
+							"ipv6RoutingEnabled": true,
+							"longDesc":           "long desc",
+							"orgServerFqdn":      "http://example.test",
+							"profileName":        nil,
+							"tenant":             "root",
+							"xmlId":              "test-ds2",
+						}),
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+				},
+				"BAD REQUEST when MISSING REQUIRED FIELDS": {
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"deliveryService": map[string]interface{}{
+							"type":  "HTTP",
+							"xmlId": "test-ds-fields",
+						},
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+				},
+				"BAD REQUEST when VALIDATION RULES ARE NOT FOLLOWED": {
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"deliveryService": map[string]interface{}{
+							"ccrDnsTtl":            30,
+							"deepCachingType":      "NEVER",
+							"displayName":          strings.Repeat("X", 49),
+							"dscp":                 0,
+							"geoLimit":             0,
+							"geoProvider":          1,
+							"infoUrl":              "xxx",
+							"initialDispersion":    1,
+							"ipv6RoutingEnabled":   true,
+							"logsEnabled":          true,
+							"longDesc":             "long desc",
+							"missLat":              0.0,
+							"missLong":             0.0,
+							"multiSiteOrigin":      false,
+							"orgServerFqdn":        "http://example.test",
+							"protocol":             0,
+							"qstringIgnore":        0,
+							"rangeRequestHandling": 0,
+							"regionalGeoBlocking":  true,
+							"routingName":          strings.Repeat("X", 1) + "." + strings.Repeat("X", 48),
+							"tenant":               "tenant1",
+							"type":                 "HTTP",
+							"xmlId":                "X " + strings.Repeat("X", 46),
+						},
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+				},
+				"BAD REQUEST when NON-DRAFT": {
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"deliveryService": map[string]interface{}{
+							"active":               false,
+							"cdnName":              "cdn1",
+							"displayName":          "Testing transitions",
+							"dscp":                 3,
+							"geoLimit":             1,
+							"geoProvider":          1,
+							"initialDispersion":    1,
+							"ipv6RoutingEnabled":   true,
+							"logsEnabled":          true,
+							"missLat":              0.0,
+							"missLong":             0.0,
+							"multiSiteOrigin":      false,
+							"orgServerFqdn":        "http://example.test",
+							"protocol":             0,
+							"qstringIgnore":        0,
+							"rangeRequestHandling": 0,
+							"regionalGeoBlocking":  true,
+							"routingName":          "goodroute",
+							"tenant":               "tenant1",
+							"type":                 "HTTP",
+							"xmlId":                "test-transitions",
+						},
+						"status": "pending",
+					},
+					Expectations: utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+				},
+				"BAD REQUEST when ALREADY EXISTS": {
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"deliveryService": map[string]interface{}{
+							"active":               true,
+							"cdnName":              "cdn1",
+							"displayName":          "Good Kabletown CDN",
+							"dscp":                 1,
+							"geoLimit":             1,
+							"geoProvider":          1,
+							"initialDispersion":    1,
+							"ipv6RoutingEnabled":   true,
+							"logsEnabled":          true,
+							"missLat":              0.0,
+							"missLong":             0.0,
+							"multiSiteOrigin":      false,
+							"orgServerFqdn":        "http://example.test",
+							"protocol":             0,
+							"qstringIgnore":        0,
+							"rangeRequestHandling": 0,
+							"regionalGeoBlocking":  true,
+							"routingName":          "goodroute",
+							"tenant":               "tenant1",
+							"type":                 "HTTP",
+							"xmlId":                "test-ds1",
+						},
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+				},
+			},
+			"DELETE": {
+				"OK when VALID request": {
+					EndpointId:    GetDeliveryServiceRequestId(t, "test-deletion"),
+					ClientSession: TOSession,
+					Expectations:  utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+				},
+			},
+			"GET AFTER CHANGES": {
+				"OK when CHANGES made": {
+					ClientSession:  TOSession,
+					RequestHeaders: http.Header{rfc.IfModifiedSince: {currentTimeRFC}},
+					Expectations:   utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+				},
+			},
 		}
-	})
-}
-
-func TestDeliveryServiceRequestRules(t *testing.T) {
-	WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants}, func() {
-		routingName := strings.Repeat("X", 1) + "." + strings.Repeat("X", 48)
-		// Test the xmlId length and form
-		XMLID := "X " + strings.Repeat("X", 46)
-		displayName := strings.Repeat("X", 49)
-
-		dsr := testData.DeliveryServiceRequests[dsrGood]
-		dsr.DeliveryService.DisplayName = displayName
-		dsr.DeliveryService.RoutingName = routingName
-		dsr.DeliveryService.XMLID = XMLID
-
-		_, _, err := TOSession.CreateDeliveryServiceRequest(dsr)
-		if err == nil {
-			t.Error("expected: validation error, actual: nil")
-		}
-	})
-}
-
-func TestDeliveryServiceRequestTypeFields(t *testing.T) {
-	WithObjs(t, []TCObj{CDNs, Types, Tenants, Parameters}, func() {
-		dsr := testData.DeliveryServiceRequests[dsrBadTenant]
 
-		alerts, _, err := TOSession.CreateDeliveryServiceRequest(dsr)
-		if err != nil {
-			t.Errorf("Error occurred %v", err)
+		for method, testCases := range methodTests {
+			t.Run(method, func(t *testing.T) {
+				for name, testCase := range testCases {
+					dsReq := tc.DeliveryServiceRequest{}
+
+					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, &dsReq)
+						assert.NoError(t, err, "Error occurred when unmarshalling request body: %v", err)
+					}
+
+					switch method {
+					case "GET", "GET AFTER CHANGES":
+						t.Run(name, func(t *testing.T) {
+							if name == "OK when VALID XMLID parameter" {
+								resp, reqInf, err := testCase.ClientSession.GetDeliveryServiceRequestByXMLIDWithHdr(testCase.RequestParams["xmlId"][0], testCase.RequestHeaders)
+								for _, check := range testCase.Expectations {
+									check(t, reqInf, resp, tc.Alerts{}, err)
+								}
+							} else {
+								resp, reqInf, err := testCase.ClientSession.GetDeliveryServiceRequestsWithHdr(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.CreateDeliveryServiceRequest(dsReq)
+							for _, check := range testCase.Expectations {
+								check(t, reqInf, nil, alerts, err)
+							}
+						})
+					case "PUT":
+						t.Run(name, func(t *testing.T) {
+							alerts, reqInf, err := testCase.ClientSession.UpdateDeliveryServiceRequestByIDWithHdr(testCase.EndpointId(), dsReq, testCase.RequestHeaders)
+							for _, check := range testCase.Expectations {
+								check(t, reqInf, nil, alerts, err)
+							}
+						})
+					case "DELETE":
+						t.Run(name, func(t *testing.T) {
+							alerts, reqInf, err := testCase.ClientSession.DeleteDeliveryServiceRequestByID(testCase.EndpointId())
+							for _, check := range testCase.Expectations {
+								check(t, reqInf, nil, alerts, err)
+							}
+						})
+					}
+				}
+			})
 		}
 
-		found := false
-		for _, alert := range alerts.Alerts {
-			if alert.Level == tc.ErrorLevel.String() {
-				t.Errorf("Expected only succuss-level alerts creating a DSR, got error-level alert: %s", alert.Text)
-			} else if alert.Level == tc.SuccessLevel.String() {
-				t.Logf("Got expected alert creating a DSR: %s", alert.Text)
-				found = true
-			}
-		}
-		if !found {
-			t.Errorf("Expected a success-level alert creating a DSR, got none")
-		}
-
-		dsrs, _, err := TOSession.GetDeliveryServiceRequestByXMLID(dsr.DeliveryService.XMLID)
-		if len(dsrs) != 1 {
-			t.Errorf("expected 1 deliveryservice_request with XMLID %s;  got %d", dsr.DeliveryService.XMLID, len(dsrs))
-		}
-		alert, _, err := TOSession.DeleteDeliveryServiceRequestByID(dsrs[0].ID)
-		if err != nil {
-			t.Errorf("cannot DELETE DeliveryServiceRequest by id: %d - %v - %v", dsrs[0].ID, err, alert)
-		}
 	})
 }
 
-func TestDeliveryServiceRequestBad(t *testing.T) {
-	WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants}, func() {
-		// try to create non-draft/submitted
-		src := testData.DeliveryServiceRequests[dsrDraft]
-		s, err := tc.RequestStatusFromString("pending")
-		if err != nil {
-			t.Errorf(`unable to create Status from string "pending"`)
-		}
-		src.Status = s
-
-		_, _, err = TOSession.CreateDeliveryServiceRequest(src)
-		if err == nil {
-			t.Fatal("expected: validation error, actual: nil")
-		}
-	})
+func GetDeliveryServiceRequestId(t *testing.T, xmlId string) func() int {
+	return func() int {
+		resp, _, err := TOSession.GetDeliveryServiceRequestByXMLIDWithHdr(xmlId, http.Header{})
+		assert.RequireNoError(t, err, "Get Delivery Service Requests failed with error: %v", err)
+		assert.RequireGreaterOrEqual(t, len(resp), 1, "Expected delivery service requests response object length of atleast 1, but got %d", len(resp))
+		assert.RequireNotNil(t, resp[0].ID, "Expected id to not be nil")
+		return resp[0].ID
+	}
 }
 
-// TestDeliveryServiceRequestWorkflow tests that transitions of Status are
-func TestDeliveryServiceRequestWorkflow(t *testing.T) {
-	WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants}, func() {
-		// test empty request table
-		dsrs, _, err := TOSession.GetDeliveryServiceRequests()
-		if err != nil {
-			t.Errorf("Error getting empty list of DeliveryServiceRequests %v++", err)
-		}
-		if dsrs == nil {
-			t.Error("Expected empty DeliveryServiceRequest slice -- got nil")
-		}
-		if len(dsrs) != 0 {
-			t.Errorf("Expected no entries in DeliveryServiceRequest slice -- got %d", len(dsrs))
-		}
-
-		// Create a draft request
-		src := testData.DeliveryServiceRequests[dsrDraft]
-
-		alerts, _, err := TOSession.CreateDeliveryServiceRequest(src)
-		if err != nil {
-			t.Errorf("Error creating DeliveryServiceRequest %v", err)
-		}
-
-		found := false
-		for _, alert := range alerts.Alerts {
-			if alert.Level == tc.ErrorLevel.String() {
-				t.Errorf("Expected only succuss-level alerts creating a DSR, got error-level alert: %s", alert.Text)
-			} else if alert.Level == tc.SuccessLevel.String() {
-				t.Logf("Got expected alert creating a DSR: %s", alert.Text)
-				found = true
-			}
-		}
-		if !found {
-			t.Errorf("Expected a success-level alert creating a DSR, got none")
-		}
-
-		// Create a duplicate request -- should fail because xmlId is the same
-		alerts, _, err = TOSession.CreateDeliveryServiceRequest(src)
-		if err == nil {
-			t.Fatal("expected: validation error, actual: nil")
-		}
-
-		// TODO: the client needs to be fixed to return alerts on error. But
-		// that's gotten harder to do "semantically" now that most of the logic
-		// is shared between all API versions.
-		// found = false
-		// for _, alert := range alerts.Alerts {
-		// 	if alert.Level == tc.SuccessLevel.String() {
-		// 		t.Errorf("Expected only error-level alerts creating a duplicate DSR, got success-level alert: %s", alert.Text)
-		// 	} else if alert.Level == tc.ErrorLevel.String() {
-		// 		t.Logf("Got expected alert creating a duplicate DSR: %s", alert.Text)
-		// 		found = true
-		// 	}
-		// }
-		// if !found {
-		// 	t.Errorf("Expected an error-level alert creating a duplicate DSR, got none")
-		// }
-
-		dsrs, _, err = TOSession.GetDeliveryServiceRequestByXMLID(`test-transitions`)
-		if len(dsrs) != 1 {
-			t.Errorf("Expected 1 deliveryServiceRequest -- got %d", len(dsrs))
-			if len(dsrs) == 0 {
-				t.Fatal("Cannot proceed")
+func validateGetDSRequestFields(expectedResp map[string]interface{}) utils.CkReqFunc {
+	return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ tc.Alerts, _ error) {
+		dsReqResp := resp.([]tc.DeliveryServiceRequest)
+		for field, expected := range expectedResp {
+			for _, ds := range dsReqResp {
+				switch field {
+				case "XMLID":
+					assert.Equal(t, expected, ds.DeliveryService.XMLID, "Expected XMLID to be %v, but got %v", expected, ds.DeliveryService.XMLID)
+				default:
+					t.Errorf("Expected field: %v, does not exist in response", field)
+				}
 			}
 		}
-
-		alerts, dsr := updateDeliveryServiceRequestStatus(t, dsrs[0], "submitted", nil)
-
-		found = false
-		for _, alert := range alerts.Alerts {
-			if alert.Level == tc.ErrorLevel.String() {
-				t.Errorf("Expected only succuss-level alerts updating a DSR, got error-level alert: %s", alert.Text)
-			} else if alert.Level == tc.SuccessLevel.String() {
-				t.Logf("Got expected alert updating a DSR: %s", alert.Text)
-				found = true
-			}
-		}
-		if !found {
-			t.Errorf("Expected a success-level alert updating a DSR, got none")
-		}
-
-		if dsr.Status != tc.RequestStatus("submitted") {
-			t.Errorf("expected status=submitted,  got %s", string(dsr.Status))
-		}
-	})
-}
-
-func updateDeliveryServiceRequestStatus(t *testing.T, dsr tc.DeliveryServiceRequest, newstate string, header http.Header) (tc.Alerts, tc.DeliveryServiceRequest) {
-	ID := dsr.ID
-	dsr.Status = tc.RequestStatus("submitted")
-
-	alerts, _, err := TOSession.UpdateDeliveryServiceRequestByIDWithHdr(ID, dsr, header)
-	if err != nil {
-		t.Errorf("Error updating deliveryservice_request: %v", err)
-		return alerts, dsr
-	}
-
-	d, _, err := TOSession.GetDeliveryServiceRequestByID(ID)
-	if err != nil {
-		t.Errorf("Error updating deliveryservice_request %d: %v", ID, err)
-		return alerts, dsr
-	}
-
-	if len(d) != 1 {
-		t.Errorf("Expected 1 deliveryservice_request, got %d", len(d))
-	}
-	return alerts, d[0]
-}
-
-func GetTestDeliveryServiceRequestsIMS(t *testing.T) {
-	var header http.Header
-	header = make(map[string][]string)
-	futureTime := time.Now().AddDate(0, 0, 1)
-	time := futureTime.Format(time.RFC1123)
-	header.Set(rfc.IfModifiedSince, time)
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	_, reqInf, err := TOSession.GetDeliveryServiceRequestByXMLIDWithHdr(dsr.DeliveryService.XMLID, header)
-	if err != nil {
-		t.Fatalf("Expected no error, but got %v", err.Error())
-	}
-	if reqInf.StatusCode != http.StatusNotModified {
-		t.Fatalf("Expected 304 status code, got %v", reqInf.StatusCode)
-	}
-}
-
-func GetTestDeliveryServiceRequests(t *testing.T) {
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	resp, _, err := TOSession.GetDeliveryServiceRequestByXMLID(dsr.DeliveryService.XMLID)
-	if err != nil {
-		t.Errorf("cannot GET DeliveryServiceRequest by XMLID: %v - %v", err, resp)
 	}
 }
 
-func UpdateTestDeliveryServiceRequests(t *testing.T) {
-
-	// Retrieve the DeliveryServiceRequest by name so we can get the id for the Update
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	resp, _, err := TOSession.GetDeliveryServiceRequestByXMLID(dsr.DeliveryService.XMLID)
-	if err != nil {
-		t.Errorf("cannot GET DeliveryServiceRequest by name: %v - %v", dsr.DeliveryService.XMLID, err)
-	}
-	if len(resp) == 0 {
-		t.Fatal("Length of GET DeliveryServiceRequest is 0")
-	}
-	respDSR := resp[0]
-	expDisplayName := "new display name"
-	respDSR.DeliveryService.DisplayName = expDisplayName
-	var alert tc.Alerts
-	alert, _, err = TOSession.UpdateDeliveryServiceRequestByID(respDSR.ID, respDSR)
-	t.Log("Response: ", alert)
-	if err != nil {
-		t.Errorf("cannot UPDATE DeliveryServiceRequest by id: %v - %v", err, alert)
-		return
-	}
-
-	// Retrieve the DeliveryServiceRequest to check DeliveryServiceRequest name got updated
-	resp, _, err = TOSession.GetDeliveryServiceRequestByID(respDSR.ID)
-	if err != nil {
-		t.Errorf("cannot GET DeliveryServiceRequest by name: %v - %v", respDSR.ID, err)
-	} else {
-		respDSR = resp[0]
-		if respDSR.DeliveryService.DisplayName != expDisplayName {
-			t.Errorf("results do not match actual: %s, expected: %s", respDSR.DeliveryService.DisplayName, expDisplayName)
-		}
+func CreateTestDeliveryServiceRequests(t *testing.T) {
+	for _, dsr := range testData.DeliveryServiceRequests {
+		respDSR, _, err := TOSession.CreateDeliveryServiceRequest(dsr)
+		assert.NoError(t, err, "Could not create Delivery Service Requests: %v - alerts: %+v", err, respDSR.Alerts)
 	}
-
 }
 
 func DeleteTestDeliveryServiceRequests(t *testing.T) {
-
-	// Retrieve the DeliveryServiceRequest by name so we can get the id for the Update
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	resp, _, err := TOSession.GetDeliveryServiceRequestByXMLID(dsr.DeliveryService.XMLID)
-	if err != nil {
-		t.Errorf("cannot GET DeliveryServiceRequest by id: %v - %v", dsr.DeliveryService.XMLID, err)
-	}
-	respDSR := resp[0]
-	alert, _, err := TOSession.DeleteDeliveryServiceRequestByID(respDSR.ID)
-	t.Log("Response: ", alert)
-	if err != nil {
-		t.Errorf("cannot DELETE DeliveryServiceRequest by id: %d - %v - %v", respDSR.ID, err, alert)
-	}
-
-	// Retrieve the DeliveryServiceRequest to see if it got deleted
-	dsrs, _, err := TOSession.GetDeliveryServiceRequestByXMLID(dsr.DeliveryService.XMLID)
-	if err != nil {
-		t.Errorf("error deleting DeliveryServiceRequest name: %s", err.Error())
-	}
-	if len(dsrs) > 0 {
-		t.Errorf("expected DeliveryServiceRequest XMLID: %s to be deleted", dsr.DeliveryService.XMLID)
+	resp, _, err := TOSession.GetDeliveryServiceRequestsWithHdr(http.Header{})
+	assert.NoError(t, err, "Cannot get Delivery Service Requests: %v", err)
+	for _, request := range resp {
+		alert, _, err := TOSession.DeleteDeliveryServiceRequestByID(request.ID)
+		assert.NoError(t, err, "Cannot delete Delivery Service Request #%d: %v - alerts: %+v", request.ID, err, alert.Alerts)
+
+		// Retrieve the DeliveryServiceRequest to see if it got deleted
+		dsr, _, err := TOSession.GetDeliveryServiceRequestByIDWithHdr(request.ID, http.Header{})
+		assert.NoError(t, err, "Unexpected error fetching Delivery Service Request #%d after deletion: %v", request.ID, err)
+		assert.Equal(t, len(dsr), 0, "Expected Delivery Service Request #%d to be deleted, but it was found in Traffic Ops", request.ID)
 	}
 }
diff --git a/traffic_ops/testing/api/v3/tc-fixtures.json b/traffic_ops/testing/api/v3/tc-fixtures.json
index 7c2f2994ff..d9b962a512 100644
--- a/traffic_ops/testing/api/v3/tc-fixtures.json
+++ b/traffic_ops/testing/api/v3/tc-fixtures.json
@@ -327,51 +327,8 @@
                 "cdnName": "cdn1",
                 "ccrDnsTtl": 30,
                 "deepCachingType": "NEVER",
-                "displayName": "Bad Tenant",
-                "dscp": 0,
-                "geoLimit": 0,
-                "geoProvider": 0,
-                "initialDispersion": 3,
-                "logsEnabled": false,
-                "longDesc": "long desc",
-                "regionalGeoBlocking": false,
-                "tenant": "root",
-                "type": "HTTP",
-                "xmlId": "test-ds2"
-            },
-            "status": "draft"
-        },
-        {
-            "changeType": "create",
-            "deliveryService": {
-                "ccrDnsTtl": 30,
-                "deepCachingType": "NEVER",
-                "displayName": "Bad Test Case CDN",
-                "dscp": 0,
-                "geoLimit": 0,
-                "geoProvider": 1,
-                "infoUrl": "xxx",
-                "initialDispersion": 1,
-                "logsEnabled": true,
-                "longDesc": "long desc",
-                "orgServerFqdn": "xxx",
-                "regionalGeoBlocking": true,
-                "routingName": "x routing",
-                "tenant": "tenant1",
-                "type": "HTTP",
-                "xmlId": "test-ds3"
-            },
-            "status": "draft"
-        },
-        {
-            "changeType": "create",
-            "deliveryService": {
-                "active": false,
-                "cdnName": "cdn1",
-                "ccrDnsTtl": 30,
-                "deepCachingType": "NEVER",
-                "displayName": "Testing transitions",
-                "dscp": 3,
+                "displayName": "Good Kabletown CDN",
+                "dscp": 1,
                 "geoLimit": 1,
                 "geoProvider": 1,
                 "initialDispersion": 1,
@@ -381,7 +338,7 @@
                 "routingName": "goodroute",
                 "tenant": "tenant1",
                 "type": "HTTP",
-                "xmlId": "test-transitions"
+                "xmlId": "test-deletion"
             },
             "status": "draft"
         }
diff --git a/traffic_ops/testing/api/v4/deliveryservice_requests_test.go b/traffic_ops/testing/api/v4/deliveryservice_requests_test.go
index d0ccf8c735..6890c33148 100644
--- a/traffic_ops/testing/api/v4/deliveryservice_requests_test.go
+++ b/traffic_ops/testing/api/v4/deliveryservice_requests_test.go
@@ -16,25 +16,22 @@ package v4
 */
 
 import (
+	"encoding/json"
 	"net/http"
+	"net/url"
 	"strconv"
 	"strings"
 	"testing"
 	"time"
 
 	"github.com/apache/trafficcontrol/lib/go-rfc"
-	tc "github.com/apache/trafficcontrol/lib/go-tc"
-	"github.com/apache/trafficcontrol/lib/go-util"
+	"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"
 )
 
-const (
-	dsrGood      = 0
-	dsrBadTenant = 1
-	dsrRequired  = 2
-	dsrDraft     = 3
-)
-
 // this resets the IDs of things attached to a DS, which needs to be done
 // because the WithObjs flow destroys and recreates those object IDs
 // non-deterministically with each test - BUT, the client method permanently
@@ -58,630 +55,340 @@ func resetDS(ds *tc.DeliveryServiceV4) {
 
 func TestDeliveryServiceRequests(t *testing.T) {
 	WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants, DeliveryServiceRequests}, func() {
-		GetTestDeliveryServiceRequestsIMS(t)
-		GetTestDeliveryServiceRequests(t)
-		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)
-		header.Set(rfc.IfUnmodifiedSince, time)
-		UpdateTestDeliveryServiceRequestsWithLongDescFields(t)
-		UpdateTestDeliveryServiceRequests(t)
-		UpdateTestDeliveryServiceRequestsWithHeaders(t, header)
-		GetTestDeliveryServiceRequestsIMSAfterChange(t, header)
-		header = make(map[string][]string)
-		etag := rfc.ETag(currentTime)
-		header.Set(rfc.IfMatch, etag)
-		UpdateTestDeliveryServiceRequestsWithHeaders(t, header)
-	})
-}
-
-func UpdateTestDeliveryServiceRequestsWithLongDescFields(t *testing.T) {
-	if len(testData.DeliveryServiceRequests) < dsrGood+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test updating them", dsrGood+1)
-	}
-
-	// Retrieve the DeliveryServiceRequest by name so we can get the id for the Update
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	var ds *tc.DeliveryServiceV4
-	if dsr.ChangeType == tc.DSRChangeTypeDelete {
-		dsr.Original.LongDesc1 = util.StrPtr("long desc 1")
-		dsr.Original.LongDesc2 = util.StrPtr("long desc 2")
-		ds = dsr.Original
-	} else {
-		dsr.Requested.LongDesc1 = util.StrPtr("long desc 1")
-		dsr.Requested.LongDesc2 = util.StrPtr("long desc 2")
-		ds = dsr.Requested
-	}
-
-	if ds == nil || ds.XMLID == nil {
-		t.Fatalf("the %dth DSR in the test data had no DeliveryService - or that DeliveryService had no XMLID", dsrGood)
-	}
-
-	opts := client.NewRequestOptions()
-	opts.QueryParameters.Set("xmlId", *ds.XMLID)
-	resp, _, err := TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Errorf("cannot get Delivery Service Request with XMLID '%s': %v - alerts: %+v", *ds.XMLID, err, resp.Alerts)
-	}
-	if len(resp.Response) == 0 {
-		t.Fatalf("Expected at least one Deliver Service Request to exist with XMLID '%s', but none were found in Traffic Ops", *ds.XMLID)
-	}
-	respDSR := resp.Response[0]
-	if respDSR.ID == nil {
-		t.Fatalf("got a DSR by XMLID '%s' with a null or undefined ID", *ds.XMLID)
-	}
-	var respDS *tc.DeliveryServiceV4
-	if dsr.ChangeType == tc.DSRChangeTypeDelete {
-		respDS = dsr.Original
-		respDSR.Original = respDS
-	} else {
-		respDS = dsr.Requested
-		respDSR.Requested = respDS
-	}
-	expDisplayName := "new display name"
-	respDS.DisplayName = &expDisplayName
-	id := *respDSR.ID
-	_, reqInf, err := TOSession.UpdateDeliveryServiceRequest(id, respDSR, client.RequestOptions{})
-	if err == nil {
-		t.Errorf("expected an error stating that Long Desc 1 and Long Desc 2 fields are not supported in api version 4.0 onwards, but got nothing")
-	}
-	if reqInf.StatusCode != http.StatusBadRequest {
-		t.Errorf("expected a 400 status code, but got %d", reqInf.StatusCode)
-	}
-}
 
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func UpdateTestDeliveryServiceRequestsWithHeaders(t *testing.T, header http.Header) {
-	if len(testData.DeliveryServiceRequests) < dsrGood+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test updating them using headers", dsrGood+1)
-	}
-	// Retrieve the DeliveryServiceRequest by name so we can get the id for the Update
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	var ds *tc.DeliveryServiceV4
-	if dsr.ChangeType == tc.DSRChangeTypeDelete {
-		ds = dsr.Original
-	} else {
-		ds = dsr.Requested
-	}
-	resetDS(ds)
-	if ds == nil || ds.XMLID == nil {
-		t.Fatalf("the %dth DSR in the test data had no Delivery Service, or that Delivery Service had a null or undefined XMLID", dsrGood)
-	}
-	opts := client.NewRequestOptions()
-	opts.Header = header
-	opts.QueryParameters.Set("xmlId", *ds.XMLID)
-	resp, _, err := TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Errorf("cannot get Delivery Service Request by XMLID '%s': %v - alerts: %+v", *ds.XMLID, err, resp.Alerts)
-	}
-	if len(resp.Response) == 0 {
-		t.Fatal("Length of GET DeliveryServiceRequest is 0")
-	}
-	respDSR := resp.Response[0]
-	if respDSR.ID == nil {
-		t.Fatalf("Got a DSR for XML ID '%s' that had a nil ID", *ds.XMLID)
-	}
-	if respDSR.ChangeType != dsr.ChangeType {
-		t.Fatalf("remote representation of DSR with XMLID '%s' differed from stored data", *ds.XMLID)
-	}
-	var respDS *tc.DeliveryServiceV4
-	if respDSR.ChangeType == tc.DSRChangeTypeDelete {
-		respDS = respDSR.Original
-	} else {
-		respDS = respDSR.Requested
-	}
-
-	respDS.DisplayName = new(string)
-	*respDS.DisplayName = "new display name"
-	opts.QueryParameters.Del("xmlId")
-	_, reqInf, err := TOSession.UpdateDeliveryServiceRequest(*respDSR.ID, respDSR, opts)
-	if err == nil {
-		t.Errorf("Expected error about precondition failed, but got none")
-	}
-	if reqInf.StatusCode != http.StatusPreconditionFailed {
-		t.Errorf("Expected status code 412, got %v", reqInf.StatusCode)
-	}
-}
-
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func GetTestDeliveryServiceRequestsIMSAfterChange(t *testing.T, header http.Header) {
-	if len(testData.DeliveryServiceRequests) < dsrGood+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test updating them with IMS", dsrGood+1)
-	}
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	var ds *tc.DeliveryServiceV4
-	if dsr.ChangeType == tc.DSRChangeTypeDelete {
-		ds = dsr.Original
-	} else {
-		ds = dsr.Requested
-	}
-
-	resetDS(ds)
-	if ds == nil || ds.XMLID == nil {
-		t.Fatalf("the %dth DSR in the test data had no Delivery Service, or that Delivery Service had a null or undefined XMLID", dsrGood)
-	}
-
-	opts := client.NewRequestOptions()
-	opts.Header = header
-	opts.QueryParameters.Set("xmlId", *ds.XMLID)
-	resp, reqInf, err := TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Fatalf("Expected no error, but got: %v - alerts: %+v", err, resp.Alerts)
-	}
-	if reqInf.StatusCode != http.StatusOK {
-		t.Fatalf("Expected 200 status code, got %v", reqInf.StatusCode)
-	}
-	currentTime := time.Now().UTC()
-	currentTime = currentTime.Add(1 * time.Second)
-	timeStr := currentTime.Format(time.RFC1123)
-	opts.Header.Set(rfc.IfModifiedSince, timeStr)
-	resp, reqInf, err = TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Fatalf("Expected no error, but got: %v - alerts: %+v", err, resp.Alerts)
-	}
-	if reqInf.StatusCode != http.StatusNotModified {
-		t.Fatalf("Expected 304 status code, got %v", reqInf.StatusCode)
-	}
-}
-
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func CreateTestDeliveryServiceRequests(t *testing.T) {
-	if len(testData.DeliveryServiceRequests) < dsrGood+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test creating Delivery Service Requests", dsrGood+1)
-	}
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	resetDS(dsr.Original)
-	resetDS(dsr.Requested)
-	respDSR, _, err := TOSession.CreateDeliveryServiceRequest(dsr, client.RequestOptions{})
-	if err != nil {
-		t.Errorf("could not create Delivery Service Requests: %v - alerts: %+v", err, respDSR.Alerts)
-	}
-
-}
-
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func TestDeliveryServiceRequestRequired(t *testing.T) {
-	WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants}, func() {
-		if len(testData.DeliveryServiceRequests) < dsrRequired+1 {
-			t.Fatalf("Need at least %d Delivery Service Requests to test creating a Delivery Service Request missing required fields", dsrRequired+1)
+		currentTime := time.Now().UTC().Add(-15 * time.Second)
+		currentTimeRFC := currentTime.Format(time.RFC1123)
+		tomorrow := currentTime.AddDate(0, 0, 1).Format(time.RFC1123)
+
+		methodTests := utils.V4TestCase{
+			"GET": {
+				"NOT MODIFIED when NO CHANGES made": {
+					ClientSession: TOSession,
+					RequestOpts:   client.RequestOptions{Header: http.Header{rfc.IfModifiedSince: {tomorrow}}},
+					Expectations:  utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusNotModified)),
+				},
+				"OK when VALID XMLID parameter": {
+					ClientSession: TOSession,
+					RequestOpts:   client.RequestOptions{QueryParameters: url.Values{"xmlId": {"test-ds1"}}},
+					Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK), utils.ResponseLengthGreaterOrEqual(1),
+						validateGetDSRequestFields(map[string]interface{}{"XMLID": "test-ds1"})),
+				},
+			},
+			"PUT": {
+				"OK when VALID request": {
+					EndpointId:    GetDeliveryServiceRequestId(t, "test-ds1"),
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"requested": generateDeliveryService(t, map[string]interface{}{
+							"displayName": "NEW DISPLAY NAME",
+							"tenantId":    GetTenantId(t, "tenant1"),
+							"xmlId":       "test-ds1",
+						}),
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+				},
+				"OK when UPDATING STATUS FROM DRAFT TO SUBMITTED": {
+					EndpointId:    GetDeliveryServiceRequestId(t, "test-ds1"),
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"requested": generateDeliveryService(t, map[string]interface{}{
+							"tenantId": GetTenantId(t, "tenant1"),
+							"xmlId":    "test-ds1",
+						}),
+						"status": "submitted",
+					},
+					Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
+						validatePutDSRequestFields(map[string]interface{}{"STATUS": tc.RequestStatusSubmitted})),
+				},
+				"BAD REQUEST when using LONG DESCRIPTION 2 and 3 fields": {
+					EndpointId:    GetDeliveryServiceRequestId(t, "test-ds1"),
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"requested": generateDeliveryService(t, map[string]interface{}{
+							"longDesc1": "long desc 1",
+							"longDesc2": "long desc 2",
+							"tenantId":  GetTenantId(t, "tenant1"),
+							"xmlId":     "test-ds1",
+						}),
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+				},
+				"PRECONDITION FAILED when updating with IF-UNMODIFIED-SINCE Header": {
+					EndpointId:    GetDeliveryServiceRequestId(t, "test-ds1"),
+					ClientSession: TOSession,
+					RequestOpts:   client.RequestOptions{Header: http.Header{rfc.IfUnmodifiedSince: {currentTimeRFC}}},
+					RequestBody:   map[string]interface{}{},
+					Expectations:  utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusPreconditionFailed)),
+				},
+				"PRECONDITION FAILED when updating with IFMATCH ETAG Header": {
+					EndpointId:    GetDeliveryServiceRequestId(t, "test-ds1"),
+					ClientSession: TOSession,
+					RequestBody:   map[string]interface{}{},
+					RequestOpts:   client.RequestOptions{Header: http.Header{rfc.IfMatch: {rfc.ETag(currentTime)}}},
+					Expectations:  utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusPreconditionFailed)),
+				},
+			},
+			"POST": {
+				"CREATED when VALID request": {
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"requested": generateDeliveryService(t, map[string]interface{}{
+							"ccrDnsTtl":          30,
+							"deepCachingType":    "NEVER",
+							"initialDispersion":  3,
+							"ipv6RoutingEnabled": true,
+							"longDesc":           "long desc",
+							"orgServerFqdn":      "http://example.test",
+							"profileName":        nil,
+							"tenant":             "root",
+							"xmlId":              "test-ds2",
+						}),
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusCreated)),
+				},
+				"BAD REQUEST when MISSING REQUIRED FIELDS": {
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"requested": map[string]interface{}{
+							"type":  "HTTP",
+							"xmlId": "test-ds-fields",
+						},
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+				},
+				"BAD REQUEST when VALIDATION RULES ARE NOT FOLLOWED": {
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"requested": map[string]interface{}{
+							"ccrDnsTtl":            30,
+							"deepCachingType":      "NEVER",
+							"displayName":          strings.Repeat("X", 49),
+							"dscp":                 0,
+							"geoLimit":             0,
+							"geoProvider":          1,
+							"infoUrl":              "xxx",
+							"initialDispersion":    1,
+							"ipv6RoutingEnabled":   true,
+							"logsEnabled":          true,
+							"longDesc":             "long desc",
+							"missLat":              0.0,
+							"missLong":             0.0,
+							"multiSiteOrigin":      false,
+							"orgServerFqdn":        "http://example.test",
+							"protocol":             0,
+							"qstringIgnore":        0,
+							"rangeRequestHandling": 0,
+							"regionalGeoBlocking":  true,
+							"routingName":          strings.Repeat("X", 1) + "." + strings.Repeat("X", 48),
+							"tenant":               "tenant1",
+							"type":                 "HTTP",
+							"xmlId":                "X " + strings.Repeat("X", 46),
+						},
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+				},
+				"BAD REQUEST when NON-DRAFT": {
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"requested": map[string]interface{}{
+							"active":               false,
+							"cdnName":              "cdn1",
+							"displayName":          "Testing transitions",
+							"dscp":                 3,
+							"geoLimit":             1,
+							"geoProvider":          1,
+							"initialDispersion":    1,
+							"ipv6RoutingEnabled":   true,
+							"logsEnabled":          true,
+							"missLat":              0.0,
+							"missLong":             0.0,
+							"multiSiteOrigin":      false,
+							"orgServerFqdn":        "http://example.test",
+							"protocol":             0,
+							"qstringIgnore":        0,
+							"rangeRequestHandling": 0,
+							"regionalGeoBlocking":  true,
+							"routingName":          "goodroute",
+							"tenant":               "tenant1",
+							"type":                 "HTTP",
+							"xmlId":                "test-transitions",
+						},
+						"status": "pending",
+					},
+					Expectations: utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+				},
+				"BAD REQUEST when ALREADY EXISTS": {
+					ClientSession: TOSession,
+					RequestBody: map[string]interface{}{
+						"changeType": "create",
+						"requested": map[string]interface{}{
+							"active":               true,
+							"cdnName":              "cdn1",
+							"displayName":          "Good Kabletown CDN",
+							"dscp":                 1,
+							"geoLimit":             1,
+							"geoProvider":          1,
+							"initialDispersion":    1,
+							"ipv6RoutingEnabled":   true,
+							"logsEnabled":          true,
+							"missLat":              0.0,
+							"missLong":             0.0,
+							"multiSiteOrigin":      false,
+							"orgServerFqdn":        "http://example.test",
+							"protocol":             0,
+							"qstringIgnore":        0,
+							"rangeRequestHandling": 0,
+							"regionalGeoBlocking":  true,
+							"routingName":          "goodroute",
+							"tenant":               "tenant1",
+							"type":                 "HTTP",
+							"xmlId":                "test-ds1",
+						},
+						"status": "draft",
+					},
+					Expectations: utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+				},
+			},
+			"DELETE": {
+				"OK when VALID request": {
+					EndpointId:    GetDeliveryServiceRequestId(t, "test-deletion"),
+					ClientSession: TOSession,
+					Expectations:  utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+				},
+			},
+			"GET AFTER CHANGES": {
+				"OK when CHANGES made": {
+					ClientSession: TOSession,
+					RequestOpts:   client.RequestOptions{Header: http.Header{rfc.IfModifiedSince: {currentTimeRFC}}},
+					Expectations:  utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+				},
+			},
 		}
-		dsr := testData.DeliveryServiceRequests[dsrRequired]
-		resetDS(dsr.Original)
-		resetDS(dsr.Requested)
-		_, _, err := TOSession.CreateDeliveryServiceRequest(dsr, client.RequestOptions{})
-		if err == nil {
-			t.Error("expected: validation error, actual: nil")
-		}
-	})
-}
 
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func TestDeliveryServiceRequestRules(t *testing.T) {
-	if len(testData.DeliveryServiceRequests) < dsrGood+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test creating Delivery Service Request rules", dsrGood+1)
-	}
-	WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants}, func() {
-		routingName := strings.Repeat("X", 1) + "." + strings.Repeat("X", 48)
-		// Test the xmlId length and form
-		XMLID := "X " + strings.Repeat("X", 46)
-		displayName := strings.Repeat("X", 49)
-
-		dsr := testData.DeliveryServiceRequests[dsrGood]
-		var ds *tc.DeliveryServiceV4
-		if dsr.ChangeType == tc.DSRChangeTypeDelete {
-			ds = dsr.Original
-		} else {
-			ds = dsr.Requested
-		}
-		resetDS(ds)
-		if ds == nil {
-			t.Fatalf("the %dth DSR in the test data had no DeliveryService", dsrGood)
+		for method, testCases := range methodTests {
+			t.Run(method, func(t *testing.T) {
+				for name, testCase := range testCases {
+					dsReq := tc.DeliveryServiceRequestV4{}
+
+					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, &dsReq)
+						assert.NoError(t, err, "Error occurred when unmarshalling request body: %v", err)
+					}
+
+					switch method {
+					case "GET", "GET AFTER CHANGES":
+						t.Run(name, func(t *testing.T) {
+							resp, reqInf, err := testCase.ClientSession.GetDeliveryServiceRequests(testCase.RequestOpts)
+							for _, check := range testCase.Expectations {
+								check(t, reqInf, resp.Response, resp.Alerts, err)
+							}
+						})
+					case "POST":
+						t.Run(name, func(t *testing.T) {
+							resp, reqInf, err := testCase.ClientSession.CreateDeliveryServiceRequest(dsReq, testCase.RequestOpts)
+							for _, check := range testCase.Expectations {
+								check(t, reqInf, resp.Response, resp.Alerts, err)
+							}
+						})
+					case "PUT":
+						t.Run(name, func(t *testing.T) {
+							resp, reqInf, err := testCase.ClientSession.UpdateDeliveryServiceRequest(testCase.EndpointId(), dsReq, testCase.RequestOpts)
+							for _, check := range testCase.Expectations {
+								check(t, reqInf, resp.Response, resp.Alerts, err)
+							}
+						})
+					case "DELETE":
+						t.Run(name, func(t *testing.T) {
+							resp, reqInf, err := testCase.ClientSession.DeleteDeliveryServiceRequest(testCase.EndpointId(), testCase.RequestOpts)
+							for _, check := range testCase.Expectations {
+								check(t, reqInf, resp.Response, resp.Alerts, err)
+							}
+						})
+					}
+				}
+			})
 		}
-		ds.DisplayName = &displayName
-		ds.RoutingName = &routingName
-		ds.XMLID = &XMLID
 
-		_, _, err := TOSession.CreateDeliveryServiceRequest(dsr, client.RequestOptions{})
-		if err == nil {
-			t.Error("expected: validation error, actual: nil")
-		}
 	})
 }
 
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func TestDeliveryServiceRequestTypeFields(t *testing.T) {
-	if len(testData.DeliveryServiceRequests) < dsrBadTenant+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test creating a Delivery Service Request with missing fields for its Type", dsrBadTenant+1)
-	}
-
-	WithObjs(t, []TCObj{CDNs, Types, Tenants, Parameters}, func() {
-		dsr := testData.DeliveryServiceRequests[dsrBadTenant]
-		var ds *tc.DeliveryServiceV4
-		if dsr.ChangeType == tc.DSRChangeTypeDelete {
-			ds = dsr.Original
-		} else {
-			ds = dsr.Requested
-		}
-		resetDS(ds)
-		if ds == nil || ds.XMLID == nil {
-			t.Fatalf("the %dth DSR in the test data had no Delivery Service, or that Delivery Service had a null or undefined XMLID", dsrBadTenant)
-		}
-
-		resp, _, err := TOSession.CreateDeliveryServiceRequest(dsr, client.RequestOptions{})
-		if err != nil {
-			t.Errorf("Unexpected error creating a Delivery Service Request: %v - alerts: %+v", err, resp.Alerts)
-		}
-
-		found := false
-		for _, alert := range resp.Alerts.Alerts {
-			if alert.Level == tc.ErrorLevel.String() {
-				t.Errorf("Expected only succuss-level alerts creating a DSR, got error-level alert: %s", alert.Text)
-			} else if alert.Level == tc.SuccessLevel.String() {
-				t.Logf("Got expected alert creating a DSR: %s", alert.Text)
-				found = true
-			}
-		}
-
-		if !found {
-			t.Errorf("Expected a success-level alert creating a DSR, got none")
-		}
-
+func GetDeliveryServiceRequestId(t *testing.T, xmlId string) func() int {
+	return func() int {
 		opts := client.NewRequestOptions()
-		opts.QueryParameters.Set("xmlId", *ds.XMLID)
-		dsrs, _, err := TOSession.GetDeliveryServiceRequests(opts)
-		if err != nil {
-			t.Errorf("Unexpected error retriving Delivery Service Requests with XMLID '%s': %v - alerts: %+v", *ds.XMLID, err, dsrs.Alerts)
-		}
-		if len(dsrs.Response) != 1 {
-			t.Fatalf("expected exactly one Deliveryservice Request with XMLID '%s'; got %d", *ds.XMLID, len(dsrs.Response))
-		}
-		if dsrs.Response[0].ID == nil {
-			t.Fatalf("got a DSR with a null ID by XMLID '%s'", *ds.XMLID)
-		}
-
-		alert, _, err := TOSession.DeleteDeliveryServiceRequest(*dsrs.Response[0].ID, client.RequestOptions{})
-		if err != nil {
-			t.Errorf("cannot delete Delivery Service Request #%d: %v - alerts: %+v", dsrs.Response[0].ID, err, alert.Alerts)
-		}
-	})
-}
-
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func TestDeliveryServiceRequestBad(t *testing.T) {
-	if len(testData.DeliveryServiceRequests) < dsrDraft+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test creating a non-draft Delivery Service Request", dsrDraft+1)
+		opts.QueryParameters.Set("xmlId", xmlId)
+		resp, _, err := TOSession.GetDeliveryServiceRequests(opts)
+		assert.RequireNoError(t, err, "Get Delivery Service Requests failed with error: %v", err)
+		assert.RequireGreaterOrEqual(t, len(resp.Response), 1, "Expected delivery service requests response object length of atleast 1, but got %d", len(resp.Response))
+		assert.RequireNotNil(t, resp.Response[0].ID, "Expected id to not be nil")
+		return *resp.Response[0].ID
 	}
-	WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants}, func() {
-		// try to create non-draft/submitted
-		src := testData.DeliveryServiceRequests[dsrDraft]
-		resetDS(src.Original)
-		resetDS(src.Requested)
-		src.Status = tc.RequestStatusPending
-
-		if _, _, err := TOSession.CreateDeliveryServiceRequest(src, client.RequestOptions{}); err == nil {
-			t.Fatal("expected: validation error, actual: nil")
-		}
-	})
 }
 
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func TestDeliveryServiceRequestWorkflow(t *testing.T) {
-	if len(testData.DeliveryServiceRequests) < dsrDraft+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test Delivery Service Request workflow", dsrDraft+1)
-	}
-
-	WithObjs(t, []TCObj{CDNs, Types, Parameters, Tenants}, func() {
-		// test empty request table
-		dsrs, _, err := TOSession.GetDeliveryServiceRequests(client.RequestOptions{})
-		if err != nil {
-			t.Errorf("Error getting empty list of Delivery Service Requests: %v - alerts: %+v", err, dsrs.Alerts)
-		}
-		if dsrs.Response == nil {
-			t.Error("Expected empty Delivery Service Request slice -- got nil")
-		}
-		if len(dsrs.Response) != 0 {
-			t.Errorf("Expected no entries in Delivery Service Request slice, got %d", len(dsrs.Response))
-		}
-
-		// Create a draft request
-		src := testData.DeliveryServiceRequests[dsrDraft]
-		resetDS(src.Original)
-		resetDS(src.Requested)
-
-		alerts, _, err := TOSession.CreateDeliveryServiceRequest(src, client.RequestOptions{})
-		if err != nil {
-			t.Errorf("Error creating Delivery Service Request: %v - alerts: %+v", err, alerts.Alerts)
-		}
-
-		found := false
-		for _, alert := range alerts.Alerts.Alerts {
-			if alert.Level == tc.ErrorLevel.String() {
-				t.Errorf("Expected only succuss-level alerts creating a DSR, got error-level alert: %s", alert.Text)
-			} else if alert.Level == tc.SuccessLevel.String() {
-				t.Logf("Got expected alert creating a DSR: %s", alert.Text)
-				found = true
-			}
-		}
-
-		if !found {
-			t.Errorf("Expected a success-level alert creating a DSR, got none")
-		}
-
-		// Create a duplicate request -- should fail because xmlId is the same
-		alerts, _, err = TOSession.CreateDeliveryServiceRequest(src, client.RequestOptions{})
-		if err == nil {
-			t.Fatal("expected: validation error, actual: nil")
-		}
-
-		found = false
-		for _, alert := range alerts.Alerts.Alerts {
-			if alert.Level == tc.SuccessLevel.String() {
-				t.Errorf("Expected only error-level alerts creating a duplicate DSR, got success-level alert: %s", alert.Text)
-			} else if alert.Level == tc.ErrorLevel.String() {
-				t.Logf("Got expected alert creating a duplicate DSR: %s", alert.Text)
-				found = true
+func validateGetDSRequestFields(expectedResp map[string]interface{}) utils.CkReqFunc {
+	return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ tc.Alerts, _ error) {
+		dsReqResp := resp.([]tc.DeliveryServiceRequestV40)
+		for field, expected := range expectedResp {
+			for _, ds := range dsReqResp {
+				switch field {
+				case "XMLID":
+					assert.Equal(t, expected, *ds.Requested.XMLID, "Expected XMLID to be %v, but got %v", expected, *ds.Requested.XMLID)
+				default:
+					t.Errorf("Expected field: %v, does not exist in response", field)
+				}
 			}
 		}
-		if !found {
-			t.Errorf("Expected an error-level alert creating a duplicate DSR, got none")
-		}
-
-		opts := client.NewRequestOptions()
-		opts.QueryParameters.Set("xmlId", "test-transitions")
-		dsrs, _, err = TOSession.GetDeliveryServiceRequests(opts)
-		if err != nil {
-			t.Errorf("Unexpected error getting Delivery Service Requests with XMLID 'test-transitions': %v - alerts: %+v", err, dsrs.Alerts)
-		}
-		if len(dsrs.Response) != 1 {
-			t.Errorf("Expected exactly one Delivery Service Request with XMLID 'test-transitions', got: %d", len(dsrs.Response))
-			if len(dsrs.Response) == 0 {
-				t.Fatal("Cannot proceed")
-			}
-		}
-
-		alerts = updateDeliveryServiceRequestStatus(t, dsrs.Response[0], "submitted", nil)
-
-		found = false
-		for _, alert := range alerts.Alerts.Alerts {
-			if alert.Level == tc.ErrorLevel.String() {
-				t.Errorf("Expected only succuss-level alerts updating a DSR, got error-level alert: %s", alert.Text)
-			} else if alert.Level == tc.SuccessLevel.String() {
-				t.Logf("Got expected alert updating a DSR: %s", alert.Text)
-				found = true
-			}
-		}
-		if !found {
-			t.Errorf("Expected a success-level alert updating a DSR, got none: %v", alerts.Alerts)
-		}
-
-		if alerts.Response.Status != tc.RequestStatus("submitted") {
-			t.Errorf("expected status=submitted, got %s", alerts.Response.Status)
-		}
-	})
-}
-
-func updateDeliveryServiceRequestStatus(t *testing.T, dsr tc.DeliveryServiceRequestV4, newstate string, header http.Header) tc.DeliveryServiceRequestResponseV4 {
-	var resp tc.DeliveryServiceRequestResponseV4
-	ID := dsr.ID
-	if ID == nil {
-		t.Error("updateDeliveryServiceRequestStatus called with a DSR that has a nil ID")
-		return resp
-	}
-	dsr.Status = tc.RequestStatus("submitted")
-	resp, _, err := TOSession.UpdateDeliveryServiceRequest(*ID, dsr, client.RequestOptions{Header: header})
-	if err != nil {
-		t.Errorf("Unexpected error updating Delivery Service Request: %v - alerts: %+v", err, resp.Alerts)
-		return resp
 	}
-
-	opts := client.NewRequestOptions()
-	opts.QueryParameters.Set("id", strconv.Itoa(*ID))
-	d, _, err := TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Errorf("Error fetching Delivery Service Request #%d after status update: %v - alerts: %+v", ID, err, d.Alerts)
-		return resp
-	}
-	if len(d.Response) != 1 {
-		t.Errorf("Expected exactly one Delivery Service Request to exist with ID %d, found: %d", *ID, len(d.Response))
-	}
-
-	resp.Response = d.Response[0]
-
-	return resp
 }
 
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func GetTestDeliveryServiceRequestsIMS(t *testing.T) {
-	if len(testData.DeliveryServiceRequests) < dsrGood+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test getting them with IMS", dsrGood+1)
-	}
-
-	futureTime := time.Now().AddDate(0, 0, 1)
-	time := futureTime.Format(time.RFC1123)
-
-	opts := client.NewRequestOptions()
-	opts.Header.Set(rfc.IfModifiedSince, time)
-
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	var ds *tc.DeliveryServiceV4
-	if dsr.ChangeType == tc.DSRChangeTypeDelete {
-		ds = dsr.Original
-	} else {
-		ds = dsr.Requested
-	}
-	resetDS(ds)
-	if ds == nil || ds.XMLID == nil {
-		t.Fatalf("the %dth DSR in the test data had no Delivery Service, or that Delivery Service had null or undefined XMLID", dsrGood)
-	}
-
-	opts.QueryParameters.Set("xmlId", *ds.XMLID)
-	resp, reqInf, err := TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Fatalf("Unexpected error getting Delivery Service Requests with XMLID '%s': %v - alerts: %+v", *ds.XMLID, err, resp.Alerts)
-	}
-	if reqInf.StatusCode != http.StatusNotModified {
-		t.Fatalf("Expected 304 status code, got %v", reqInf.StatusCode)
-	}
-}
-
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func GetTestDeliveryServiceRequests(t *testing.T) {
-	if len(testData.DeliveryServiceRequests) < dsrGood+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test getting them", dsrGood+1)
-	}
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	var ds *tc.DeliveryServiceV4
-	if dsr.ChangeType == tc.DSRChangeTypeDelete {
-		ds = dsr.Original
-	} else {
-		ds = dsr.Requested
-	}
-	resetDS(ds)
-
-	if ds == nil || ds.XMLID == nil {
-		t.Fatalf("the %dth DSR in the test data had no Delivery Service, or that Delivery Service had a null or undefined XMLID", dsrGood)
-	}
-
-	opts := client.NewRequestOptions()
-	opts.QueryParameters.Set("xmlId", *ds.XMLID)
-	resp, _, err := TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Errorf("cannot get Delivery Service Requests with XMLID '%s': %v - alerts: %+v", *ds.XMLID, err, resp.Alerts)
+func validatePutDSRequestFields(expectedResp map[string]interface{}) utils.CkReqFunc {
+	return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _ tc.Alerts, _ error) {
+		dsReqResp := resp.(tc.DeliveryServiceRequestV40)
+		for field, expected := range expectedResp {
+			switch field {
+			case "STATUS":
+				assert.Equal(t, expected, dsReqResp.Status, "Expected status to be %v, but got %v", expected, dsReqResp.Status)
+			default:
+				t.Errorf("Expected field: %v, does not exist in response", field)
+			}
+		}
 	}
 }
 
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
-func UpdateTestDeliveryServiceRequests(t *testing.T) {
-	if len(testData.DeliveryServiceRequests) < dsrGood+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test updating them", dsrGood+1)
-	}
-
-	// Retrieve the DeliveryServiceRequest by name so we can get the id for the Update
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	var ds *tc.DeliveryServiceV4
-	if dsr.ChangeType == tc.DSRChangeTypeDelete {
-		ds = dsr.Original
-	} else {
-		ds = dsr.Requested
-	}
-
-	resetDS(ds)
-	if ds == nil || ds.XMLID == nil {
-		t.Fatalf("the %dth DSR in the test data had no Delivery Service, or that Delivery Service had a null or undefined XMLID", dsrGood)
-	}
-
-	opts := client.NewRequestOptions()
-	opts.QueryParameters.Set("xmlId", *ds.XMLID)
-	resp, _, err := TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Errorf("cannot get Delivery Service Request with XMLID '%s': %v - alerts: %+v", *ds.XMLID, err, resp.Alerts)
-	}
-	if len(resp.Response) == 0 {
-		t.Fatalf("Expected at least one Deliver Service Request to exist with XMLID '%s', but none were found in Traffic Ops", *ds.XMLID)
-	}
-	respDSR := resp.Response[0]
-	if respDSR.ID == nil {
-		t.Fatalf("got a DSR by XMLID '%s' with a null or undefined ID", *ds.XMLID)
-	}
-	var respDS *tc.DeliveryServiceV4
-	if dsr.ChangeType == tc.DSRChangeTypeDelete {
-		respDS = dsr.Original
-	} else {
-		respDS = dsr.Requested
-	}
-	expDisplayName := "new display name"
-	respDS.DisplayName = &expDisplayName
-	id := *respDSR.ID
-	alerts, _, err := TOSession.UpdateDeliveryServiceRequest(id, respDSR, client.RequestOptions{})
-	if err != nil {
-		t.Errorf("cannot update Delivery Service Request #%d: %v - alerts: %+v", id, err, alerts.Alerts)
-		return
-	}
-
-	// Retrieve the DeliveryServiceRequest to check DeliveryServiceRequest name got updated
-	opts.QueryParameters.Del("xmlId")
-	opts.QueryParameters.Set("id", strconv.Itoa(id))
-	dsrResp, _, err := TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Fatalf("cannot get Delivery Service Request #%d: %v - alerts: %+v", id, err, dsrResp.Alerts)
-	}
-	if len(dsrResp.Response) != 1 {
-		t.Fatalf("Expected exactly one Delivery Service Request to have id %d, found: %d", id, len(dsrResp.Response))
-	}
-
-	respDSR = dsrResp.Response[0]
-	if respDSR.ChangeType == tc.DSRChangeTypeDelete {
-		respDS = dsr.Original
-	} else {
-		respDS = dsr.Requested
-	}
-
-	if respDS == nil || respDS.DisplayName == nil {
-		t.Fatalf("Got DSR by ID '%d' that had no DeliveryService - or said DeliveryService had no DisplayName", id)
-	}
-	if *respDS.DisplayName != expDisplayName {
-		t.Errorf("results do not match actual: %s, expected: %s", *respDS.DisplayName, expDisplayName)
+func CreateTestDeliveryServiceRequests(t *testing.T) {
+	for _, dsr := range testData.DeliveryServiceRequests {
+		resetDS(dsr.Original)
+		resetDS(dsr.Requested)
+		respDSR, _, err := TOSession.CreateDeliveryServiceRequest(dsr, client.RequestOptions{})
+		assert.NoError(t, err, "Could not create Delivery Service Requests: %v - alerts: %+v", err, respDSR.Alerts)
 	}
 }
 
-// Note that this test is susceptible to breaking if the structure of the test
-// data's DSRs is altered at all.
 func DeleteTestDeliveryServiceRequests(t *testing.T) {
-	if len(testData.DeliveryServiceRequests) < dsrGood+1 {
-		t.Fatalf("Need at least %d Delivery Service Requests to test deleting them", dsrGood+1)
-	}
+	resp, _, err := TOSession.GetDeliveryServiceRequests(client.RequestOptions{})
+	assert.NoError(t, err, "Cannot get Delivery Service Requests: %v - alerts: %+v", err, resp.Alerts)
+	for _, request := range resp.Response {
+		alert, _, err := TOSession.DeleteDeliveryServiceRequest(*request.ID, client.RequestOptions{})
+		assert.NoError(t, err, "Cannot delete Delivery Service Request #%d: %v - alerts: %+v", request.ID, err, alert.Alerts)
 
-	// Retrieve the DeliveryServiceRequest by name so we can get the id for the Update
-	dsr := testData.DeliveryServiceRequests[dsrGood]
-	var ds *tc.DeliveryServiceV4
-	if dsr.ChangeType == tc.DSRChangeTypeDelete {
-		ds = dsr.Original
-	} else {
-		ds = dsr.Requested
-	}
-
-	resetDS(ds)
-	if ds == nil || ds.XMLID == nil {
-		t.Fatalf("the %dth DSR in the test data had no DeliveryService - or that DeliveryService had no XMLID", dsrGood)
-	}
-
-	opts := client.NewRequestOptions()
-	opts.QueryParameters.Set("xmlId", *ds.XMLID)
-	resp, _, err := TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Fatalf("cannot get Delivery Service Requests with XMLID '%s': %v - alerts: %+v", *ds.XMLID, err, resp.Alerts)
-	}
-	if len(resp.Response) < 1 {
-		t.Fatalf("expected at least one Delivery Service Request to have XMLID '%s', got none", *ds.XMLID)
-	}
-	respDSR := resp.Response[0]
-	if respDSR.ID == nil {
-		t.Fatalf("Got a DSR by XMLID '%s' that had no ID", *ds.XMLID)
-	}
-	alert, _, err := TOSession.DeleteDeliveryServiceRequest(*respDSR.ID, client.RequestOptions{})
-	if err != nil {
-		t.Errorf("cannot delete Delivery Service Request #%d: %v - alerts: %+v", respDSR.ID, err, alert.Alerts)
-	}
-
-	// Retrieve the DeliveryServiceRequest to see if it got deleted
-	dsrs, _, err := TOSession.GetDeliveryServiceRequests(opts)
-	if err != nil {
-		t.Errorf("Unexpected error fetching Delivery Service Request #%d after deletion: %v - alerts: %+v", *respDSR.ID, err, dsrs.Alerts)
-	}
-	if len(dsrs.Response) > 0 {
-		t.Errorf("expected Delivery Service Request #%d to be deleted, but it was found in Traffic Ops", *respDSR.ID)
+		// Retrieve the DeliveryServiceRequest to see if it got deleted
+		opts := client.NewRequestOptions()
+		opts.QueryParameters.Set("id", strconv.Itoa(*request.ID))
+		dsr, _, err := TOSession.GetDeliveryServiceRequests(opts)
+		assert.NoError(t, err, "Unexpected error fetching Delivery Service Request #%d after deletion: %v - alerts: %+v", *request.ID, err, dsr.Alerts)
+		assert.Equal(t, len(dsr.Response), 0, "Expected Delivery Service Request #%d to be deleted, but it was found in Traffic Ops", *request.ID)
 	}
 }
diff --git a/traffic_ops/testing/api/v4/tc-fixtures.json b/traffic_ops/testing/api/v4/tc-fixtures.json
index ebf1fab2aa..632153f725 100644
--- a/traffic_ops/testing/api/v4/tc-fixtures.json
+++ b/traffic_ops/testing/api/v4/tc-fixtures.json
@@ -364,66 +364,8 @@
                 "cdnName": "cdn1",
                 "ccrDnsTtl": 30,
                 "deepCachingType": "NEVER",
-                "displayName": "Bad Tenant",
-                "dscp": 0,
-                "geoLimit": 0,
-                "geoProvider": 0,
-                "initialDispersion": 3,
-                "ipv6RoutingEnabled": true,
-                "logsEnabled": false,
-                "longDesc": "long desc",
-                "missLat": 0.0,
-                "missLong": 0.0,
-                "multiSiteOrigin": false,
-                "orgServerFqdn": "http://example.test",
-                "protocol": 0,
-                "qstringIgnore": 0,
-                "rangeRequestHandling": 0,
-                "regionalGeoBlocking": false,
-                "tenant": "root",
-                "type": "HTTP",
-                "xmlId": "test-ds2"
-            },
-            "status": "draft"
-        },
-        {
-            "changeType": "create",
-            "requested": {
-                "ccrDnsTtl": 30,
-                "deepCachingType": "NEVER",
-                "displayName": "Bad Test Case CDN",
-                "dscp": 0,
-                "geoLimit": 0,
-                "geoProvider": 1,
-                "infoUrl": "xxx",
-                "initialDispersion": 1,
-                "ipv6RoutingEnabled": true,
-                "logsEnabled": true,
-                "longDesc": "long desc",
-                "missLat": 0.0,
-                "missLong": 0.0,
-                "multiSiteOrigin": false,
-                "orgServerFqdn": "http://example.test",
-                "protocol": 0,
-                "qstringIgnore": 0,
-                "rangeRequestHandling": 0,
-                "regionalGeoBlocking": true,
-                "routingName": "x routing",
-                "tenant": "tenant1",
-                "type": "HTTP",
-                "xmlId": "test-ds3"
-            },
-            "status": "draft"
-        },
-        {
-            "changeType": "create",
-            "requested": {
-                "active": false,
-                "cdnName": "cdn1",
-                "ccrDnsTtl": 30,
-                "deepCachingType": "NEVER",
-                "displayName": "Testing transitions",
-                "dscp": 3,
+                "displayName": "Good Kabletown CDN",
+                "dscp": 1,
                 "geoLimit": 1,
                 "geoProvider": 1,
                 "initialDispersion": 1,
@@ -441,7 +383,7 @@
                 "routingName": "goodroute",
                 "tenant": "tenant1",
                 "type": "HTTP",
-                "xmlId": "test-transitions"
+                "xmlId": "test-deletion"
             },
             "status": "draft"
         }