From 69c9a2dca164c31c66489bac8036acaed16aafe7 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Sun, 28 Jul 2013 19:36:02 +0200 Subject: [PATCH] improve test to be more descriptive when it fails --- .../zen/ping/unicast/UnicastZenPingTests.java | 10 +++++----- .../unit/transport/AbstractSimpleTransportTests.java | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/unit/discovery/zen/ping/unicast/UnicastZenPingTests.java b/src/test/java/org/elasticsearch/test/unit/discovery/zen/ping/unicast/UnicastZenPingTests.java index 89a1cbeb1a4..84c0774b138 100644 --- a/src/test/java/org/elasticsearch/test/unit/discovery/zen/ping/unicast/UnicastZenPingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/discovery/zen/ping/unicast/UnicastZenPingTests.java @@ -58,13 +58,13 @@ public class UnicastZenPingTests extends ElasticsearchTestCase { NettyTransport transportA = new NettyTransport(settings, threadPool, networkService, Version.CURRENT); final TransportService transportServiceA = new TransportService(transportA, threadPool).start(); - final DiscoveryNode nodeA = new DiscoveryNode("A", transportServiceA.boundAddress().publishAddress(), Version.CURRENT); + final DiscoveryNode nodeA = new DiscoveryNode("UZP_A", transportServiceA.boundAddress().publishAddress(), Version.CURRENT); InetSocketTransportAddress addressA = (InetSocketTransportAddress) transportA.boundAddress().publishAddress(); NettyTransport transportB = new NettyTransport(settings, threadPool, networkService, Version.CURRENT); final TransportService transportServiceB = new TransportService(transportB, threadPool).start(); - final DiscoveryNode nodeB = new DiscoveryNode("B", transportServiceA.boundAddress().publishAddress(), Version.CURRENT); + final DiscoveryNode nodeB = new DiscoveryNode("UZP_B", transportServiceA.boundAddress().publishAddress(), Version.CURRENT); InetSocketTransportAddress addressB = (InetSocketTransportAddress) transportB.boundAddress().publishAddress(); @@ -77,7 +77,7 @@ public class UnicastZenPingTests extends ElasticsearchTestCase { zenPingA.setNodesProvider(new DiscoveryNodesProvider() { @Override public DiscoveryNodes nodes() { - return DiscoveryNodes.newNodesBuilder().put(nodeA).localNodeId("A").build(); + return DiscoveryNodes.newNodesBuilder().put(nodeA).localNodeId("UZP_A").build(); } @Override @@ -91,7 +91,7 @@ public class UnicastZenPingTests extends ElasticsearchTestCase { zenPingB.setNodesProvider(new DiscoveryNodesProvider() { @Override public DiscoveryNodes nodes() { - return DiscoveryNodes.newNodesBuilder().put(nodeB).localNodeId("B").build(); + return DiscoveryNodes.newNodesBuilder().put(nodeB).localNodeId("UZP_B").build(); } @Override @@ -104,7 +104,7 @@ public class UnicastZenPingTests extends ElasticsearchTestCase { try { ZenPing.PingResponse[] pingResponses = zenPingA.pingAndWait(TimeValue.timeValueSeconds(1)); assertThat(pingResponses.length, equalTo(1)); - assertThat(pingResponses[0].target().id(), equalTo("B")); + assertThat(pingResponses[0].target().id(), equalTo("UZP_B")); } finally { zenPingA.close(); zenPingB.close(); diff --git a/src/test/java/org/elasticsearch/test/unit/transport/AbstractSimpleTransportTests.java b/src/test/java/org/elasticsearch/test/unit/transport/AbstractSimpleTransportTests.java index e6dfd1944b8..9bc9893c041 100644 --- a/src/test/java/org/elasticsearch/test/unit/transport/AbstractSimpleTransportTests.java +++ b/src/test/java/org/elasticsearch/test/unit/transport/AbstractSimpleTransportTests.java @@ -61,10 +61,10 @@ public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase @Before public void setUp() { threadPool = new ThreadPool(); - serviceA = build(ImmutableSettings.builder().put("name", "A").build(), version0); - nodeA = new DiscoveryNode("A", "A", serviceA.boundAddress().publishAddress(), ImmutableMap.of(), version0); - serviceB = build(ImmutableSettings.builder().put("name", "B").build(), version1); - nodeB = new DiscoveryNode("B", "B", serviceB.boundAddress().publishAddress(), ImmutableMap.of(), version1); + serviceA = build(ImmutableSettings.builder().put("name", "TS_A").build(), version0); + nodeA = new DiscoveryNode("TS_A", "TS_A", serviceA.boundAddress().publishAddress(), ImmutableMap.of(), version0); + serviceB = build(ImmutableSettings.builder().put("name", "TS_B").build(), version1); + nodeB = new DiscoveryNode("TS_B", "TS_B", serviceB.boundAddress().publishAddress(), ImmutableMap.of(), version1); serviceA.connectToNode(nodeB); serviceA.connectToNode(nodeA); @@ -344,7 +344,7 @@ public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase TransportConnectionListener disconnectListener = new TransportConnectionListener() { @Override public void onNodeConnected(DiscoveryNode node) { - throw new RuntimeException("Should not be called"); + assert false : "node connected should not be called, all connection have been done previously, node: " + node; } @Override