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