This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves #53 by moving httpClient setting on jestClient before starti…
…ng NodeChecker. also adds default discovery frequencies in ClientConfig.
- Loading branch information
Cihat Keser
committed
Jul 11, 2013
1 parent
dda3159
commit d62daa0
Showing
4 changed files
with
76 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/java/io/searchbox/client/JestClientFactoryIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.searchbox.client; | ||
|
||
import com.github.tlrx.elasticsearch.test.annotations.ElasticsearchAdminClient; | ||
import com.github.tlrx.elasticsearch.test.annotations.ElasticsearchNode; | ||
import com.github.tlrx.elasticsearch.test.support.junit.runners.ElasticsearchRunner; | ||
import io.searchbox.client.config.ClientConfig; | ||
import io.searchbox.client.http.JestHttpClient; | ||
import org.elasticsearch.client.AdminClient; | ||
import org.elasticsearch.node.Node; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
import static junit.framework.Assert.assertNotNull; | ||
|
||
/** | ||
* @author cihat keser | ||
*/ | ||
@RunWith(ElasticsearchRunner.class) | ||
@ElasticsearchNode | ||
public class JestClientFactoryIntegrationTest { | ||
|
||
|
||
@ElasticsearchNode(name = "2nd") | ||
Node node; | ||
@ElasticsearchAdminClient | ||
AdminClient adminClient; | ||
JestClientFactory factory = new JestClientFactory(); | ||
|
||
@Test | ||
public void testDiscovery() throws InterruptedException { | ||
// wait for 2 active nodes | ||
adminClient.cluster().prepareHealth().setWaitForGreenStatus(). | ||
setWaitForNodes("2").setWaitForRelocatingShards(0).execute().actionGet(); | ||
|
||
factory.setClientConfig(new ClientConfig | ||
.Builder("http://localhost:9200") | ||
.discoveryEnabled(true) | ||
.discoveryFrequency(1l, TimeUnit.SECONDS) | ||
.build()); | ||
JestHttpClient jestClient = (JestHttpClient) factory.getObject(); | ||
assertNotNull(jestClient); | ||
|
||
// wait for NodeChecker to do the discovery | ||
Thread.sleep(3000); | ||
|
||
assertEquals("All 2 nodes should be discovered and be in the client's server list", 2, jestClient.getServers().size()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters