run traffic between pods/services/nodes … (200+ testcases)
It would be great If I can paralelize it using pabot, but when I do something like: pabot --processes 10 --testlevelsplit .... every suite generated by pabot, is trying to run suite setup.
Is there any way how to set pabot:
run setup once, and than parallelize all the others tests? Or what would be the solid approach for this?
dir structure:
<root>
.. __init__.robot # containing suite setup/ suite teardown
.. host_to_host.robot #suites
.. pod_to_pod.robot #suites
... ....
This suites do not interfere to each other, they are just ‘static’ and trying differend kind of traffic in the k8s cluster
The main problem here is, even there is Run Setup Only Once keyword, I’m not able to propagate even Global Variables to all the other tests, that are run this way… so for example, if setup creates ${var1} variable, only 1 suite gets it, and all the others are without it.
How to proceed with this? Do any have the same setup?
You could create two suite setups. One Global Suite Setup which would be run once and using keyword Set Parallel Value For Key set value for later retrieval in local suite setups. In local setup retrieve previously set variable and set new global variable.
So it could look like this:
# setups.resouce
*** Settings ***
Library String
Library pabot.PabotLib
*** Keywords ***
Global Suite Setup
${random} Generate Random String
Set Parallel Value For Key GLOBAL_RANDOM ${random}
Local Suite Setup
${random} Get Parallel Value For Key GLOBAL_RANDOM
Set Global Variable ${GLOBAL_RANDOM} ${random}
# __init__.robot
*** Settings ***
Resource setups.resource
Suite Setup Run Only Once Global Suite Setup
# Suite1.robot
*** Settings ***
Resource setups.resource
Suite Setup Local Suite Setup
*** Test Cases ***
Test 1-1
Log ${GLOBAL_RANDOM}
as mentioned in the similar topic few weeks back - I didnt like the idea of injecting Pabot specific code (Run Setup Only Once) into my testsuites because that would mean, i would need to stub those out if someone else in the future would need to run the same test assets without Pabot and because my setup/teardown is not relevant suite basis but for for testrun and i didnt spot any mention of pabot supporting dunder init type of setup/teardown …
Also, my usecase is that for reporting purposes, i do not use robot’s own reporting features for actual test reporting but i need to construct a file suitable for 3rd party application …
So what i did was - i wrote my own test runner in python that runs runs setup / teardown as a separate testsuites with vanilla robot and pabot runs the actual tests in between … something like this;
import robot
from robot import rebot
from pabot.pabot import main_program as pabot
# my own "setup" code that reads cli args, path names etc and builds up the necessary arguments for pabot and robot here
robot.run(setup_suite, ... rest of the arguments here ..)
pabot(pabot_arguments)
robot.run(teardown_suite, ... rest of the arguments here ..)
rebot(setup_output, pabot_output, teardown_output, ... rest of the arguments here ...)
And what happens is that each testcase that is executed, drops its needed data (json, could have used pickle but json made things easier to debug) into output directory and then final call to teardown suite reads all the matching files off outputdir and generates the final report file that then gets stored into network share for the particular 3rd party app to read it from …
I understand your point but i think you answer may lead to wrong conclusions as the command robot still runs the setup even if the pabotlib KWD is included in the setup.
This means the same tests can be executed both via pabot or robot command without changing the source.
I tested this with this simple project structure and runned both robot TestPlan and pabot --pabotlib TestPlan with success.
This means that the solution is 100% compatible with the robot command (still pabot dependency is required even if not used)