Background:
I have a selenium test suite for end-to-end web testing.
Currently, it is running on jenkins box but it is taking so long to finish all the tests.
So, next step is to parallelize the selenium tests.
As a first step, I need to start multiple jetty servers using different port.
With Gradle jetty plugin, I camp up how to run the multiple jetty servers before tests.
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
// start multiple jetties before test | |
// | |
// useful for parallel web end-to-end testing | |
// | |
import org.gradle.api.plugins.jetty.JettyRun | |
apply plugin: 'java' | |
apply plugin: 'jetty' | |
repositories { | |
mavenCentral() | |
} | |
// configuration for each jetty server | |
def jettyConfigs = [ | |
[port:8001], | |
[port:8002] | |
] | |
def jettyMultiRunTasks = [] | |
// create jetty tasks and assign them | |
jettyConfigs.eachWithIndex {jettyConfig, index -> | |
jettyMultiRunTasks << task("jettyMultiRun-${index}", type: JettyRun) { | |
httpPort = jettyConfig.port | |
daemon = true | |
// more configuration to specify each jetty to use different env... | |
} | |
} | |
test { | |
// start jetties before running tests | |
dependsOn(jettyMultiRunTasks) | |
// more test options such as maxParallelForks, etc. | |
} | |
2 comments:
Nice! This is cool...
Really cool! Gradle is a breath of air, especially
after ugly boileplating with maven xml.
Cool hack of jetty.
Thanks!
Post a Comment