You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/06/18 21:15:28 UTC

[GitHub] [trafficcontrol] dmohan001c opened a new pull request #5960: Add TO Client API for Origin Automation

dmohan001c opened a new pull request #5960:
URL: https://github.com/apache/trafficcontrol/pull/5960


   ## What does this PR (Pull Request) do?
   
   - [x] This PR is not related to any Issue
   
   ## Which Traffic Control components are affected by this PR?
   
   - CDN in a Box
   - Traffic Control Client <!-- Please specify which; e.g. 'Python', 'Go', 'Java' -->
   - Traffic Ops
   - CI tests
   
   ## What is the best way to verify this PR?
   Execute all the Integration tests and make sure the tests passed.
   
   ## The following criteria are ALL met by this PR
   <!-- Check the boxes to signify that the associated statement is true. To
   "check a box", replace the space inside of the square brackets with an 'x'.
   e.g.
   
   - [ x] <- Wrong
   - [x ] <- Wrong
   - [] <- Wrong
   - [*] <- Wrong
   - [x] <- Correct!
   
   -->
   
   - [x] This PR includes tests OR I have explained why tests are unnecessary
   - [x] This PR includes documentation OR I have explained why documentation is unnecessary
   - [x] This PR includes an update to CHANGELOG.md OR such an update is not necessary
   - [x] This PR includes any and all required license headers
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] dmohan001c commented on a change in pull request #5960: Add TO Client API for Origin Automation

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5960:
URL: https://github.com/apache/trafficcontrol/pull/5960#discussion_r679240730



##########
File path: traffic_ops/testing/api/v4/origins_test.go
##########
@@ -374,3 +473,411 @@ func DeleteTestOrigins(t *testing.T) {
 		}
 	}
 }
+
+func GetTestOriginsByParams(t *testing.T) {
+	if len(testData.Origins) < 1 {
+		t.Fatal("Need at least one Origin to test Get Origins by params")
+	}
+	origins := testData.Origins[0]
+	if origins.Name == nil || len(*origins.Name) == 0 {
+		t.Fatal("Found nil value in Origin name")
+	}
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("name", *origins.Name)
+	originByName, _, _ := TOSession.GetOrigins(opts)
+	if len(originByName.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByName.Response))
+	}
+	if originByName.Response[0].DeliveryServiceID == nil {
+		t.Fatal("Found nil value in delivery service")
+	}
+	if originByName.Response[0].CachegroupID == nil {
+		t.Fatal("Found nil value in Cachegroup")
+	}
+	if originByName.Response[0].CoordinateID == nil {
+		t.Fatal("Found nil value in Coordinate")
+	}
+	if originByName.Response[0].ProfileID == nil {
+		t.Fatal("Found nil value in Profile")
+	}
+	if originByName.Response[0].IsPrimary == nil {
+		t.Fatal("Found nil value in IsPrimary field")
+	}
+
+	//Get Origins by DSID
+	dsId := *originByName.Response[0].DeliveryServiceID
+	opts.QueryParameters.Del("name")
+	opts.QueryParameters.Set("deliveryservice", strconv.Itoa(dsId))
+	originByDs, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by DeliveryService ID: %v - alerts: %+v", err, originByDs.Alerts)
+	}
+	if len(originByDs.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByDs.Response))
+	}
+
+	//Get Origins by Cachegroup
+	cachegroupID := *originByName.Response[0].CachegroupID
+	opts.QueryParameters.Del("deliveryservice")
+	opts.QueryParameters.Set("cachegroup", strconv.Itoa(cachegroupID))
+	originByCg, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Cachegroup ID: %v - alerts: %+v", err, originByCg.Alerts)
+	}
+	if len(originByCg.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Cachegroups, but found %d", len(originByCg.Response))
+	}
+
+	//Get Origins by Coordinate
+	CoordinateID := *originByName.Response[0].CoordinateID
+	opts.QueryParameters.Del("cachegroup")
+	opts.QueryParameters.Set("coordinate", strconv.Itoa(CoordinateID))
+	originByCoordinate, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Coordinate ID: %v - alerts: %+v", err, originByCoordinate.Alerts)
+	}
+	if len(originByCoordinate.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Coordinate, but found %d", len(originByCoordinate.Response))
+	}
+
+	//Get Origins by Profile
+	profileId := *originByName.Response[0].ProfileID
+	opts.QueryParameters.Del("coordinate")
+	opts.QueryParameters.Set("profileId", strconv.Itoa(profileId))
+	originByProfile, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Profile ID: %v - alerts: %+v", err, originByProfile.Alerts)
+	}
+	if len(originByProfile.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Profile, but found %d", len(originByProfile.Response))
+	}
+
+	//Get Origins by Primary
+	isPrimary := *originByName.Response[0].IsPrimary
+	opts.QueryParameters.Del("profileId")
+	opts.QueryParameters.Set("isPrimary", strconv.FormatBool(isPrimary))
+	originByPrimary, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Primary ID: %v - alerts: %+v", err, originByPrimary.Alerts)
+	}
+	if len(originByPrimary.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Primary, but found %d", len(originByPrimary.Response))
+	}
+
+	//Get Origins by Tenant
+	tenant := *originByName.Response[0].TenantID
+	opts.QueryParameters.Del("isPrimary")
+	opts.QueryParameters.Set("tenant", strconv.Itoa(tenant))
+	originByTenant, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Tenant ID: %v - alerts: %+v", err, originByTenant.Alerts)
+	}
+	if len(originByTenant.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Tenant, but found %d", len(originByTenant.Response))
+	}
+}
+
+func GetTestOriginsByInvalidParams(t *testing.T) {

Review comment:
       Added negative test for the scenarios.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] dmohan001c commented on a change in pull request #5960: Add TO Client API for Origin Automation

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5960:
URL: https://github.com/apache/trafficcontrol/pull/5960#discussion_r678258965



