Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / genius / Configure_ITM.robot
1 *** Settings ***
2 Documentation     Test Suite for ITM
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           Collections
8 Library           OperatingSystem
9 Library           RequestsLibrary
10 Library           String
11 Resource          ../../libraries/DataModels.robot
12 Resource          ../../libraries/Genius.robot
13 Resource          ../../libraries/KarafKeywords.robot
14 Resource          ../../libraries/ToolsSystem.robot
15 Resource          ../../libraries/Utils.robot
16 Resource          ../../variables/netvirt/Variables.robot
17 Resource          ../../variables/Variables.robot
18 Variables         ../../variables/genius/Modules.py
19
20 *** Variables ***
21 ${gateway_regex_IPV4}    [0-9]\{1,3}\.[0-9]\{1,3}\.[0-9]\{1,3}\.
22 ${gateway_regex_IPV6}    [0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:
23
24 *** Test Cases ***
25 Create and Verify VTEP -No Vlan
26     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs without VLAN and Gateway configured in Json.
27     Genius.Create Vteps    ${NO_VLAN}    ${gateway_ip}
28     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Get ITM    ${itm_created[0]}
29     ${type} =    BuiltIn.Set Variable    odl-interface:tunnel-type-vxlan
30     Genius.Update Dpn id list and get tunnels    ${type}
31     Genius.Verify Response Code Of Dpn Endpointconfig API
32     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Ovs Interface Verification
33     BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Verify Tunnel Status As Up
34     Verify Network Topology
35     Verify Ietf Interface State
36     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Verify Table0 Entry After fetching Port Number
37     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_NODES_API}
38     ${respjson} =    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
39     BuiltIn.Log    ${respjson}
40     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
41
42 Delete and Verify VTEP -No Vlan
43     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
44     ${tunnel_list} =    Genius.Get Tunnels List
45     FOR    ${dpn_id}    IN    @{DPN_ID_LIST}
46         CompareStream.Run_Keyword_If_Less_Than_Sodium    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/subnets/${SUBNET}%2F16/vteps/${dpn_id}/${port_name}
47         CompareStream.Run_Keyword_If_At_Least_Sodium    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/vteps/${dpn_id}
48     END
49     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
50     BuiltIn.Should Not Contain    ${output}    ${itm_created[0]}
51     Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
52     ${resp} =    Utils.Get Data From URI    session    ${CONFIG_API}/itm:transport-zones/
53     BuiltIn.Should Not Contain    ${resp} =    ${itm_created[0]}
54     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Verify Deleted Tunnels On OVS    ${tunnel_list}    ${resp}
55     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${tunnel_list}
56
57 Create and Verify VTEP IPv6 - No Vlan
58     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs without VLAN and Gateway configured in Json.
59     ${gateway_ip} =    BuiltIn.Set Variable    ::
60     Build Tools System IPV6 List
61     Create Vteps IPv6    ${NO_VLAN}    ${gateway_ip}    ${TOOLS_SYSTEM_IPV6_LIST}
62     BuiltIn.Wait Until Keyword Succeeds    40    10    Get ITM IPV6    ${itm_created[0]}
63     ${type} =    BuiltIn.Set Variable    odl-interface:tunnel-type-vxlan
64     Genius.Update Dpn id list and get tunnels    ${type}
65     FOR    ${dpn}    IN    @{DPN_ID_LIST}
66         BuiltIn.Wait Until Keyword Succeeds    40    5    Utils.Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${dpn}/
67         ...    headers=${ACCEPT_XML}
68     END
69     BuiltIn.Wait Until Keyword Succeeds    40    10    OVS Verification Between IPV6
70     @{all_tunnels} =    BuiltIn.Create List
71     FOR    ${conn_id}    IN    @{TOOLS_SYSTEM_ALL_CONN_IDS}
72         ${tun_names} =    Genius.Get Tunnels On OVS    ${conn_id}
73         Collections.Append To List    ${all_tunnels}    @{tun_names}
74     END
75     @{network_topology_list} =    BuiltIn.Create List    @{all_tunnels}
76     @{network_topology_list} =    Collections.Append To List    ${network_topology_list}    ${Bridge}
77     ${resp} =    BuiltIn.Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${OPERATIONAL_TOPO_API}    ${network_topology_list}
78
79 Delete and Verify VTEP IPv6 -No Vlan
80     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
81     ${type} =    BuiltIn.Set Variable    odl-interface:tunnel-type-vxlan
82     ${tunnel_list} =    Genius.Get Tunnels List
83     FOR    ${dpn_id}    IN    @{DPN_ID_LIST}
84         CompareStream.Run_Keyword_If_Less_Than_Sodium    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/subnets/${SUBNET_IPV6}%2F16/vteps/${dpn_id}/${port_name}
85         CompareStream.Run_Keyword_If_At_Least_Sodium    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/vteps/${dpn_id}
86     END
87     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
88     BuiltIn.Should Not Contain    ${output}    ${itm_created[0]}
89     BuiltIn.Run Keyword And Ignore Error    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
90     ${resp} =    Utils.Get Data From URI    session    ${CONFIG_API}/itm:transport-zones/
91     BuiltIn.Should Not Contain    ${resp}    ${itm_created[0]}
92     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Verify Deleted Tunnels On OVS    ${tunnel_list}    ${resp}
93     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${tunnel_list}
94
95 Create and Verify VTEP-Vlan
96     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs with VLAN and without Gateway configured in Json.
97     Genius.Create Vteps    ${VLAN}    ${gateway_ip}
98     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Get ITM    ${itm_created[0]}
99     ${type} =    BuiltIn.Set Variable    odl-interface:tunnel-type-vxlan
100     Genius.Update Dpn id list and get tunnels    ${type}
101     Genius.Verify Response Code Of Dpn Endpointconfig API
102     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Ovs Interface Verification
103     Verify Network Topology
104     Verify Ietf Interface State
105     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Verify Table0 Entry After fetching Port Number
106
107 Delete and Verify VTEP -Vlan
108     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
109     ${type} =    BuiltIn.Set Variable    odl-interface:tunnel-type-vxlan
110     ${tunnel_list} =    Genius.Get Tunnels List
111     FOR    ${dpn_id}    IN    @{DPN_ID_LIST}
112         CompareStream.Run_Keyword_If_Less_Than_Sodium    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/subnets/${SUBNET}%2F16/vteps/${dpn_id}/${port_name}
113         CompareStream.Run_Keyword_If_At_Least_Sodium    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/vteps/${dpn_id}
114     END
115     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
116     BuiltIn.Should Not Contain    ${output}    ${itm_created[0]}
117     Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
118     ${resp} =    Utils.Get Data From URI    session    ${CONFIG_API}/itm:transport-zones/
119     BuiltIn.Should Not Contain    ${resp}    ${itm_created[0]}
120     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Verify Deleted Tunnels On OVS    ${tunnel_list}    ${resp}
121     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${tunnel_list}
122
123 Create VTEP - Vlan and Gateway
124     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs with VLAN and Gateway configured in Json.
125     ${substr} =    BuiltIn.Should Match Regexp    ${TOOLS_SYSTEM_IP}    ${gateway_regex_IPV4}
126     ${gateway_ip} =    BuiltIn.Catenate    ${substr}1
127     Genius.Create Vteps    ${VLAN}    ${gateway_ip}
128     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Get ITM    ${itm_created[0]}
129     ${type} =    BuiltIn.Set Variable    odl-interface:tunnel-type-vxlan
130     Genius.Update Dpn id list and get tunnels    ${type}
131     ${tunnel-type} =    BuiltIn.Set Variable    type: vxlan
132     Genius.Verify Response Code Of Dpn Endpointconfig API
133     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Ovs Interface Verification
134     BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Verify Tunnel Status As Up
135     Verify Network Topology
136     Verify Ietf Interface State
137     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Verify Table0 Entry After fetching Port Number
138
139 Delete VTEP -Vlan and gateway
140     [Documentation]    This testcase deletes the ITM tunnel created between 2 dpns.
141     ${type} =    BuiltIn.Set Variable    odl-interface:tunnel-type-vxlan
142     ${tunnel_list} =    Genius.Get Tunnels List
143     FOR    ${dpn_id}    IN    @{DPN_ID_LIST}
144         CompareStream.Run_Keyword_If_Less_Than_Sodium    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/subnets/${SUBNET}%2F16/vteps/${dpn_id}/${port_name}
145         CompareStream.Run_Keyword_If_At_Least_Sodium    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/vteps/${dpn_id}
146     END
147     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
148     BuiltIn.Should Not Contain    ${output}    ${itm_created[0]}
149     Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
150     ${resp} =    Utils.Get Data From URI    session    ${CONFIG_API}/itm:transport-zones/
151     BuiltIn.Should Not Contain    ${resp}    ${itm_created[0]}
152     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Verify Deleted Tunnels On OVS    ${tunnel_list}    ${resp}
153     BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${tunnel_list}
154
155 *** Keywords ***
156 Create Vteps IPv6
157     [Arguments]    ${vlan}    ${gateway_ip}    ${tools_ips}
158     [Documentation]    This keyword creates VTEPs between IPV6 ip's
159     ${substr} =    BuiltIn.Should Match Regexp    @{tools_ips}[0]    ${gateway_regex_IPV6}
160     ${SUBNET_IPV6} =    BuiltIn.Catenate    ${substr}0
161     BuiltIn.Set Suite Variable    ${SUBNET_IPV6}
162     ${body} =    Genius.Set Json    ${vlan}    ${gateway_ip}    ${SUBNET_IPV6}    @{TOOLS_SYSTEM_IPV6_LIST}
163     Utils.Post Log Check    ${CONFIG_API}/itm:transport-zones/    ${body}    status_codes=${204}
164
165 Get Network Topology with Tunnel
166     [Arguments]    ${url}    ${network_topology_list}
167     [Documentation]    Returns the Network topology with Tunnel info in it.
168     Utils.Check For Elements At URI    ${url}    ${network_topology_list}
169
170 Get ITM IPV6
171     [Arguments]    ${itm_created[0]}
172     [Documentation]    It returns the created ITM Transport zone with the passed values during the creation is done.
173     @{Itm-no-vlan} =    Collections.Combine Lists    ${TOOLS_SYSTEM_IPV6_LIST}    ${DPN_ID_LIST}
174     Collections.Append To List    ${Itm-no-vlan}    ${itm_created[0]}
175     Utils.Check For Elements At URI    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}    ${Itm-no-vlan}
176
177 OVS Verification Between IPV6
178     [Documentation]    This keyword will verify tunnels available on ovs
179     FOR    ${tools_ip}    IN    @{TOOLS_SYSTEM_ALL_IPS}
180         Genius.Ovs Verification For Each Dpn    ${tools_ip}    ${TOOLS_SYSTEM_IPV6_LIST}
181     END
182
183 Verify Network Topology
184     [Documentation]    This keyword will verify whether all tunnels and bridges are populated in network topology
185     ${all_tunnels} =    Genius.Get Tunnels List
186     @{network_topology_list} =    BuiltIn.Create List
187     @{network_topology_list} =    Collections.Append To List    ${network_topology_list}    ${Bridge}
188     @{network_topology_list} =    Collections.Combine Lists    ${network_topology_list}    ${all_tunnels}
189     ${resp} =    BuiltIn.Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${OPERATIONAL_TOPO_API}    ${network_topology_list}
190
191 Verify Ietf Interface State
192     Utils.Check For Elements At URI    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/    ${DPN_ID_LIST}    session    True
193     ${all_tunnels} =    Genius.Get Tunnels List
194     Utils.Check For Elements At URI    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/    ${all_tunnels}    session    True
195
196 Build Tools System IPV6 List
197     [Documentation]    Create a list of tools system ips with IPV6.
198     @{TOOLS_SYSTEM_IPV6_LIST} =    BuiltIn.Create List
199     FOR    ${tool_system_index}    IN RANGE    ${NUM_TOOLS_SYSTEM}
200         Collections.Append To List    ${TOOLS_SYSTEM_IPV6_LIST}    fd96:2a25:4ad3:3c7d:0:0:${tool_system_index}:1000
201     END
202     BuiltIn.Set Suite Variable    @{TOOLS_SYSTEM_IPV6_LIST}