Fix unexpected JVM termination during ZookeeperDiscoverySpiTestSuite1 execution
@@ -19,6 +19,7 @@ package org.apache.ignite.spi.discovery.zk;
import java.io.File;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.curator.test.InstanceSpec;
@@ -30,6 +31,12 @@ import org.jetbrains.annotations.Nullable;
* Utility to run regular Ignite tests with {@link org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi}.
*/
public class ZookeeperDiscoverySpiTestUtil {
+ /** Property name for Zookeeper's election port bind retry attempts count. */
+ public static final String ZK_ELECTION_PORT_BIND_RETRY = "electionPortBindRetry";
+
+ /** Property name for Zookeeper's 'enable admin server' flag. */
+ public static final String ZK_ENABLE_ADMIN_SERVER = "admin.enableServer";
+
/**
* @param instances Number of instances in cluster.
* @return Test cluster.
@@ -61,14 +68,29 @@ public class ZookeeperDiscoverySpiTestUtil {
throw new IgniteException("Failed to create directory for test Zookeeper server: " + file.getAbsolutePath());
}
- Map<String, Object> props = customProps != null ? customProps[i] : null;
-
- specs.add(new InstanceSpec(file, -1, -1, -1, true, -1, -1, 500, props));
+ specs.add(new InstanceSpec(file, -1, -1, -1, true, -1, -1, 500,
+ optimizeProperties(customProps, i)));
}
return new TestingCluster(specs);
}
+ /**
+ *
+ */
+ private static Map<String, Object> optimizeProperties(Map<String, Object>[] customProps, int idx) {
+ Map<String, Object> props = customProps != null && customProps[idx] != null ? customProps[idx] : new HashMap<>();
+
+ // In container environment, especially in Kubernetes, this value should be increased or set to 0
+ // (infinite retry) to overcome issues related to DNS name resolving.
+ props.putIfAbsent(ZK_ELECTION_PORT_BIND_RETRY, "0");
+
+ // Disable the AdminServer
+ props.putIfAbsent(ZK_ENABLE_ADMIN_SERVER, "false");
+
+ return props;
+ }
+
/**
* @param file File or directory to delete.
*/
