You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ne...@apache.org on 2019/01/24 19:36:23 UTC
[incubator-pinot] branch segment_status_checker_integration_test
updated: Fix tests in SegmentStatusCheckerTest
This is an automated email from the ASF dual-hosted git repository.
nehapawar pushed a commit to branch segment_status_checker_integration_test
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/segment_status_checker_integration_test by this push:
new f45b48d Fix tests in SegmentStatusCheckerTest
f45b48d is described below
commit f45b48d8f17b92867566d08aa05302800ccb16b8
Author: Neha Pawar <np...@linkedin.com>
AuthorDate: Thu Jan 24 11:36:10 2019 -0800
Fix tests in SegmentStatusCheckerTest
---
.../controller/helix/SegmentStatusChecker.java | 12 ++++--
.../controller/helix/SegmentStatusCheckerTest.java | 45 ++++++++++++----------
2 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/SegmentStatusChecker.java b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/SegmentStatusChecker.java
index ef6c251..3cb1ee4 100644
--- a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/SegmentStatusChecker.java
+++ b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/SegmentStatusChecker.java
@@ -122,6 +122,12 @@ public class SegmentStatusChecker extends ControllerPeriodicTask {
IdealState idealState = _pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+ if (idealState == null) {
+ LOGGER.warn("Table {} has null ideal state. Skipping segment status checks", tableNameWithType);
+ resetTableMetrics(tableNameWithType);
+ return;
+ }
+
if (!idealState.isEnabled()) {
if (_logDisabledTables) {
LOGGER.warn("Table {} is disabled. Skipping segment status checks", tableNameWithType);
@@ -131,12 +137,10 @@ public class SegmentStatusChecker extends ControllerPeriodicTask {
return;
}
- if ((idealState == null) || (idealState.getPartitionSet().isEmpty())) {
+ if (idealState.getPartitionSet().isEmpty()) {
int nReplicasFromIdealState = 1;
try {
- if (idealState != null) {
- nReplicasFromIdealState = Integer.valueOf(idealState.getReplicas());
- }
+ nReplicasFromIdealState = Integer.valueOf(idealState.getReplicas());
} catch (NumberFormatException e) {
// Ignore
}
diff --git a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/SegmentStatusCheckerTest.java b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/SegmentStatusCheckerTest.java
index db33605..c3cddaaf 100644
--- a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/SegmentStatusCheckerTest.java
+++ b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/SegmentStatusCheckerTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.pinot.controller.helix;
+import com.google.common.collect.Lists;
import com.yammer.metrics.core.MetricsRegistry;
import java.util.ArrayList;
import java.util.List;
@@ -266,7 +267,7 @@ public class SegmentStatusCheckerTest {
@Test
public void missingIdealTest() throws Exception {
final String tableName = "myTable_REALTIME";
- List<String> allTableNames = new ArrayList<String>();
+ List<String> allTableNames = new ArrayList<>();
allTableNames.add(tableName);
{
@@ -288,9 +289,9 @@ public class SegmentStatusCheckerTest {
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName,
ControllerGauge.SEGMENTS_IN_ERROR_STATE), Long.MIN_VALUE);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName,
- ControllerGauge.NUMBER_OF_REPLICAS), 1);
+ ControllerGauge.NUMBER_OF_REPLICAS), Long.MIN_VALUE);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName,
- ControllerGauge.PERCENT_OF_REPLICAS), 100);
+ ControllerGauge.PERCENT_OF_REPLICAS), Long.MIN_VALUE);
}
@Test
@@ -391,11 +392,20 @@ public class SegmentStatusCheckerTest {
}
@Test
- public void noIdealState() throws Exception {
- final String tableName = "myTable_REALTIME";
+ public void disabledTableTest() throws Exception {
+
+ final String tableName = "myTable_OFFLINE";
List<String> allTableNames = new ArrayList<String>();
allTableNames.add(tableName);
- IdealState idealState = null;
+ IdealState idealState = new IdealState(tableName);
+ // disable table in idealstate
+ idealState.enable(false);
+ idealState.setPartitionState("myTable_OFFLINE", "pinot1", "OFFLINE");
+ idealState.setPartitionState("myTable_OFFLINE", "pinot2", "OFFLINE");
+ idealState.setPartitionState("myTable_OFFLINE", "pinot3", "OFFLINE");
+ idealState.setReplicas("1");
+ idealState.setRebalanceMode(IdealState.RebalanceMode.CUSTOMIZED);
+
{
helixResourceManager = mock(PinotHelixResourceManager.class);
when(helixResourceManager.getAllTables()).thenReturn(allTableNames);
@@ -410,30 +420,25 @@ public class SegmentStatusCheckerTest {
metricsRegistry = new MetricsRegistry();
controllerMetrics = new ControllerMetrics(metricsRegistry);
segmentStatusChecker = new SegmentStatusChecker(helixResourceManager, config, controllerMetrics);
+ // verify state before test
+ Assert.assertEquals(controllerMetrics.getValueOfGlobalGauge(
+ ControllerGauge.DISABLED_TABLE_COUNT), 0);
+ // update metrics
segmentStatusChecker.init();
segmentStatusChecker.run();
- Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName,
- ControllerGauge.SEGMENTS_IN_ERROR_STATE), Long.MIN_VALUE);
- Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName,
- ControllerGauge.NUMBER_OF_REPLICAS), 1);
- Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName,
- ControllerGauge.PERCENT_OF_REPLICAS), 100);
- Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName,
- ControllerGauge.PERCENT_SEGMENTS_AVAILABLE), 100);
+ Assert.assertEquals(controllerMetrics.getValueOfGlobalGauge(
+ ControllerGauge.DISABLED_TABLE_COUNT), 1);
}
+
@Test
- public void disabledTableTest() throws Exception {
+ public void disabledEmptyTableTest() throws Exception {
final String tableName = "myTable_OFFLINE";
- List<String> allTableNames = new ArrayList<String>();
- allTableNames.add(tableName);
+ List<String> allTableNames = Lists.newArrayList(tableName);
IdealState idealState = new IdealState(tableName);
// disable table in idealstate
idealState.enable(false);
- idealState.setPartitionState("myTable_OFFLINE", "pinot1", "OFFLINE");
- idealState.setPartitionState("myTable_OFFLINE", "pinot2", "OFFLINE");
- idealState.setPartitionState("myTable_OFFLINE", "pinot3", "OFFLINE");
idealState.setReplicas("1");
idealState.setRebalanceMode(IdealState.RebalanceMode.CUSTOMIZED);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org