Remove code for backuprestore
[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    SSHKeywords.robot
10 Resource    Utils.robot
11
12
13 *** Keywords ***
14 Run Read Service Python Script on Controller Vm
15     [Documentation]    This keyword creates a new virtual environment, installs pyzmq & zmq and starts the read service on controller vm
16     [Arguments]    ${host_index}=${FIRST_CONTROLLER_INDEX}
17     ${host_index}    Builtin.Convert To Integer    ${host_index}
18     ${host}    ClusterManagement.Resolve IP Address For Member    ${host_index}
19     ${connections}    SSHKeywords.Open_Connection_To_ODL_System    ${host}
20     SSHLibrary.Switch Connection    ${connections}
21     SSHLibrary.Put File    ${READ_SERVICE_SCRIPT}    ${WORKSPACE}/${BUNDLEFOLDER}/    mode=664
22     ${module}    OperatingSystem.Get File    ${JSONRPCCONFIG_MODULE_JSON}
23     ${data}    OperatingSystem.Get File    ${JSONRPCCONFIG_DATA_JSON}
24     ${cmd}    Builtin.Set Variable
25     ...    nohup python ${WORKSPACE}/${BUNDLEFOLDER}/odl-jsonrpc-test-read tcp://0.0.0.0:${DEFAULT_PORT} 'config' ${DEFAULT_ENDPOINT} '${module.replace("\n","").replace(" ","")}' '${data.replace("\n","").replace(" ","")}'
26     Log    ${cmd}
27     SSHKeywords.Virtual_Env_Set_Path    /tmp/jsonrpc_venv
28     SSHKeywords.Virtual_Env_Create_Python3    True
29     SSHKeywords.Virtual_Env_Install_Package    pyzmq
30     SSHKeywords.Virtual_Env_Install_Package    zmq
31     SSHKeywords.Virtual_Env_Activate_On_Current_Session    True
32     ${stdout}    SSHLibrary.Write    rm -rf nohup.out
33     ${stdout}    SSHLibrary.Write    ${cmd} &
34     ${stdout}    SSHLibrary.Write    echo
35     Log    ${stdout}
36     BuiltIn.Sleep    2s
37     ${stdout}    SSHLibrary.Execute Command    /usr/sbin/ss -nlt
38     Log    ${stdout}
39     ${stdout}    SSHLibrary.Execute Command    cat nohup.out
40     Log    ${stdout}
41     SSHLibrary.Close_Connection
42
43 Mount Read Service Endpoint
44     [Documentation]    This keyword mounts an endpoint after starting service
45     [Arguments]    ${controller_index}=${FIRST_CONTROLLER_INDEX}    ${file}=${READ_SERVICE_PEER_PAYLOAD}    ${endpoint}=${DEFAULT_ENDPOINT}
46     ${JSON1}    OperatingSystem.Get File    ${file}
47     Log    ${JSON1}
48     ${response_json}    ClusterManagement.Put_As_Json_To_Member
49     ...    ${READ_SERVICE_PEER_URL}=${endpoint}
50     ...    ${JSON1}
51     ...    ${controller_index}
52     Builtin.Log    ${response_json}
53
54 Verify Data On Mounted Endpoint
55     [Documentation]    This keyword verifies if the data we get on the mount point is same as what we put
56     [Arguments]    ${controller_index}=${FIRST_CONTROLLER_INDEX}    ${endpoint}=${DEFAULT_ENDPOINT}
57     ${resp}    ClusterManagement.Get_From_Member
58     ...    ${READ_SERVICE_PEER_URL}=${endpoint}${READ_SERVICE_PEER_MOUNT_PATH}?content=config
59     ...    ${controller_index}
60     ${response_json}    Builtin.Convert To String    ${resp}
61     Log    ${response_json}
62     Verify Restconf Get On Mounted Endpoint    ${response_json}    ${READSERVICE_NAME}
63
64 Verify Restconf Get On Mounted Endpoint
65     [Documentation]    This keyword parses restconf get of mountpoint
66     [Arguments]    ${output}    ${name}
67     Builtin.Should Match Regexp    ${output}    "name":"${name}"