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