You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "desaikomal (via GitHub)" <gi...@apache.org> on 2023/06/13 15:08:27 UTC

[GitHub] [helix] desaikomal opened a new pull request, #2532: Fix CI: testPostRequestFormat::TestCustomRestClient

desaikomal opened a new pull request, #2532:
URL: https://github.com/apache/helix/pull/2532

   ### Issues
   
   - [x] My PR addresses the following Helix issues and references them in the PR description:
   Fixes #2402 and Fixes #2188 
   
   ### Description
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   The method testPostRequestFormat tries to connect to an external site: http://httpbin.org which is Echo server which will reply back with whatever has been sent.
   But the end-point sometimes gives out 504, ie. gateway timeout.
   
   This makes the test unstable. So add the check to see if status is OK, then only validate the rest of the fields.
   
   
   ### Tests
   
   - [ ] The following tests are written for this issue:
   
   - The following is the result of the "mvn test" command on the appropriate module:
   
   mvn test in progress.
   
   ### Changes that Break Backward Compatibility (Optional)
   
   - My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:
   
   (Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
   
   ### Documentation (Optional)
   
   - In case of new functionality, my PR adds documentation in the following wiki page:
   
   (Link the GitHub wiki you added)
   
   ### Commits
   
   - My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - My diff has been formatted using helix-style.xml 
   (helix-style-intellij.xml if IntelliJ IDE is used)
   


-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] desaikomal commented on pull request #2532: Fix CI: testPostRequestFormat::TestCustomRestClient

Posted by "desaikomal (via GitHub)" <gi...@apache.org>.
desaikomal commented on PR #2532:
URL: https://github.com/apache/helix/pull/2532#issuecomment-1601432545

   Thanks @GrantPSpencer, @rahulrane50 and @xyuanlu for reviewing the change. This change has been approved by @xyuanlu and ready to merge.
   Commit message: Test is trying to reach endpoint echobin.org which MAY not be available. So test only when the site is healthy. 


-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] desaikomal commented on a diff in pull request #2532: Fix CI: testPostRequestFormat::TestCustomRestClient

Posted by "desaikomal (via GitHub)" <gi...@apache.org>.
desaikomal commented on code in PR #2532:
URL: https://github.com/apache/helix/pull/2532#discussion_r1237471318


##########
helix-rest/src/test/java/org/apache/helix/rest/client/TestCustomRestClient.java:
##########
@@ -158,11 +158,12 @@ public void testPostRequestFormat() throws IOException {
     final String echoServer = "http://httpbin.org/post";
     CustomRestClientImpl customRestClient = new CustomRestClientImpl(HttpClients.createDefault());
     HttpResponse response = customRestClient.post(echoServer, Collections.emptyMap());
-    JsonNode json = customRestClient.getJsonObject(response);
+    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {

Review Comment:
   Thanks for review. Test is ECHOing the request to outside server. If you can't reach the outside server, test used to fail. That is why we validate only if we can successfully reach the end-point. Else part, we can't validate. 



-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] desaikomal commented on a diff in pull request #2532: Fix CI: testPostRequestFormat::TestCustomRestClient

Posted by "desaikomal (via GitHub)" <gi...@apache.org>.
desaikomal commented on code in PR #2532:
URL: https://github.com/apache/helix/pull/2532#discussion_r1232941199


##########
helix-rest/src/test/java/org/apache/helix/rest/client/TestCustomRestClient.java:
##########
@@ -158,11 +158,13 @@ public void testPostRequestFormat() throws IOException {
     final String echoServer = "http://httpbin.org/post";
     CustomRestClientImpl customRestClient = new CustomRestClientImpl(HttpClients.createDefault());
     HttpResponse response = customRestClient.post(echoServer, Collections.emptyMap());
-    JsonNode json = customRestClient.getJsonObject(response);
+    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+      JsonNode json = customRestClient.getJsonObject(response);
 
-    Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_OK);
-    Assert.assertEquals(json.get("headers").get("Accept").asText(), "application/json");
-    Assert.assertEquals(json.get("data").asText(), "{}");
+      Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_OK);

Review Comment:
   true, it is redundant. I was wondering if there is a better way to detect if the endpoint is accessible? i couldn't find any other way. do you have any suggestion?



-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rahulrane50 commented on a diff in pull request #2532: Fix CI: testPostRequestFormat::TestCustomRestClient

Posted by "rahulrane50 (via GitHub)" <gi...@apache.org>.
rahulrane50 commented on code in PR #2532:
URL: https://github.com/apache/helix/pull/2532#discussion_r1237430716


##########
helix-rest/src/test/java/org/apache/helix/rest/client/TestCustomRestClient.java:
##########
@@ -158,11 +158,12 @@ public void testPostRequestFormat() throws IOException {
     final String echoServer = "http://httpbin.org/post";
     CustomRestClientImpl customRestClient = new CustomRestClientImpl(HttpClients.createDefault());
     HttpResponse response = customRestClient.post(echoServer, Collections.emptyMap());
-    JsonNode json = customRestClient.getJsonObject(response);
+    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {

Review Comment:
   Shouldn't we assert in else block as well? Or we are expecting any other status code is fine?



-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] GrantPSpencer commented on a diff in pull request #2532: Fix CI: testPostRequestFormat::TestCustomRestClient

Posted by "GrantPSpencer (via GitHub)" <gi...@apache.org>.
GrantPSpencer commented on code in PR #2532:
URL: https://github.com/apache/helix/pull/2532#discussion_r1232827454


##########
helix-rest/src/test/java/org/apache/helix/rest/client/TestCustomRestClient.java:
##########
@@ -158,11 +158,13 @@ public void testPostRequestFormat() throws IOException {
     final String echoServer = "http://httpbin.org/post";
     CustomRestClientImpl customRestClient = new CustomRestClientImpl(HttpClients.createDefault());
     HttpResponse response = customRestClient.post(echoServer, Collections.emptyMap());
-    JsonNode json = customRestClient.getJsonObject(response);
+    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+      JsonNode json = customRestClient.getJsonObject(response);
 
-    Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_OK);
-    Assert.assertEquals(json.get("headers").get("Accept").asText(), "application/json");
-    Assert.assertEquals(json.get("data").asText(), "{}");
+      Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_OK);

Review Comment:
   Is this a redundant assertion? Above if statement already checks 
   `response.getStatusLine().getStatusCode() == HttpStatus.SC_OK`
   



-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] xyuanlu merged pull request #2532: Fix CI: testPostRequestFormat::TestCustomRestClient

Posted by "xyuanlu (via GitHub)" <gi...@apache.org>.
xyuanlu merged PR #2532:
URL: https://github.com/apache/helix/pull/2532


-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org