Open alinpa opened 6 years ago
Hello,
If someone are interested to know how you can do it, please check the following method:
import groovy.json.JsonSlurper def waitSeleniumNodes(int expectedNumberOfSeleniumNodes) { int count = 600 def seleniumGridInfo = ["curl", "-k", "-X", "GET", "-H", "Content-Type: application/json", "http://your-jenkins-link:4444/grid/api/hub"].execute().text int actualNumberOfSeleniumNodes = 0
while(!(actualNumberOfSeleniumNodes == expectedNumberOfSeleniumNodes) && (count >=0)) {
sleep(2)
def seleniumGridInfoJson = new JsonSlurper().parseText(["curl", "-k", "-X", "GET", "-H", "Content-Type: application/json", "http://your-jenkins-link:4444/grid/api/hub"].execute().text)
actualNumberOfSeleniumNodes = (seleniumGridInfoJson.slotCounts.total as Integer)/5
println('Selenium nodes already registered are ' + actualNumberOfSeleniumNodes + ' and should be '+ expectedNumberOfSeleniumNodes)
println('Remaining ' + count*2 + ' seconds!')
count--
}
if (count == -1) {
println('Not all selenium nodes are registered to master! Number of selenium nodes registered are ' + actualNumberOfSeleniumNodes +'and should be ' + expectedNumberOfSeleniumNodes)
currentBuild.result = 'FAILURE'
}
}
The previous method checks for a while if a number of nodes are registered to the selenium grid. The previous method was written on groovy.
Hello Guys and Girls,
Do you have any idea how can I verify programmatically how many nodes are registered to my selenium hub?
How can I have access to the jenkins selenium plugin instance?
Thank you!