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

**URL:** <https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049>\
**Category:** Robot Framework\
**Created:** [22 March 2024 03:25 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049 "2024-03-22T03:25:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![gl1mpse](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@gl1mpse](https://forum.robotframework.org/u/gl1mpse)\
**Post date:** [22 March 2024 03:25 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/1 "2024-03-22T03:25:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [22 March 2024 04:36 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/2 "2024-03-22T04:36:43Z")

</div>

Hi @gl1mpse,

There’s a good guide to Pabot here: [Running tests in parallel | ROBOT FRAMEWORK](https://docs.robotframework.org/docs/parallel)

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.

---

<div class="post-metadata">

**Author:** ![gl1mpse](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@gl1mpse](https://forum.robotframework.org/u/gl1mpse)\
**Post date:** [25 March 2024 11:25 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/3 "2024-03-25T11:25:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [25 March 2024 14:17 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/4 "2024-03-25T14:17:48Z")

</div>

I confirmed `--resourcefile` is what you want, using the [PabotLib example](https://github.com/mkorpela/pabot?tab=readme-ov-file#pabotlib-example) I constructed an example for you.

I created 5 robot files as follows:

**glpdufntyA.robot**

```python
***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**

```python
[pabot1]
tags=user-data
USERNAME=user1

[pabot2]
tags=user-data
USERNAME=user2

```

Then I ran the pabot command like this:

```python
$ 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:

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/0/03cd398c3037956da9b0af24cff1b45b549844ef.png)

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

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [25 March 2024 14:20 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/5 "2024-03-25T14:20:00Z")

</div>

FYI - Log.html:

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/0/0ab0e512651e3c013dfa3a88ca3b8925d658ec8e.png)

---

<div class="post-metadata">

**Author:** ![gl1mpse](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@gl1mpse](https://forum.robotframework.org/u/gl1mpse)\
**Post date:** [3 April 2024 08:54 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/6 "2024-04-03T08:54:21Z")

</div>

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

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/6/6aa4cc59e977cd5ec1c47bd6c99ca1805e5cbc89.png)

---

<div class="post-metadata">

**Author:** ![gl1mpse](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@gl1mpse](https://forum.robotframework.org/u/gl1mpse)\
**Post date:** [3 April 2024 08:56 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/7 "2024-04-03T08:56:11Z")

</div>

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}?

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [3 April 2024 10:30 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/8 "2024-04-03T10:30:27Z")

</div>

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:

```python
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](https://forum.robotframework.org/uploads/short-url/4DtPPSjm2wzUj2lndDyFFi0zD5A.robot) (424 Bytes)  
[glpdufntyB.robot](https://forum.robotframework.org/uploads/short-url/eRrinjtJFGErWCAtvuJIajKpdaV.robot) (335 Bytes)  
[glpdufntyC.robot](https://forum.robotframework.org/uploads/short-url/qN0SVh2n4Jn7rdIu1sDin9t5paL.robot) (335 Bytes)  
[glpdufntyD.robot](https://forum.robotframework.org/uploads/short-url/8M0NtKtqJsBHz0JtrXe6tLtvLBA.robot) (335 Bytes)  
[glpdufntyE.robot](https://forum.robotframework.org/uploads/short-url/lFY029voPEsLFNzcDqz7hCf8Am2.robot) (335 Bytes)  
[users.dat.resource](https://forum.robotframework.org/uploads/short-url/nw28SfrcFaVxnKkYvrsNnbLHO4S.resource) (79 Bytes)

Hope that helps,

Dave.

---

<div class="post-metadata">

**Author:** ![gl1mpse](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@gl1mpse](https://forum.robotframework.org/u/gl1mpse)\
**Post date:** [3 April 2024 10:37 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/9 "2024-04-03T10:37:51Z")

</div>

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.”

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [3 April 2024 10:49 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/10 "2024-04-03T10:49:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gl1mpse](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@gl1mpse](https://forum.robotframework.org/u/gl1mpse)\
**Post date:** [3 April 2024 10:56 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/11 "2024-04-03T10:56:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [3 April 2024 11:17 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/12 "2024-04-03T11:17:39Z")

</div>

So I changed my directory structure to look like this:  
 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/b/b146784da5459e97513cf434c1a44782f6cb0e3c.png)

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

```python
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:

```python
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](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/0/0d5b06a818f9bd86c1928e616763fa40342ce943.png)

and running the command:

```python
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](https://github.com/mkorpela/pabot/issues):

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

```

Then you’ll know when it gets fixed.

Dave.

---

<div class="post-metadata">

**Author:** ![gl1mpse](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@gl1mpse](https://forum.robotframework.org/u/gl1mpse)\
**Post date:** [3 April 2024 11:22 UTC](https://forum.robotframework.org/t/how-do-you-setup-test-data-when-running-parallel-tests-using-pabot/7049/13 "2024-04-03T11:22:14Z")

</div>

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
