This is an automated email from the ASF dual-hosted git repository.
xiangfu 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 884dbdbb6e Fix flaky TableViewsTest (#11770)
884dbdbb6e is described below
commit 884dbdbb6e2242f65f9b1614bf96e304e7acd5de
Author: Xiaotian (Jackie) Jiang <[email protected]>
AuthorDate: Wed Oct 11 12:03:56 2023 -0700
Fix flaky TableViewsTest (#11770)
---
.../pinot/controller/api/TableViewsTest.java | 42 +++++++++-------------
1 file changed, 17 insertions(+), 25 deletions(-)
diff --git
a/pinot-controller/src/test/java/org/apache/pinot/controller/api/TableViewsTest.java
b/pinot-controller/src/test/java/org/apache/pinot/controller/api/TableViewsTest.java
index 178fb5720b..639542eab1 100644
---
a/pinot-controller/src/test/java/org/apache/pinot/controller/api/TableViewsTest.java
+++
b/pinot-controller/src/test/java/org/apache/pinot/controller/api/TableViewsTest.java
@@ -18,7 +18,6 @@
*/
package org.apache.pinot.controller.api;
-import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
@@ -34,12 +33,16 @@ import org.apache.pinot.spi.utils.InstanceTypeUtils;
import org.apache.pinot.spi.utils.JsonUtils;
import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.apache.pinot.util.TestUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
public class TableViewsTest extends ControllerTest {
@@ -67,37 +70,26 @@ public class TableViewsTest extends ControllerTest {
tableConfig = new
TableConfigBuilder(TableType.OFFLINE).setTableName(HYBRID_TABLE_NAME)
.setNumReplicas(DEFAULT_MIN_NUM_REPLICAS).build();
DEFAULT_INSTANCE.getHelixResourceManager().addTable(tableConfig);
-
- // add schema for realtime table
StreamConfig streamConfig =
FakeStreamConfigUtils.getDefaultLowLevelStreamConfigs(4);
tableConfig = new
TableConfigBuilder(TableType.REALTIME).setTableName(HYBRID_TABLE_NAME)
.setNumReplicas(DEFAULT_MIN_NUM_REPLICAS).setStreamConfigs(streamConfig.getStreamConfigsMap()).build();
DEFAULT_INSTANCE.getHelixResourceManager().addTable(tableConfig);
// Wait for external view get updated
- long endTime = System.currentTimeMillis() + 10_000L;
- while (System.currentTimeMillis() < endTime) {
- Thread.sleep(100L);
- TableViews.TableView tableView;
+ TestUtils.waitForCondition(aVoid -> {
try {
- tableView = getTableView(OFFLINE_TABLE_NAME, TableViews.EXTERNALVIEW,
null);
- } catch (IOException e) {
- // Table may not be created yet.
- continue;
- }
- if ((tableView._offline == null) || (tableView._offline.size() != 1)) {
- continue;
- }
- tableView = getTableView(HYBRID_TABLE_NAME, TableViews.EXTERNALVIEW,
null);
- if (tableView._offline == null) {
- continue;
+ TableViews.TableView tableView = getTableView(OFFLINE_TABLE_NAME,
TableViews.EXTERNALVIEW, null);
+ if (tableView._offline == null || tableView._offline.size() != 1) {
+ return false;
+ }
+ tableView = getTableView(HYBRID_TABLE_NAME, TableViews.EXTERNALVIEW,
null);
+ return tableView._offline != null && tableView._realtime != null
+ && tableView._realtime.size() == DEFAULT_NUM_SERVER_INSTANCES;
+ } catch (Exception e) {
+ // Expected before external view is created
+ return false;
}
- if ((tableView._realtime == null) || (tableView._realtime.size() !=
DEFAULT_NUM_SERVER_INSTANCES)) {
- continue;
- }
- return;
- }
- fail("Failed to get external view updated");
+ }, 10_000L, "Failed to get external view updated");
}
@DataProvider(name = "viewProvider")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]