##########
File path: traffic_ops/testing/api/v4/origins_test.go
##########
@@ -374,3 +473,411 @@ func DeleteTestOrigins(t *testing.T) {
 		}
 	}
 }
+
+func GetTestOriginsByParams(t *testing.T) {
+	if len(testData.Origins) < 1 {
+		t.Fatal("Need at least one Origin to test Get Origins by params")
+	}
+	origins := testData.Origins[0]
+	if origins.Name == nil || len(*origins.Name) == 0 {
+		t.Fatal("Found nil value in Origin name")
+	}
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("name", *origins.Name)
+	originByName, _, _ := TOSession.GetOrigins(opts)
+	if len(originByName.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByName.Response))
+	}
+	if originByName.Response[0].DeliveryServiceID == nil {
+		t.Fatal("Found nil value in delivery service")
+	}
+	if originByName.Response[0].CachegroupID == nil {
+		t.Fatal("Found nil value in Cachegroup")
+	}
+	if originByName.Response[0].CoordinateID == nil {
+		t.Fatal("Found nil value in Coordinate")
+	}
+	if originByName.Response[0].ProfileID == nil {
+		t.Fatal("Found nil value in Profile")
+	}
+	if originByName.Response[0].IsPrimary == nil {
+		t.Fatal("Found nil value in IsPrimary field")
+	}
+
+	//Get Origins by DSID
+	dsId := *originByName.Response[0].DeliveryServiceID
+	opts.QueryParameters.Del("name")
+	opts.QueryParameters.Set("deliveryservice", strconv.Itoa(dsId))
+	originByDs, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by DeliveryService ID: %v - alerts: %+v", err, originByDs.Alerts)
+	}
+	if len(originByDs.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByDs.Response))
+	}
+
+	//Get Origins by Cachegroup
+	cachegroupID := *originByName.Response[0].CachegroupID
+	opts.QueryParameters.Del("deliveryservice")
+	opts.QueryParameters.Set("cachegroup", strconv.Itoa(cachegroupID))
+	originByCg, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Cachegroup ID: %v - alerts: %+v", err, originByCg.Alerts)
+	}
+	if len(originByCg.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Cachegroups, but found %d", len(originByCg.Response))
+	}
+
+	//Get Origins by Coordinate
+	CoordinateID := *originByName.Response[0].CoordinateID
+	opts.QueryParameters.Del("cachegroup")
+	opts.QueryParameters.Set("coordinate", strconv.Itoa(CoordinateID))
+	originByCoordinate, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Coordinate ID: %v - alerts: %+v", err, originByCoordinate.Alerts)
+	}
+	if len(originByCoordinate.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Coordinate, but found %d", len(originByCoordinate.Response))
+	}
+
+	//Get Origins by Profile
+	profileId := *originByName.Response[0].ProfileID
+	opts.QueryParameters.Del("coordinate")
+	opts.QueryParameters.Set("profileId", strconv.Itoa(profileId))
+	originByProfile, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Profile ID: %v - alerts: %+v", err, originByProfile.Alerts)
+	}
+	if len(originByProfile.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Profile, but found %d", len(originByProfile.Response))
+	}
+
+	//Get Origins by Primary
+	isPrimary := *originByName.Response[0].IsPrimary
+	opts.QueryParameters.Del("profileId")
+	opts.QueryParameters.Set("isPrimary", strconv.FormatBool(isPrimary))
+	originByPrimary, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Primary ID: %v - alerts: %+v", err, originByPrimary.Alerts)
+	}
+	if len(originByPrimary.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Primary, but found %d", len(originByPrimary.Response))
+	}
+
+	//Get Origins by Tenant
+	tenant := *originByName.Response[0].TenantID
+	opts.QueryParameters.Del("isPrimary")
+	opts.QueryParameters.Set("tenant", strconv.Itoa(tenant))
+	originByTenant, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Tenant ID: %v - alerts: %+v", err, originByTenant.Alerts)
+	}
+	if len(originByTenant.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Tenant, but found %d", len(originByTenant.Response))
+	}
+}
+
+func GetTestOriginsByInvalidParams(t *testing.T) {
+
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("deliveryservice", "12345")
+	originByDs, _, _ := TOSession.GetOrigins(opts)
+	if len(originByDs.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Delivery Service, but found %d", len(originByDs.Response))
+	}
+
+	//Get Origins by Cachegroup
+	opts.QueryParameters.Del("deliveryservice")
+	opts.QueryParameters.Set("cachegroup", "12345")
+	originByCg, _, _ := TOSession.GetOrigins(opts)
+	if len(originByCg.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Cachegroups, but found %d", len(originByCg.Response))
+	}
+
+	//Get Origins by Coordinate
+	opts.QueryParameters.Del("cachegroup")
+	opts.QueryParameters.Set("coordinate", "12345")
+	originByCoordinate, _, _ := TOSession.GetOrigins(opts)
+	if len(originByCoordinate.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Coordinate, but found %d", len(originByCoordinate.Response))
+	}
+
+	//Get Origins by Profile
+	opts.QueryParameters.Del("coordinate")
+	opts.QueryParameters.Set("profileId", "12345")
+	originByProfile, _, _ := TOSession.GetOrigins(opts)
+	if len(originByProfile.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Profile, but found %d", len(originByProfile.Response))
+	}
+
+	//Get Origins by Tenant
+	opts.QueryParameters.Del("profileId")
+	opts.QueryParameters.Set("tenant", "12345")
+	originByTenant, _, _ := TOSession.GetOrigins(opts)
+	if len(originByTenant.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Tenant, but found %d", len(originByTenant.Response))
+	}
+}
+
+func CreateTestOriginInvalidData(t *testing.T) {

Review comment:
       Do you want me to change the order. Either fail, expected would be the same.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5960: Add TO Client API for Origin Automation

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5960:
URL: https://github.com/apache/trafficcontrol/pull/5960#discussion_r678320717



##########
File path: traffic_ops/testing/api/v4/origins_test.go
##########
@@ -374,3 +473,411 @@ func DeleteTestOrigins(t *testing.T) {
 		}
 	}
 }
