Skip to content

Commit

Permalink
Fixed tests that were using incosistent type name in their mapping.
Browse files Browse the repository at this point in the history
In master (1.0.0beta) we have added a check that makes this fail. The check it self is not backported to 0.90 as it is not comptabile but we want to keep the code base as similar as possible.

See elastic#4038
  • Loading branch information
bleskes committed Nov 5, 2013
1 parent e188ba0 commit 8549004
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 159 deletions.
Expand Up @@ -51,10 +51,10 @@
/**
*
*/
@ClusterScope(numNodes=0, scope=Scope.TEST)
@ClusterScope(numNodes = 0, scope = Scope.TEST)
public class SimpleRecoveryLocalGatewayTests extends AbstractIntegrationTest {


private ImmutableSettings.Builder settingsBuilder() {
return ImmutableSettings.settingsBuilder().put("gateway.type", "local");
}
Expand Down Expand Up @@ -237,7 +237,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
public boolean clearData(String nodeName) {
return firstNode.equals(nodeName);
}

});

logger.info("Running Cluster Health (wait for the shards to startup)");
Expand Down Expand Up @@ -290,7 +290,7 @@ public void doAfterNodes(int numNodes, Client client) throws Exception {

logger.info("--> add some metadata, additional type and template");
client.admin().indices().preparePutMapping("test").setType("type2")
.setSource(jsonBuilder().startObject().startObject("type1").startObject("_source").field("enabled", false).endObject().endObject().endObject())
.setSource(jsonBuilder().startObject().startObject("type2").startObject("_source").field("enabled", false).endObject().endObject().endObject())
.execute().actionGet();
client.admin().indices().preparePutTemplate("template_1")
.setTemplate("te*")
Expand All @@ -303,9 +303,9 @@ public void doAfterNodes(int numNodes, Client client) throws Exception {
client.admin().indices().prepareAliases().addAlias("test", "test_alias", FilterBuilders.termFilter("field", "value")).execute().actionGet();
logger.info("--> starting two nodes back, verifying we got the latest version");
}

}

});

logger.info("--> running cluster_health (wait for the shards to startup)");
Expand Down Expand Up @@ -333,7 +333,7 @@ public void testReusePeerRecovery() throws Exception {
ImmutableSettings.Builder settings = settingsBuilder()
.put("action.admin.cluster.node.shutdown.delay", "10ms")
.put("gateway.recover_after_nodes", 4)

.put(BalancedShardsAllocator.SETTING_THRESHOLD, 1.1f); // use less agressive settings

cluster().startNode(settings);
Expand Down
51 changes: 26 additions & 25 deletions src/test/java/org/elasticsearch/get/GetActionTests.java
Expand Up @@ -60,7 +60,7 @@ public void simpleGetTests() {
response = client().prepareGet("test", "type1", "1").setFields(Strings.EMPTY_ARRAY).execute().actionGet();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getSourceAsBytes(), nullValue());

logger.info("--> realtime get 1 (no type)");
response = client().prepareGet("test", null, "1").execute().actionGet();
assertThat(response.isExists(), equalTo(true));
Expand Down Expand Up @@ -200,8 +200,8 @@ public void realtimeGetWithCompress() throws Exception {
public void getFieldsWithDifferentTypes() throws Exception {

client().admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.refresh_interval", -1))
.addMapping("type1", jsonBuilder().startObject().startObject("type").startObject("_source").field("enabled", true).endObject().endObject().endObject())
.addMapping("type2", jsonBuilder().startObject().startObject("type")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("_source").field("enabled", true).endObject().endObject().endObject())
.addMapping("type2", jsonBuilder().startObject().startObject("type2")
.startObject("_source").field("enabled", false).endObject()
.startObject("properties")
.startObject("str").field("type", "string").field("store", "yes").endObject()
Expand Down Expand Up @@ -374,13 +374,13 @@ public void testThatGetFromTranslogShouldWorkWithExclude() throws Exception {

String mapping = jsonBuilder()
.startObject()
.startObject("source_excludes")
.startObject("_source")
.array("excludes", "excluded")
.endObject()
.endObject()
.startObject(type)
.startObject("_source")
.array("excludes", "excluded")
.endObject()
.endObject()
.string();
.endObject()
.string();

client().admin().indices().prepareCreate(index)
.addMapping(type, mapping)
Expand Down Expand Up @@ -408,14 +408,14 @@ public void testThatGetFromTranslogShouldWorkWithInclude() throws Exception {
String type = "type1";

String mapping = jsonBuilder()
.startObject()
.startObject("source_excludes")
.startObject("_source")
.array("includes", "included")
.endObject()
.startObject()
.startObject(type)
.startObject("_source")
.array("includes", "included")
.endObject()
.endObject()
.endObject()
.string();
.endObject()
.string();

client().admin().indices().prepareCreate(index)
.addMapping(type, mapping)
Expand Down Expand Up @@ -443,15 +443,15 @@ public void testThatGetFromTranslogShouldWorkWithIncludeExcludeAndFields() throw
String type = "type1";

String mapping = jsonBuilder()
.startObject()
.startObject("source_excludes")
.startObject("_source")
.array("includes", "included")
.array("exlcudes", "excluded")
.endObject()
.startObject()
.startObject(type)
.startObject("_source")
.array("includes", "included")
.array("exlcudes", "excluded")
.endObject()
.endObject()
.endObject()
.string();
.endObject()
.string();

client().admin().indices().prepareCreate(index)
.addMapping(type, mapping)
Expand All @@ -463,7 +463,7 @@ public void testThatGetFromTranslogShouldWorkWithIncludeExcludeAndFields() throw
.field("field", "1", "2")
.field("included", "should be seen")
.field("excluded", "should not be seen")
.endObject())
.endObject())
.execute().actionGet();

GetResponse responseBeforeFlush = client().prepareGet(index, type, "1").setFields("_source", "included", "excluded").execute().actionGet();
Expand All @@ -476,6 +476,7 @@ public void testThatGetFromTranslogShouldWorkWithIncludeExcludeAndFields() throw
assertThat(responseBeforeFlush.getSourceAsMap(), not(hasKey("field")));
assertThat(responseBeforeFlush.getSourceAsMap(), hasKey("included"));
assertThat(responseBeforeFlush.getSourceAsString(), is(responseAfterFlush.getSourceAsString()));

}

}
Expand Up @@ -150,14 +150,14 @@ public void testDefaultMappingAndNoMapping() throws Exception {
// all is well
}
}

@Test
public void testDefaultMappingAndWithMappingOverride() throws Exception {
String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING)
.startObject("_source").field("enabled", false).endObject()
.endObject().endObject().string();

String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
String mapping = XContentFactory.jsonBuilder().startObject().startObject("my_type")
.startObject("_source").field("enabled", true).endObject()
.endObject().endObject().string();

Expand Down Expand Up @@ -189,7 +189,7 @@ public void testDefaultMappingAndWithMappingOverrideWithMapperService() throws E
MapperService mapperService = MapperTestUtils.newMapperService();
mapperService.merge(MapperService.DEFAULT_MAPPING, defaultMapping, true);

String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
String mapping = XContentFactory.jsonBuilder().startObject().startObject("my_type")
.startObject("_source").field("enabled", true).endObject()
.endObject().endObject().string();
mapperService.merge("my_type", mapping, true);
Expand Down

0 comments on commit 8549004

Please sign in to comment.