Hi.
Ive created integration tests for the ES integration in our product. We use
version 0.18.6
For all tests, the flow is like this:
Index data -> this.client.index( request ).actionGet();
Flush index -> client.admin().indices().flush( Requests.flushRequest(
INDEX_NAME ).refresh( true ) ).actionGet();
Query -> this.client.search( req ).actionGet();
When running a lot of tests, usually one or two test fails with not
expected results from query, meaning that the query is executed before the
index is updated properly. When running all tests again, another test may
fail while to previous was successfull.
What can I do to enshure that the test will run properly each time? I
thought the flush-index would make shure that everything was flushed into
the index?
The settings for the test-environment is like this:
protected static final String NUMBER_OF_SHARDS = "5";
protected static final String NUMBER_OF_REPLICAS = "1";
public ImmutableSettings.Builder buildSettings()
{
ImmutableSettings.Builder settings =
ImmutableSettings.settingsBuilder();
settings.loadFromSource( buildDistributionSettings() );
settings.loadFromSource( buildStorageSettings() );
//settings.loadFromSource( buildAnalyserSettings() );
return settings;
}
private String buildStorageSettings()
{
try
{
return jsonBuilder().startObject().startObject( "store"
).field( "type", "memory" ).endObject().endObject().string();
}
catch ( IOException e )
{
throw new ContentIndexException( "Not able to create settings
for index", e );
}
}
private String buildDistributionSettings()
{
try
{
return jsonBuilder().startObject()
.field( "number_of_shards", NUMBER_OF_SHARDS )
.field( "number_of_replicas", NUMBER_OF_REPLICAS )
.endObject()
.string();
}
catch ( IOException e )
{
throw new ContentIndexException( "Not able to create settings
for index", e );
}
}
mvh
Runar Myklebust