+
+func GetTestOriginsByParams(t *testing.T) {
+	if len(testData.Origins) < 1 {
+		t.Fatal("Need at least one Origin to test Get Origins by params")
+	}
+	origins := testData.Origins[0]
+	if origins.Name == nil || len(*origins.Name) == 0 {
+		t.Fatal("Found nil value in Origin name")
+	}
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("name", *origins.Name)
+	originByName, _, _ := TOSession.GetOrigins(opts)
+	if len(originByName.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByName.Response))
+	}
+	if originByName.Response[0].DeliveryServiceID == nil {
+		t.Fatal("Found nil value in delivery service")
+	}
+	if originByName.Response[0].CachegroupID == nil {
+		t.Fatal("Found nil value in Cachegroup")
+	}
+	if originByName.Response[0].CoordinateID == nil {
+		t.Fatal("Found nil value in Coordinate")
+	}
+	if originByName.Response[0].ProfileID == nil {
+		t.Fatal("Found nil value in Profile")
+	}
+	if originByName.Response[0].IsPrimary == nil {
+		t.Fatal("Found nil value in IsPrimary field")
+	}
+
+	//Get Origins by DSID
+	dsId := *originByName.Response[0].DeliveryServiceID
+	opts.QueryParameters.Del("name")
+	opts.QueryParameters.Set("deliveryservice", strconv.Itoa(dsId))
+	originByDs, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by DeliveryService ID: %v - alerts: %+v", err, originByDs.Alerts)
+	}
+	if len(originByDs.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByDs.Response))
+	}
+
+	//Get Origins by Cachegroup
+	cachegroupID := *originByName.Response[0].CachegroupID
+	opts.QueryParameters.Del("deliveryservice")
+	opts.QueryParameters.Set("cachegroup", strconv.Itoa(cachegroupID))
+	originByCg, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Cachegroup ID: %v - alerts: %+v", err, originByCg.Alerts)
+	}
+	if len(originByCg.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Cachegroups, but found %d", len(originByCg.Response))
+	}
+
+	//Get Origins by Coordinate
+	CoordinateID := *originByName.Response[0].CoordinateID
+	opts.QueryParameters.Del("cachegroup")
+	opts.QueryParameters.Set("coordinate", strconv.Itoa(CoordinateID))
+	originByCoordinate, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Coordinate ID: %v - alerts: %+v", err, originByCoordinate.Alerts)
+	}
+	if len(originByCoordinate.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Coordinate, but found %d", len(originByCoordinate.Response))
+	}
+
+	//Get Origins by Profile
+	profileId := *originByName.Response[0].ProfileID
+	opts.QueryParameters.Del("coordinate")
+	opts.QueryParameters.Set("profileId", strconv.Itoa(profileId))
+	originByProfile, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Profile ID: %v - alerts: %+v", err, originByProfile.Alerts)
+	}
+	if len(originByProfile.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Profile, but found %d", len(originByProfile.Response))
+	}
+
+	//Get Origins by Primary
+	isPrimary := *originByName.Response[0].IsPrimary
+	opts.QueryParameters.Del("profileId")
+	opts.QueryParameters.Set("isPrimary", strconv.FormatBool(isPrimary))
+	originByPrimary, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Primary ID: %v - alerts: %+v", err, originByPrimary.Alerts)
+	}
+	if len(originByPrimary.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Primary, but found %d", len(originByPrimary.Response))
+	}
+
+	//Get Origins by Tenant
+	tenant := *originByName.Response[0].TenantID
+	opts.QueryParameters.Del("isPrimary")
+	opts.QueryParameters.Set("tenant", strconv.Itoa(tenant))
+	originByTenant, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Tenant ID: %v - alerts: %+v", err, originByTenant.Alerts)
+	}
+	if len(originByTenant.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Tenant, but found %d", len(originByTenant.Response))
+	}
+}
+
+func GetTestOriginsByInvalidParams(t *testing.T) {
+
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("deliveryservice", "12345")
+	originByDs, _, _ := TOSession.GetOrigins(opts)
+	if len(originByDs.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Delivery Service, but found %d", len(originByDs.Response))
+	}
+
+	//Get Origins by Cachegroup
+	opts.QueryParameters.Del("deliveryservice")
+	opts.QueryParameters.Set("cachegroup", "12345")
+	originByCg, _, _ := TOSession.GetOrigins(opts)
+	if len(originByCg.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Cachegroups, but found %d", len(originByCg.Response))
+	}
+
+	//Get Origins by Coordinate
+	opts.QueryParameters.Del("cachegroup")
+	opts.QueryParameters.Set("coordinate", "12345")
+	originByCoordinate, _, _ := TOSession.GetOrigins(opts)
+	if len(originByCoordinate.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Coordinate, but found %d", len(originByCoordinate.Response))
+	}
+
+	//Get Origins by Profile
+	opts.QueryParameters.Del("coordinate")
+	opts.QueryParameters.Set("profileId", "12345")
+	originByProfile, _, _ := TOSession.GetOrigins(opts)
+	if len(originByProfile.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Profile, but found %d", len(originByProfile.Response))
+	}
+
+	//Get Origins by Tenant
+	opts.QueryParameters.Del("profileId")
+	opts.QueryParameters.Set("tenant", "12345")
+	originByTenant, _, _ := TOSession.GetOrigins(opts)
+	if len(originByTenant.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Tenant, but found %d", len(originByTenant.Response))
+	}
+}
+
+func CreateTestOriginInvalidData(t *testing.T) {

Review comment:
       No, I'm ok with order. Normally, I would check for error first before check for any response or reqInf.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on pull request #5960: Add TO Client API for Origin Automation

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on pull request #5960:
URL: https://github.com/apache/trafficcontrol/pull/5960#issuecomment-887932388


   Api/v4 and E2E-Integration tests pass on local.
   A couple of minor comments.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] zrhoffman merged pull request #5960: Add TO Client API for Origin Automation

