Adding verify controller log to scalability test.
[integration/test.git] / test / csit / libraries / Utils.txt
1 *** Settings ***
2 Library           SSHLibrary
3 Library           ./UtilLibrary.py
4 Resource          KarafKeywords.txt
5
6 *** Variables ***
7 ${start}          sudo mn --controller=remote,ip=${CONTROLLER} --topo tree,1 --switch ovsk,protocols=OpenFlow13
8 ${linux_prompt}   >
9
10 *** Keywords ***
11 Start Suite
12     [Documentation]    Basic setup/cleanup work that can be done safely before any system
13     ...    is run.
14     Log    Start the test on the base edition
15     ${mininet_conn_id}=     Open Connection    ${MININET}    prompt=${linux_prompt}    timeout=30s
16     Set Suite Variable  ${mininet_conn_id}
17     Login With Public Key    ${MININET_USER}    ${USER_HOME}/.ssh/id_rsa    any
18     Write    sudo ovs-vsctl set-manager ptcp:6644
19     Read Until    ${linux_prompt}
20     Write    sudo mn -c
21     Read Until    ${linux_prompt}
22     Write    ${start}
23     Read Until    mininet>
24     Sleep    6
25
26 Stop Suite
27     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all
28     ...    tests
29     Log    Stop the test on the base edition
30     Switch Connection   ${mininet_conn_id}
31     Read
32     Write    exit
33     Read Until    ${linux_prompt}
34     Close Connection
35
36 Ensure All Nodes Are In Response
37     [Arguments]    ${URI}    ${node_list}
38     [Documentation]    A GET is made to the supplied ${URI} and every item in the ${node_list}
39     ...    is verified to exist in the repsonse. This keyword currently implies that it's node
40     ...    specific but any list of strings can be given in ${node_list}. Refactoring of this
41     ...    to make it more generic should be done. (see keyword "Check For Elements At URI")
42     : FOR    ${node}    IN    @{node_list}
43     \    ${resp}    RequestsLibrary.Get    session    ${URI}
44     \    Should Be Equal As Strings    ${resp.status_code}    200
45     \    Should Contain    ${resp.content}    ${node}
46
47 Check Nodes Stats
48     [Arguments]    ${node}
49     [Documentation]    A GET on the /node/${node} API is made and specific flow stat
50     ...    strings are checked for existence.
51     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT}/node/${node}
52     Should Be Equal As Strings    ${resp.status_code}    200
53     Should Contain    ${resp.content}    flow-capable-node-connector-statistics
54     Should Contain    ${resp.content}    flow-table-statistics
55
56 Check That Port Count Is Ok
57     [Arguments]    ${node}    ${count}
58     [Documentation]    A GET on the /port API is made and the specified port ${count} is
59     ...    verified. A more generic Keyword "Check For Specific Number Of Elements At URI"
60     ...    also does this work and further consolidation should be done.
61     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT}/${CONTAINER}/port
62     Log    ${resp.content}
63     Should Be Equal As Strings    ${resp.status_code}    200
64     Should Contain X Times    ${resp.content}    ${node}    ${count}
65
66 Check For Specific Number Of Elements At URI
67     [Arguments]    ${uri}    ${element}    ${expected_count}
68     [Documentation]    A GET is made to the specified ${URI} and the specific count of a
69     ...    given element is done (as supplied by ${element} and ${expected_count})
70     ${resp}    RequestsLibrary.Get    session    ${uri}
71     Log    ${resp.content}
72     Should Be Equal As Strings    ${resp.status_code}    200
73     Should Contain X Times    ${resp.content}    ${element}    ${expected_count}
74
75 Check For Elements At URI
76     [Arguments]    ${uri}    ${elements}
77     [Documentation]    A GET is made at the supplied ${URI} and every item in the list of
78     ...    ${elements} is verified to exist in the response
79     ${resp}    RequestsLibrary.Get    session    ${uri}
80     Log    ${resp.content}
81     Should Be Equal As Strings    ${resp.status_code}    200
82     : FOR    ${i}    IN    @{elements}
83     \    Should Contain    ${resp.content}    ${i}
84
85 Check For Elements Not At URI
86     [Arguments]    ${uri}    ${elements}
87     [Documentation]    A GET is made at the supplied ${URI} and every item in the list of
88     ...    ${elements} is verified to NOT exist in the response
89     ${resp}    RequestsLibrary.Get    session    ${uri}
90     Log    ${resp.content}
91     Should Be Equal As Strings    ${resp.status_code}    200
92     : FOR    ${i}    IN    @{elements}
93     \    Should Not Contain    ${resp.content}    ${i}
94
95 Extract Value From Content
96     [Arguments]    ${content}    ${index}    ${strip}=nostrip
97     [Documentation]    Will take the given response content and return the value at the given index as a string
98     ${value}=    Get Json Value    ${content}    ${index}
99     ${value}=    Convert To String    ${value}
100     ${value}=    Run Keyword If    '${strip}' == 'strip'    Strip Quotes    ${value}
101     [Return]    ${value}
102
103 Strip Quotes
104     [Arguments]    ${string_to_strip}
105     [Documentation]    Will strip ALL quotes from given string and return the new string
106     ${string_to_return}=    Replace String    ${string_to_strip}    "    \    count=-1
107     [Return]    ${string_to_return}
108
109 Run Command On Remote System
110     [Arguments]     ${remote_system}    ${cmd}  ${user}=${MININET_USER}    ${prompt}=${LINUX_PROMPT}   ${prompt_timeout}=30s
111     [Documentation]     Reduces the common work of running a command on a remote system to a single higher level robot keyword,
112     ...     taking care to log in with a public key and. The command given is written and the output returned.  No test conditions
113     ...     are checked.
114     Log    Attempting to execute ${cmd} on ${remote_system}
115     ${conn_id}=     Open Connection    ${remote_system}    prompt=${prompt}    timeout=${prompt_timeout}
116     Login With Public Key    ${user}    ${USER_HOME}/.ssh/id_rsa    any
117     Write    ${cmd}
118     ${output}=  Read Until    ${linux_prompt}
119     Close Connection
120     [Return]    ${output}
121
122 Verify File Exists On Remote System
123     [Arguments]  ${remote_system}    ${file}  ${user}=${MININET_USER}    ${prompt}=${LINUX_PROMPT}   ${prompt_timeout}=5s
124     [Documentation]     Will create connection with public key and will PASS if the given ${file} exists, otherwise will FAIL
125     ${conn_id}=     Open Connection    ${remote_system}    prompt=${prompt}    timeout=${prompt_timeout}
126     Login With Public Key    ${user}    ${USER_HOME}/.ssh/id_rsa    any
127     SSHLibrary.File Should Exist   ${file}
128     Close Connection
129
130 Verify Controller Is Not Dead
131     [Arguments]     ${controller_ip}=${CONTROLLER}
132     [Documentation]     Will execute any tests to verify the controller is not dead. Some checks are
133     ...     Out Of Memory Execptions.
134     Check Karaf Log File Does Not Have Messages     ${controller_ip}  java.lang.OutOfMemoryError