-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
223 lines (191 loc) · 7.76 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
plugins {
id "maven"
id "idea"
id "groovy"
id "com.github.erdi.webdriver-binaries" version "2.4.1"
id "com.github.erdi.idea-base" version "2.2"
id 'com.adarshr.test-logger' version "2.0.0"
}
group="org.ods.e2e"
version="1.0.1"
// Create JAR with test fixtures
task testJar(type: Jar, dependsOn: testClasses) {
from sourceSets.test.output
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier='sources'
from sourceSets.main.allSource
}
artifacts {
archives testJar
archives sourcesJar
}
ext {
// The drivers we want to use
drivers = ["firefox", "chrome", "chromeHeadless", "htmlunit"]
spockVersion = "1.3-groovy-2.5"
gebVersion = '3.4'
unirestVersion = "3.7.02"
seleniumVersion = '3.141.59'
chromeDriverVersion = '87.0.4280.20'
geckoDriverVersion = '0.26.0'
htmlunitVersion = "2.36.0"
openshiftClientVersion = '9.0.1.Final'
// Environment variable needed to run the tests
dotEnvFile = './.env'
odsConfigFile = '../ods-configuration/ods-core.env'
environmentVariables = [
PROV_APP_DEPLOY_CFG : '',
PROV_APP_PROJECT : '',
PROV_APP_USER : '',
PROV_APP_PASSWORD : '',
BITBUCKET_BASE_BRANCH : '',
QUICKSTARTERS_CONFIGMAP : '',
ADDITIONAL_TEMPLATES_CONFIGMAP : '',
ATLASSIAN_USER : '',
ATLASSIAN_PASSWORD : '',
JENKINS_USER : '',
JENKINS_PASSWORD : '',
OPENSHIFT_USER : '',
OPENSHIFT_PASSWORD : '',
PROV_APP_NAME : '',
JIRA_URL : '',
OPENSHIFT_PROJECT : '',
OPENSHIFT_PUBLIC_HOST : '',
OPENSHIFT_CLUSTER : '',
BITBUCKET_URL : '',
SIMULATE : '',
NEXUS_URL : '',
NEXUS_USERNAME : '',
NEXUS_PASSWORD : '',
NEXUS_FOLDER_RELEASES : '',
NEXUS_FOLDER_SNAPSHOTS: '',
NO_NEXUS : (project.findProperty('no_nexus') ?: System.getenv('NO_NEXUS') ?: false).toBoolean(),
]
loadEnvironmentVariables()
}
repositories {
mavenLocal()
if (environmentVariables.NO_NEXUS) {
println("using repositories 'mavenCentral', because property no_nexus=$environmentVariables.NO_NEXUS")
mavenCentral()
} else {
println("using nexus repositories")
maven() {
url "${environmentVariables.NEXUS_URL}/repository/maven-public/"
credentials {
username = "${environmentVariables.NEXUS_USERNAME}"
password = "${environmentVariables.NEXUS_PASSWORD}"
}
}
maven() {
url "${environmentVariables.NEXUS_URL}/repository/atlassian_public/"
credentials {
username = "${environmentVariables.NEXUS_USERNAME}"
password = "${environmentVariables.NEXUS_PASSWORD}"
}
}
}
}
dependencies {
// If using Spock, need to depend on geb-spock
testImplementation "org.gebish:geb-spock:${gebVersion}"
testImplementation("org.spockframework:spock-core:1.3-groovy-2.5") {
exclude group: "org.codehaus.groovy"
}
// If using JUnit, need to depend on geb-junit (3 or 4)
testImplementation "org.gebish:geb-junit4:$gebVersion"
// Drivers
testImplementation "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
testImplementation "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
testImplementation "org.seleniumhq.selenium:htmlunit-driver:$htmlunitVersion"
testImplementation "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
// Utils
testImplementation "com.konghq:unirest-java:$unirestVersion:standalone"
// Use of git
implementation "org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r"
testImplementation "org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r"
testImplementation "org.yaml:snakeyaml:1.26"
// Openshift client
testImplementation "com.openshift:openshift-restclient-java:$openshiftClientVersion"
}
def loadEnvironmentVariables() {
println "Loading Environment Variables"
def props = new Properties()
if (file(odsConfigFile).exists()) {
file(odsConfigFile).withInputStream { props.load(it) }
environmentVariables.JIRA_URL = props.JIRA_URL
environmentVariables.OPENSHIFT_PUBLIC_HOST = props.OPENSHIFT_APPS_BASEDOMAIN
environmentVariables.OPENSHIFT_CLUSTER = props.OPENSHIFT_CONSOLE_HOST
environmentVariables.BITBUCKET_URL = props.BITBUCKET_URL
environmentVariables.NEXUS_URL = props.NEXUS_URL
environmentVariables.NEXUS_USERNAME = props.NEXUS_USERNAME
environmentVariables.NEXUS_PASSWORD = props.NEXUS_PASSWORD
println 'ods-core.env: ' + environmentVariables.JIRA_URL
println 'ods-core.env: ' + environmentVariables.OPENSHIFT_PUBLIC_HOST
println 'ods-core.env: ' + environmentVariables.OPENSHIFT_CLUSTER
println 'ods-core.env: ' + environmentVariables.BITBUCKET_URL
println 'ods-core.env: ' + environmentVariables.NEXUS_URL
} else {
logger.warn('There is no ods-core.env file')
}
// Load .env file with extra properties
def dotEnvProps = new Properties()
if (file(dotEnvFile).exists()) {
file(dotEnvFile).withInputStream { dotEnvProps.load(it) }
dotEnvProps.keys().each { envVar ->
environmentVariables[envVar] = dotEnvProps[envVar]
}
println '.env: ' + environmentVariables.JIRA_URL
println '.env: ' + environmentVariables.OPENSHIFT_PUBLIC_HOST
println '.env: ' + environmentVariables.OPENSHIFT_CLUSTER
println '.env: ' + environmentVariables.BITBUCKET_URL
println '.env: ' + environmentVariables.NEXUS_URL
} else {
logger.warn('There is no .env file, it will be used only system enviroment variables')
}
def nexus_url = "${environmentVariables.NEXUS_URL ?: System.getenv('NEXUS_URL') ?: System.getenv('NEXUS_HOST')}"
def nexus_user = "${environmentVariables.NEXUS_USERNAME ?: System.getenv('NEXUS_USERNAME')}"
def nexus_pw = "${environmentVariables.NEXUS_PASSWORD ?: System.getenv('NEXUS_PASSWORD')}"
def no_nexus = (environmentVariables.NO_NEXUS ?: System.getenv('NO_NEXUS') ?: false).toBoolean()
if (!no_nexus && (nexus_url == "null" || nexus_user == "null" || nexus_pw == "null")) {
throw new GradleException("property no_nexus='false' (or not defined) but at least one of the properties nexus_url, nexus_user or nexus_pw is not configured. Please configure those properties!")
}
}
webdriverBinaries {
chromedriver chromeDriverVersion
geckodriver geckoDriverVersion
fallbackTo32Bit = true
driverUrlsConfiguration = resources.text.fromFile('repository-3.0.json')
drivers.each { driver ->
task "${driver}Test"(type: Test) {
group JavaBasePlugin.VERIFICATION_GROUP
outputs.upToDateWhen { false } // Always run tests
systemProperty "geb.build.reportsDir", reporting.file("geb/$name")
systemProperty "geb.env", driver
environmentVariables.each { key, value ->
if (!System.env.get(key)) {
environment key, value
}
}
}
}
}
test {
dependsOn drivers.collect { tasks["${it}Test"] }
enabled = false
systemProperties System.properties
}
tasks.withType(Test) {
maxHeapSize = "1g"
jvmArgs '-XX:MaxMetaspaceSize=128m'
testLogging {
exceptionFormat = 'full'
}
}
tasks.withType(GroovyCompile) {
groovyOptions.forkOptions.memoryMaximumSize = '256m'
}
testlogger {
showStandardStreams true
}