Skip to content

Commit

Permalink
Pass itest jar path to tests through system property (#1443)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaiera authored Mar 19, 2020
1 parent 3438a08 commit 7f36061
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ class BuildPlugin implements Plugin<Project> {

Test integrationTest = project.tasks.create('integrationTest', RestTestRunnerTask.class)
integrationTest.dependsOn(itestJar)
integrationTest.doFirst {
integrationTest.systemProperty("es.hadoop.job.jar", itestJar.getArchiveFile().get().asFile.absolutePath)
}

integrationTest.testClassesDirs = project.sourceSets.itest.output.classesDirs
integrationTest.classpath = project.sourceSets.itest.runtimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.elasticsearch.hadoop;

import org.elasticsearch.hadoop.HdpBootstrap;
import org.elasticsearch.hadoop.Provisioner;
import org.junit.Test;

public class ProvisionerTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,17 @@
*/
package org.elasticsearch.spark.integration;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.Arrays;

import org.apache.spark.SparkConf;
import org.elasticsearch.hadoop.util.Assert;
import org.elasticsearch.hadoop.Provisioner;
import org.elasticsearch.hadoop.util.ReflectionUtils;

import com.esotericsoftware.kryo.Kryo;

public abstract class SparkUtils {

public static final String[] ES_SPARK_TESTING_JAR;

static {
// init ES-Hadoop JAR
// expect the jar under build\libs
try {
File folder = new File("build" + File.separator + "libs" + File.separator).getCanonicalFile();
System.out.println(folder.getAbsolutePath());
// find proper jar
File[] files = folder.listFiles(new FileFilter() {

@Override
public boolean accept(File pathname) {
return pathname.getName().contains("-testing.jar");
}
});
Assert.isTrue(files != null && files.length == 1,
String.format("Cannot find elasticsearch spark jar (too many or no file found);%s", Arrays.toString(files)));
ES_SPARK_TESTING_JAR = new String[] { files[0].getAbsoluteFile().toURI().toString() };

} catch (IOException ex) {
throw new RuntimeException("Cannot find required files", ex);
}
}
public static final String[] ES_SPARK_TESTING_JAR = new String[] {Provisioner.ESHADOOP_TESTING_JAR};

public static Kryo sparkSerializer(SparkConf conf) throws Exception {
// reflection galore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,21 @@ public abstract class Provisioner {

public static final String ESHADOOP_TESTING_JAR;
public static final String HDFS_ES_HDP_LIB = "/eshdp/libs/es-hadoop.jar";
public static final String SYS_PROP_JOB_JAR = "es.hadoop.job.jar";

static {
// init ES-Hadoop JAR
// expect the jar under build\libs
try {
File folder = new File("build" + File.separator + "libs" + File.separator).getCanonicalFile();
// find proper jar
File[] files = folder.listFiles(new FileFilter() {

@Override
public boolean accept(File pathname) {
return pathname.getName().contains("-testing");
}
});
Assert.isTrue(files != null && files.length == 1,
String.format("Cannot find elasticsearch hadoop jar (too many or no file found);%s", Arrays.toString(files)));
ESHADOOP_TESTING_JAR = files[0].getAbsoluteFile().toURI().toString();
String jobJarLocation = System.getProperty(SYS_PROP_JOB_JAR);
if (jobJarLocation == null) {
throw new RuntimeException("Cannot find elasticsearch hadoop jar. System Property [" + SYS_PROP_JOB_JAR + "] was not set.");
}

File testJar = new File(jobJarLocation).getCanonicalFile();
Assert.isTrue(testJar.exists(),
String.format("Cannot find elasticsearch hadoop jar. File not found [%s]", testJar));
ESHADOOP_TESTING_JAR = testJar.getAbsolutePath();
} catch (IOException ex) {
throw new RuntimeException("Cannot find required files", ex);
}
Expand Down

0 comments on commit 7f36061

Please sign in to comment.