forked from h2oai/sparkling-water
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
121 lines (101 loc) · 3.67 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
description = "Sparkling Water Examples"
dependencies {
// Sparkling Water Core
compile( project(":sparkling-water-core") ) {
exclude group: "javax.servlet", module: "servlet-api"
}
// And Scala library
compile "org.scala-lang:scala-library:${scalaVersion}"
// Add streaming
compile "org.apache.spark:spark-streaming_${scalaBinaryVersion}:${sparkVersion}"
// And use scalatest for Scala testing
testCompile "org.scalatest:scalatest_${scalaBinaryVersion}:2.2.1"
testCompile "junit:junit:4.11"
// Integration tests requirements
integTestCompile "org.scalatest:scalatest_${scalaBinaryVersion}:2.2.1"
integTestCompile "junit:junit:4.11"
// To enable Idea compiler even for integTestCode which use mllib
/*integTestCompile*/ compile "org.apache.spark:spark-mllib_${scalaBinaryVersion}:${sparkVersion}"
// Put Spark Assembly on runtime path
integTestRuntime fileTree(dir: new File((String) sparkHome, "lib/"), include: '*.jar' )
}
//
// Setup integration tests environment
//
artifacts {
integTestAssembly jar
// No tests for examples
//integTestAssembly testJar
integTestAssembly integTestJar
// pull selected dependencies
dep(testDependencies + [ "ai.h2o:sparkling-water-core", "ai.h2o:h2o-scala_${scalaBinaryVersion}" ]).each {
integTestAssembly it
}
}
integTest {
// Pass references to libraries to test launcher
systemProperty "spark.testing", "true"
systemProperty "spark.test.home", "${sparkHome}"
if (sparkMaster != null)
systemProperty "spark.master", "${sparkMaster}"
// Pass list of jars required for testing
systemProperty "sparkling.test.assembly", "${configurations.integTestAssembly.artifacts.file.join(',')}"
systemProperty "sparkling.test.jar", "${integTestJar.archivePath}"
//configurations.integTestRuntime. { println(it)}
// Decide which tests should be launch here based on environment
switch ( detectEnvironment() ) {
case "yarn":
include "water/sparkling/itest/yarn/**"
break
case "standalone":
include "water/sparkling/itest/standalone/**"
break
case "local":
include "water/sparkling/itest/local/**"
break
}
// Run with assertions ON
enableAssertions = true
// For a new JVM for each test class
forkEvery = 1
// Working dir will be root project
workingDir = rootDir
// Increase test runner memory
maxHeapSize = "2g"
// Show standard out and standard error of the test JVM(s) on the console
// DEBUG testLogging.showStandardStreams = true
}
String detectEnvironment(String defaultEnv = "local") {
String denv = [ project.hasProperty("sparklingTestEnv") ? project["sparklingTestEnv"] : null,
System.properties["sparklingTestEnv"],
defaultEnv
].find { h -> h!=null } // first match
// Return env
logger.info("* Detected '$denv' Sparkling test environment (configure via property 'sparklingTestEnv')")
denv
}
/**
* Find dependencies from 'configuration.runtime' matching given specification.
*
* Specification is given in form group_name:module_name
*
* @param d list of specifications.
* @return
*/
public FileCollection dep(List<String> d) {
Configuration conf = configurations.runtime
List<String[]> depsSpec = d.collect { it.split(":")}
Set<ResolvedDependency> toInclude = []
resolve(conf.resolvedConfiguration.firstLevelModuleDependencies, toInclude, depsSpec)
files( toInclude.collect {
it.moduleArtifacts*.file
}.flatten())
}
void resolve(Set<ResolvedDependency> deps, Set<ResolvedDependency> includeDeps, List<String[]> depsSpec) {
deps.each { d->
if (depsSpec.any { ds -> d.moduleGroup==ds[0] && d.moduleName==ds[1] })
if (includeDeps.add(d)) {
resolve(d.children, includeDeps, depsSpec)
}
}
}