Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Running configuration on all nodes #4086

ari ·

Hi have to run an automation test, and i want to run it on all the agent i have

My idea is to build one step to choose the agent and update the configuration variable with the agent user properties

Then the following step will load the variables and run the test

I tried but i cant run the configuration at the same time although i set them to be run in parrallel

How can i do this and if you have a better way/idea

Thanks
Ari

  • replies 8
  • views 38
  • stars 0
robinshen ADMIN ·

The suggested approach to loop a step over all build agents:

  1. In advanced setting of the step, define a repeat parameter say "agent", and choose the option "addresses of all nodes matching specified criteria" for value, and specify "any build agent" for the option
  2. In node selection setting of the step, choose option "on node with address equal to specified step parameter", and input parameter as "agent" (defined in step 1)
ari ·

Hi Robin
it is quite what i am looking for, but it need that the script runs from the server
Four our testing the test must run from the server and get the parameters of the agent and then run a script on the agent including agent reset

In addition during our tests we will have a step that occurs more than one time (reset the board) but one the step is used we cannot used anymore in the configuration

Thanks,
Ari

robinshen ADMIN ·

Then below logic may help. It loops over all build agents at server side, and can run some groovy script on desired agent if necessary:

groovy:
for (agent in system.agentManager.buildAgents) {
  // do something on server
  def scriptRunOnAgent = "print 'hello'"
  def evalContext = ["var1", "value1"]
  agent.nodeService.evalGroovyScript(scriptRunOnAgent, evalContext);
}
ari ·

Thank you, but this mean that my script to run must be written in groovy, but we want to run a python script so what should be the follow command for python if possible agent.nodeService.evalGroovyScript(scriptRunOnAgent, evalContext);

thanks,
ari

robinshen ADMIN ·

Yes you can execute any external command from groovy. For instance, below script executes "cmd.exe" and prints a "hello world":

groovy:
def evalContext = ["var1":"value1"] // put any variables here you want 
def script = '''
return "cmd /c echo hello world".execute().text
'''
def output = node.nodeService.evalGroovyScript(script, evalContext);
logger.info(output);
ari ·

HI Robin,

I tried your suggestion and this is my script
groovy:
for (agent in system.agentManager.buildAgents) {
logger.info("******************************************************")

def evalContext = ["pdu_ip":"${vars.getValue("pdu_ip")}",
"pdu_port":"${vars.getValue("pdu_port")}" ,
"number_of_pf":"2" ,
"gpio_ip":"${vars.getValue("gpio_ip")}",
"gpio_port":"${vars.getValue("gpio_port")}"]

logger.info(agent.ip)
logger.info(agent.hostName)
logger.info("gpio_ip = {} ", agent.userAttributes.get("gpio_board_ip"));
logger.info("gpio_port = {} ", agent.userAttributes.get("gpio_port"));
logger.info("pdu_ip = {} ", agent.userAttributes.get("pdu_ip"));
logger.info("pdu_port = {} ", agent.userAttributes.get("pdu_port"));

//def scriptRunOnAgent = "python /home/svjer/my_tests/Scripts/automation/ssh.py ${vars.getValue("pdu_ip")} ${vars.getValue("pdu_port")} 2 ${vars.getValue("gpio_ip")} ${vars.getValue("gpio_port")}"
def scriptRunOnAgent = '''
return "python /home/svjer/my_tests/Scripts/automation/ssh.py ".execute().text
'''

def output = node.nodeService.evalGroovyScript(scriptRunOnAgent, evalContext);
logger.info(output)

}

and i get this output

18:42:17,150 INFO - Executing pre-execute action...
18:42:17,150 INFO - Running step...
18:42:17,158 INFO - Checking step execute condition...
18:42:17,158 INFO - Step execute condition not satisfied, step will be skipped.
18:42:17,177 INFO - Checking step execute condition...
18:42:17,177 INFO - Step execute condition not satisfied, step will be skipped.
18:42:17,192 INFO - Checking step execute condition...
18:42:17,193 INFO - Step execute condition satisfied, executing...
18:42:17,307 INFO - Executing pre-execute action...
18:42:17,307 INFO - Running step...
18:42:17,326 INFO - ******************************************************
18:42:17,326 INFO - 10.12.234.244
18:42:17,326 INFO - Platform2
18:42:17,326 INFO - gpio_ip = 10.12.249.49
18:42:17,326 INFO - gpio_port = 4
18:42:17,326 INFO - pdu_ip = 10.12.235.3
18:42:17,326 INFO - pdu_port = 2
18:42:17,445 INFO -
18:42:17,445 INFO - ******************************************************
18:42:17,445 INFO - 10.12.234.70
18:42:17,445 INFO - Platform3
18:42:17,445 INFO - gpio_ip = 10.12.249.49
18:42:17,445 INFO - gpio_port = 1
18:42:17,445 INFO - pdu_ip = 10.12.235.3
18:42:17,445 INFO - pdu_port = 3
18:42:17,556 INFO -
18:42:17,556 INFO - Executing post-execute action...
18:42:17,698 INFO - Executing post-execute action...

the python script is not running
what is wrong with the command

robinshen ADMIN ·

Please check agent log of "10.12.234.244" to see if there are any errors printed there.

robinshen ADMIN ·