Pabot - run suite in parallel but with 1 setup


I have one big suite with 200+ testcases… This suite has one generic Suite Setup and Suite Teardown.

Simple writting its something like this:

  • setup k8s cluster (deploy pods, deployments, services)
  • generate few suite variables
  • 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:

..   __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}

Hi Tomas,

Did a bit of looking at Pabot today and found this:

I think the keyword you want is Run Setup Only Once, but not sure if you use it in replacement to Suite Setup or inside your Suite Setup keyword.

Sorry I’m not that familiar with Pabot.


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,  ... rest of the arguments here ..)

pabot(pabot_arguments),  ... 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 …

this is actually a good, very good idea :slight_smile: thanks

I tried the Run Setup Only Once etc… it was working but it was connected with pabotlib. I like this solution