HC2VPP-253 - Update routing csit jobs
[csit.git] / resources / test_data / honeycomb / routing.py
1 # Copyright (c) 2017 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 """Test data for Honeycomb routing test."""
15
16 from resources.libraries.python.topology import Topology
17
18
19 def get_variables(node, ip_version, out_interface):
20
21     out_interface = Topology.convert_interface_reference(
22         node, out_interface, "name")
23
24     ip_version = ip_version.lower()
25     variables = {}
26
27     # base network settings
28     ipv4_base = {
29         "dut_to_tg_if1_ip": "16.0.0.1",
30         "dut_to_tg_if2_ip": "16.0.1.1",
31         "src_ip": "16.0.0.2",
32         "dst_ip": "16.0.2.1",
33         "dst_net": "16.0.2.0",
34         "prefix_len": 24,
35         "next_hop": "16.0.1.2",
36         "next_hop1": "16.0.1.3",
37         "next_hop2": "16.0.1.4",
38         "next_hop_mac1": "00:11:22:33:44:55",
39         "next_hop_mac2": "11:22:33:44:55:66"
40     }
41
42     ipv6_base = {
43         "dut_to_tg_if1_ip": "10::1",
44         "dut_to_tg_if2_ip": "11::1",
45         "src_ip": "10::2",
46         "dst_ip": "12::1",
47         "dst_net": "12::",
48         "prefix_len": 64,
49         "next_hop": "11::2",
50         "next_hop1": "11::3",
51         "next_hop2": "11::4",
52         "next_hop_mac1": "00:11:22:33:44:55",
53         "next_hop_mac2": "11:22:33:44:55:66"
54     }
55
56     if ip_version == "ipv4":
57         variables.update(ipv4_base)
58     elif ip_version == "ipv6":
59         variables.update(ipv6_base)
60     else:
61         raise ValueError("IP version must be either IPv4 or IPv6.")
62
63     # route configuration used in tests
64     tables_cfg = {
65         "table1": {
66             "description": "single hop ipv4",
67             "destination-prefix":
68                 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
69             "next-hop": {
70                 "next-hop-address" : ipv4_base["next_hop"],
71                 "outgoing-interface": out_interface
72             },
73             "vpp-ipv4-unicast-routing:vpp-ipv4-route": {}
74         },
75         "table2": {
76             "description": "multi hop ipv4",
77             "destination-prefix":
78                 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
79             "next-hop":{
80                 "next-hop-list": {
81                     "next-hop": [
82                         {
83                             "index": "1",
84                             "next-hop-address": ipv4_base["next_hop1"],
85                             "outgoing-interface": out_interface,
86                             "weight": "1"
87                         },
88                         {
89                             "index": "2",
90                             "next-hop-address": ipv4_base["next_hop2"],
91                             "outgoing-interface": out_interface,
92                             "weight": "1"
93                         }
94                     ]
95                 }
96             }
97         },
98         "table3": {
99             "description": "blackhole ipv4",
100             "destination-prefix":
101                 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
102             "next-hop": {
103                 "special-next-hop-enum": "blackhole"
104             }
105         },
106         "table4": {
107             "description": "single hop ipv6",
108             "destination-prefix":
109                 "{0}/{1}".format(ipv6_base["dst_net"], ipv6_base["prefix_len"]),
110             "next-hop": {
111                 "next-hop-address": ipv6_base["next_hop"],
112                 "outgoing-interface": out_interface
113             },
114             "vpp-ipv6-unicast-routing:vpp-ipv6-route": {}
115         },
116         "table5": {
117             "description": "multi hop ipv6",
118             "destination-prefix":
119                 "{0}/{1}".format(ipv6_base["dst_net"], ipv6_base["prefix_len"]),
120             "next-hop":{
121                 "next-hop-list": {
122                     "next-hop": [
123                         {
124                             "index": "1",
125                             "next-hop-address": ipv6_base["next_hop1"],
126                             "outgoing-interface": out_interface,
127                             "weight": "1"
128                         },
129                         {
130                             "index": "2",
131                             "next-hop-address": ipv6_base["next_hop2"],
132                             "outgoing-interface": out_interface,
133                             "weight": "1"
134                         }
135                     ]
136                 }
137             }
138         },
139         "table6": {
140             "description": "blackhole ipv6",
141             "destination-prefix":
142                 "{0}/{1}".format(ipv6_base["dst_net"], ipv6_base["prefix_len"]),
143             "next-hop":{
144                 "special-next-hop-enum": "blackhole"
145             }
146         }
147     }
148
149     # expected route operational data
150     tables_oper = {
151         "table1_oper": {
152             "destination-prefix":
153                 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
154             "next-hop":{
155                 "next-hop-address": ipv4_base["next_hop"],
156                 "outgoing-interface": out_interface
157             },
158             "vpp-ipv4-unicast-routing:vpp-ipv4-route": {}
159         },
160         "table2_oper": {
161             "destination-prefix":
162                 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
163             "next-hop":{
164                 "next-hop-list": {
165                     "next-hop": [
166                         {
167                             "index": "2",
168                             "next-hop-address": ipv4_base["next_hop2"],
169                             "outgoing-interface": out_interface,
170                             "vpp-ipv4-unicast-routing:weight": 1
171                         },
172                         {
173                             "index": "1",
174                             "next-hop-address": ipv4_base["next_hop1"],
175                             "outgoing-interface": out_interface,
176                             "vpp-ipv4-unicast-routing:weight": 1
177                         }
178                     ]
179                 }
180             },
181             "vpp-ipv4-unicast-routing:vpp-ipv4-route": {}
182         },
183         "table3_oper": {
184             "destination-prefix":
185                 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
186             "next-hop":{
187                 "special-next-hop-enum": "blackhole"
188             },
189             "vpp-ipv4-unicast-routing:vpp-ipv4-route": {}
190         },
191         "table4_oper": {
192             "destination-prefix":
193                 "{0}/{1}".format(ipv6_base["dst_net"],
194                                  ipv6_base["prefix_len"]),
195             "next-hop":{
196                 "next-hop-address": ipv6_base["next_hop"],
197                 "outgoing-interface": out_interface
198             },
199             "vpp-ipv6-unicast-routing:vpp-ipv6-route": {}
200         },
201         "table5_oper": {
202             "destination-prefix":
203                 "{0}/{1}".format(ipv6_base["dst_net"],
204                                  ipv6_base["prefix_len"]),
205             "next-hop":{
206                 "next-hop-list": {
207                     "next-hop": [
208                         {
209                             "index": "2",
210                             "next-hop-address": ipv6_base["next_hop2"],
211                             "outgoing-interface": out_interface,
212                             "vpp-ipv6-unicast-routing:weight": 1
213                         },
214                         {
215                             "index": "1",
216                             "next-hop-address": ipv6_base["next_hop1"],
217                             "outgoing-interface": out_interface,
218                             "vpp-ipv6-unicast-routing:weight": 1
219                         }
220                     ]
221                 }
222             },
223             "vpp-ipv6-unicast-routing:vpp-ipv6-route": {}
224         },
225         "table6_oper": {
226             "destination-prefix":
227                 "{0}/{1}".format(ipv6_base["dst_net"],
228                                  ipv6_base["prefix_len"]),
229             "next-hop":{
230                 "special-next-hop-enum": "blackhole"
231             },
232             "vpp-ipv6-unicast-routing:vpp-ipv6-route": {}
233         }
234     }
235
236     for item in tables_oper.values():
237         if "next-hop-list" in item.keys():
238             item["next-hop-list"]["next-hop"].sort()
239
240     variables.update(tables_cfg)
241     variables.update(tables_oper)
242     return variables