2424import org .elasticsearch .common .settings .ImmutableSettings ;
2525import org .elasticsearch .common .settings .Settings ;
2626import org .elasticsearch .env .Environment ;
27+ import org .elasticsearch .http .HttpServerTransport ;
28+ import org .elasticsearch .node .Node ;
29+ import org .elasticsearch .node .internal .InternalNode ;
2730import org .elasticsearch .node .internal .InternalSettingsPerparer ;
2831import org .elasticsearch .plugins .PluginManager ;
2932import org .elasticsearch .rest .RestStatus ;
@@ -53,10 +56,10 @@ public void testLocalPluginInstallSingleFolder() throws Exception {
5356 URL url = PluginManagerTests .class .getResource ("plugin_single_folder.zip" );
5457 downloadAndExtract (pluginName , "file://" + url .getFile ());
5558
56- startNode ();
59+ Node node = startNode ();
5760
5861 assertPluginLoaded (pluginName );
59- assertPluginAvailable (pluginName );
62+ assertPluginAvailable (node , pluginName );
6063 }
6164
6265 @ Test
@@ -67,10 +70,10 @@ public void testLocalPluginInstallSiteFolder() throws Exception {
6770 URL url = PluginManagerTests .class .getResource ("plugin_folder_site.zip" );
6871 downloadAndExtract (pluginName , "file://" + url .getFile ());
6972
70- startNode ();
73+ Node node = startNode ();
7174
7275 assertPluginLoaded (pluginName );
73- assertPluginAvailable (pluginName );
76+ assertPluginAvailable (node , pluginName );
7477 }
7578
7679 @ Test
@@ -80,10 +83,10 @@ public void testLocalPluginWithoutFolders() throws Exception {
8083 URL url = PluginManagerTests .class .getResource ("plugin_without_folders.zip" );
8184 downloadAndExtract (pluginName , "file://" + url .getFile ());
8285
83- startNode ();
86+ Node node = startNode ();
8487
8588 assertPluginLoaded (pluginName );
86- assertPluginAvailable (pluginName );
89+ assertPluginAvailable (node , pluginName );
8790 }
8891
8992 @ Test
@@ -93,26 +96,25 @@ public void testLocalPluginFolderAndFile() throws Exception {
9396 URL url = PluginManagerTests .class .getResource ("plugin_folder_file.zip" );
9497 downloadAndExtract (pluginName , "file://" + url .getFile ());
9598
96- startNode ();
99+ Node node = startNode ();
97100
98101 assertPluginLoaded (pluginName );
99- assertPluginAvailable (pluginName );
102+ assertPluginAvailable (node , pluginName );
100103 }
101104
102105 private static void downloadAndExtract (String pluginName , String pluginUrl ) throws Exception {
103106 Tuple <Settings , Environment > initialSettings = InternalSettingsPerparer .prepareSettings (
104- ImmutableSettings .settingsBuilder ()/*.put("path.plugins", PLUGIN_DIR)*/ .build (), false );
107+ ImmutableSettings .settingsBuilder ().build (), false );
105108 if (!initialSettings .v2 ().pluginsFile ().exists ()) {
106109 FileSystemUtils .mkdirs (initialSettings .v2 ().pluginsFile ());
107110 }
108111 PluginManager pluginManager = new PluginManager (initialSettings .v2 (), pluginUrl );
109112 pluginManager .downloadAndExtract (pluginName , false );
110113 }
111114
112- private void startNode () {
113- startNode (NODE_NAME , ImmutableSettings .settingsBuilder ()
114- .put ("discovery.zen.ping.multicast.enabled" , false )
115- /*.put("path.plugins", PLUGIN_DIR)*/ );
115+ private Node startNode () {
116+ return startNode (NODE_NAME , ImmutableSettings .settingsBuilder ()
117+ .put ("discovery.zen.ping.multicast.enabled" , false ));
116118 }
117119
118120 private void assertPluginLoaded (String pluginName ) {
@@ -124,8 +126,9 @@ private void assertPluginLoaded(String pluginName) {
124126 assertThat (nodesInfoResponse .getNodes ()[0 ].getPlugins ().getInfos ().get (0 ).isSite (), equalTo (true ));
125127 }
126128
127- private void assertPluginAvailable (String pluginName ) {
128- HttpClient httpClient = new HttpClient ("http://127.0.0.1:9200/" );
129+ private void assertPluginAvailable (Node node , String pluginName ) {
130+ HttpServerTransport httpServerTransport = ((InternalNode ) node ).injector ().getInstance (HttpServerTransport .class );
131+ HttpClient httpClient = new HttpClient (httpServerTransport .boundAddress ().publishAddress ());
129132 //checking that the http connector is working properly
130133 HttpClientResponse response = httpClient .request ("" );
131134 assertThat (response .errorCode (), equalTo (RestStatus .OK .getStatus ()));
0 commit comments