Posted by GitBox <gi...@apache.org>.
zrhoffman merged pull request #5960:
URL: https://github.com/apache/trafficcontrol/pull/5960


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5960: Add TO Client API for Origin Automation

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5960:
URL: https://github.com/apache/trafficcontrol/pull/5960#discussion_r677890930



##########
File path: traffic_ops/testing/api/v4/origins_test.go
##########
@@ -374,3 +473,411 @@ func DeleteTestOrigins(t *testing.T) {
 		}
 	}
 }
+
+func GetTestOriginsByParams(t *testing.T) {
+	if len(testData.Origins) < 1 {
+		t.Fatal("Need at least one Origin to test Get Origins by params")
+	}
+	origins := testData.Origins[0]
+	if origins.Name == nil || len(*origins.Name) == 0 {
+		t.Fatal("Found nil value in Origin name")
+	}
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("name", *origins.Name)
+	originByName, _, _ := TOSession.GetOrigins(opts)
+	if len(originByName.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByName.Response))
+	}
+	if originByName.Response[0].DeliveryServiceID == nil {
+		t.Fatal("Found nil value in delivery service")
+	}
+	if originByName.Response[0].CachegroupID == nil {
+		t.Fatal("Found nil value in Cachegroup")
+	}
+	if originByName.Response[0].CoordinateID == nil {
+		t.Fatal("Found nil value in Coordinate")
+	}
+	if originByName.Response[0].ProfileID == nil {
+		t.Fatal("Found nil value in Profile")
+	}
+	if originByName.Response[0].IsPrimary == nil {
+		t.Fatal("Found nil value in IsPrimary field")
+	}
+
+	//Get Origins by DSID
+	dsId := *originByName.Response[0].DeliveryServiceID
+	opts.QueryParameters.Del("name")
+	opts.QueryParameters.Set("deliveryservice", strconv.Itoa(dsId))
+	originByDs, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by DeliveryService ID: %v - alerts: %+v", err, originByDs.Alerts)
+	}
+	if len(originByDs.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByDs.Response))
+	}
+
+	//Get Origins by Cachegroup
+	cachegroupID := *originByName.Response[0].CachegroupID
+	opts.QueryParameters.Del("deliveryservice")
+	opts.QueryParameters.Set("cachegroup", strconv.Itoa(cachegroupID))
+	originByCg, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Cachegroup ID: %v - alerts: %+v", err, originByCg.Alerts)
+	}
+	if len(originByCg.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Cachegroups, but found %d", len(originByCg.Response))
+	}
+
+	//Get Origins by Coordinate
+	CoordinateID := *originByName.Response[0].CoordinateID
+	opts.QueryParameters.Del("cachegroup")
+	opts.QueryParameters.Set("coordinate", strconv.Itoa(CoordinateID))
+	originByCoordinate, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Coordinate ID: %v - alerts: %+v", err, originByCoordinate.Alerts)
+	}
+	if len(originByCoordinate.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Coordinate, but found %d", len(originByCoordinate.Response))
+	}
+
+	//Get Origins by Profile
+	profileId := *originByName.Response[0].ProfileID
+	opts.QueryParameters.Del("coordinate")
+	opts.QueryParameters.Set("profileId", strconv.Itoa(profileId))
+	originByProfile, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Profile ID: %v - alerts: %+v", err, originByProfile.Alerts)
+	}
+	if len(originByProfile.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Profile, but found %d", len(originByProfile.Response))
+	}
+
+	//Get Origins by Primary
+	isPrimary := *originByName.Response[0].IsPrimary
+	opts.QueryParameters.Del("profileId")
+	opts.QueryParameters.Set("isPrimary", strconv.FormatBool(isPrimary))
+	originByPrimary, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Primary ID: %v - alerts: %+v", err, originByPrimary.Alerts)
+	}
+	if len(originByPrimary.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Primary, but found %d", len(originByPrimary.Response))
+	}
+
+	//Get Origins by Tenant
+	tenant := *originByName.Response[0].TenantID
+	opts.QueryParameters.Del("isPrimary")
+	opts.QueryParameters.Set("tenant", strconv.Itoa(tenant))
+	originByTenant, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Tenant ID: %v - alerts: %+v", err, originByTenant.Alerts)
+	}
+	if len(originByTenant.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Tenant, but found %d", len(originByTenant.Response))
+	}
+}
+
+func GetTestOriginsByInvalidParams(t *testing.T) {
+
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("deliveryservice", "12345")
+	originByDs, _, _ := TOSession.GetOrigins(opts)
+	if len(originByDs.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Delivery Service, but found %d", len(originByDs.Response))
+	}
+
+	//Get Origins by Cachegroup
+	opts.QueryParameters.Del("deliveryservice")
+	opts.QueryParameters.Set("cachegroup", "12345")
+	originByCg, _, _ := TOSession.GetOrigins(opts)
+	if len(originByCg.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Cachegroups, but found %d", len(originByCg.Response))
+	}
+
+	//Get Origins by Coordinate
+	opts.QueryParameters.Del("cachegroup")
+	opts.QueryParameters.Set("coordinate", "12345")
+	originByCoordinate, _, _ := TOSession.GetOrigins(opts)
+	if len(originByCoordinate.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Coordinate, but found %d", len(originByCoordinate.Response))
+	}
+
+	//Get Origins by Profile
+	opts.QueryParameters.Del("coordinate")
+	opts.QueryParameters.Set("profileId", "12345")
+	originByProfile, _, _ := TOSession.GetOrigins(opts)
+	if len(originByProfile.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Profile, but found %d", len(originByProfile.Response))
+	}
+
+	//Get Origins by Tenant
+	opts.QueryParameters.Del("profileId")
+	opts.QueryParameters.Set("tenant", "12345")
+	originByTenant, _, _ := TOSession.GetOrigins(opts)
+	if len(originByTenant.Response) > 0 {
+		t.Fatalf("Expected empty response for GET Origin by invalid Tenant, but found %d", len(originByTenant.Response))
+	}
+}
+
+func CreateTestOriginInvalidData(t *testing.T) {

Review comment:
       In this function, shouldn't one test for err first, before checking for status code?, L645, L658, L671, L684, L697, L710, L723




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5960: Add TO Client API for Origin Automation

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5960:
URL: https://github.com/apache/trafficcontrol/pull/5960#discussion_r677891452



##########
File path: traffic_ops/testing/api/v4/origins_test.go
##########
@@ -374,3 +473,411 @@ func DeleteTestOrigins(t *testing.T) {
 		}
 	}
 }
