Merge "Adding test for hosttracker"
[integration/test.git] / test / csit / libraries / Utils.txt
1 *** Settings ***
2 Library           SSHLibrary
3
4 *** Variables ***
5 ${start}          sudo mn --controller=remote,ip=${CONTROLLER} --topo tree,1 --switch ovsk,protocols=OpenFlow13
6
7 *** Keywords ***
8 Start Suite
9     [Documentation]    Basic setup/cleanup work that can be done safely before any system
10     ...    is run.
11     Log    Start the test on the base edition
12     Open Connection    ${MININET}    prompt=>    timeout=30s
13     Login With Public Key    ${MININET_USER}    ${USER_HOME}/.ssh/id_rsa    any
14     Write    sudo ovs-vsctl set-manager ptcp:6644
15     Write    sudo mn -c
16     Read Until    >
17     Write    ${start}
18     Read Until    mininet>
19
20 Stop Suite
21     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all
22     ...    tests
23     Log    Stop the test on the base edition
24     Read
25     Write    exit
26     Read Until    >
27     Close Connection
28
29 Ensure All Nodes Are In Response
30     [Arguments]    ${URI}    ${node_list}
31     [Documentation]    A GET is made to the supplied ${URI} and every item in the ${node_list}
32     ...    is verified to exist in the repsonse. This keyword currently implies that it's node
33     ...    specific but any list of strings can be given in ${node_list}. Refactoring of this
34     ...    to make it more generic should be done. (see keyword "Check For Elements At URI")
35     : FOR    ${node}    IN    @{node_list}
36     \    ${resp}    Get    session    ${URI}
37     \    Should Be Equal As Strings    ${resp.status_code}    200
38     \    Should Contain    ${resp.content}    ${node}
39
40 Check Nodes Stats
41     [Arguments]    ${node}
42     [Documentation]    A GET on the /node/${node} API is made and specific flow stat
43     ...    strings are checked for existence.
44     ${resp}    Get    session    ${REST_CONTEXT}/node/${node}
45     Should Be Equal As Strings    ${resp.status_code}    200
46     Should Contain    ${resp.content}    flow-capable-node-connector-statistics
47     Should Contain    ${resp.content}    flow-table-statistics
48
49 Check That Port Count Is Ok
50     [Arguments]    ${node}    ${count}
51     [Documentation]    A GET on the /port API is made and the specified port ${count} is
52     ...    verified. A more generic Keyword "Check For Specific Number Of Elements At URI"
53     ...    also does this work and further consolidation should be done.
54     ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}/port
55     Log    ${resp.content}
56     Should Be Equal As Strings    ${resp.status_code}    200
57     Should Contain X Times    ${resp.content}    ${node}    ${count}
58
59 Check For Specific Number Of Elements At URI
60     [Arguments]    ${uri}    ${element}    ${expected_count}
61     [Documentation]    A GET is made to the specified ${URI} and the specific count of a
62     ...    given element is done (as supplied by ${element} and ${expected_count})
63     ${resp}    Get    session    ${uri}
64     Log    ${resp.content}
65     Should Be Equal As Strings    ${resp.status_code}    200
66     Should Contain X Times    ${resp.content}    ${element}    ${expected_count}
67
68 Check For Elements At URI
69     [Arguments]    ${uri}    ${elements}
70     [Documentation]    A GET is made at the supplied ${URI} and every item in the list of
71     ...    ${elements} is verified to exist in the response
72     ${resp}    Get    session    ${uri}
73     Log    ${resp.content}
74     Should Be Equal As Strings    ${resp.status_code}    200
75     : FOR    ${i}    IN    @{elements}
76     \    Should Contain    ${resp.content}    ${i}
77
78 Check For Elements Not At URI
79     [Arguments]    ${uri}    ${elements}
80     [Documentation]    A GET is made at the supplied ${URI} and every item in the list of
81     ...    ${elements} is verified to NOT exist in the response
82     ${resp}    Get    session    ${uri}
83     Log    ${resp.content}
84     Should Be Equal As Strings    ${resp.status_code}    200
85     : FOR    ${i}    IN    @{elements}
86     \    Should Not Contain    ${resp.content}    ${i}