Skip to content

Commit 7f25718

Browse files
authored
[Zen2] Update default for USE_ZEN2 to true (#35998)
Today the default for USE_ZEN2 is false and it is overridden in many places. By defaulting it to true we can be sure that the only places in which Zen2 does not work are those in which it is explicitly set to false.
1 parent 277ccba commit 7f25718

File tree

10 files changed

+40
-12
lines changed

10 files changed

+40
-12
lines changed

server/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void testNodeVersionIsUpdated() throws IOException, NodeValidationExcepti
6666
.put("transport.type", getTestTransportType())
6767
.put(Node.NODE_DATA_SETTING.getKey(), false)
6868
.put("cluster.name", "foobar")
69-
.put(TestZenDiscovery.USE_ZEN2.getKey(), true)
69+
.put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2())
7070
.put(ClusterBootstrapService.INITIAL_MASTER_NODE_COUNT_SETTING.getKey(), 1)
7171
.build(), Arrays.asList(getTestTransportPlugin(), TestZenDiscovery.TestPlugin.class,
7272
MockHttpTransport.TestPlugin.class)).start()) {

test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,8 +1925,8 @@ protected NodeConfigurationSource getNodeConfigSource() {
19251925
initialNodeSettings.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType());
19261926
initialTransportClientSettings.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType());
19271927
}
1928-
if (addTestZenDiscovery()) {
1929-
initialNodeSettings.put(TestZenDiscovery.USE_ZEN2.getKey(), true);
1928+
if (addTestZenDiscovery() && getUseZen2() == false) {
1929+
initialNodeSettings.put(TestZenDiscovery.USE_ZEN2.getKey(), false);
19301930
}
19311931
return new NodeConfigurationSource() {
19321932
@Override

test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private Node newNode() {
191191
.put(EsExecutors.PROCESSORS_SETTING.getKey(), 1) // limit the number of threads created
192192
.put("transport.type", getTestTransportType())
193193
.put(Node.NODE_DATA_SETTING.getKey(), true)
194-
.put(TestZenDiscovery.USE_ZEN2.getKey(), true)
194+
.put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2())
195195
.put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong())
196196
// default the watermarks low values to prevent tests from failing on nodes without enough disk space
197197
.put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "1b")

