This is an automated email from the ASF dual-hosted git repository. jackie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push: new 34a5c944bd [FLaky test] Fix OfflineClusterIntegrationTest.testLiteralOnlyFunc() (#9736) 34a5c944bd is described below commit 34a5c944bd6ebb7e1eb7b6738d52ca853bb47424 Author: Xiaotian (Jackie) Jiang <17555551+jackie-ji...@users.noreply.github.com> AuthorDate: Fri Nov 4 22:07:56 2022 -0700 [FLaky test] Fix OfflineClusterIntegrationTest.testLiteralOnlyFunc() (#9736) --- .../tests/OfflineClusterIntegrationTest.java | 112 ++++++++++----------- 1 file changed, 53 insertions(+), 59 deletions(-) diff --git a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/OfflineClusterIntegrationTest.java b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/OfflineClusterIntegrationTest.java index a404c10ad8..bcecc3696a 100644 --- a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/OfflineClusterIntegrationTest.java +++ b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/OfflineClusterIntegrationTest.java @@ -97,7 +97,6 @@ public class OfflineClusterIntegrationTest extends BaseClusterIntegrationTestSet private static final int NUM_BROKERS = 1; private static final int NUM_SERVERS = 1; private static final int NUM_SEGMENTS = 12; - private static final long ONE_HOUR_IN_MS = TimeUnit.HOURS.toMillis(1); private static final String SEGMENT_UPLOAD_TEST_TABLE = "segmentUploadTestTable"; // For table config refresh test, make an expensive query to ensure the query won't finish in 5ms @@ -961,69 +960,64 @@ public class OfflineClusterIntegrationTest extends BaseClusterIntegrationTestSet @Test public void testLiteralOnlyFunc() throws Exception { - long currentTsMin = System.currentTimeMillis(); - long oneHourAgoTsMin = currentTsMin - ONE_HOUR_IN_MS; + long queryStartTimeMs = System.currentTimeMillis(); String sqlQuery = "SELECT 1, now() as currentTs, ago('PT1H') as oneHourAgoTs, 'abc', toDateTime(now(), 'yyyy-MM-dd z') as " + "today, now(), ago('PT1H'), encodeUrl('key1=value 1&key2=value@!$2&key3=value%3') as encodedUrl, " + "decodeUrl('key1%3Dvalue+1%26key2%3Dvalue%40%21%242%26key3%3Dvalue%253') as decodedUrl, toBase64" + "(toUtf8('hello!')) as toBase64, fromUtf8(fromBase64('aGVsbG8h')) as fromBase64"; - JsonNode response = postQuery(sqlQuery, _brokerBaseApiUrl); - long currentTsMax = System.currentTimeMillis(); - long oneHourAgoTsMax = currentTsMax - ONE_HOUR_IN_MS; - - assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(0).asText(), "1"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(1).asText(), "currentTs"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(2).asText(), "oneHourAgoTs"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(3).asText(), "abc"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(4).asText(), "today"); - String nowColumnName = response.get("resultTable").get("dataSchema").get("columnNames").get(5).asText(); - String oneHourAgoColumnName = response.get("resultTable").get("dataSchema").get("columnNames").get(6).asText(); - assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(7).asText(), "encodedUrl"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(8).asText(), "decodedUrl"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(9).asText(), "toBase64"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnNames").get(10).asText(), "fromBase64"); - assertTrue(Long.parseLong(nowColumnName) > currentTsMin); - assertTrue(Long.parseLong(nowColumnName) < currentTsMax); - assertTrue(Long.parseLong(oneHourAgoColumnName) > oneHourAgoTsMin); - assertTrue(Long.parseLong(oneHourAgoColumnName) < oneHourAgoTsMax); - - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(0).asText(), "LONG"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(1).asText(), "LONG"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(2).asText(), "LONG"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(3).asText(), "STRING"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(4).asText(), "STRING"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(5).asText(), "LONG"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(6).asText(), "LONG"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(7).asText(), "STRING"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(8).asText(), "STRING"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(9).asText(), "STRING"); - assertEquals(response.get("resultTable").get("dataSchema").get("columnDataTypes").get(10).asText(), "STRING"); - - int first = response.get("resultTable").get("rows").get(0).get(0).asInt(); - long second = response.get("resultTable").get("rows").get(0).get(1).asLong(); - long third = response.get("resultTable").get("rows").get(0).get(2).asLong(); - String fourth = response.get("resultTable").get("rows").get(0).get(3).asText(); - assertEquals(first, 1); - assertTrue(second > currentTsMin); - assertTrue(second < currentTsMax); - assertTrue(third > oneHourAgoTsMin); - assertTrue(third < oneHourAgoTsMax); - assertEquals(fourth, "abc"); - String todayStr = response.get("resultTable").get("rows").get(0).get(4).asText(); - String expectedTodayStr = - Instant.now().atZone(ZoneId.of("UTC")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd z")); - assertEquals(todayStr, expectedTodayStr); - long nowValue = response.get("resultTable").get("rows").get(0).get(5).asLong(); - assertEquals(nowValue, Long.parseLong(nowColumnName)); - long oneHourAgoValue = response.get("resultTable").get("rows").get(0).get(6).asLong(); - assertEquals(oneHourAgoValue, Long.parseLong(oneHourAgoColumnName)); - assertEquals(response.get("resultTable").get("rows").get(0).get(7).asText(), - "key1%3Dvalue+1%26key2%3Dvalue%40%21%242%26key3%3Dvalue%253"); - assertEquals(response.get("resultTable").get("rows").get(0).get(8).asText(), - "key1=value 1&key2=value@!$2&key3=value%3"); - assertEquals(response.get("resultTable").get("rows").get(0).get(9).asText(), "aGVsbG8h"); - assertEquals(response.get("resultTable").get("rows").get(0).get(10).asText(), "hello!"); + JsonNode response = postQuery(sqlQuery); + long queryEndTimeMs = System.currentTimeMillis(); + + JsonNode resultTable = response.get("resultTable"); + JsonNode dataSchema = resultTable.get("dataSchema"); + JsonNode columnNames = dataSchema.get("columnNames"); + assertEquals(columnNames.get(0).asText(), "1"); + assertEquals(columnNames.get(1).asText(), "currentTs"); + assertEquals(columnNames.get(2).asText(), "oneHourAgoTs"); + assertEquals(columnNames.get(3).asText(), "abc"); + assertEquals(columnNames.get(4).asText(), "today"); + String nowColumnName = columnNames.get(5).asText(); + String oneHourAgoColumnName = columnNames.get(6).asText(); + assertEquals(columnNames.get(7).asText(), "encodedUrl"); + assertEquals(columnNames.get(8).asText(), "decodedUrl"); + assertEquals(columnNames.get(9).asText(), "toBase64"); + assertEquals(columnNames.get(10).asText(), "fromBase64"); + + JsonNode columnDataTypes = dataSchema.get("columnDataTypes"); + assertEquals(columnDataTypes.get(0).asText(), "LONG"); + assertEquals(columnDataTypes.get(1).asText(), "LONG"); + assertEquals(columnDataTypes.get(2).asText(), "LONG"); + assertEquals(columnDataTypes.get(3).asText(), "STRING"); + assertEquals(columnDataTypes.get(4).asText(), "STRING"); + assertEquals(columnDataTypes.get(5).asText(), "LONG"); + assertEquals(columnDataTypes.get(6).asText(), "LONG"); + assertEquals(columnDataTypes.get(7).asText(), "STRING"); + assertEquals(columnDataTypes.get(8).asText(), "STRING"); + assertEquals(columnDataTypes.get(9).asText(), "STRING"); + assertEquals(columnDataTypes.get(10).asText(), "STRING"); + + JsonNode results = resultTable.get("rows").get(0); + assertEquals(results.get(0).asInt(), 1); + long nowResult = results.get(1).asLong(); + assertTrue(nowResult >= queryStartTimeMs); + assertTrue(nowResult <= queryEndTimeMs); + long oneHourAgoResult = results.get(2).asLong(); + assertTrue(oneHourAgoResult >= queryStartTimeMs - TimeUnit.HOURS.toMillis(1)); + assertTrue(oneHourAgoResult <= queryEndTimeMs - TimeUnit.HOURS.toMillis(1)); + assertEquals(results.get(3).asText(), "abc"); + String queryStartTimeDay = Instant.ofEpochMilli(queryStartTimeMs).atZone(ZoneId.of("UTC")) + .format(DateTimeFormatter.ofPattern("yyyy-MM-dd z")); + String queryEndTimeDay = Instant.ofEpochMilli(queryEndTimeMs).atZone(ZoneId.of("UTC")) + .format(DateTimeFormatter.ofPattern("yyyy-MM-dd z")); + String dateTimeResult = results.get(4).asText(); + assertTrue(dateTimeResult.equals(queryStartTimeDay) || dateTimeResult.equals(queryEndTimeDay)); + assertEquals(results.get(5).asText(), nowColumnName); + assertEquals(results.get(6).asText(), oneHourAgoColumnName); + assertEquals(results.get(7).asText(), "key1%3Dvalue+1%26key2%3Dvalue%40%21%242%26key3%3Dvalue%253"); + assertEquals(results.get(8).asText(), "key1=value 1&key2=value@!$2&key3=value%3"); + assertEquals(results.get(9).asText(), "aGVsbG8h"); + assertEquals(results.get(10).asText(), "hello!"); } @Test(dependsOnMethods = "testBloomFilterTriggering") --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org