Resurrect exceptions library
[integration/test.git] / csit / libraries / ODLTools.robot
1 *** Settings ***
2 Documentation       Robot wrapper around ODLTools.
3
4 Library             OperatingSystem
5 Resource            ../variables/Variables.robot
6
7
8 *** Keywords ***
9 Version
10     [Documentation]    Get the odltools version
11     ${cmd} =    BuiltIn.Set Variable    odltools -V
12     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${cmd}
13     BuiltIn.Log    rc: ${rc}, output: ${output}
14     BuiltIn.Should Be True    '${rc}' == '0'
15     RETURN    ${output}
16
17 Get EOS
18     [Documentation]    Get the various ODL entity ownership information
19     [Arguments]    ${node_ip}=${ODL_SYSTEM_IP}    ${port}=${RESTCONFPORT}    ${test_name}=${SUITE_NAME}.${TEST_NAME}
20     ${dstdir} =    Get Path    ${test_name}
21     ${cmd} =    BuiltIn.Set Variable
22     ...    odltools show eos -i ${node_ip} -t ${port} -u ${ODL_RESTCONF_USER} -w ${ODL_RESTCONF_PASSWORD} --path ${dstdir}
23     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${cmd}
24     BuiltIn.Log    rc: ${rc}, output: ${output}
25     BuiltIn.Should Be True    '${rc}' == '0'
26     RETURN    ${output}
27
28 Get Cluster Info
29     [Documentation]    Get ODL Cluster related information like transaction counts, commit rates, etc.
30     [Arguments]    ${port}=${RESTCONFPORT}
31     FOR    ${i}    IN RANGE    ${NUM_ODL_SYSTEM}
32         ${cmd} =    BuiltIn.Set Variable
33         ...    odltools show cluster-info -i ${ODL_SYSTEM_${i+1}_IP} -t ${port} -u ${ODL_RESTCONF_USER} -w ${ODL_RESTCONF_PASSWORD}
34         ${output} =    OperatingSystem.Run    ${cmd}
35         BuiltIn.Log    output: ${output}
36     END
37
38 Analyze Tunnels
39     [Documentation]    Analyze Tunnel Mesh creation for any errors and log results
40     [Arguments]    ${node_ip}=${ODL_SYSTEM_IP}    ${port}=${RESTCONFPORT}    ${test_name}=${SUITE_NAME}.${TEST_NAME}
41     ${dstdir} =    Get Path    ${test_name}
42     ${cmd} =    BuiltIn.Set Variable
43     ...    odltools analyze tunnels -i ${node_ip} -t ${port} -u ${ODL_RESTCONF_USER} -w ${ODL_RESTCONF_PASSWORD} --path ${dstdir}
44     ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${cmd}
45     BuiltIn.Log    rc: ${rc}, output: ${output}
46     BuiltIn.Should Be True    '${rc}' == '0'
47     RETURN    ${output}
48
49 Get All
50     [Documentation]    Get all results provided by ODLTools
51     [Arguments]    ${node_ip}=${ODL_SYSTEM_IP}    ${port}=${RESTCONFPORT}    ${test_name}=${SUITE_NAME}.${TEST_NAME}
52     ODLTools.Get Cluster Info
53     BuiltIn.run Keyword And Ignore Error    ODLTools.Get EOS    ${node_ip}    test_name=${test_name}
54     BuiltIn.run Keyword And Ignore Error    ODLTools.Analyze Tunnels    ${node_ip}    test_name=${test_name}
55
56 Get Path
57     [Documentation]    Get odltools path for a given test case
58     [Arguments]    ${test_name}=${SUITE_NAME}.${TEST_NAME}
59     ${tmpdir} =    BuiltIn.Evaluate
60     ...    """${test_name}""".replace(" ","_").replace("/","_").replace(".","_").replace("(","_").replace(")","_")
61     RETURN    /tmp/${tmpdir}