test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,10 +995,21 @@ public static String randomGeohash(int minPrecision, int maxPrecision) {
995995
private static boolean useNio;
996996

997997
@BeforeClass
998-
public static void setUseNio() throws Exception {
998+
public static void setUseNio() {
999999
useNio = randomBoolean();
10001000
}
10011001

1002+
private static boolean useZen2;
1003+
1004+
@BeforeClass
1005+
public static void setUseZen2() {
1006+
useZen2 = true;
1007+
}
1008+
1009+
protected static boolean getUseZen2() {
1010+
return useZen2;
1011+
}
1012+
10021013
public static String getTestTransportType() {
10031014
return useNio ? MockNioTransportPlugin.MOCK_NIO_TRANSPORT_NAME : MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME;
10041015
}

test/framework/src/main/java/org/elasticsearch/test/discovery/TestZenDiscovery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class TestZenDiscovery extends ZenDiscovery {
6464
Setting.boolSetting("discovery.zen.use_mock_pings", true, Setting.Property.NodeScope);
6565

6666
public static final Setting<Boolean> USE_ZEN2 =
67-
Setting.boolSetting("discovery.zen.use_zen2", false, Setting.Property.NodeScope);
67+
Setting.boolSetting("discovery.zen.use_zen2", true, Setting.Property.NodeScope);
6868

6969
public static final Setting<Boolean> USE_ZEN2_PERSISTED_STATE =
7070
Setting.boolSetting("discovery.zen.use_zen2_persisted_state", false, Setting.Property.NodeScope);

test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
import org.elasticsearch.common.network.NetworkModule;
2828
import org.elasticsearch.common.settings.Settings;
2929
import org.elasticsearch.core.internal.io.IOUtils;
30+
import org.elasticsearch.discovery.DiscoveryModule;
3031
import org.elasticsearch.discovery.DiscoverySettings;
32+
import org.elasticsearch.discovery.zen.SettingsBasedHostsProvider;
3133
import org.elasticsearch.discovery.zen.ZenDiscovery;
3234
import org.elasticsearch.env.NodeEnvironment;
3335
import org.elasticsearch.plugins.Plugin;
@@ -55,10 +57,12 @@
5557
import java.util.function.Function;
5658
import java.util.stream.Collectors;
5759

60+
import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODE_COUNT_SETTING;
5861
import static org.elasticsearch.cluster.node.DiscoveryNode.Role.DATA;
5962
import static org.elasticsearch.cluster.node.DiscoveryNode.Role.INGEST;
6063
import static org.elasticsearch.cluster.node.DiscoveryNode.Role.MASTER;
6164
import static org.elasticsearch.discovery.zen.ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING;
65+
import static org.elasticsearch.test.discovery.TestZenDiscovery.USE_ZEN2;
6266
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFileExists;
6367
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFileNotExists;
6468
import static org.hamcrest.Matchers.equalTo;
@@ -190,11 +194,14 @@ public Settings nodeSettings(int nodeOrdinal) {
190194
.put(
191195
NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(),
192196
2 * ((masterNodes ? InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES : 0) + maxNumDataNodes + numClientNodes))
197+
.put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file")
198+
.putList(SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey())
193199
.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType());
194200
if (autoManageMinMasterNodes == false) {
195201
assert minNumDataNodes == maxNumDataNodes;
196202
assert masterNodes == false;
197-
settings.put(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), minNumDataNodes / 2 + 1);
203+
settings.put(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), minNumDataNodes / 2 + 1)
204+
.put(INITIAL_MASTER_NODE_COUNT_SETTING.getKey(), minNumDataNodes);
198205
}
199206
return settings.build();
200207
}
@@ -265,6 +272,7 @@ public Settings nodeSettings(int nodeOrdinal) {
265272
NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(),
266273
2 + (masterNodes ? InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES : 0) + maxNumDataNodes + numClientNodes)
267274
.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType())
275+
.put(USE_ZEN2.getKey(), false) // full cluster restarts not yet supported
268276
.build();
269277
}
270278

@@ -375,6 +383,7 @@ public Settings nodeSettings(int nodeOrdinal) {
375383
// speedup join timeout as setting initial state timeout to 0 makes split
376384
// elections more likely
377385
.put(ZenDiscovery.JOIN_TIMEOUT_SETTING.getKey(), "3s")
386+
.put(USE_ZEN2.getKey(), false) // full cluster restarts not yet supported
378387
.build();
379388
}
380389

@@ -457,6 +466,7 @@ public Settings nodeSettings(int nodeOrdinal) {
457466
return Settings.builder()
458467
.put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), 2)
459468
.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType())
469+
.put(USE_ZEN2.getKey(), false) // full cluster restarts not yet supported
460470
.build();
461471
}
462472

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ private NodeConfigurationSource createNodeConfigurationSource() {
174174
builder.put(IndicesStore.INDICES_STORE_DELETE_SHARD_TIMEOUT.getKey(), new TimeValue(1, TimeUnit.SECONDS));
175175
builder.putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()); // empty list disables a port scan for other nodes
176176
builder.putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file");
177+
builder.put(TestZenDiscovery.USE_ZEN2.getKey(), false); // some tests do full cluster restarts
177178
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType());
178179
builder.put(XPackSettings.SECURITY_ENABLED.getKey(), false);
179180
builder.put(XPackSettings.MONITORING_ENABLED.getKey(), false);

