Skip to content

Instantly share code, notes, and snippets.

@jayunit100
Last active August 29, 2015 14:01
Show Gist options
  • Save jayunit100/a0fa4e70b69151aa7151 to your computer and use it in GitHub Desktop.
Save jayunit100/a0fa4e70b69151aa7151 to your computer and use it in GitHub Desktop.
first attempt at building gradle runner for bigtop tests
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
//needed to avoid groovy not on classpath error.
testCompile module('org.codehaus.groovy:groovy:1.8.0')
testCompile group:'org.apache.bigtop.itest', name:'itest-common', version:'0.7.0',transitive:'true'
testCompile group:'org.apache.hadoop',name:'hadoop-common', version:'2.0.6-alpha',transitive:'true'
testCompile group:'org.apache.hadoop',name:'hadoop-hdfs', version:'2.1.0-beta',transitive:'true'
}
def tests_to_include(){
return [
"TestHadoopExamples.groovy"
]
}
/**
* This is a function which includes directories from source sets,
* but filters out any groovy tests which don't match those in the
* defined list of tests we want to run.
*
* For users: Add new groovy script names to the array list below
* in order to include them.
*/
def doExclude(filename) {
print("Exclude? ${filename} ... ")
def keep_this_test=false;
tests_to_include().each() {
if(filename.contains(".groovy")){
if(filename.contains(it))
keep_this_test=true
else
keep_this_test=false
}
else
keep_this_test=true;
};
println("Keep = ${keep_this_test} "+filename);
return !keep_this_test ;
}
sourceSets {
test {
/**
* This will put the input files into the jar.
* TODO: We should refactor tests, over time, not to require running from jar.
*/
resources {
srcDirs =
[
//'/opt/bigtop/bigtop-tests/test-artifacts/hadoop/src/main/resources/',
//In here, we put the log4j.properties, so we have fine grained logging control.
'conf/']
}
groovy {
srcDirs = ['/opt/bigtop/bigtop-tests/test-artifacts/hadoop/']
exclude 'src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/**'
//exclude 'src/main/groovy/org/apache/bigtop/itest/hadoop/hcfs/**'
//exclude 'src/main/groovy/org/apache/bigtop/itest/hadoop/yarn/**'
exclude { FileTreeElement elem -> ( doExclude(elem.getName()) ) }
}
}
}
println "SOURCES="
println sourceSets.main.allSource.files
println sourceSets.test.allSource.files
test.doFirst {
def vars = [
"BIGTOP_HOME", // for copying input files / resources
"HADOOP_MAPRED_HOME" // required for mapreduce programs to run
];
vars.each() {
def value = System.getenv("${it}")
if(value == null || value == "null")
throw new GradleException("undeclared env variable: ${it}")
else
println("${it} = $value");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment