How do you setup test data when running parallel tests using Pabot

I’m planning to setup running scripts in parallel with 2 or 3 processes using Pabot. Any tips you can share when dealing with limited data for each processes. I need to have unique account for each script as concurrent login is not allowed in the system.

Hi @gl1mpse,

There’s a good guide to Pabot here: Running tests in parallel | ROBOT FRAMEWORK

At the beginning of the page is a video, I suggest you watch it.

  • In the video it mentionsto use --argumentfile to have different users for each robot.
  • In that page also there is the --resourcefile that may also help with what you want.

Dave.

1 Like

I tried using the argument files but it only ran the scripts twice but using data from arg1 then arg2 file.

So, i have a project structure like this;

TestData:

  • apple
  • banana

Scripts:

  • ScriptA (apple)
  • ScriptB (banana)
  • ScriptC (apple)
  • ScriptD (banana)
  • ScriptE (apple)

Note: Concurrent login using same test data is not allowed by the system.

I want to run the scripts using pabot with only 2 processes, the execution will be like

First 2 scripts will start to run…
ScriptA (apple)
ScriptB (banana)

Then whichever finish first the next script will start execution also but the problem is that it is using the same test data which will result to failed as the system will force logout the other session

Any advise on this, thanks in advance.

I confirmed --resourcefile is what you want, using the PabotLib example I constructed an example for you.

I created 5 robot files as follows:

glpdufntyA.robot

*** Settings ***
Library    pabot.PabotLib

*** Test Cases ***
Test glpdufnty A
	${valuesetname}=    Acquire Value Set  user-data
	${USERNAME}=     Get Value From Set   username
	Log 	Test A Variable: ${USERNAME} 		console=True
	Set Tags 	${USERNAME}
	${random}= 	Evaluate 	random.randint(1, 10)
	Sleep    ${random}
	Release Value Set

glpdufntyB.robot, glpdufntyC.robot, glpdufntyD.robot, and glpdufntyE.robot were all basically the same, just change the test case name to their respective letters (i.e. Test glpdufnty A became Test glpdufnty B in glpdufntyB.robot, etc) and likewise the Log line Test A Variable became Test B Variable, etc.

So that was my 5 test files

Next I needed a resourcefile, so I created:

users.dat

[pabot1]
tags=user-data
USERNAME=user1

[pabot2]
tags=user-data
USERNAME=user2

Then I ran the pabot command like this:

$ pabot --processes 2 --pabotlib --resourcefile users.dat .
Robot Framework remote server at 127.0.0.1:8270 started.
Storing .pabotsuitenames file
2024-03-25 23:56:33.324353 [PID:647617] [0] [ID:0] EXECUTING Glpdufnty.glpdufntyA
2024-03-25 23:56:33.329751 [PID:647619] [1] [ID:1] EXECUTING Glpdufnty.glpdufntyB
2024-03-25 23:56:37.842675 [PID:647617] [0] [ID:0] PASSED Glpdufnty.glpdufntyA in 4.5 seconds
2024-03-25 23:56:37.843610 [PID:647634] [0] [ID:2] EXECUTING Glpdufnty.glpdufntyC
2024-03-25 23:56:42.858867 [PID:647619] [1] [ID:1] PASSED Glpdufnty.glpdufntyB in 9.5 seconds
2024-03-25 23:56:42.860654 [PID:647643] [1] [ID:3] EXECUTING Glpdufnty.glpdufntyD
2024-03-25 23:56:48.373381 [PID:647634] [0] [ID:2] PASSED Glpdufnty.glpdufntyC in 10.5 seconds
2024-03-25 23:56:48.374602 [PID:647651] [0] [ID:4] EXECUTING Glpdufnty.glpdufntyE
2024-03-25 23:56:49.886148 [PID:647651] [0] [ID:4] PASSED Glpdufnty.glpdufntyE in 1.5 seconds
2024-03-25 23:56:53.390689 [PID:647643] [1] [ID:3] PASSED Glpdufnty.glpdufntyD in 10.5 seconds
5 tests, 5 passed, 0 failed, 0 skipped.
===================================================
Output:  /home/dave/Documents/tmp/glpdufnty/output.xml
Log:     /home/dave/Documents/tmp/glpdufnty/log.html
Report:  /home/dave/Documents/tmp/glpdufnty/report.html
Stopping PabotLib process
Robot Framework remote server at 127.0.0.1:8270 stopped.
PabotLib process stopped
Total testing: 36.50 seconds
Elapsed time:  20.48 seconds
$

As you can see only 2 robots (0 and 1) ran at any time, and because I tagged the test with the user name we can see in the report.html:

  • Test A got User 2
  • Test C also got User 2, but didn’t start until after Test A finished
  • Test E also got User 2, but didn’t start until after Test C finished
  • Test B got User 1
  • Test D also got User 1, but didn’t start until after Test B finished

So no user was in use by 2 tests at the same time, meeting your requirement “Concurrent login using same test data is not allowed by the system.”

--processes 2 is what controls how many robots run
--pabotlib is needed so the robots can talk to pabot and get the Value Set

Hopefully from that you can reproduce this and then implement what you need in your tests.

Dave.

FYI - Log.html:

Hi D,

I tried using the pabotlib --resourcefile as you’ve mentioned but I’m encountering this error. I used the same command as what you’ve shared and just added a directory to my resource file

Also I placed my Acquire Value Set and Release in keywords that I used for Test Setup and Teardown.

Question, where did you use the variable ${valuesetname}?

I found you need to have the --pabotlib option when using --resourcefile did you have that?

If so I’m not sure why your getting that error.

Often it easier to troubleshoot when you have a working example to start with;

So what I can do is provide my files exactly as they are and what worked for me below, download them all into the same folder and then rename users.dat.resource to users.dat, cd to that folder and rune the command exactly as here Including the " ." after users.dat:

pabot --processes 2 --pabotlib --resourcefile users.dat .

See that you can reproduce the result I got with the same files, then you can compare to what you had for your own tests and see what’s different.

glpdufntyA.robot (424 Bytes)
glpdufntyB.robot (335 Bytes)
glpdufntyC.robot (335 Bytes)
glpdufntyD.robot (335 Bytes)
glpdufntyE.robot (335 Bytes)
users.dat.resource (79 Bytes)

Hope that helps,

Dave.

Yes I included the --pabotlib in the command. Just to check, if my resource file directory has spaces, underscore, dashes, etc. how do I need to input it in the command? I tried enclosing the whole directory with resource filename using single and double quotes but it seems the resource file cant be found. This is based on the warning I saw from the terminal “specified resource file doesn’t exist. Some test may fail or continue forever.”

Not sure (only spaces should be a problem in the path), but which OS are you on?

  • If windows I’d expect double quotes around the path to the file would be correct.
  • If on linux/mac you cane use \ before the space in the path, i.e. my\ path\ with \spaces/my\ file.dat
    Not sure if escaping the spaces in the path works in windows?

I’ll give it a try.

pabot --processes 1 --pabotlib --resourcefile “C:/development/robot-scripts/rf-test-automation/Pabot Automation/Pabot-Automation-Script/Data/TeacherCredentials.dat” “C:/development/robot-scripts/rf-test-automation/Pabot Automation/Pabot-Automation-Script/Tests/Sanity0002/Script0002.robot”

This is the command I’m trying to run, I already tried single and double quotes around the directory. I’m using Windows. I’m running the command in the terminal inside Pycharm

So I changed my directory structure to look like this:
image

The only way I can get pabot to run is like this:

pabot --processes 2 --pabotlib --resourcefile "my\ data\ files/users.dat" "my tests"

But then it gives the same error you got,

Anything else I’ve tried it gives me:

ValueError: invalid literal for int() with base 10: 'files/users.dat'

Indicating that it’s spitting the path on the spaces

When I renamed the path to the data file replacing the spaces with - like this:
image

and running the command:

pabot --processes 2 --pabotlib --resourcefile my-data-files/users.dat "my tests"

It works, so it seems you can’t have a space in the path to the resource file, but spaces in the path to the tests is ok.

I couldn’t see an issue already logged for this, so I suggest you raise one:

[ERROR] PLEASE CONSIDER REPORTING THIS ISSUE TO https://github.com/mkorpela/pabot/issues

Then you’ll know when it gets fixed.

Dave.

1 Like

I also encountered this error “ValueError: invalid literal for int() with base 10: ‘files/users.dat’” when I played around the quotes in command

Ok will rename the directory of the project.

Thanks for helping, much appreciated

1 Like