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