-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow overriding mvn commands in integration test
* mavenIntegrationTest: allow overriding mvn commands This patch allows the `mavenCI{}` to over maven command in order to allow `mavenIntegrationTest{}` to pass specific command to execute. It has added a util method to retrieve default test namespace. Fixes: openshiftio/openshift.io#763 Fixes: openshiftio/openshift.io#3134 Related to: #412 * refactored code as per review comments - extracted default maven command code to separate method - changed variable names - updated readme
- Loading branch information
Showing
4 changed files
with
46 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,46 @@ | ||
#!/usr/bin/groovy | ||
|
||
import io.fabric8.Utils | ||
|
||
def call(body) { | ||
|
||
if (new Utils().isDisabledITests()) { | ||
echo "WARNING: Integration tests DISABLED for these pipelines!" | ||
return | ||
} | ||
|
||
// evaluate the body block, and collect configuration into the object | ||
def config = [:] | ||
body.resolveStrategy = Closure.DELEGATE_FIRST | ||
body.delegate = config | ||
body() | ||
|
||
def cmd = config.cmd ?: defaultTestCommand(config) | ||
sh cmd | ||
junitResults(body); | ||
} | ||
|
||
def defaultTestCommand(config) { | ||
def utils = new Utils() | ||
|
||
def envName = config.environment | ||
def kubeNS = "-Dfabric8.environment=${envName}" | ||
|
||
if (envName) { | ||
// lets try find the actual kubernetes namespace | ||
try { | ||
def ns = utils.environmentNamespace(envName) | ||
if (ns) { | ||
kubeNS = "-Dnamespace.use.existing=${ns}" | ||
echo "Running the integration tests in the namespace: ${ns}" | ||
echo "Running the integration tests in namespace : ${ns}" | ||
} | ||
} catch (e) { | ||
echo "ERROR: failed to find the environment namespace for ${envName} due to ${e}" | ||
e.printStackTrace() | ||
} | ||
} | ||
|
||
if (utils.isDisabledITests()) { | ||
echo "WARNING: Integration tests are current DISABLED for these pipelines!" | ||
|
||
} else { | ||
sh "mvn org.apache.maven.plugins:maven-failsafe-plugin:integration-test ${kubeNS} -P openshift-it -Dit.test=${config.itestPattern} -DfailIfNoTests=${config.failIfNoTests} org.apache.maven.plugins:maven-failsafe-plugin:verify" | ||
|
||
junitResults(body); | ||
} | ||
return "mvn \ | ||
org.apache.maven.plugins:maven-failsafe-plugin:integration-test \ | ||
org.apache.maven.plugins:maven-failsafe-plugin:verify \ | ||
-P openshift-it ${kubeNS} \ | ||
-Dit.test=${config.itestPattern} -DfailIfNoTests=${config.failIfNoTests}" | ||
} |