Skip to content

Commit

Permalink
fix the test execution order (related to elastic#27) and add Embedded…
Browse files Browse the repository at this point in the history
…ElasticSerach in before/after class
  • Loading branch information
tzolov committed Apr 12, 2013
1 parent 3d94d37 commit bd389e3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 11 deletions.
Expand Up @@ -15,13 +15,12 @@
*/
package org.elasticsearch.hadoop.cascading;

import java.util.Properties;

import org.elasticsearch.hadoop.cfg.ConfigurationOptions;
import org.elasticsearch.hadoop.EmbeddedElasticsearchServer;
import org.elasticsearch.hadoop.util.TestUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import cascading.flow.FlowDef;
import cascading.flow.hadoop.HadoopFlowConnector;
import cascading.operation.Identity;
import cascading.pipe.Each;
Expand All @@ -33,25 +32,41 @@

public class CascadingHadoopTest {

private static EmbeddedElasticsearchServer esServer;

{
TestUtils.hackHadoopStagingOnWin();
}

@BeforeClass
public static void beforeClass() {
esServer = new EmbeddedElasticsearchServer();
}

@AfterClass
public static void afterClass() {
esServer.shutdown();
}

@Test
public void testWriteToES() throws Exception {
public void testWriteToESAdnReadFromES() throws Exception {
testWriteToES();

testReadFromES();
}

private void testWriteToES() throws Exception {
// local file-system source
Tap in = new Lfs(new TextDelimited(new Fields("id", "name", "url", "picture")), "src/test/resources/artists.dat");
Tap out = new ESTap("radio/artists", new Fields("name", "url", "picture"));
Pipe pipe = new Pipe("copy");

// rename "id" -> "garbage"
pipe = new Each(pipe, new Identity(new Fields("garbage", "name", "url", "picture")));
new HadoopFlowConnector().connect(in, out, pipe).complete();
}

@Test
public void testReadFromES() throws Exception {
private void testReadFromES() throws Exception {
Tap in = new ESTap("http://localhost:9200/radio/artists/_search?q=me*");
Pipe copy = new Pipe("copy");
// print out
Expand Down
Expand Up @@ -15,6 +15,9 @@
*/
package org.elasticsearch.hadoop.cascading;

import org.elasticsearch.hadoop.EmbeddedElasticsearchServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import cascading.flow.local.LocalFlowConnector;
Expand All @@ -30,8 +33,28 @@

public class CascadingLocalTest {

private static EmbeddedElasticsearchServer esServer;


@BeforeClass
public static void beforeClass() {
esServer = new EmbeddedElasticsearchServer();
}

@AfterClass
public static void afterClass() {
esServer.shutdown();
}

@Test
public void testWriteToES() throws Exception {
public void testWriteToESAdnReadFromES() throws Exception {

testWriteToES();

testReadFromES();
}

private void testWriteToES() throws Exception {
// local file-system source
Tap in = new FileTap(new TextDelimited(new Fields("id", "name", "url", "picture")), "src/test/resources/artists.dat");
Tap out = new ESTap("radio/artists", new Fields("name", "url", "picture"));
Expand All @@ -43,8 +66,8 @@ public void testWriteToES() throws Exception {
new LocalFlowConnector().connect(in, out, pipe).complete();
}

@Test
public void testReadFromES() throws Exception {

private void testReadFromES() throws Exception {
Tap in = new ESTap("http://localhost:9200/radio/artists/_search?q=me*");
Pipe copy = new Pipe("copy");
// print out
Expand Down

0 comments on commit bd389e3

Please sign in to comment.