x-pack/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public void testNodeJoinWithoutSecurityExplicitlyEnabled() throws Exception {
300300
.put("path.home", home)
301301
.put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false)
302302
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "test-zen")
303-
.put(TestZenDiscovery.USE_ZEN2.getKey(), true)
303+
.put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2())
304304
.putList(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey())
305305
.putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey(), unicastHostsList)
306306
.build();

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailTests.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.elasticsearch.common.transport.TransportAddress;
3434
import org.elasticsearch.common.util.concurrent.EsExecutors;
3535
import org.elasticsearch.common.util.set.Sets;
36+
import org.elasticsearch.discovery.DiscoveryModule;
37+
import org.elasticsearch.discovery.zen.SettingsBasedHostsProvider;
3638
import org.elasticsearch.http.HttpChannel;
3739
import org.elasticsearch.plugins.MetaDataUpgrader;
3840
import org.elasticsearch.plugins.Plugin;
@@ -43,6 +45,7 @@
4345
import org.elasticsearch.test.SecurityIntegTestCase;
4446
import org.elasticsearch.test.SecuritySettingsSource;
4547
import org.elasticsearch.test.SecuritySettingsSourceField;
48+
import org.elasticsearch.test.discovery.TestZenDiscovery;
4649
import org.elasticsearch.threadpool.TestThreadPool;
4750
import org.elasticsearch.threadpool.ThreadPool;
4851
import org.elasticsearch.transport.TransportInfo;
@@ -78,8 +81,8 @@
7881
import java.util.Map;
7982
import java.util.Set;
8083
import java.util.function.Function;
81-
import static java.util.Collections.emptyMap;
8284

85+
import static java.util.Collections.emptyMap;
8386
import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
8487
import static org.elasticsearch.test.InternalTestCluster.clusterName;
8588
import static org.elasticsearch.xpack.security.audit.index.IndexNameResolver.Rollover.DAILY;
@@ -89,11 +92,11 @@
8992
import static org.hamcrest.Matchers.containsInAnyOrder;
9093
import static org.hamcrest.Matchers.containsString;
9194
import static org.hamcrest.Matchers.equalTo;
95+
import static org.hamcrest.Matchers.hasSize;
9296
import static org.hamcrest.Matchers.hasToString;
9397
import static org.hamcrest.Matchers.is;
9498
import static org.hamcrest.Matchers.notNullValue;
9599
import static org.hamcrest.Matchers.nullValue;
96-
import static org.hamcrest.Matchers.hasSize;
97100
import static org.mockito.Mockito.mock;
98101
import static org.mockito.Mockito.when;
99102

@@ -183,6 +186,9 @@ public void initializeRemoteClusterIfNecessary() throws Exception {
183186
public Settings nodeSettings(int nodeOrdinal) {
184187
Settings.Builder builder = Settings.builder()
185188
.put(super.nodeSettings(nodeOrdinal))
189+
.put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file")
190+
.putList(SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey())
191+
.put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2())
186192
.put("xpack.security.audit.index.settings.index.number_of_shards", numShards)
187193
.put("xpack.security.audit.index.settings.index.number_of_replicas", numReplicas)
188194
// Disable native ML autodetect_process as the c++ controller won't be available

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void testThatConnectionToServerTypeConnectionWorks() throws IOException,
108108
.put(XPackSettings.WATCHER_ENABLED.getKey(), false)
109109
.put("path.home", home)
110110
.put(Node.NODE_MASTER_SETTING.getKey(), false)
111-
.put(TestZenDiscovery.USE_ZEN2.getKey(), true)
111+
.put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2())
112112
.put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false);
113113
//.put("xpack.ml.autodetect_process", false);
114114
Collection<Class<? extends Plugin>> mockPlugins = Arrays.asList(
@@ -152,7 +152,7 @@ public void testThatConnectionToClientTypeConnectionIsRejected() throws IOExcept
152152
.put("discovery.initial_state_timeout", "0s")
153153
.put("path.home", home)
154154
.put(Node.NODE_MASTER_SETTING.getKey(), false)
155-
.put(TestZenDiscovery.USE_ZEN2.getKey(), true)
155+
.put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2())
156156
.put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false);
157157
//.put("xpack.ml.autodetect_process", false);
158158
Collection<Class<? extends Plugin>> mockPlugins = Arrays.asList(

0 commit comments

Comments
 (0)