前提是使用 Idea 进行单框架的集成,其他工具没有尝试过.
问题来源
在参考 Elasticsearch 官方单元测试集成方式的时候,在编写自己的单元测试的时候,出现了让人郁闷的异常,这里我的单元测试是创建一个名称为"test-index"的索引,代码如下:
public class SampleTest extends ESIntegTestCase {
@Test
public void test() throws Exception {
createIndex("test-index");
assertTrue(indexExists("test-index"));
}
}
运行单元测试,出现以下异常:
java.lang.RuntimeException: found jar hell in test classpath
at org.elasticsearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:92)
at org.elasticsearch.test.ESTestCase.<clinit>(ESTestCase.java:186)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:592)
Caused by: java.lang.IllegalStateException: jar hell!
duplicate jar[*****]
at org.elasticsearch.bootstrap.JarHell.parseClassPath(JarHell.java:142)
at org.elasticsearch.bootstrap.JarHell.parseClassPath(JarHell.java:99)
at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:90)
at org.elasticsearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:90)
... 4 more
Test ignored.
Exception in thread "Thread-1" java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.test.ESTestCase
at java.lang.Thread.run(Thread.java:748)
Suppressed: java.lang.IllegalStateException: No context information for thread: Thread[id=13, name=Thread-1, state=RUNNABLE, group=TGRP-SampleTest]. Is this thread running under a class com.carrotsearch.randomizedtesting.RandomizedRunner runner context? Add @RunWith(class com.carrotsearch.randomizedtesting.RandomizedRunner.class) to your test class. Make sure your code accesses random contexts within @BeforeClass and @AfterClass boundary (for example, static test class initializers are not permitted to access random contexts).
at com.carrotsearch.randomizedtesting.RandomizedContext.context(RandomizedContext.java:248)
at com.carrotsearch.randomizedtesting.RandomizedContext.current(RandomizedContext.java:134)
at com.carrotsearch.randomizedtesting.RandomizedRunner.augmentStackTrace(RandomizedRunner.java:1848)
at com.carrotsearch.randomizedtesting.RunnerThreadGroup.uncaughtException(RunnerThreadGroup.java:20)
at java.lang.Thread.dispatchUncaughtException(Thread.java:1959)
我们看下一共出现了哪些异常,见下面的 ##问题和解决方法##
问题和解决方法
问题 1
- ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
解决方式:
在 pom.xml 文件添加 log4j-core 的依赖 jar 包,参考如下:
<dependency>
<groupId>org.apache.logging.log4jgroupId>
<artifactId>log4j-coreartifactId>
<version>2.8.2version>
dependency>
问题 2
- found jar hell in test classpath
解决方式:
-
在你的测试代码目录下创建一个包:org.elasticsearch.bootstrap
-
在 org.elasticsearch.bootstrap 包下创建 JarHell 类,源码如下:
package org.elasticsearch.bootstrap; import java.net.URL; /** * @auhthor lei.fang@shijue.me * @since . 2017-11-24 */public class JarHell { private JarHell() {} public static void checkJarHell() throws Exception {} public static void checkJarHell(URL urls[]) throws Exception {} public static void checkVersionFormat(String targetVersion) {} public static void checkJavaVersion(String resource, String targetVersion) {} public static URL[] parseClassPath() {return new URL[]{};} }
-
添加 VM options 参数 -ea -Dtests.security.manager=false
这样就能自己编写单元测试来测试 Elasticsearch 和 Lucene 的相关功能,整个 pom.xml 如下
<dependencies>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>7.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
<version>6.0.0</version>
<scope>test</scope>
<dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.2</version>
</dependency>
<dependencies>
重新运行单元测试,测试结果如下:
[2017-11-23T21:57:29,271][INFO ][o.f.e.d.SampleTest ] [test]: before test
[2017-11-23T21:57:29,273][INFO ][o.f.e.d.SampleTest ] [SampleTest#test]: setting up test
[2017-11-23T21:57:29,286][INFO ][o.e.t.InternalTestCluster] Setup InternalTestCluster [SUITE-CHILD_VM=[0]-CLUSTER_SEED=[9180804499904000471]-HASH=[13F343E443BAE]-cluster] with seed [7F68C50CF915F1D7] using [0] dedicated masters, [3] (data) nodes and [1] coord only nodes (min_master_nodes are [auto-managed])
[2017-11-23T21:57:29,580][INFO ][o.e.n.Node ] [node_s0] initializing ...
[2017-11-23T21:57:29,635][INFO ][o.e.e.NodeEnvironment ] [node_s0] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [129.5gb], net total_space [232.6gb], types [hfs]
[2017-11-23T21:57:29,635][INFO ][o.e.e.NodeEnvironment ] [node_s0] heap size [3.5gb], compressed ordinary object pointers [true]
[2017-11-23T21:57:29,637][INFO ][o.e.n.Node ] [node_s0] node name [node_s0], node ID [pCcOJN9vQjqSeC8bsMCyxA]
[2017-11-23T21:57:29,637][INFO ][o.e.n.Node ] [node_s0] version[6.0.0], pid[44762], build[8f0685b/2017-11-10T18:41:22.859Z], OS[Mac OS X/10.12.6/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_144/25.144-b01]
[2017-11-23T21:57:29,637][INFO ][o.e.n.Node ] [node_s0] JVM arguments [-ea, -Dtests.security.manager=false, -Didea.test.cyclic.buffer.size=1048576, -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=61668:/Applications/IntelliJ IDEA.app/Contents/bin, -Dfile.encoding=UTF-8]
[2017-11-23T21:57:29,642][INFO ][o.e.p.PluginsService ] [node_s0] no modules loaded
[2017-11-23T21:57:29,643][INFO ][o.e.p.PluginsService ] [node_s0] loaded plugin [org.elasticsearch.index.MockEngineFactoryPlugin]
[2017-11-23T21:57:29,643][INFO ][o.e.p.PluginsService ] [node_s0] loaded plugin [org.elasticsearch.node.NodeMocksPlugin]
[2017-11-23T21:57:29,643][INFO ][o.e.p.PluginsService ] [node_s0] loaded plugin [org.elasticsearch.search.MockSearchService$TestPlugin]
[2017-11-23T21:57:29,643][INFO ][o.e.p.PluginsService ] [node_s0] loaded plugin [org.elasticsearch.test.ESIntegTestCase$TestSeedPlugin]
[2017-11-23T21:57:29,643][INFO ][o.e.p.PluginsService ] [node_s0] loaded plugin [org.elasticsearch.test.discovery.TestZenDiscovery$TestPlugin]
[2017-11-23T21:57:29,644][INFO ][o.e.p.PluginsService ] [node_s0] loaded plugin [org.elasticsearch.test.store.MockFSIndexStore$TestPlugin]
[2017-11-23T21:57:29,644][INFO ][o.e.p.PluginsService ] [node_s0] loaded plugin [org.elasticsearch.test.transport.MockTransportService$TestPlugin]
[2017-11-23T21:57:29,644][INFO ][o.e.p.PluginsService ] [node_s0] loaded plugin [org.elasticsearch.transport.AssertingTransportInterceptor$TestPlugin]
[2017-11-23T21:57:29,644][INFO ][o.e.p.PluginsService ] [node_s0] loaded plugin [org.elasticsearch.transport.MockTcpTransportPlugin]
[2017-11-23T21:57:30,919][INFO ][o.e.d.DiscoveryModule ] [node_s0] using discovery type [test-zen]
[2017-11-23T21:57:31,463][INFO ][o.e.n.Node ] [node_s0] initialized
[2017-11-23T21:57:31,468][INFO ][o.e.n.Node ] [node_s1] initializing ...
[2017-11-23T21:57:31,473][INFO ][o.e.e.NodeEnvironment ] [node_s1] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [129.5gb], net total_space [232.6gb], types [hfs]
[2017-11-23T21:57:31,473][INFO ][o.e.e.NodeEnvironment ] [node_s1] heap size [3.5gb], compressed ordinary object pointers [true]
[2017-11-23T21:57:31,473][INFO ][o.e.n.Node ] [node_s1] node name [node_s1], node ID [JD1UL8tJTZafqwmXjfM_Vw]
[2017-11-23T21:57:31,474][INFO ][o.e.n.Node ] [node_s1] version[6.0.0], pid[44762], build[8f0685b/2017-11-10T18:41:22.859Z], OS[Mac OS X/10.12.6/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_144/25.144-b01]
[2017-11-23T21:57:31,474][INFO ][o.e.n.Node ] [node_s1] JVM arguments [-ea, -Dtests.security.manager=false, -Didea.test.cyclic.buffer.size=1048576, -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=61668:/Applications/IntelliJ IDEA.app/Contents/bin, -Dfile.encoding=UTF-8]
[2017-11-23T21:57:31,474][INFO ][o.e.p.PluginsService ] [node_s1] no modules loaded
[2017-11-23T21:57:31,474][INFO ][o.e.p.PluginsService ] [node_s1] loaded plugin [org.elasticsearch.index.MockEngineFactoryPlugin]
[2017-11-23T21:57:31,474][INFO ][o.e.p.PluginsService ] [node_s1] loaded plugin [org.elasticsearch.node.NodeMocksPlugin]
[2017-11-23T21:57:31,474][INFO ][o.e.p.PluginsService ] [node_s1] loaded plugin [org.elasticsearch.search.MockSearchService$TestPlugin]
[2017-11-23T21:57:31,474][INFO ][o.e.p.PluginsService ] [node_s1] loaded plugin [org.elasticsearch.test.ESIntegTestCase$TestSeedPlugin]
[2017-11-23T21:57:31,474][INFO ][o.e.p.PluginsService ] [node_s1] loaded plugin [org.elasticsearch.test.discovery.TestZenDiscovery$TestPlugin]
[2017-11-23T21:57:31,475][INFO ][o.e.p.PluginsService ] [node_s1] loaded plugin [org.elasticsearch.test.store.MockFSIndexStore$TestPlugin]
[2017-11-23T21:57:31,475][INFO ][o.e.p.PluginsService ] [node_s1] loaded plugin [org.elasticsearch.test.transport.MockTransportService$TestPlugin]
[2017-11-23T21:57:31,475][INFO ][o.e.p.PluginsService ] [node_s1] loaded plugin [org.elasticsearch.transport.AssertingTransportInterceptor$TestPlugin]
[2017-11-23T21:57:31,475][INFO ][o.e.p.PluginsService ] [node_s1] loaded plugin [org.elasticsearch.transport.MockTcpTransportPlugin]
[2017-11-23T21:57:31,494][INFO ][o.e.d.DiscoveryModule ] [node_s1] using discovery type [test-zen]
[2017-11-23T21:57:31,530][INFO ][o.e.n.Node ] [node_s1] initialized
[2017-11-23T21:57:31,534][INFO ][o.e.n.Node ] [node_s2] initializing ...
[2017-11-23T21:57:31,538][INFO ][o.e.e.NodeEnvironment ] [node_s2] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [129.5gb], net total_space [232.6gb], types [hfs]
[2017-11-23T21:57:31,538][INFO ][o.e.e.NodeEnvironment ] [node_s2] heap size [3.5gb], compressed ordinary object pointers [true]
[2017-11-23T21:57:31,539][INFO ][o.e.n.Node ] [node_s2] node name [node_s2], node ID [9AtjFK_iSImBX-GovTgMyQ]
[2017-11-23T21:57:31,539][INFO ][o.e.n.Node ] [node_s2] version[6.0.0], pid[44762], build[8f0685b/2017-11-10T18:41:22.859Z], OS[Mac OS X/10.12.6/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_144/25.144-b01]
[2017-11-23T21:57:31,539][INFO ][o.e.n.Node ] [node_s2] JVM arguments [-ea, -Dtests.security.manager=false, -Didea.test.cyclic.buffer.size=1048576, -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=61668:/Applications/IntelliJ IDEA.app/Contents/bin, -Dfile.encoding=UTF-8]
[2017-11-23T21:57:31,540][INFO ][o.e.p.PluginsService ] [node_s2] no modules loaded
[2017-11-23T21:57:31,540][INFO ][o.e.p.PluginsService ] [node_s2] loaded plugin [org.elasticsearch.index.MockEngineFactoryPlugin]
[2017-11-23T21:57:31,540][INFO ][o.e.p.PluginsService ] [node_s2] loaded plugin [org.elasticsearch.node.NodeMocksPlugin]
[2017-11-23T21:57:31,540][INFO ][o.e.p.PluginsService ] [node_s2] loaded plugin [org.elasticsearch.search.MockSearchService$TestPlugin]
[2017-11-23T21:57:31,540][INFO ][o.e.p.PluginsService ] [node_s2] loaded plugin [org.elasticsearch.test.ESIntegTestCase$TestSeedPlugin]
[2017-11-23T21:57:31,540][INFO ][o.e.p.PluginsService ] [node_s2] loaded plugin [org.elasticsearch.test.discovery.TestZenDiscovery$TestPlugin]
[2017-11-23T21:57:31,540][INFO ][o.e.p.PluginsService ] [node_s2] loaded plugin [org.elasticsearch.test.store.MockFSIndexStore$TestPlugin]
[2017-11-23T21:57:31,540][INFO ][o.e.p.PluginsService ] [node_s2] loaded plugin [org.elasticsearch.test.transport.MockTransportService$TestPlugin]
[2017-11-23T21:57:31,540][INFO ][o.e.p.PluginsService ] [node_s2] loaded plugin [org.elasticsearch.transport.AssertingTransportInterceptor$TestPlugin]
[2017-11-23T21:57:31,540][INFO ][o.e.p.PluginsService ] [node_s2] loaded plugin [org.elasticsearch.transport.MockTcpTransportPlugin]
[2017-11-23T21:57:31,556][INFO ][o.e.d.DiscoveryModule ] [node_s2] using discovery type [test-zen]
[2017-11-23T21:57:31,593][INFO ][o.e.n.Node ] [node_s2] initialized
[2017-11-23T21:57:31,596][INFO ][o.e.n.Node ] [node_sc3] initializing ...
[2017-11-23T21:57:31,600][INFO ][o.e.e.NodeEnvironment ] [node_sc3] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [129.5gb], net total_space [232.6gb], types [hfs]
[2017-11-23T21:57:31,600][INFO ][o.e.e.NodeEnvironment ] [node_sc3] heap size [3.5gb], compressed ordinary object pointers [true]
[2017-11-23T21:57:31,601][INFO ][o.e.n.Node ] [node_sc3] node name [node_sc3], node ID [-N3NCafBR-O1JHNvit89rg]
[2017-11-23T21:57:31,601][INFO ][o.e.n.Node ] [node_sc3] version[6.0.0], pid[44762], build[8f0685b/2017-11-10T18:41:22.859Z], OS[Mac OS X/10.12.6/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_144/25.144-b01]
[2017-11-23T21:57:31,601][INFO ][o.e.n.Node ] [node_sc3] JVM arguments [-ea, -Dtests.security.manager=false, -Didea.test.cyclic.buffer.size=1048576, -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=61668:/Applications/IntelliJ IDEA.app/Contents/bin, -Dfile.encoding=UTF-8]
[2017-11-23T21:57:31,602][INFO ][o.e.p.PluginsService ] [node_sc3] no modules loaded
[2017-11-23T21:57:31,602][INFO ][o.e.p.PluginsService ] [node_sc3] loaded plugin [org.elasticsearch.index.MockEngineFactoryPlugin]
[2017-11-23T21:57:31,602][INFO ][o.e.p.PluginsService ] [node_sc3] loaded plugin [org.elasticsearch.node.NodeMocksPlugin]
[2017-11-23T21:57:31,602][INFO ][o.e.p.PluginsService ] [node_sc3] loaded plugin [org.elasticsearch.search.MockSearchService$TestPlugin]
[2017-11-23T21:57:31,602][INFO ][o.e.p.PluginsService ] [node_sc3] loaded plugin [org.elasticsearch.test.ESIntegTestCase$TestSeedPlugin]
[2017-11-23T21:57:31,602][INFO ][o.e.p.PluginsService ] [node_sc3] loaded plugin [org.elasticsearch.test.discovery.TestZenDiscovery$TestPlugin]
[2017-11-23T21:57:31,602][INFO ][o.e.p.PluginsService ] [node_sc3] loaded plugin [org.elasticsearch.test.store.MockFSIndexStore$TestPlugin]
[2017-11-23T21:57:31,603][INFO ][o.e.p.PluginsService ] [node_sc3] loaded plugin [org.elasticsearch.test.transport.MockTransportService$TestPlugin]
[2017-11-23T21:57:31,603][INFO ][o.e.p.PluginsService ] [node_sc3] loaded plugin [org.elasticsearch.transport.AssertingTransportInterceptor$TestPlugin]
[2017-11-23T21:57:31,603][INFO ][o.e.p.PluginsService ] [node_sc3] loaded plugin [org.elasticsearch.transport.MockTcpTransportPlugin]
[2017-11-23T21:57:31,618][INFO ][o.e.d.DiscoveryModule ] [node_sc3] using discovery type [test-zen]
[2017-11-23T21:57:31,648][INFO ][o.e.n.Node ] [node_sc3] initialized
[2017-11-23T21:57:31,653][INFO ][o.e.n.Node ] [node_s0] starting ...
[2017-11-23T21:57:31,653][INFO ][o.e.n.Node ] [node_s2] starting ...
[2017-11-23T21:57:31,653][INFO ][o.e.n.Node ] [node_s1] starting ...
[2017-11-23T21:57:31,653][INFO ][o.e.n.Node ] [node_sc3] starting ...
[2017-11-23T21:57:31,672][INFO ][o.e.t.t.MockTransportService] [node_sc3] publish_address {127.0.0.1:9400}, bound_addresses {[fe80::1]:9400}, {[::1]:9400}, {127.0.0.1:9400}
[2017-11-23T21:57:31,672][INFO ][o.e.t.t.MockTransportService] [node_s0] publish_address {127.0.0.1:9402}, bound_addresses {[fe80::1]:9402}, {[::1]:9401}, {127.0.0.1:9402}
[2017-11-23T21:57:31,672][INFO ][o.e.t.t.MockTransportService] [node_s2] publish_address {127.0.0.1:9403}, bound_addresses {[fe80::1]:9401}, {[::1]:9403}, {127.0.0.1:9403}
[2017-11-23T21:57:31,672][INFO ][o.e.t.t.MockTransportService] [node_s1] publish_address {127.0.0.1:9401}, bound_addresses {[fe80::1]:9403}, {[::1]:9402}, {127.0.0.1:9401}
[2017-11-23T21:57:31,703][INFO ][o.e.t.d.MockZenPing ] [node_s2] pinging using mock zen ping
[2017-11-23T21:57:31,703][INFO ][o.e.t.d.MockZenPing ] [node_s1] pinging using mock zen ping
[2017-11-23T21:57:31,703][INFO ][o.e.t.d.MockZenPing ] [node_s0] pinging using mock zen ping
[2017-11-23T21:57:31,703][INFO ][o.e.t.d.MockZenPing ] [node_sc3] pinging using mock zen ping
[2017-11-23T21:57:31,813][INFO ][o.e.c.s.MasterService ] [node_s2] zen-disco-elected-as-master ([1] nodes joined)[{node_s0}{pCcOJN9vQjqSeC8bsMCyxA}{F90SN69rSt2IL7hfG0vCrw}{127.0.0.1}{127.0.0.1:9402}], zen-disco-node-join[{node_s1}{JD1UL8tJTZafqwmXjfM_Vw}{uVdNVr8zSCigujYJf1nI-g}{127.0.0.1}{127.0.0.1:9401}], reason: new_master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403}, added {{node_s1}{JD1UL8tJTZafqwmXjfM_Vw}{uVdNVr8zSCigujYJf1nI-g}{127.0.0.1}{127.0.0.1:9401},{node_s0}{pCcOJN9vQjqSeC8bsMCyxA}{F90SN69rSt2IL7hfG0vCrw}{127.0.0.1}{127.0.0.1:9402},}
[2017-11-23T21:57:31,828][INFO ][o.e.c.s.ClusterApplierService] [node_s0] detected_master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403}, added {{node_s1}{JD1UL8tJTZafqwmXjfM_Vw}{uVdNVr8zSCigujYJf1nI-g}{127.0.0.1}{127.0.0.1:9401},{node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403},}, reason: apply cluster state (from master [master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403} committed version [1]])
[2017-11-23T21:57:31,828][INFO ][o.e.c.s.ClusterApplierService] [node_s1] detected_master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403}, added {{node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403},{node_s0}{pCcOJN9vQjqSeC8bsMCyxA}{F90SN69rSt2IL7hfG0vCrw}{127.0.0.1}{127.0.0.1:9402},}, reason: apply cluster state (from master [master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403} committed version [1]])
[2017-11-23T21:57:31,841][INFO ][o.e.n.Node ] [node_s0] started
[2017-11-23T21:57:31,841][INFO ][o.e.n.Node ] [node_s1] started
[2017-11-23T21:57:31,843][INFO ][o.e.c.s.ClusterApplierService] [node_s2] new_master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403}, added {{node_s1}{JD1UL8tJTZafqwmXjfM_Vw}{uVdNVr8zSCigujYJf1nI-g}{127.0.0.1}{127.0.0.1:9401},{node_s0}{pCcOJN9vQjqSeC8bsMCyxA}{F90SN69rSt2IL7hfG0vCrw}{127.0.0.1}{127.0.0.1:9402},}, reason: apply cluster state (from master [master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403} committed version [1] source [zen-disco-elected-as-master ([1] nodes joined)[{node_s0}{pCcOJN9vQjqSeC8bsMCyxA}{F90SN69rSt2IL7hfG0vCrw}{127.0.0.1}{127.0.0.1:9402}], zen-disco-node-join[{node_s1}{JD1UL8tJTZafqwmXjfM_Vw}{uVdNVr8zSCigujYJf1nI-g}{127.0.0.1}{127.0.0.1:9401}]]])
[2017-11-23T21:57:31,847][INFO ][o.e.n.Node ] [node_s2] started
[2017-11-23T21:57:31,851][INFO ][o.e.c.s.MasterService ] [node_s2] zen-disco-node-join[{node_sc3}{-N3NCafBR-O1JHNvit89rg}{bhbfD7YCSsKUBAtch1B_qg}{127.0.0.1}{127.0.0.1:9400}], reason: added {{node_sc3}{-N3NCafBR-O1JHNvit89rg}{bhbfD7YCSsKUBAtch1B_qg}{127.0.0.1}{127.0.0.1:9400},}
[2017-11-23T21:57:31,874][INFO ][o.e.c.s.ClusterApplierService] [node_s1] added {{node_sc3}{-N3NCafBR-O1JHNvit89rg}{bhbfD7YCSsKUBAtch1B_qg}{127.0.0.1}{127.0.0.1:9400},}, reason: apply cluster state (from master [master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403} committed version [2]])
[2017-11-23T21:57:31,873][INFO ][o.e.c.s.ClusterApplierService] [node_sc3] detected_master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403}, added {{node_s1}{JD1UL8tJTZafqwmXjfM_Vw}{uVdNVr8zSCigujYJf1nI-g}{127.0.0.1}{127.0.0.1:9401},{node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403},{node_s0}{pCcOJN9vQjqSeC8bsMCyxA}{F90SN69rSt2IL7hfG0vCrw}{127.0.0.1}{127.0.0.1:9402},}, reason: apply cluster state (from master [master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403} committed version [2]])
[2017-11-23T21:57:31,874][INFO ][o.e.c.s.ClusterApplierService] [node_s0] added {{node_sc3}{-N3NCafBR-O1JHNvit89rg}{bhbfD7YCSsKUBAtch1B_qg}{127.0.0.1}{127.0.0.1:9400},}, reason: apply cluster state (from master [master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403} committed version [2]])
[2017-11-23T21:57:31,883][INFO ][o.e.n.Node ] [node_sc3] started
[2017-11-23T21:57:31,884][INFO ][o.e.c.s.ClusterApplierService] [node_s2] added {{node_sc3}{-N3NCafBR-O1JHNvit89rg}{bhbfD7YCSsKUBAtch1B_qg}{127.0.0.1}{127.0.0.1:9400},}, reason: apply cluster state (from master [master {node_s2}{9AtjFK_iSImBX-GovTgMyQ}{h1KGFtA5T1itCPLVKvbWvA}{127.0.0.1}{127.0.0.1:9403} committed version [2] source [zen-disco-node-join[{node_sc3}{-N3NCafBR-O1JHNvit89rg}{bhbfD7YCSsKUBAtch1B_qg}{127.0.0.1}{127.0.0.1:9400}]]])
[2017-11-23T21:57:31,886][INFO ][o.e.p.PluginsService ] [transport_client_node_sc3] no modules loaded
[2017-11-23T21:57:31,886][INFO ][o.e.p.PluginsService ] [transport_client_node_sc3] loaded plugin [org.elasticsearch.transport.MockTcpTransportPlugin]
[2017-11-23T21:57:31,895][INFO ][o.e.g.GatewayService ] [node_s2] recovered [0] indices into cluster_state
[2017-11-23T21:57:31,952][INFO ][o.e.p.PluginsService ] [transport_client_node_s2] no modules loaded
[2017-11-23T21:57:31,953][INFO ][o.e.p.PluginsService ] [transport_client_node_s2] loaded plugin [org.elasticsearch.transport.MockTcpTransportPlugin]
[2017-11-23T21:57:32,123][INFO ][o.f.e.d.SampleTest ] [SampleTest#test]: all set up test
[2017-11-23T21:57:32,124][INFO ][o.e.p.PluginsService ] [transport_client_node_s1] no modules loaded
[2017-11-23T21:57:32,125][INFO ][o.e.p.PluginsService ] [transport_client_node_s1] loaded plugin [org.elasticsearch.transport.MockTcpTransportPlugin]
[2017-11-23T21:57:32,228][INFO ][o.e.c.m.MetaDataCreateIndexService] [node_s2] [test-index] creating index, cause [api], templates [random_index_template], shards [4]/[0], mappings []
[2017-11-23T21:57:32,531][INFO ][o.e.c.r.a.AllocationService] [node_s2] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[test-index][1], [test-index][3]] ...]).
[2017-11-23T21:57:32,551][INFO ][o.f.e.d.SampleTest ] [SampleTest#test]: cleaning up after test
[2017-11-23T21:57:32,566][INFO ][o.e.p.PluginsService ] [transport_client_node_s0] no modules loaded
[2017-11-23T21:57:32,566][INFO ][o.e.p.PluginsService ] [transport_client_node_s0] loaded plugin [org.elasticsearch.transport.MockTcpTransportPlugin]
[2017-11-23T21:57:32,664][INFO ][o.e.c.m.MetaDataDeleteIndexService] [node_s2] [test-index/PQ0jLcgnQ-yyV9-d4-MQLw] deleting index
[2017-11-23T21:57:32,674][INFO ][o.e.t.s.MockFSIndexStore$Listener] [node_s0] [test-index][1] start check index
[2017-11-23T21:57:32,675][INFO ][o.e.t.s.MockFSIndexStore$Listener] [node_s1] [test-index][0] start check index
[2017-11-23T21:57:32,687][INFO ][o.e.t.s.MockFSIndexStore$Listener] [node_s0] [test-index][1] end check index
[2017-11-23T21:57:32,687][INFO ][o.e.t.s.MockFSIndexStore$Listener] [node_s1] [test-index][0] end check index
[2017-11-23T21:57:32,694][INFO ][o.e.t.s.MockFSIndexStore$Listener] [node_s1] [test-index][3] start check index
[2017-11-23T21:57:32,695][INFO ][o.e.t.s.MockFSIndexStore$Listener] [node_s1] [test-index][3] end check index
[2017-11-23T21:57:32,703][INFO ][o.e.t.s.MockFSIndexStore$Listener] [node_s2] [test-index][2] start check index
[2017-11-23T21:57:32,708][INFO ][o.e.t.s.MockFSIndexStore$Listener] [node_s2] [test-index][2] end check index
[2017-11-23T21:57:32,732][INFO ][o.f.e.d.SampleTest ] [SampleTest#test]: cleaned up after test
[2017-11-23T21:57:32,733][INFO ][o.f.e.d.SampleTest ] [test]: after test
其中输出日志有有一句:
[2017-11-23T21:57:32,228][INFO ][o.e.c.m.MetaDataCreateIndexService] [node_s2] [test-index] creating index, cause [api], templates [random_index_template], shards [4]/[0], mappings []
表示测试成功,终于可以开心的去用 Elasticsearch 官方提供的单元测试框架来测试 Elasticsearch 强大的各种功能和原理.
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于