Library  pabot.PabotLib
Version: 0.67
Scope: global
PabotLib helps in parallel execution with pabot. PabotLib contains 4 types of keywords: To take PabotLib into use call pabot with flag --pabotlib:
pabot --pabotlib [other arguments]
and include PabotLib library in your robot files.
Library  pabot.PabotLib

Execution affecting keywords

These allow control to when and where a keyword will be executed.
Run Setup Only Once
[keyword, *args]
Runs a setup keyword with args only once at the first possible moment when an execution has gone through this step. The executions after that will skip this step. If the first execution fails, all others will also.
Run Teardown Only Once
[keyword, *args]
Runs a teardown keyword with args only once after all executions have gone throught this step in the last possible moment. Note it is important to not have any conditions preventing from executing this step as that may prevent this keyword from working correctly.
Run Only Once
[keyword]
Runs a keyword only once in one of the parallel processes. Others executing "Run Only Once" with same keyword name wait before going through this keyword before the actual command has been executed.
Run On Last Process
[keyword]
Runs a keyword on last process used by pabot. This keyword will wait until all other processes have stopped executing.

Value transfer between processes

Pabot processes do not share variables by default. These keywords allow sharing of a value between all processes.

This can be used for example to limit work done by all the processes. One process can create a new testing environment in a suite setup (use Run Setup Only Once keyword to limit to only one process). The process can in the setup publish created environment related values with Set Parallel Value For Key. All processes can access these values with Get Parallel Value For Key.

Also a custom wrapper library pabot.SharedLibrary is provided to allow adding new shared functionalities as a remote library.

Set Parallel Value For Key
[key, value]
Set a globally available key and value that can be accessed from all the pabot processes.
Get Parallel Value For Key
[key]
Get the value for a key. If there is no value for the key then empty string is returned.
Library
pabot.SharedLibrary
[library]
Wrap a library import with pabot.SharedLibrary to automatically make it a remote library when running with pabot. When running with robot, this will produce a normal library. Library instance will be shared with all executions. Scope of the library is global from pabot execution start to the end.

Using a shared resource

Tests may need exclusive access to a resource from a pool of resources. For example only one test might be able to use a test user at a time and you might have to create multiple test user accounts so that tests can be executed parallely.

To use these keywords pabot needs to be called with the following command line parameters: pabot --pabotlib --resourcefile [FILEPATH] [other arguments]. FILEPATH must contain a resource file.

A resource file uses windows INI file syntax and is parsed with configparser. Sections are value sets and only one process can access a value set at a time. Special key "tags" can be used to limit what value sets will be acquired. Example use case.

Acquire Value Set
[*tags]
Reserve a set of values for this execution. No other process can reserve the same set of values while the set is reserved. Acquired value set needs to be released after use to allow other processes to access it. Add tags to limit the possible value sets that this returns.
Get Value From Set
[key]
Get a value from previously reserved value set.
Release Value Set
[]
Release a reserved value set so that other executions can use it also.
Disable Value Set
[]
Disable and release a reserved value set so that executions can not use it. After calling this a new value set can be aquired by calling execution.

Locks

A lock is a synchronization mechanism for enforcing limits on access to a resource. Locks allow to enforce a mutual exclusion concurrency control policy.
Acquire Lock
[name]
Wait for a lock with name. This will prevent other processes from acquiring the lock with the name while it is held. Thus they will wait in the position where they are acquiring the lock until the process that has it releases it.
Release Lock
[name]
Release a lock with name. This will enable other processes to acquire the lock.
Release Locks
[]
Release all locks owned by this process.