Fix test bug in DynamicMappingsIT.
Closes
@@ -24,6 +24,7 @@ import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.test.ESIntegTestCase;
+import org.hamcrest.Matchers;
import java.io.IOException;
import java.util.Map;
@@ -40,7 +41,15 @@ public class DynamicMappingIT extends ESIntegTestCase {
client().prepareIndex("index", "type", "2").setSource("foo", "bar").get();
fail("Indexing request should have failed!");
} catch (MapperParsingException e) {
- // expected
+ // general case, the parsing code complains that it can't parse "bar" as a "long"
+ assertThat(e.getMessage(),
+ Matchers.containsString("failed to parse field [foo] of type [long]"));
+ } catch (IllegalArgumentException e) {
+ // rare case: the node that processes the index request doesn't have the mappings
+ // yet and sends a mapping update to the master node to map "bar" as "text". This
+ // fails as it had been already mapped as a long by the previous index request.
+ assertThat(e.getMessage(),
+ Matchers.containsString("mapper [foo] of different type, current_type [long], merged_type [text]"));
}
}
