|
|
@@ -31,12 +31,16 @@ import org.elasticsearch.search.aggregations.AggregationBuilders;
|
|
|
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
|
|
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
|
|
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
|
|
|
+import org.hamcrest.Matchers;
|
|
|
|
|
|
import java.util.Set;
|
|
|
+import java.util.concurrent.Callable;
|
|
|
|
|
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
|
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFailures;
|
|
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
|
|
|
+import static org.hamcrest.Matchers.equalTo;
|
|
|
+import static org.hamcrest.Matchers.notNullValue;
|
|
|
|
|
|
@ClusterScope(randomDynamicTemplates = false)
|
|
|
public class DisabledFieldDataFormatTests extends ElasticsearchIntegrationTest {
|
|
|
@@ -119,41 +123,24 @@ public class DisabledFieldDataFormatTests extends ElasticsearchIntegrationTest {
|
|
|
.endObject()
|
|
|
.endObject()).get());
|
|
|
logger.info(">> put mapping end {}", format);
|
|
|
- boolean applied = awaitBusy(new Predicate<Object>() {
|
|
|
+ assertBusy(new Callable<Object>() {
|
|
|
@Override
|
|
|
- public boolean apply(Object input) {
|
|
|
- try {
|
|
|
- Set<String> nodes = internalCluster().nodesInclude("test");
|
|
|
- if (nodes.isEmpty()) { // we expect at least one node to hold an index, so wait if not allocated yet
|
|
|
- return false;
|
|
|
- }
|
|
|
- for (String node : nodes) {
|
|
|
- IndicesService indicesService = internalCluster().getInstance(IndicesService.class, node);
|
|
|
- IndexService indexService = indicesService.indexService("test");
|
|
|
- if (indexService == null) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- final SmartNameFieldMappers mappers = indexService.mapperService().smartName("s");
|
|
|
- if (mappers == null || !mappers.hasMapper()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- final String currentFormat = mappers.mapper().fieldDataType().getFormat(ImmutableSettings.EMPTY);
|
|
|
- if (!format.equals(currentFormat)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- logger.info("got exception waiting for concrete mappings", e);
|
|
|
- return false;
|
|
|
+ public Object call() throws Exception {
|
|
|
+ Set<String> nodes = internalCluster().nodesInclude("test");
|
|
|
+ assertFalse(nodes.isEmpty());
|
|
|
+ for (String node : nodes) {
|
|
|
+ IndicesService indicesService = internalCluster().getInstance(IndicesService.class, node);
|
|
|
+ IndexService indexService = indicesService.indexService("test");
|
|
|
+ assertThat(indexService, notNullValue());
|
|
|
+ final SmartNameFieldMappers mappers = indexService.mapperService().smartName("s");
|
|
|
+ assertThat(mappers, notNullValue());
|
|
|
+ assertTrue(mappers.hasMapper());
|
|
|
+ final String currentFormat = mappers.mapper().fieldDataType().getFormat(ImmutableSettings.EMPTY);
|
|
|
+ assertThat(currentFormat, equalTo(format));
|
|
|
}
|
|
|
- return true;
|
|
|
+ return null;
|
|
|
}
|
|
|
});
|
|
|
- waitNoPendingTasksOnAll();
|
|
|
- logger.info(">> put mapping verified {}, applies {}", format, applied);
|
|
|
- if (!applied) {
|
|
|
- fail();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
}
|