+
+func GetTestOriginsByParams(t *testing.T) {
+	if len(testData.Origins) < 1 {
+		t.Fatal("Need at least one Origin to test Get Origins by params")
+	}
+	origins := testData.Origins[0]
+	if origins.Name == nil || len(*origins.Name) == 0 {
+		t.Fatal("Found nil value in Origin name")
+	}
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("name", *origins.Name)
+	originByName, _, _ := TOSession.GetOrigins(opts)
+	if len(originByName.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByName.Response))
+	}
+	if originByName.Response[0].DeliveryServiceID == nil {
+		t.Fatal("Found nil value in delivery service")
+	}
+	if originByName.Response[0].CachegroupID == nil {
+		t.Fatal("Found nil value in Cachegroup")
+	}
+	if originByName.Response[0].CoordinateID == nil {
+		t.Fatal("Found nil value in Coordinate")
+	}
+	if originByName.Response[0].ProfileID == nil {
+		t.Fatal("Found nil value in Profile")
+	}
+	if originByName.Response[0].IsPrimary == nil {
+		t.Fatal("Found nil value in IsPrimary field")
+	}
+
+	//Get Origins by DSID
+	dsId := *originByName.Response[0].DeliveryServiceID
+	opts.QueryParameters.Del("name")
+	opts.QueryParameters.Set("deliveryservice", strconv.Itoa(dsId))
+	originByDs, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by DeliveryService ID: %v - alerts: %+v", err, originByDs.Alerts)
+	}
+	if len(originByDs.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByDs.Response))
+	}
+
+	//Get Origins by Cachegroup
+	cachegroupID := *originByName.Response[0].CachegroupID
+	opts.QueryParameters.Del("deliveryservice")
+	opts.QueryParameters.Set("cachegroup", strconv.Itoa(cachegroupID))
+	originByCg, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Cachegroup ID: %v - alerts: %+v", err, originByCg.Alerts)
+	}
+	if len(originByCg.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Cachegroups, but found %d", len(originByCg.Response))
+	}
+
+	//Get Origins by Coordinate
+	CoordinateID := *originByName.Response[0].CoordinateID
+	opts.QueryParameters.Del("cachegroup")
+	opts.QueryParameters.Set("coordinate", strconv.Itoa(CoordinateID))
+	originByCoordinate, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Coordinate ID: %v - alerts: %+v", err, originByCoordinate.Alerts)
+	}
+	if len(originByCoordinate.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Coordinate, but found %d", len(originByCoordinate.Response))
+	}
+
+	//Get Origins by Profile
+	profileId := *originByName.Response[0].ProfileID
+	opts.QueryParameters.Del("coordinate")
+	opts.QueryParameters.Set("profileId", strconv.Itoa(profileId))
+	originByProfile, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Profile ID: %v - alerts: %+v", err, originByProfile.Alerts)
+	}
+	if len(originByProfile.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Profile, but found %d", len(originByProfile.Response))
+	}
+
+	//Get Origins by Primary
+	isPrimary := *originByName.Response[0].IsPrimary
+	opts.QueryParameters.Del("profileId")
+	opts.QueryParameters.Set("isPrimary", strconv.FormatBool(isPrimary))
+	originByPrimary, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Primary ID: %v - alerts: %+v", err, originByPrimary.Alerts)
+	}
+	if len(originByPrimary.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Primary, but found %d", len(originByPrimary.Response))
+	}
+
+	//Get Origins by Tenant
+	tenant := *originByName.Response[0].TenantID
+	opts.QueryParameters.Del("isPrimary")
+	opts.QueryParameters.Set("tenant", strconv.Itoa(tenant))
+	originByTenant, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Tenant ID: %v - alerts: %+v", err, originByTenant.Alerts)
+	}
+	if len(originByTenant.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Tenant, but found %d", len(originByTenant.Response))
+	}
+}
+
+func GetTestOriginsByInvalidParams(t *testing.T) {

Review comment:
       Do we need to test negative cases for `name`, `primary` and `dsid`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] dmohan001c commented on a change in pull request #5960: Add TO Client API for Origin Automation

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5960:
URL: https://github.com/apache/trafficcontrol/pull/5960#discussion_r678313937



