...
C/Python Synchronization APIs
- Execute tests on the LUTFAssign work to LUTF Agents from LUTF Master
- This will result in a YAML rpc block being sent to the LUTF agent
- Wait for work completion events from LUTF Agents
- Register for asynchronus events
- Asynchronous events come in the form of YAML blocks.
...
LUTF Communication Protocol
The Master and the Agent need to exchange information on which scripts to execute and the results of the scripts. Luckily, YAML provides an easy way to transport information. Python YAML parser converts YAML blocks into dictionaries, which are in turn easy to handle in Python code. Therefore YAML is a good way to define Remote Procedure Calls. It is understood that there are other libraries which implement RPCs; however, the intent is to keep the LUTF as simply and easily debug-able as possible.
To execute a function call on a remote node the following RPC YAML block is sent
Code Block |
---|
rpc:
target: agent_id # the ID of the agent to execute the function on
type: function_call # Type of the RPC
script: script_path # Path to the script which includes the function to execute
fname: function_name # Name of function to execute
parameters: # Parameters to pass the function
param0: value # parameters can be string, integer, float or list
param1: value2
paramN: valueN |
To return the results of the script execution
Code Block |
---|
rpc:
target: master_id # master ID. There should only be one
type: results # Type of the RPC
results:
script: script_path # Path to the script which was executed
status: PASS # Pass or Fail
duration: 2 # how long the execution took
return_code: 0 # return code if applicable
error: descriptive string # descriptive information about the result |
A python class will wrap the RPC protocol, such that the scripts do not need to form the RPC YAML block manually.
Code Block |
---|
####### Part of the LUTF infrastructure ########
# The BaseTest class is provided by the LUTF infrastructure
# The rpc method of the BaseTest class will take the parameters,
# serialize it into a YAML block and send it to the target specified.
class BaseTest():
def run(target, parameters);
self.rpc(class_name+'execute', parameters)
###### In the test script ######
# Each test case will inherit from the BaseTest class.
class Test_1a(BaseTest):
def execute(parameters):
# do the logic of the test
# The run function will be executed by the LUTF master
# it will instantiate the Test or the step of the test to run
# then call the class' run function providing it with a dictionary
# of parameters
def run(dictionary):
# do some logic
Test1a = Test_1a();
Test1a.run(params) |
Code Block |
rpc:
target: agent_id
type: function_call
fname: function_name
parameters:
param0: value
param1: value2
param2: 1
param3: [1, 2, 3]
param4: 1.4 |
Test Environment Set-Up
Each node which will run the LUTF will need to have the following installed
...