Change opendaylight to karaf distro
[integration/test.git] / csit / libraries / JsonrpcKeywords.robot
1 *** Settings ***
2 Library           OperatingSystem
3 Library           SSHLibrary
4 Library           Collections
5 Library           RequestsLibrary
6 Resource          ClusterManagement.robot
7 Resource          ../variables/jsonrpc/JsonrpcVariables.robot
8 Resource          ../variables/Variables.robot
9 Resource          Utils.robot
10
11 *** Keywords ***
12 Run Read Service Python Script on Controller Vm
13     [Arguments]    ${host_index}=${FIRST_CONTROLLER_INDEX}    ${ub_system}=${FALSE}
14     [Documentation]    This keyword installs pip,zmq,pyzmq and starts the read service on controller vm
15     ${cmd}    Builtin.Set Variable If    ${ub_system}    ${UB_PIP}    ${CENTOS_PIP}
16     ${host_index}    Builtin.Convert To Integer    ${host_index}
17     ${host}    ClusterManagement.Resolve IP Address For Member    ${host_index}
18     ${connections}    SSHKeywords.Open_Connection_To_ODL_System    ${host}
19     SSHLibrary.Switch Connection    ${connections}
20     SSHLibrary.Put File    ${READ_SERVICE_SCRIPT}    ${WORKSPACE}/${BUNDLEFOLDER}/    mode=664
21     ${stdout}    ${stderr}    ${rc}=    SSHLibrary.Execute Command    ${cmd}    return_stdout=True    return_stderr=True
22     ...    return_rc=True
23     Log    ${stdout}
24     ${stdout}    ${stderr}    ${rc}=    SSHLibrary.Execute Command    sudo pip install --upgrade pip    return_stdout=True    return_stderr=True
25     ...    return_rc=True
26     Log    ${stdout}
27     ${stdout}    ${stderr}    ${rc}=    SSHLibrary.Execute Command    sudo pip install zmq pyzmq    return_stdout=True    return_stderr=True
28     ...    return_rc=True
29     Log    ${stdout}
30     ${module}    OperatingSystem.Get File    ${JSONRPCCONFIG_MODULE_JSON}
31     ${data}    OperatingSystem.Get File    ${JSONRPCCONFIG_DATA_JSON}
32     ${cmd}    Builtin.Set Variable    nohup python ${WORKSPACE}/${BUNDLEFOLDER}/odl-jsonrpc-test-read tcp://0.0.0.0:${DEFAULT_PORT} 'config' ${DEFAULT_ENDPOINT} '${module}' '${data}'
33     Log    ${cmd}
34     ${stdout}    SSHLibrary.Write    echo | rm -rf nohup.out
35     ${stdout}    SSHLibrary.Write    echo | nohup python ${WORKSPACE}/${BUNDLEFOLDER}/odl-jsonrpc-test-read tcp://0.0.0.0:${DEFAULT_PORT} 'config' ${DEFAULT_ENDPOINT} '${module}' '${data}' &
36     ${stdout}    SSHLibrary.Write    echo
37     Log    ${stdout}
38     ${stdout}    SSHLibrary.Execute Command    cat nohup.out
39     Log    ${stdout}
40     SSHLibrary.Close_Connection
41
42 Mount Read Service Endpoint
43     [Arguments]    ${controller_index}=${FIRST_CONTROLLER_INDEX}    ${file}=${READ_SERVICE_PEER_PAYLOAD}    ${endpoint}=${DEFAULT_ENDPOINT}
44     [Documentation]    This keyword mounts an endpoint after starting service
45     ${JSON1}    OperatingSystem.Get File    ${file}
46     Log    ${JSON1}
47     ${response_json}    ClusterManagement.Put_As_Json_To_Member    ${READ_SERVICE_PEER_PUT_URL}${endpoint}    ${JSON1}    ${controller_index}
48     Builtin.Log    ${response_json}
49
50 Verify Data On Mounted Endpoint
51     [Arguments]    ${controller_index}=${FIRST_CONTROLLER_INDEX}    ${endpoint}=${DEFAULT_ENDPOINT}
52     [Documentation]    This keyword verifies if the data we get on the mount point is same as what we put
53     ${resp}    ClusterManagement.Get_From_Member    ${READ_SERVICE_PEER_GET_1}${endpoint}${READ_SERVICE_PEER_GET_2}    ${controller_index}
54     ${response_json}    Builtin.Convert To String    ${resp}
55     Log    ${response_json}
56     Verify Restconf Get On Mounted Endpoint    ${response_json}    ${READSERVICE_NAME}
57
58 Verify Restconf Get On Mounted Endpoint
59     [Arguments]    ${output}    ${name}
60     [Documentation]    This keyword parses restconf get of mountpoint
61     Builtin.Should Match Regexp    ${output}    "name":"${name}"