##########
File path: traffic_ops/testing/api/v4/origins_test.go
##########
@@ -374,3 +473,411 @@ func DeleteTestOrigins(t *testing.T) {
 		}
 	}
 }
+
+func GetTestOriginsByParams(t *testing.T) {
+	if len(testData.Origins) < 1 {
+		t.Fatal("Need at least one Origin to test Get Origins by params")
+	}
+	origins := testData.Origins[0]
+	if origins.Name == nil || len(*origins.Name) == 0 {
+		t.Fatal("Found nil value in Origin name")
+	}
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("name", *origins.Name)
+	originByName, _, _ := TOSession.GetOrigins(opts)
+	if len(originByName.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByName.Response))
+	}
+	if originByName.Response[0].DeliveryServiceID == nil {
+		t.Fatal("Found nil value in delivery service")
+	}
+	if originByName.Response[0].CachegroupID == nil {
+		t.Fatal("Found nil value in Cachegroup")
+	}
+	if originByName.Response[0].CoordinateID == nil {
+		t.Fatal("Found nil value in Coordinate")
+	}
+	if originByName.Response[0].ProfileID == nil {
+		t.Fatal("Found nil value in Profile")
+	}
+	if originByName.Response[0].IsPrimary == nil {
+		t.Fatal("Found nil value in IsPrimary field")
+	}
+
+	//Get Origins by DSID
+	dsId := *originByName.Response[0].DeliveryServiceID
+	opts.QueryParameters.Del("name")
+	opts.QueryParameters.Set("deliveryservice", strconv.Itoa(dsId))
+	originByDs, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by DeliveryService ID: %v - alerts: %+v", err, originByDs.Alerts)
+	}
+	if len(originByDs.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByDs.Response))
+	}
+
+	//Get Origins by Cachegroup
+	cachegroupID := *originByName.Response[0].CachegroupID
+	opts.QueryParameters.Del("deliveryservice")
+	opts.QueryParameters.Set("cachegroup", strconv.Itoa(cachegroupID))
+	originByCg, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Cachegroup ID: %v - alerts: %+v", err, originByCg.Alerts)
+	}
+	if len(originByCg.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Cachegroups, but found %d", len(originByCg.Response))
+	}
+
+	//Get Origins by Coordinate
+	CoordinateID := *originByName.Response[0].CoordinateID
+	opts.QueryParameters.Del("cachegroup")
+	opts.QueryParameters.Set("coordinate", strconv.Itoa(CoordinateID))
+	originByCoordinate, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Coordinate ID: %v - alerts: %+v", err, originByCoordinate.Alerts)
+	}
+	if len(originByCoordinate.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Coordinate, but found %d", len(originByCoordinate.Response))
+	}
+
+	//Get Origins by Profile
+	profileId := *originByName.Response[0].ProfileID
+	opts.QueryParameters.Del("coordinate")
+	opts.QueryParameters.Set("profileId", strconv.Itoa(profileId))
+	originByProfile, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Profile ID: %v - alerts: %+v", err, originByProfile.Alerts)
+	}
+	if len(originByProfile.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Profile, but found %d", len(originByProfile.Response))
+	}
+
+	//Get Origins by Primary
+	isPrimary := *originByName.Response[0].IsPrimary
+	opts.QueryParameters.Del("profileId")
+	opts.QueryParameters.Set("isPrimary", strconv.FormatBool(isPrimary))
+	originByPrimary, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Primary ID: %v - alerts: %+v", err, originByPrimary.Alerts)
+	}
+	if len(originByPrimary.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Primary, but found %d", len(originByPrimary.Response))
+	}
+
+	//Get Origins by Tenant
+	tenant := *originByName.Response[0].TenantID
+	opts.QueryParameters.Del("isPrimary")
+	opts.QueryParameters.Set("tenant", strconv.Itoa(tenant))
+	originByTenant, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Tenant ID: %v - alerts: %+v", err, originByTenant.Alerts)
+	}
+	if len(originByTenant.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Tenant, but found %d", len(originByTenant.Response))
+	}
+}
+
+func GetTestOriginsByInvalidParams(t *testing.T) {

Review comment:
       I don't have negative tests for this scenario. I will add.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5960: Add TO Client API for Origin Automation

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5960:
URL: https://github.com/apache/trafficcontrol/pull/5960#discussion_r677891452



##########
File path: traffic_ops/testing/api/v4/origins_test.go
##########
@@ -374,3 +473,411 @@ func DeleteTestOrigins(t *testing.T) {
 		}
 	}
 }
