Skip to content

Commit

Permalink
beef up M/R integration tests
Browse files Browse the repository at this point in the history
relates to #9
  • Loading branch information
costin committed Jan 17, 2014
1 parent 0b7e7f4 commit a5367b2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
Expand Up @@ -107,8 +107,8 @@ public static Collection<Object[]> configs() throws IOException {
private Configuration config;

public MRNewApiSaveTest(Job job, String indexPrefix) {
this.indexPrefix = indexPrefix;
this.config = job.getConfiguration();
this.indexPrefix = indexPrefix;
}


Expand Down
Expand Up @@ -45,24 +45,26 @@ public static Collection<Object[]> 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);
}

@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);
}
Expand All @@ -71,23 +73,23 @@ 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);
}

@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);
}

@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);
}
Expand All @@ -96,15 +98,15 @@ 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);
}

@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");

Expand Down
Expand Up @@ -45,24 +45,26 @@ public static Collection<Object[]> 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);
}

@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);
}
Expand All @@ -79,15 +81,15 @@ 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);
}

@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);
}
Expand All @@ -96,15 +98,15 @@ 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);
}

@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");

Expand All @@ -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");
Expand Down
Expand Up @@ -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();
Expand Down

0 comments on commit a5367b2

Please sign in to comment.