From a5367b2ab38b8632a26f215f2765852d926268d7 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Fri, 17 Jan 2014 21:46:17 +0200 Subject: [PATCH] beef up M/R integration tests relates to #9 --- .../integration/mr/MRNewApiSaveTest.java | 2 +- .../integration/mr/MRNewApiSearchTest.java | 20 ++++++++++--------- .../integration/mr/MROldApiSearchTest.java | 20 ++++++++++--------- .../hadoop/integration/mr/MRSuite.java | 2 +- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/test/java/org/elasticsearch/hadoop/integration/mr/MRNewApiSaveTest.java b/src/test/java/org/elasticsearch/hadoop/integration/mr/MRNewApiSaveTest.java index d9b3a22cd..e95b614e5 100644 --- a/src/test/java/org/elasticsearch/hadoop/integration/mr/MRNewApiSaveTest.java +++ b/src/test/java/org/elasticsearch/hadoop/integration/mr/MRNewApiSaveTest.java @@ -107,8 +107,8 @@ public static Collection configs() throws IOException { private Configuration config; public MRNewApiSaveTest(Job job, String indexPrefix) { - this.indexPrefix = indexPrefix; this.config = job.getConfiguration(); + this.indexPrefix = indexPrefix; } diff --git a/src/test/java/org/elasticsearch/hadoop/integration/mr/MRNewApiSearchTest.java b/src/test/java/org/elasticsearch/hadoop/integration/mr/MRNewApiSearchTest.java index 963640acf..066d8a87f 100644 --- a/src/test/java/org/elasticsearch/hadoop/integration/mr/MRNewApiSearchTest.java +++ b/src/test/java/org/elasticsearch/hadoop/integration/mr/MRNewApiSearchTest.java @@ -45,16 +45,18 @@ public static Collection queries() { return QueryTestParams.params(); } - private String query; + private final String query; + private final String indexPrefix; - public MRNewApiSearchTest(String query) { + public MRNewApiSearchTest(String indexPrefix, String query) { + this.indexPrefix = indexPrefix; this.query = query; } @Test public void testBasicSearch() throws Exception { Configuration conf = createConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mrnewapi/save"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mrnewapi/save"); new Job(conf).waitForCompletion(true); } @@ -62,7 +64,7 @@ public void testBasicSearch() throws Exception { @Test public void testSearchWithId() throws Exception { Configuration conf = createConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mrnewapi/savewithid"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mrnewapi/savewithid"); new Job(conf).waitForCompletion(true); } @@ -71,7 +73,7 @@ public void testSearchWithId() throws Exception { public void testSearchNonExistingIndex() throws Exception { Configuration conf = createConf(); conf.setBoolean(ConfigurationOptions.ES_INDEX_READ_MISSING_AS_EMPTY, true); - conf.set(ConfigurationOptions.ES_RESOURCE, "foobar/save"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "foobar/save"); new Job(conf).waitForCompletion(true); } @@ -79,7 +81,7 @@ public void testSearchNonExistingIndex() throws Exception { @Test public void testSearchCreated() throws Exception { Configuration conf = createConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mrnewapi/createwithid"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mrnewapi/createwithid"); new Job(conf).waitForCompletion(true); } @@ -87,7 +89,7 @@ public void testSearchCreated() throws Exception { @Test public void testSearchUpdated() throws Exception { Configuration conf = createConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mrnewapi/update"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mrnewapi/update"); new Job(conf).waitForCompletion(true); } @@ -96,7 +98,7 @@ public void testSearchUpdated() throws Exception { public void testSearchUpdatedWithoutUpsertMeaningNonExistingIndex() throws Exception { Configuration conf = createConf(); conf.setBoolean(ConfigurationOptions.ES_INDEX_READ_MISSING_AS_EMPTY, false); - conf.set(ConfigurationOptions.ES_RESOURCE, "mrnewapi/updatewoupsert"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mrnewapi/updatewoupsert"); new Job(conf).waitForCompletion(true); } @@ -104,7 +106,7 @@ public void testSearchUpdatedWithoutUpsertMeaningNonExistingIndex() throws Excep @Test public void testParentChild() throws Exception { Configuration conf = createConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mrnewapi/child"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mrnewapi/child"); conf.set(ConfigurationOptions.ES_INDEX_AUTO_CREATE, "no"); conf.set(ConfigurationOptions.ES_MAPPING_PARENT, "number"); diff --git a/src/test/java/org/elasticsearch/hadoop/integration/mr/MROldApiSearchTest.java b/src/test/java/org/elasticsearch/hadoop/integration/mr/MROldApiSearchTest.java index 65e97ba6b..3dfc11e32 100644 --- a/src/test/java/org/elasticsearch/hadoop/integration/mr/MROldApiSearchTest.java +++ b/src/test/java/org/elasticsearch/hadoop/integration/mr/MROldApiSearchTest.java @@ -45,16 +45,18 @@ public static Collection queries() { return QueryTestParams.params(); } - private String query; + private final String query; + private final String indexPrefix; - public MROldApiSearchTest(String query) { + public MROldApiSearchTest(String indexPrefix, String query) { this.query = query; + this.indexPrefix = indexPrefix; } @Test public void testBasicSearch() throws Exception { JobConf conf = createJobConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mroldapi/save"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mroldapi/save"); JobClient.runJob(conf); } @@ -62,7 +64,7 @@ public void testBasicSearch() throws Exception { @Test public void testSearchWithId() throws Exception { JobConf conf = createJobConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mroldapi/savewithid"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mroldapi/savewithid"); JobClient.runJob(conf); } @@ -79,7 +81,7 @@ public void testSearchNonExistingIndex() throws Exception { @Test public void testSearchCreated() throws Exception { JobConf conf = createJobConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mroldapi/createwithid"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mroldapi/createwithid"); JobClient.runJob(conf); } @@ -87,7 +89,7 @@ public void testSearchCreated() throws Exception { @Test public void testSearchUpdated() throws Exception { JobConf conf = createJobConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mroldapi/update"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mroldapi/update"); JobClient.runJob(conf); } @@ -96,7 +98,7 @@ public void testSearchUpdated() throws Exception { public void testSearchUpdatedWithoutUpsertMeaningNonExistingIndex() throws Exception { JobConf conf = createJobConf(); conf.setBoolean(ConfigurationOptions.ES_INDEX_READ_MISSING_AS_EMPTY, false); - conf.set(ConfigurationOptions.ES_RESOURCE, "mroldapi/updatewoupsert"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mroldapi/updatewoupsert"); JobClient.runJob(conf); } @@ -104,7 +106,7 @@ public void testSearchUpdatedWithoutUpsertMeaningNonExistingIndex() throws Excep @Test public void testParentChild() throws Exception { JobConf conf = createJobConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mroldapi/child"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mroldapi/child"); conf.set(ConfigurationOptions.ES_INDEX_AUTO_CREATE, "no"); conf.set(ConfigurationOptions.ES_MAPPING_PARENT, "number"); @@ -115,7 +117,7 @@ public void testParentChild() throws Exception { //@Test public void testNested() throws Exception { JobConf conf = createJobConf(); - conf.set(ConfigurationOptions.ES_RESOURCE, "mroldapi/nested"); + conf.set(ConfigurationOptions.ES_RESOURCE, indexPrefix + "mroldapi/nested"); conf.set(ConfigurationOptions.ES_INDEX_AUTO_CREATE, "no"); //conf.set(Stream.class.getName(), "OUT"); diff --git a/src/test/java/org/elasticsearch/hadoop/integration/mr/MRSuite.java b/src/test/java/org/elasticsearch/hadoop/integration/mr/MRSuite.java index 346cd0dfe..ba11f4d4e 100644 --- a/src/test/java/org/elasticsearch/hadoop/integration/mr/MRSuite.java +++ b/src/test/java/org/elasticsearch/hadoop/integration/mr/MRSuite.java @@ -28,7 +28,7 @@ @RunWith(Suite.class) @Suite.SuiteClasses({ MROldApiSaveTest.class, MROldApiSearchTest.class, MRNewApiSaveTest.class, MRNewApiSearchTest.class }) -//@Suite.SuiteClasses({ MRNewApiSaveTest.class }) +//@Suite.SuiteClasses({ MRNewApiSaveTest.class, MRNewApiSearchTest.class }) public class MRSuite { @ClassRule public static ExternalResource resource = new LocalEs();