Skip to content

Commit

Permalink
Fix flaky OfflineClusterIntegrationTest on server response size tests (
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackie-Jiang authored Nov 1, 2023
1 parent 8d49b11 commit 168d630
Showing 1 changed file with 32 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,19 +626,21 @@ public void testMaxServerResponseSizeQueryOption()
throws Exception {
String queryWithOption = "SET maxServerResponseSizeBytes=1000; " + SELECT_STAR_QUERY;
JsonNode response = postQuery(queryWithOption);
assert response.get("exceptions").size() > 0;
int errorCode = response.get("exceptions").get(0).get("errorCode").asInt();
assertEquals(errorCode, 503);
JsonNode exceptions = response.get("exceptions");
assertFalse(exceptions.isEmpty());
int errorCode = exceptions.get(0).get("errorCode").asInt();
assertEquals(errorCode, QueryException.QUERY_CANCELLATION_ERROR_CODE);
}

@Test
public void testMaxQueryResponseSizeQueryOption()
throws Exception {
String queryWithOption = "SET maxQueryResponseSizeBytes=1000; " + SELECT_STAR_QUERY;
JsonNode response = postQuery(queryWithOption);
assert response.get("exceptions").size() > 0;
int errorCode = response.get("exceptions").get(0).get("errorCode").asInt();
assertEquals(errorCode, 503);
JsonNode exceptions = response.get("exceptions");
assertFalse(exceptions.isEmpty());
int errorCode = exceptions.get(0).get("errorCode").asInt();
assertEquals(errorCode, QueryException.QUERY_CANCELLATION_ERROR_CODE);
}

@Test
Expand All @@ -649,16 +651,13 @@ public void testMaxQueryResponseSizeTableConfig() throws Exception {

TestUtils.waitForCondition(aVoid -> {
try {
// Server should return an exception
// Server should return exception after the table config is picked up
JsonNode response = postQuery(SELECT_STAR_QUERY);
assert response.get("exceptions").size() > 0;
int errorCode = response.get("exceptions").get(0).get("errorCode").asInt();
if (errorCode == 503) {
return true;
}
return false;
JsonNode exceptions = response.get("exceptions");
return !exceptions.isEmpty()
&& exceptions.get(0).get("errorCode").asInt() == QueryException.QUERY_CANCELLATION_ERROR_CODE;
} catch (Exception e) {
return false;
throw new RuntimeException(e);
}
}, 60_000L, "Failed to execute query");

Expand All @@ -667,14 +666,11 @@ public void testMaxQueryResponseSizeTableConfig() throws Exception {

TestUtils.waitForCondition(aVoid -> {
try {
// Server should not return an exception
// Server should not return exception after the table config is picked up
JsonNode response = postQuery(SELECT_STAR_QUERY);
if (response.get("exceptions").size() == 0) {
return true;
}
return false;
return response.get("exceptions").isEmpty();
} catch (Exception e) {
return false;
throw new RuntimeException(e);
}
}, 60_000L, "Failed to execute query");
}
Expand All @@ -687,16 +683,13 @@ public void testMaxServerResponseSizeTableConfig() throws Exception {

TestUtils.waitForCondition(aVoid -> {
try {
// Server should return an exception
// Server should return exception after the table config is picked up
JsonNode response = postQuery(SELECT_STAR_QUERY);
assert response.get("exceptions").size() > 0;
int errorCode = response.get("exceptions").get(0).get("errorCode").asInt();
if (errorCode == 503) {
return true;
}
return false;
JsonNode exceptions = response.get("exceptions");
return !exceptions.isEmpty()
&& exceptions.get(0).get("errorCode").asInt() == QueryException.QUERY_CANCELLATION_ERROR_CODE;
} catch (Exception e) {
return false;
throw new RuntimeException(e);
}
}, 60_000L, "Failed to execute query");

Expand All @@ -705,14 +698,11 @@ public void testMaxServerResponseSizeTableConfig() throws Exception {

TestUtils.waitForCondition(aVoid -> {
try {
// Server should not return an exception
// Server should not return exception after the table config is picked up
JsonNode response = postQuery(SELECT_STAR_QUERY);
if (response.get("exceptions").size() == 0) {
return true;
}
return false;
return response.get("exceptions").isEmpty();
} catch (Exception e) {
return false;
throw new RuntimeException(e);
}
}, 60_000L, "Failed to execute query");
}
Expand All @@ -725,16 +715,13 @@ public void testMaxResponseSizeTableConfigOrdering() throws Exception {

TestUtils.waitForCondition(aVoid -> {
try {
// Server should return an exception
// Server should return exception after the table config is picked up
JsonNode response = postQuery(SELECT_STAR_QUERY);
assert response.get("exceptions").size() > 0;
int errorCode = response.get("exceptions").get(0).get("errorCode").asInt();
if (errorCode == 503) {
return true;
}
return false;
JsonNode exceptions = response.get("exceptions");
return !exceptions.isEmpty()
&& exceptions.get(0).get("errorCode").asInt() == QueryException.QUERY_CANCELLATION_ERROR_CODE;
} catch (Exception e) {
return false;
throw new RuntimeException(e);
}
}, 60_000L, "Failed to execute query");

Expand All @@ -743,14 +730,11 @@ public void testMaxResponseSizeTableConfigOrdering() throws Exception {

TestUtils.waitForCondition(aVoid -> {
try {
// Server should not return an exception
// Server should not return exception after the table config is picked up
JsonNode response = postQuery(SELECT_STAR_QUERY);
if (response.get("exceptions").size() == 0) {
return true;
}
return false;
return response.get("exceptions").isEmpty();
} catch (Exception e) {
return false;
throw new RuntimeException(e);
}
}, 60_000L, "Failed to execute query");
}
Expand Down

0 comments on commit 168d630

Please sign in to comment.