68f18d89c5696ffb95b4cf478135942a116748a0
[integration/test.git] / test / csit / libraries / Scalability.txt
1 *** Settings ***
2 Library           SSHLibrary
3
4 *** Variables ***
5 ${linux_prompt}    >
6
7 *** Keywords ***
8 Find Max Switches
9     [Arguments]    ${start}    ${stop}    ${step}
10     [Documentation]    Will find out max switches starting from ${start} till reaching ${stop} and in steps defined by ${step}
11     ${max-switches}    Set Variable    ${1}
12     ${start}    Convert to Integer    ${start}
13     ${stop}    Convert to Integer    ${stop}
14     ${step}    Convert to Integer    ${step}
15     : FOR    ${switches}    IN RANGE    ${start}    ${stop+1}    ${step}
16     \    Start Mininet Linear    ${switches}
17     \    ${status}    ${result}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    2s
18     \    ...    Check Every Switch    ${switches}
19     \    Return From Keyword If    '${status}' == 'FAIL'
20     \    ${status}    ${result}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    2s
21     \    ...    Check Linear Topology    ${switches}
22     \    Return From Keyword If    '${status}' == 'FAIL'
23     \    Stop Mininet
24     \    ${status}    ${result}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    2s
25     \    ...    Check No Switches    ${switches}
26     \    Return From Keyword If    '${status}' == 'FAIL'
27     \    ${status}    ${result}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    2s
28     \    ...    Check No Topology    ${switches}
29     \    Return From Keyword If    '${status}' == 'FAIL'
30     \    ${max-switches}    Convert To String    ${switches}
31     [Return]    ${max-switches}
32
33 Start Mininet Linear
34     [Arguments]    ${switches}
35     [Documentation]    Start mininet linear topology with ${switches} nodes
36     Log    Start mininet linear ${switches}
37     ${mininet_conn_id}=    Open Connection    ${MININET}    prompt=${linux_prompt}    timeout=${switches*2}
38     Set Suite Variable    ${mininet_conn_id}
39     Login With Public Key    ${MININET_USER}    ${USER_HOME}/.ssh/id_rsa    any
40     Write    sudo mn --controller=remote,ip=${CONTROLLER} --topo linear,${switches} --switch ovsk,protocols=OpenFlow13
41     Read Until    mininet>
42     Sleep    6
43
44 Check Every Switch
45     [Arguments]    ${switches}
46     [Documentation]    Check all switches and stats in operational inventory
47     : FOR    ${switch}    IN RANGE    1    ${switches+1}
48     \    ${resp}    RequestsLibrary.Get    session    /restconf/operational/opendaylight-inventory:nodes/node/openflow:${switch}
49     \    Log    ${resp.content}
50     \    Should Be Equal As Strings    ${resp.status_code}    200
51     \    Should Contain    ${resp.content}    flow-capable-node-connector-statistics
52     \    Should Contain    ${resp.content}    flow-table-statistics
53
54 Check Linear Topology
55     [Arguments]    ${switches}
56     [Documentation]    Check Linear topology given ${switches}
57     ${resp}    RequestsLibrary.Get    session    /restconf/operational/network-topology:network-topology/
58     Log    ${resp.content}
59     Should Be Equal As Strings    ${resp.status_code}    200
60     : FOR    ${switch}    IN RANGE    1    ${switches+1}
61     \    Should Contain    ${resp.content}    "node-id":"openflow:${switch}"
62     \    Should Contain    ${resp.content}    "tp-id":"openflow:${switch}:1"
63     \    Should Contain    ${resp.content}    "tp-id":"openflow:${switch}:2"
64     \    Should Contain    ${resp.content}    "source-tp":"openflow:${switch}:2"
65     \    Should Contain    ${resp.content}    "dest-tp":"openflow:${switch}:2"
66     \    ${edge}    Evaluate    ${switch}==1 or ${switch}==${switches}
67     \    Run Keyword Unless    ${edge}    Should Contain    ${resp.content}    "tp-id":"openflow:${switch}:3"
68     \    Run Keyword Unless    ${edge}    Should Contain    ${resp.content}    "source-tp":"openflow:${switch}:3"
69     \    Run Keyword Unless    ${edge}    Should Contain    ${resp.content}    "dest-tp":"openflow:${switch}:3"
70
71 Check No Switches
72     [Arguments]    ${switches}
73     [Documentation]    Check no switch is in inventory
74     ${resp}    RequestsLibrary.Get    session    /restconf/operational/opendaylight-inventory:nodes
75     Log    ${resp.content}
76     Should Be Equal As Strings    ${resp.status_code}    200
77     : FOR    ${switch}    IN RANGE    1    ${switches+1}
78     \    Should Not Contain    ${resp.content}    openflow:${switch}
79
80 Check No Topology
81     [Arguments]    ${switches}
82     [Documentation]    Check no switch is in topology
83     ${resp}    RequestsLibrary.Get    session    /restconf/operational/network-topology:network-topology/
84     Log    ${resp.content}
85     Should Be Equal As Strings    ${resp.status_code}    200
86     : FOR    ${switch}    IN RANGE    1    ${switches+1}
87     \    Should Not Contain    ${resp.content}    openflow:${switch}
88
89 Stop Mininet
90     [Documentation]    Stop mininet
91     Log    Stop Mininet
92     Switch Connection    ${mininet_conn_id}
93     Read
94     Write    exit
95     Read Until    ${linux_prompt}
96     Close Connection