Add Honeycomb VxLAN test suite
[csit.git] / resources / libraries / robot / honeycomb / vxlan.robot
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library | resources.libraries.python.InterfaceUtil
16 | ...     | WITH NAME | interfaceCLI
17 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
18 | ...     | WITH NAME | InterfaceAPI
19
20 *** Keywords ***
21 | Honeycomb sets interface VxLAN configuration
22 | | [Documentation] | Uses Honeycomb API to configure a VxLAN tunnel.
23 | | ...
24 | | ... | *Arguments:*
25 | | ... | - node - information about a DUT node. Type: dictionary
26 | | ... | - interface - name of an interface on the specified node. Type: string
27 | | ... | - settings - Configuration data for VxLAN. Type: dictionary
28 | | ...
29 | | ... | *Example:*
30 | | ... | \| Honeycomb sets interface VxLAN configuration \
31 | | ... | \|${nodes['DUT1']} \| vxlan_01 \| ${{'src':'192.168.0.2',\
32 | | ... |  'dst':'192.168.0.3', 'vni':5, 'encap-vrf-id':0}} \|
33 | | ...
34 | | [Arguments] | ${node} | ${interface} | ${settings}
35 | | interfaceAPI.Create VxLAN interface | ${node} | ${interface}
36 | | ... | &{settings}
37
38 | Honeycomb removes VxLAN tunnel settings
39 | | [Documentation] | Uses Honeycomb API to disable a VxLAN tunnel and remove\
40 | | ... | it from configuration data.
41 | | ...
42 | | ... | *Arguments:*
43 | | ... | - node - information about a DUT node. Type: dictionary
44 | | ... | - interface - name of an interface on the specified node. Type: string
45 | | ...
46 | | ... | *Example:*
47 | | ...
48 | | ... | \| Honeycomb removes VxLAN tunnel \| ${nodes['DUT1']} \| vxlan_01 \|
49 | | [Arguments] | ${node} | ${interface}
50 | | interfaceAPI.Delete interface | ${node} | ${interface}
51
52 | VxLAN configuration from Honeycomb should be
53 | | [Documentation] | Retrieves interface VxLAN configuration through Honeycomb\
54 | | ... | and compares with settings supplied in argument.
55 | | ...
56 | | ... | *Arguments:*
57 | | ... | - node - information about a DUT node. Type: dictionary
58 | | ... | - interface - name of an interface on the specified node. Type: string
59 | | ... | - settings - Configuration data for VxLAN. Type: dictionary
60 | | ...
61 | | ... | *Example:*
62 | | ...
63 | | ... | \| VxLAN configuration from Honeycomb should be \
64 | | ... | \|${nodes['DUT1']} \| vxlan_01 \| ${{'src':'192.168.0.2',\
65 | | ... |  'dst':'192.168.0.3', 'vni':5, 'encap-vrf-id':0}} \|
66 | | ...
67 | | [Arguments] | ${node} | ${interface} | ${settings}
68 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
69 | | ${api_vxlan}= | Set Variable | ${api_data['v3po:vxlan']}
70 | | :FOR | ${key} | IN | @{settings.keys()}
71 | | | Should be equal | ${api_vxlan['${key}']} | ${settings['${key}']}
72
73 | VxLAN configuration from VAT should be
74 | | [Documentation] | Retrieves interface VxLAN configuration through VAT and\
75 | | ... | compares with settings supplied in argument.
76 | | ...
77 | | ... | *Arguments:*
78 | | ... | - node - information about a DUT node. Type: dictionary
79 | | ... | - settings - Configuration data for VxLAN. Type: dictionary
80 | | ...
81 | | ... | *Example:*
82 | | ...
83 | | ... | \| VxLAN configuration from Honeycomb should be \
84 | | ... | \|${nodes['DUT1']} \| ${{'src':'192.168.0.2',\
85 | | ... |  'dst':'192.168.0.3', 'vni':5, 'encap-vrf-id':0}} \|
86 | | ...
87 | | ... | *Note:*
88 | | ... | Due to the difficulty of identifying newly created interfaces by name\
89 | | ... | or by sw_index, this keyword assumes there is only one VxLAN tunnel\
90 | | ... | present on the specified node.
91 | | [Arguments] | ${node} | ${settings}
92 | | ${vat_data}= | VxLAN Dump | ${node}
93 | | ${vat_data}= | Set Variable | ${vat_data[0]}
94 | | Should be equal | ${vat_data['dst_address']} | ${settings['dst']}
95 | | Should be equal | ${vat_data['src_address']} | ${settings['src']}
96 | | Should be equal | ${vat_data['vni']} | ${settings['vni']}
97 | | Should be equal
98 | | ... | ${vat_data['encap_vrf_id']} | ${settings['encap-vrf-id']}
99
100 | VxLAN configuration from Honeycomb should be empty
101 | | [Documentation] | Attempts to retrieve interface VxLAN configuration\
102 | | ... | through Honeycomb and expects to recieve an empty dictionary.
103 | | ...
104 | | ... | *Arguments:*
105 | | ... | - node - information about a DUT node. Type: dictionary
106 | | ... | - interface - name of an interface on the specified node. Type: string
107 | | ...
108 | | ... | *Example:*
109 | | ...
110 | | ... | \| VxLAN configuration from Honeycomb should be empty\
111 | | ... | \|${nodes['DUT1']} \| vxlan_01 \|
112 | | ...
113 | | [Arguments] | ${node} | ${interface}
114 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
115 | | Should be empty | ${api_data}
116
117 | VxLAN configuration from VAT should be empty
118 | | [Documentation] | Attempts to retrieve interface VxLAN configuration\
119 | | ... | through VAT and expects a "no data" error.
120 | | ...
121 | | ... | *Arguments:*
122 | | ... | - node - information about a DUT node. Type: dictionary
123 | | ... | - interface - name of an interface on the specified node. Type: string
124 | | ...
125 | | ... | *Example:*
126 | | ...
127 | | ... | \| VxLAN configuration from VAT should be empty\
128 | | ... | \| ${nodes['DUT1']} \|
129 | | ...
130 | | [Arguments] | ${node}
131 | | Run Keyword And Expect Error | ValueError: No JSON object could be decoded
132 | | ... | VxLAN Dump | ${node}
133
134 | Honeycomb fails setting VxLan on different interface type
135 | | [Documentation] | Attempts to set VxLAN settings on an ethernet\
136 | | ... | type interface and expects to fail.
137 | | ...
138 | | ... | *Arguments:*
139 | | ... | - node - information about a DUT node. Type: dictionary
140 | | ... | - interface - name of an interface on the specified node. Type: string
141 | | ... | - settings - Configuration data for VxLAN. Type: dictionary
142 | | ...
143 | | ... | *Example:*
144 | | ...
145 | | ... | \| Honeycomb fails setting VxLan on different interface type\
146 | | ... | \|${nodes['DUT1']} \| GigabitEthernet0/9/0 \| ${{'src':'192.168.0.2',\
147 | | ... |  'dst':'192.168.0.3', 'vni':5, 'encap-vrf-id':0}} \|
148 | | ...
149 | | [Arguments] | ${node} | ${interface} | ${settings}
150 | | Run Keyword And Expect Error | HoneycombError: * Status code: 500.
151 | | ... | interfaceAPI.Configure interface vxlan
152 | | ... | ${node} | ${interface} | &{settings}
153
154 | Honeycomb fails setting invalid VxLAN configuration
155 | | [Documentation] | Attempts to create a VxLAN interface with invalid\
156 | | ... | configuration and expects to fail.
157 | | ...
158 | | ... | *Arguments:*
159 | | ... | - node - information about a DUT node. Type: dictionary
160 | | ... | - interface - name of an interface on the specified node. Type: string
161 | | ... | - settings_list - Bad configuration data for VxLAN. Type: list
162 | | ...
163 | | ... | *Example:*
164 | | ...
165 | | ... | \| Honeycomb fails setting invalid VxLAN configuration\
166 | | ... | \|${nodes['DUT1']} \| vxlan_01 \| ${{'src':'abcd', 'vni':-3}} \|
167 | | ...
168 | | [Arguments] | ${node} | ${interface} | ${settings_list}
169 | | :FOR | ${settings} | IN | @{settings_list}
170 | | | Run Keyword And Expect Error | HoneycombError: * Status code: 500.
171 | | | ... | interfaceAPI.Create VxLAN interface
172 | | | ... | ${node} | ${interface} | &{settings}