You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ap...@apache.org on 2021/06/09 21:49:32 UTC
[incubator-pinot] branch master updated: improve robustness of
basic auth (tls) realtime integration tests (#7038)
This is an automated email from the ASF dual-hosted git repository.
apucher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 2de40fd improve robustness of basic auth (tls) realtime integration tests (#7038)
2de40fd is described below
commit 2de40fde8051c2c0281416c2da11c179c2190435
Author: Alexander Pucher <ap...@apache.org>
AuthorDate: Wed Jun 9 14:49:16 2021 -0700
improve robustness of basic auth (tls) realtime integration tests (#7038)
Add checked wait to BasicAuth(Tls)RealtimeIntegrationTest to reduce flakiness on slow environments.
---
.../test/java/org/apache/pinot/util/TestUtils.java | 30 ++++++++++++++++++++++
.../tests/BasicAuthRealtimeIntegrationTest.java | 21 +++++++--------
.../tests/BasicAuthTlsRealtimeIntegrationTest.java | 21 +++++++--------
3 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/pinot-common/src/test/java/org/apache/pinot/util/TestUtils.java b/pinot-common/src/test/java/org/apache/pinot/util/TestUtils.java
index da175b7..d2775f2 100644
--- a/pinot-common/src/test/java/org/apache/pinot/util/TestUtils.java
+++ b/pinot-common/src/test/java/org/apache/pinot/util/TestUtils.java
@@ -106,4 +106,34 @@ public class TestUtils {
Assert.fail("Failed to meet condition in " + timeoutMs + "ms" + errorMessageSuffix);
}
}
+
+ /**
+ * Wait for a result to be returned
+ *
+ * @param supplier result value supplier
+ * @param timeoutMs timeout
+ * @return result value (non-throwable)
+ * @throws InterruptedException if {@code Thread.sleep()} is interrupted
+ */
+ public static <T> T waitForResult(SupplierWithException<T> supplier, long timeoutMs)
+ throws InterruptedException {
+ long tEnd = System.currentTimeMillis() + timeoutMs;
+ while (tEnd > System.currentTimeMillis()) {
+ try {
+ return supplier.get();
+ } catch (Throwable ignore) {
+ // ignore
+ }
+
+ Thread.sleep(1000);
+ }
+
+ throw new IllegalStateException("Failed to return result in " + timeoutMs + "ms");
+ }
+
+ @FunctionalInterface
+ public interface SupplierWithException<T> {
+ T get()
+ throws Exception;
+ }
}
diff --git a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthRealtimeIntegrationTest.java b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthRealtimeIntegrationTest.java
index fbe6cad..75c7157 100644
--- a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthRealtimeIntegrationTest.java
+++ b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthRealtimeIntegrationTest.java
@@ -169,21 +169,22 @@ public class BasicAuthRealtimeIntegrationTest extends BaseClusterIntegrationTest
// schedule offline segment generation
Assert.assertNotNull(_controllerStarter.getTaskManager().scheduleTasks());
- Thread.sleep(5000);
- ResultSetGroup resultAfterOffline = getPinotConnection().execute(query);
+ // wait for offline segments
+ JsonNode offlineSegments = TestUtils.waitForResult(() -> {
+ JsonNode segmentSets = JsonUtils.stringToJsonNode(
+ sendGetRequest(_controllerRequestURLBuilder.forSegmentListAPI(getTableName()), AUTH_HEADER));
+ JsonNode currentOfflineSegments =
+ new IntRange(0, segmentSets.size()).stream().map(segmentSets::get).filter(s -> s.has("OFFLINE"))
+ .map(s -> s.get("OFFLINE")).findFirst().get();
+ Assert.assertFalse(currentOfflineSegments.isEmpty());
+ return currentOfflineSegments;
+ }, 30000);
// Verify constant row count
+ ResultSetGroup resultAfterOffline = getPinotConnection().execute(query);
Assert.assertEquals(resultBeforeOffline.getResultSet(0).getLong(0), resultAfterOffline.getResultSet(0).getLong(0));
- // list offline segments
- JsonNode segmentSets = JsonUtils
- .stringToJsonNode(sendGetRequest(_controllerRequestURLBuilder.forSegmentListAPI(getTableName()), AUTH_HEADER));
- JsonNode offlineSegments =
- new IntRange(0, segmentSets.size()).stream().map(segmentSets::get).filter(s -> s.has("OFFLINE"))
- .map(s -> s.get("OFFLINE")).findFirst().get();
- Assert.assertFalse(offlineSegments.isEmpty());
-
// download and sanity-check size of offline segment(s)
for (int i = 0; i < offlineSegments.size(); i++) {
String segment = offlineSegments.get(i).asText();
diff --git a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthTlsRealtimeIntegrationTest.java b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthTlsRealtimeIntegrationTest.java
index db98f2f..de222cb 100644
--- a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthTlsRealtimeIntegrationTest.java
+++ b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthTlsRealtimeIntegrationTest.java
@@ -230,21 +230,22 @@ public class BasicAuthTlsRealtimeIntegrationTest extends BaseClusterIntegrationT
// schedule offline segment generation
Assert.assertNotNull(_controllerStarter.getTaskManager().scheduleTasks());
- Thread.sleep(5000);
- ResultSetGroup resultAfterOffline = getPinotConnection().execute(query);
+ // wait for offline segments
+ JsonNode offlineSegments = TestUtils.waitForResult(() -> {
+ JsonNode segmentSets = JsonUtils.stringToJsonNode(
+ sendGetRequest(_controllerRequestURLBuilder.forSegmentListAPI(getTableName()), AUTH_HEADER));
+ JsonNode currentOfflineSegments =
+ new IntRange(0, segmentSets.size()).stream().map(segmentSets::get).filter(s -> s.has("OFFLINE"))
+ .map(s -> s.get("OFFLINE")).findFirst().get();
+ Assert.assertFalse(currentOfflineSegments.isEmpty());
+ return currentOfflineSegments;
+ }, 30000);
// Verify constant row count
+ ResultSetGroup resultAfterOffline = getPinotConnection().execute(query);
Assert.assertEquals(resultBeforeOffline.getResultSet(0).getLong(0), resultAfterOffline.getResultSet(0).getLong(0));
- // list offline segments
- JsonNode segmentSets = JsonUtils
- .stringToJsonNode(sendGetRequest(_controllerRequestURLBuilder.forSegmentListAPI(getTableName()), AUTH_HEADER));
- JsonNode offlineSegments =
- new IntRange(0, segmentSets.size()).stream().map(segmentSets::get).filter(s -> s.has("OFFLINE"))
- .map(s -> s.get("OFFLINE")).findFirst().get();
- Assert.assertFalse(offlineSegments.isEmpty());
-
// download and sanity-check size of offline segment(s)
for (int i = 0; i < offlineSegments.size(); i++) {
String segment = offlineSegments.get(i).asText();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org