Check cluster status after rejoin
[integration/test.git] / csit / suites / genius / Interface_manager.robot
1 *** Settings ***
2 Documentation     Test Suite for Interface manager
3 Suite Setup       Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Test Teardown     Get Model Dump    ${ODL_SYSTEM_IP}    ${data_models}
6 Library           OperatingSystem
7 Library           String
8 Library           RequestsLibrary
9 Library           Collections
10 Library           re
11 Variables         ../../variables/Variables.py
12 Variables         ../../variables/genius/Modules.py
13 Resource          ../../libraries/DataModels.robot
14 Resource          ../../libraries/Utils.robot
15
16 *** Variables ***
17 ${genius_config_dir}    ${CURDIR}/../../variables/genius
18 ${bridgename}     BR1
19 ${interface_name}    l2vlan-trunk
20 ${trunk_json}     l2vlan.json
21 ${trunk_member_json}    l2vlan_member.json
22
23 *** Test Cases ***
24 Create l2vlan transparent interface
25     [Documentation]    This testcase creates a l2vlan transparent interface between 2 dpns.
26     Log    >>>> Creating L2vlan interface <<<<<
27     Create Interface    ${trunk_json}    transparent
28     Log    >>>> Get interface config <<<<<
29     @{l2vlan}    create list    l2vlan-trunk    l2vlan    transparent    l2vlan    true
30     Check For Elements At URI    ${CONFIG_API}/ietf-interfaces:interfaces/    ${l2vlan}
31     Log    >>>>> Get interface operational state<<<<
32     Wait Until Keyword Succeeds    50    5    get operational interface    ${interface_name}
33     ${ovs-check}    Wait Until Keyword Succeeds    40    10    table0 entry    ${conn_id_1}    ${bridgename}
34
35 Delete l2vlan transparent interface
36     [Documentation]    This testcase deletes the l2vlan transparent interface created between 2 dpns.
37     Remove All Elements At URI And Verify    ${CONFIG_API}/ietf-interfaces:interfaces/
38     No Content From URI    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces/
39     Wait Until Keyword Succeeds    30    10    no table0 entry
40
41 Create l2vlan trunk interface
42     [Documentation]    This testcase creates a l2vlan trunk interface between 2 DPNs.
43     Log    >>>> Getting file for posting json <<<<<<<
44     Create Interface    ${trunk_json}    trunk
45     Log    >>>> Get interface config <<<<<
46     @{l2vlan}    create list    l2vlan-trunk    l2vlan    trunk    tap8ed70586-6c    true
47     Check For Elements At URI    ${CONFIG_API}/ietf-interfaces:interfaces/    ${l2vlan}
48     Log    >>>>> Get interface operational state<<<<
49     Wait Until Keyword Succeeds    50    5    get operational interface    ${interface_name}
50     Wait Until Keyword Succeeds    30    10    table0 entry    ${conn_id_1}    ${bridgename}
51
52 Create l2vlan Trunk member interface
53     [Documentation]    This testcase creates a l2vlan Trunk member interface for the l2vlan trunk interface created in 1st testcase.
54     Log    >>>> Creating L2vlan member interface <<<<<
55     Log    >>>> Getting file for posting json <<<<<<<
56     ${body}    OperatingSystem.Get File    ${genius_config_dir}/l2vlan_member.json
57     ${post_resp}    RequestsLibrary.Post Request    session    ${CONFIG_API}/ietf-interfaces:interfaces/    data=${body}
58     Log    ${post_resp.content}
59     Log    ${post_resp.status_code}
60     Should Be Equal As Strings    ${post_resp.status_code}    204
61     Log    >>>> Get interface config <<<<<
62     @{l2vlan}    create list    l2vlan-trunk1    l2vlan    trunk-member    1000    l2vlan-trunk
63     ...    true
64     Check For Elements At URI    ${CONFIG_API}/ietf-interfaces:interfaces/    ${l2vlan}
65     Log    >>>>> Get interface operational state<<<<
66     Wait Until Keyword Succeeds    10    5    get operational interface    ${l2vlan[0]}
67     Wait Until Keyword Succeeds    40    10    ovs check for member interface creation    ${conn_id_1}    ${bridgename}
68
69 Bind service on Interface
70     [Documentation]    This testcase binds service to the interface created .
71     Log    >>>> Getting file for posting json <<<<<<<
72     ${body}    OperatingSystem.Get File    ${genius_config_dir}/bind_service.json
73     ${body}    replace string    ${body}    service1    VPN
74     ${body}    replace string    ${body}    service2    elan
75     log    ${body}
76     ${service_mode}    Set Variable    interface-service-bindings:service-mode-ingress
77     ${post_resp}    RequestsLibrary.Post Request    session    ${CONFIG_API}/interface-service-bindings:service-bindings/services-info/${interface_name}/${service_mode}/    data=${body}
78     log    ${post_resp.content}
79     log    ${post_resp.status_code}
80     Should Be Equal As Strings    ${post_resp.status_code}    204
81     Log    >>>>> Verifying Binded interface <<<<<
82     @{bind_array}    create list    2    3    VPN    elan    50
83     ...    21
84     Check For Elements At URI    ${CONFIG_API}/interface-service-bindings:service-bindings/services-info/${interface_name}/${service_mode}/    ${bind_array}
85     Log    >>>>> OVS check for table enteries <<<<
86     ${command}    set variable    sudo ovs-ofctl -O OpenFlow13 dump-flows ${bridgename}
87     Wait Until Keyword Succeeds    40    10    table entry    ${command}
88
89 unbind service on interface
90     [Documentation]    This testcase Unbinds the service which is binded by the 3rd testcase.
91     Log    >>>>>>Unbinding the service on interface <<<<
92     ${service-priority-1}    set variable    3
93     ${service-priority-2}    set variable    4
94     ${service_mode}    Set Variable    interface-service-bindings:service-mode-ingress
95     Remove All Elements At URI And Verify    ${CONFIG_API}/interface-service-bindings:service-bindings/services-info/${interface_name}/${service_mode}/bound-services/${service-priority-1}/
96     log    >>>> Ovs check for table 21 absence <<<
97     ${table-id}    set variable    21
98     Wait Until Keyword Succeeds    10    2    no goto_table entry    ${table-id}
99     Remove All Elements At URI And Verify    ${CONFIG_API}/interface-service-bindings:service-bindings/services-info/${interface_name}/${service_mode}/bound-services/${service-priority-2}/
100     No Content From URI    session    ${CONFIG_API}/interface-service-bindings:service-bindings/services-info/${interface_name}/${service_mode}/bound-services/${service-priority-2}/
101     log    >>>> Ovs check for table 50 absence <<<
102     ${table-id}    set variable    50
103     Wait Until Keyword Succeeds    10    2    no goto_table entry    ${table-id}
104
105 Delete l2vlan trunk interface
106     [Documentation]    Deletion of l2vlan trunk interface is done.
107     Remove All Elements At URI And Verify    ${CONFIG_API}/ietf-interfaces:interfaces/
108     No Content From URI    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces/
109     ${resp}    Wait Until Keyword Succeeds    30    10    no table0 entry
110
111 *** Keywords ***
112 get operational interface
113     [Arguments]    ${interface_name}
114     [Documentation]    checks operational status of the interface.
115     ${get_oper_resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${interface_name}/
116     ${respjson}    RequestsLibrary.To Json    ${get_oper_resp.content}    pretty_print=True
117     log    ${respjson}
118     log    ${get_oper_resp.status_code}
119     Should Be Equal As Strings    ${get_oper_resp.status_code}    200
120     Should not contain    ${get_oper_resp.content}    down
121     Should Contain    ${get_oper_resp.content}    up    up
122
123 table entry
124     [Arguments]    ${command}
125     [Documentation]    Checks for tables entry wrt the service the Interface is binded.
126     switch connection    ${conn_id_1}
127     ${result}    execute command    ${command}
128     log    ${result}
129     should contain    ${result}    table=17
130     should contain    ${result}    goto_table:21
131     should contain    ${result}    goto_table:50
132
133 no table0 entry
134     [Documentation]    After Deleting trunk interface, checking for absence of table 0 in the flow dumps
135     switch connection    ${conn_id_1}
136     ${bridgename}    set variable    BR1
137     ${ovs-check}    execute command    sudo ovs-ofctl -O OpenFlow13 dump-flows ${bridgename}
138     log    ${ovs-check}
139     should not contain    ${ovs-check}    table=0
140     should not contain    ${ovs-check}    goto_table:17
141
142 no goto_table entry
143     [Arguments]    ${table-id}
144     [Documentation]    Checks for absence of no goto_table after unbinding the service on the interface.
145     switch connection    ${conn_id_1}
146     ${ovs-check1}    execute command    sudo ovs-ofctl -O OpenFlow13 dump-flows ${bridgename}
147     Log    ${ovs-check1}
148     should not contain    ${ovs-check1}    goto_table:${table-id}
149
150 table0 entry
151     [Arguments]    ${connection-id}    ${bridgename}
152     [Documentation]    After Creating the trunk interface , checking for table 0 entry exist in the flow dumps
153     switch connection    ${connection-id}
154     log    switch connection
155     ${ovs-check}    execute command    sudo ovs-ofctl -O OpenFlow13 dump-flows ${bridgename}
156     log    sudo ovs-ofctl -O OpenFlow13 dump-flows ${bridgename}
157     log    ${ovs-check}
158     should contain    ${ovs-check}    table=0
159
160 ovs check for member interface creation
161     [Arguments]    ${connection-id}    ${bridgename}
162     [Documentation]    This keyword verifies the member interface created on OVS by checking the table0 ,vlan and action=pop_vlan entries
163     switch connection    ${connection-id}
164     ${ovs-check}    execute command    sudo ovs-ofctl -O OpenFlow13 dump-flows ${bridgename}
165     log    ${ovs-check}
166     should contain    ${ovs-check}    table=0
167     should contain    ${ovs-check}    dl_vlan=1000
168     should contain    ${ovs-check}    actions=pop_vlan
169
170 Create Interface
171     [Arguments]    ${json_file}    ${interface_mode}
172     [Documentation]    Creates an trunk/transparent interface based on input provided to the json body
173     ${body}    OperatingSystem.Get File    ${genius_config_dir}/${json_file}
174     log    ${genius_config_dir}/${json_file}
175     ${body}    replace string    ${body}    "l2vlan-mode":"trunk"    "l2vlan-mode":"${interface_mode}"
176     log    "l2vlan-mode":"${interface_mode}"
177     log    ${body}
178     ${post_resp}    RequestsLibrary.Post Request    session    ${CONFIG_API}/ietf-interfaces:interfaces/    data=${body}
179     Log    ${post_resp.content}
180     Log    ${post_resp.status_code}
181     Should Be Equal As Strings    ${post_resp.status_code}    204