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/05/26 11:57:28 UTC

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

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


   ## 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] ocket8888 merged pull request #5889: Add TO Client API for Cachegroup Automation

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


   


-- 
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] ocket8888 merged pull request #5889: Add TO Client API for Cachegroup Automation

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


   


-- 
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 #5889: Add TO Client API for Cachegroup Automation

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



##########
File path: traffic_ops/testing/api/v4/cachegroups_test.go
##########
@@ -835,3 +839,68 @@ func GetTestPaginationSupportCg(t *testing.T) {
 		t.Errorf("expected GET cachegroup to return an error for page is not a positive integer, actual error: %v - alerts: %+v", err, resp.Alerts)
 	}
 }
+
+func GetTestCacheGroupsByInvalidId(t *testing.T) {
+	opts := client.NewRequestOptions()
+	// Retrieve the CacheGroup to check CacheGroup name got updated
+	opts.QueryParameters.Set("id", "10000")
+	resp, _, _ := TOSession.GetCacheGroups(opts)
+	if len(resp.Response) > 0 {
+		t.Errorf("Expected 0 response, but got many %v", resp)
+	}
+}
+
+func GetTestCacheGroupsByInvalidType(t *testing.T) {
+	opts := client.NewRequestOptions()
+	// Retrieve the CacheGroup to check CacheGroup name got updated
+	opts.QueryParameters.Set("type", "10000")
+	resp, _, _ := TOSession.GetCacheGroups(opts)
+	if len(resp.Response) > 0 {
+		t.Errorf("Expected 0 response, but got many %v", resp)
+	}
+}
+
+func GetTestCacheGroupsByType(t *testing.T) {
+	if len(testData.CacheGroups) < 1 {
+		t.Fatal("Need at least one Cache Group to test updating Cache Groups")
+	}
+	firstCG := testData.CacheGroups[0]
+
+	if firstCG.Name == nil {
+		t.Fatal("Found Cache Group with null or undefined name in testing data")
+	}
+
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("name", *firstCG.Name)
+
+	resp, _, err := TOSession.GetCacheGroups(opts)
+	if err != nil {
+		t.Fatalf("cannot get Cache Group '%s': %v - alerts: %+v", *firstCG.Name, err, resp.Alerts)
+	}
+	if len(resp.Response) < 1 {
+		t.Fatalf("Expected exactly one Cache Group to exist with name '%s', but got: %d", *firstCG.Name, len(resp.Response))

Review comment:
       updated the error message.




-- 
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 closed pull request #5889: Add TO Client API for Cachegroup Automation

Posted by GitBox <gi...@apache.org>.
dmohan001c closed pull request #5889:
URL: https://github.com/apache/trafficcontrol/pull/5889


   


-- 
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] ocket8888 commented on a change in pull request #5889: Add TO Client API for Cachegroup Automation

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



##########
File path: traffic_ops/testing/api/v4/cachegroups_test.go
##########
@@ -835,3 +839,68 @@ func GetTestPaginationSupportCg(t *testing.T) {
 		t.Errorf("expected GET cachegroup to return an error for page is not a positive integer, actual error: %v - alerts: %+v", err, resp.Alerts)
 	}
 }
+
+func GetTestCacheGroupsByInvalidId(t *testing.T) {
+	opts := client.NewRequestOptions()
+	// Retrieve the CacheGroup to check CacheGroup name got updated
+	opts.QueryParameters.Set("id", "10000")
+	resp, _, _ := TOSession.GetCacheGroups(opts)
+	if len(resp.Response) > 0 {
+		t.Errorf("Expected 0 response, but got many %v", resp)
+	}
+}
+
+func GetTestCacheGroupsByInvalidType(t *testing.T) {
+	opts := client.NewRequestOptions()
+	// Retrieve the CacheGroup to check CacheGroup name got updated
+	opts.QueryParameters.Set("type", "10000")
+	resp, _, _ := TOSession.GetCacheGroups(opts)
+	if len(resp.Response) > 0 {
+		t.Errorf("Expected 0 response, but got many %v", resp)
+	}
+}
+
+func GetTestCacheGroupsByType(t *testing.T) {
+	if len(testData.CacheGroups) < 1 {
+		t.Fatal("Need at least one Cache Group to test updating Cache Groups")
+	}
+	firstCG := testData.CacheGroups[0]
+
+	if firstCG.Name == nil {
+		t.Fatal("Found Cache Group with null or undefined name in testing data")
+	}
+
+	opts := client.NewRequestOptions()
+	opts.QueryParameters.Set("name", *firstCG.Name)
+
+	resp, _, err := TOSession.GetCacheGroups(opts)
+	if err != nil {
+		t.Fatalf("cannot get Cache Group '%s': %v - alerts: %+v", *firstCG.Name, err, resp.Alerts)
+	}
+	if len(resp.Response) < 1 {
+		t.Fatalf("Expected exactly one Cache Group to exist with name '%s', but got: %d", *firstCG.Name, len(resp.Response))

Review comment:
       If the expectation is that "exactly one" exists, the condition should check for the length being exactly one or not, instead of merely less than one.




-- 
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] ocket8888 closed pull request #5889: Add TO Client API for Cachegroup Automation

Posted by GitBox <gi...@apache.org>.
ocket8888 closed pull request #5889:
URL: https://github.com/apache/trafficcontrol/pull/5889


   


-- 
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