+
+func GetTestOriginsByParams(t *testing.T) {
+	if len(testData.Origins) < 1 {
+		t.Fatal("Need at least one Origin to test Get Origins by params")
+	}
+	origins := testData.Origins[0]
+	if origins.Name == nil || len(*origins.Name) == 0 {
+		t.Fatal("Found nil value in Origin name")
+	}
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("name", *origins.Name)
+	originByName, _, _ := TOSession.GetOrigins(opts)
+	if len(originByName.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByName.Response))
+	}
+	if originByName.Response[0].DeliveryServiceID == nil {
+		t.Fatal("Found nil value in delivery service")
+	}
+	if originByName.Response[0].CachegroupID == nil {
+		t.Fatal("Found nil value in Cachegroup")
+	}
+	if originByName.Response[0].CoordinateID == nil {
+		t.Fatal("Found nil value in Coordinate")
+	}
+	if originByName.Response[0].ProfileID == nil {
+		t.Fatal("Found nil value in Profile")
+	}
+	if originByName.Response[0].IsPrimary == nil {
+		t.Fatal("Found nil value in IsPrimary field")
+	}
+
+	//Get Origins by DSID
+	dsId := *originByName.Response[0].DeliveryServiceID
+	opts.QueryParameters.Del("name")
+	opts.QueryParameters.Set("deliveryservice", strconv.Itoa(dsId))
+	originByDs, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by DeliveryService ID: %v - alerts: %+v", err, originByDs.Alerts)
+	}
+	if len(originByDs.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Delivery Service, but found %d", len(originByDs.Response))
+	}
+
+	//Get Origins by Cachegroup
+	cachegroupID := *originByName.Response[0].CachegroupID
+	opts.QueryParameters.Del("deliveryservice")
+	opts.QueryParameters.Set("cachegroup", strconv.Itoa(cachegroupID))
+	originByCg, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Cachegroup ID: %v - alerts: %+v", err, originByCg.Alerts)
+	}
+	if len(originByCg.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Cachegroups, but found %d", len(originByCg.Response))
+	}
+
+	//Get Origins by Coordinate
+	CoordinateID := *originByName.Response[0].CoordinateID
+	opts.QueryParameters.Del("cachegroup")
+	opts.QueryParameters.Set("coordinate", strconv.Itoa(CoordinateID))
+	originByCoordinate, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Coordinate ID: %v - alerts: %+v", err, originByCoordinate.Alerts)
+	}
+	if len(originByCoordinate.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Coordinate, but found %d", len(originByCoordinate.Response))
+	}
+
+	//Get Origins by Profile
+	profileId := *originByName.Response[0].ProfileID
+	opts.QueryParameters.Del("coordinate")
+	opts.QueryParameters.Set("profileId", strconv.Itoa(profileId))
+	originByProfile, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Profile ID: %v - alerts: %+v", err, originByProfile.Alerts)
+	}
+	if len(originByProfile.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Profile, but found %d", len(originByProfile.Response))
+	}
+
+	//Get Origins by Primary
+	isPrimary := *originByName.Response[0].IsPrimary
+	opts.QueryParameters.Del("profileId")
+	opts.QueryParameters.Set("isPrimary", strconv.FormatBool(isPrimary))
+	originByPrimary, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Primary ID: %v - alerts: %+v", err, originByPrimary.Alerts)
+	}
+	if len(originByPrimary.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Primary, but found %d", len(originByPrimary.Response))
+	}
+
+	//Get Origins by Tenant
+	tenant := *originByName.Response[0].TenantID
+	opts.QueryParameters.Del("isPrimary")
+	opts.QueryParameters.Set("tenant", strconv.Itoa(tenant))
+	originByTenant, _, err := TOSession.GetOrigins(opts)
+	if err != nil {
+		t.Errorf("cannot get Origin by Tenant ID: %v - alerts: %+v", err, originByTenant.Alerts)
+	}
+	if len(originByTenant.Response) < 1 {
+		t.Fatalf("Expected atleast one Origin for GET Origin by Tenant, but found %d", len(originByTenant.Response))
+	}
+}
+
+func GetTestOriginsByInvalidParams(t *testing.T) {

Review comment:
       Do we need to test negative cases for `name`, and `primary`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org