Skip to content

Commit e7a606d

Browse files
committed
Add @multicast annotation to disable multicast tests by default.
We only run multicast tests now when we explicitly state it. A working multicast env is required which is not always the case.
1 parent 2d7d2d0 commit e7a606d

7 files changed

Lines changed: 29 additions & 5 deletions

File tree

core/src/test/java/org/elasticsearch/bwcompat/UnicastBackwardsCompatibilityIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ protected Settings nodeSettings(int nodeOrdinal) {
3333
return Settings.builder()
3434
.put(super.nodeSettings(nodeOrdinal))
3535
.put("transport.tcp.port", 9380 + nodeOrdinal)
36-
.put("discovery.zen.ping.multicast.enabled", false)
3736
.put("discovery.zen.ping.unicast.hosts", "localhost:9380,localhost:9381,localhost:9390,localhost:9391")
3837
.build();
3938
}
@@ -43,7 +42,6 @@ protected Settings externalNodeSettings(int nodeOrdinal) {
4342
return Settings.settingsBuilder()
4443
.put(super.externalNodeSettings(nodeOrdinal))
4544
.put("transport.tcp.port", 9390 + nodeOrdinal)
46-
.put("discovery.zen.ping.multicast.enabled", false)
4745
.put("discovery.zen.ping.unicast.hosts", "localhost:9380,localhost:9381,localhost:9390,localhost:9391")
4846
.build();
4947
}

core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,15 @@ private List<String> startUnicastCluster(int numberOfNodes, @Nullable int[] unic
143143
.put("discovery.zen.join_timeout", "10s") // still long to induce failures but to long so test won't time out
144144
.put(DiscoverySettings.PUBLISH_TIMEOUT, "1s") // <-- for hitting simulated network failures quickly
145145
.put("http.enabled", false) // just to make test quicker
146+
.put("transport.host", "127.0.0.1") // only bind on one IF we use v4 here by default
147+
.put("transport.bind_host", "127.0.0.1")
148+
.put("transport.publish_host", "127.0.0.1")
146149
.put("gateway.local.list_timeout", "10s") // still long to induce failures but to long so test won't time out
147150
.put("plugin.types", MockTransportService.TestPlugin.class.getName())
148151
.build();
149152

150153
private void configureCluster(int numberOfNodes, int minimumMasterNode) throws ExecutionException, InterruptedException {
151-
if (randomBoolean()) {
154+
if (randomBoolean() && canUseMuticast()) {
152155
configureMulticastCluster(numberOfNodes, minimumMasterNode);
153156
} else {
154157
configureUnicastCluster(numberOfNodes, null, minimumMasterNode);

core/src/test/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPingIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.elasticsearch.discovery.zen.ping.PingContextProvider;
3434
import org.elasticsearch.discovery.zen.ping.ZenPing;
3535
import org.elasticsearch.node.service.NodeService;
36+
import org.elasticsearch.test.ESIntegTestCase;
3637
import org.elasticsearch.test.ESTestCase;
3738
import org.elasticsearch.threadpool.ThreadPool;
3839
import org.elasticsearch.transport.TransportService;
@@ -45,6 +46,7 @@
4546

4647
import static org.hamcrest.Matchers.equalTo;
4748

49+
@ESIntegTestCase.Multicast
4850
public class MulticastZenPingIT extends ESTestCase {
4951

5052
private Settings buildRandomMulticast(Settings settings) {

core/src/test/java/org/elasticsearch/plugins/PluginManagerIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,6 @@ public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent
648648

649649
private Tuple<Settings, Environment> buildInitialSettings() throws IOException {
650650
Settings settings = settingsBuilder()
651-
.put("discovery.zen.ping.multicast.enabled", false)
652651
.put("http.enabled", true)
653652
.put("path.home", createTempDir()).build();
654653
return InternalSettingsPreparer.prepareSettings(settings, false);

core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,4 +2003,25 @@ private static boolean isSuiteScopedTest(Class<?> clazz) {
20032003
@Retention(RetentionPolicy.RUNTIME)
20042004
@Inherited
20052005
public @interface SuppressNetworkMode {}
2006+
2007+
/**
2008+
* Annotation used to set if working multicast is required to run the test.
2009+
* By default, tests annotated with @Multicast won't be executed.
2010+
* Set -Dtests.multicast=true when running test to launch multicast tests
2011+
*/
2012+
@Retention(RetentionPolicy.RUNTIME)
2013+
@Inherited
2014+
@TestGroup(enabled = false, sysProperty = "tests.multicast")
2015+
public @interface Multicast {
2016+
}
2017+
2018+
2019+
/**
2020+
* Returns true if tests can use multicast. Default is false.
2021+
* To disable an entire test use {@link org.elasticsearch.test.ESIntegTestCase.Multicast} instead
2022+
*/
2023+
protected boolean canUseMuticast() {
2024+
return Boolean.parseBoolean(System.getProperty("tests.multicast", "false"));
2025+
}
2026+
20062027
}

core/src/test/java/org/elasticsearch/tribe/TribeIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class TribeIT extends ESIntegTestCase {
7070
public static void setupSecondCluster() throws Exception {
7171
ESIntegTestCase.beforeClass();
7272
// create another cluster
73-
cluster2 = new InternalTestCluster(internalCluster().getNodeMode(), randomLong(), createTempDir(), 2, 2, Strings.randomBase64UUID(getRandom()), 0, false, SECOND_CLUSTER_NODE_PREFIX);
73+
cluster2 = new InternalTestCluster(InternalTestCluster.configuredNodeMode(), randomLong(), createTempDir(), 2, 2, Strings.randomBase64UUID(getRandom()), 0, false, SECOND_CLUSTER_NODE_PREFIX);
7474
cluster2.beforeTest(getRandom(), 0.1);
7575
cluster2.ensureAtLeastNumDataNodes(2);
7676
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
<tests.rest.spec></tests.rest.spec>
104104
<tests.rest.load_packaged></tests.rest.load_packaged>
105105
<tests.network></tests.network>
106+
<tests.multicast></tests.multicast>
106107
<tests.cluster></tests.cluster>
107108
<tests.filter></tests.filter>
108109
<env.ES_TEST_LOCAL></env.ES_TEST_LOCAL>

0 commit comments

Comments
 (0)