Skip to content

Commit

Permalink
[apache/helix] -- Updated timeouts to use shorter timeouts [test]
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshukandwal committed Dec 14, 2023
1 parent 221ee13 commit 741d27d
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class ZKClientPool {
static final Map<String, ZkClient> _zkClientMap = new ConcurrentHashMap<>();
static final int DEFAULT_SESSION_TIMEOUT = 30 * 1000;
static final int DEFAULT_SESSION_TIMEOUT = 3 * 1000;

public static ZkClient getZkClient(String zkServer) {
// happy path that we cache the zkclient and it's still connected
Expand Down
4 changes: 2 additions & 2 deletions helix-core/src/test/java/org/apache/helix/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static public ZkServer startZkServer(final String zkAddress, final List<String>
FileUtils.deleteDirectory(new File(dataDir));
FileUtils.deleteDirectory(new File(logDir));
}
ZKClientPool.reset();
// ZKClientPool.reset();

IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
Expand All @@ -145,7 +145,7 @@ public void createDefaultNameSpace(ZkClient zkClient) {

int port = Integer.parseInt(zkAddress.substring(zkAddress.lastIndexOf(':') + 1));
ZkServer zkServer = new ZkServer(dataDir, logDir, defaultNameSpace, port);
zkServer.start();
timeIt(() -> zkServer.start());

return zkServer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ public void testCancellationWhenDisableResource() throws InterruptedException {
clusterConfig.stateTransitionCancelEnabled(true);
_configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);

// Wait for assignment done
Thread.sleep(2000);

// Disable the resource
_gSetupTool.getClusterManagementTool().enableResource(CLUSTER_NAME,
WorkflowGenerator.DEFAULT_TGT_DB, false);
Expand Down Expand Up @@ -160,8 +157,6 @@ public void testRebalancingCauseCancellation() throws InterruptedException {
MockParticipantManager[] newParticipants = new MockParticipantManager[numNodesToStart];
registerParticipants(newParticipants, numNodesToStart, _startPort + _numNodes, 1000, -3000000L);

// Wait for pipeline reaching final stage
Thread.sleep(2000L);
int numOfMasters = 0;
ExternalView externalView = _gSetupTool.getClusterManagementTool()
.getResourceExternalView(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB);
Expand Down Expand Up @@ -291,10 +286,6 @@ public Task createNewTask(TaskCallbackContext context) {
stateMach.registerStateModelFactory(MASTER_SLAVE_STATE_MODEL, delayFactory);

participants[i].syncStart();

if (sleepTime > 0) {
Thread.sleep(sleepTime);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,8 @@ private void restartZkServer() throws ExecutionException, InterruptedException {
for (int i = 0; i < 4; i++) {
Executors.newSingleThreadExecutor().submit(() -> {
try {
Thread.sleep(300);
LOG.info(System.currentTimeMillis() + ": Shutdown ZK server.");
TestHelper.stopZkServer(_zkServerRef.get());
Thread.sleep(300);
LOG.info("Restart ZK server");
_zkServerRef.set(TestHelper.startZkServer(_zkAddr, null, false));
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ public void testMissingTopStateDurationMonitoring() throws Exception {
// Trigger missing top state in manager1
participant.syncStop();

Thread.sleep(1000);

// Starting manager2
HelixManager manager2 = HelixManagerFactory
.getZKHelixManager(clusterName, clusterName + "-manager2", InstanceType.CONTROLLER,
Expand All @@ -300,8 +298,6 @@ public void testMissingTopStateDurationMonitoring() throws Exception {
// Wait for rebalance
Assert.assertTrue(clusterVerifier.verify());

Thread.sleep(1000);

// The moment before manager1 regain leadership. The topstateless duration will start counting.
long start = System.currentTimeMillis();
setLeader(manager1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void testTargetExternalViewEnable() throws InterruptedException {
_participants[0].getInstanceName(), false);

Assert.assertTrue(verifier.verifyByPolling());
Thread.sleep(1000);

targetExternalViews = _accessor.getChildValues(_accessor.keyBuilder().externalViews(), true);
idealStates = _accessor.getChildValues(_accessor.keyBuilder().idealStates(), true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public void simpleIntegrationTest() throws Exception {
// disconnect first distributed-controller, and verify second takes leadership
distributedControllers[0].disconnect();

Thread.sleep(100);

// verify leader changes to localhost_12919
result = verifier.verifyByZkCallback();
Assert.assertTrue(result);
Expand Down

0 comments on commit 741d27d

Please sign in to comment.