From 54083f7d6e7417a0c01d87fa10c55e22928dae11 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 31 Aug 2016 15:41:39 -0400 Subject: [PATCH] Randomly use Netty 3 plugin in some tests When Netty 4 was introduced, it was not the default network implementation. Some tests were constructed to randomly use Netty 4 instead of the default network implementation. When Netty 4 was made the default implementation, these tests were not updated. Thus, these tests are randomly choosing between the default network implementation (Netty 4) and Netty 4. This commit updates these tests to reverse the role of Netty 3 and Netty 4 so that the randomization is choosing between Netty 3 and the default (again, now Netty 4). Relates #20265 --- .../org/elasticsearch/index/reindex/RetryTests.java | 12 +++++------- .../smoketest/ESSmokeClientTestCase.java | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RetryTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RetryTests.java index c0c1d681a09..92e2598a5aa 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RetryTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RetryTests.java @@ -28,7 +28,6 @@ import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.Retry; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.network.NetworkModule; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; @@ -43,7 +42,6 @@ import org.junit.Before; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.concurrent.CyclicBarrier; @@ -63,12 +61,12 @@ public class RetryTests extends ESSingleNodeTestCase { private List blockedExecutors = new ArrayList<>(); - private boolean useNetty4; + private boolean useNetty3; @Before public void setUp() throws Exception { super.setUp(); - useNetty4 = randomBoolean(); + useNetty3 = randomBoolean(); createIndex("source"); // Build the test data. Don't use indexRandom because that won't work consistently with such small thread pools. BulkRequestBuilder bulk = client().prepareBulk(); @@ -112,9 +110,9 @@ public class RetryTests extends ESSingleNodeTestCase { settings.put(NetworkModule.HTTP_ENABLED.getKey(), true); // Whitelist reindexing from the http host we're going to use settings.put(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.getKey(), "myself"); - if (useNetty4) { - settings.put(NetworkModule.HTTP_TYPE_KEY, Netty4Plugin.NETTY_HTTP_TRANSPORT_NAME); - settings.put(NetworkModule.TRANSPORT_TYPE_KEY, Netty4Plugin.NETTY_TRANSPORT_NAME); + if (useNetty3) { + settings.put(NetworkModule.HTTP_TYPE_KEY, Netty3Plugin.NETTY_HTTP_TRANSPORT_NAME); + settings.put(NetworkModule.TRANSPORT_TYPE_KEY, Netty3Plugin.NETTY_TRANSPORT_NAME); } return settings.build(); } diff --git a/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java b/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java index 645cc8382d6..3402e6ea2c8 100644 --- a/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java +++ b/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java @@ -32,6 +32,7 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.env.Environment; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.transport.MockTcpTransportPlugin; +import org.elasticsearch.transport.Netty3Plugin; import org.elasticsearch.transport.Netty4Plugin; import org.elasticsearch.transport.client.PreBuiltTransportClient; import org.junit.After; @@ -91,7 +92,7 @@ public abstract class ESSmokeClientTestCase extends LuceneTestCase { break; case 1: plugins = Collections.emptyList(); - builder.put(NetworkModule.TRANSPORT_TYPE_KEY, Netty4Plugin.NETTY_TRANSPORT_NAME); + builder.put(NetworkModule.TRANSPORT_TYPE_KEY, Netty3Plugin.NETTY_TRANSPORT_NAME); break; case 2: plugins = Collections.emptyList();