aboutsummaryrefslogtreecommitdiffstats
path: root/resources/test_data/honeycomb/routing.py
blob: 25fefe942626a4567d6aec182c23c717340e8ceb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# Copyright (c) 2017 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Test data for Honeycomb routing test."""

from resources.libraries.python.topology import Topology


def get_variables(node, ip_version, out_interface):

    out_interface = Topology.convert_interface_reference(
        node, out_interface, "name")

    ip_version = ip_version.lower()
    variables = {}

    # base network settings
    ipv4_base = {
        "dut_to_tg_if1_ip": "16.0.0.1",
        "dut_to_tg_if2_ip": "16.0.1.1",
        "src_ip": "16.0.0.2",
        "dst_ip": "16.0.2.1",
        "dst_net": "16.0.2.0",
        "prefix_len": 24,
        "next_hop": "16.0.1.2",
        "next_hop1": "16.0.1.3",
        "next_hop2": "16.0.1.4",
        "next_hop_mac1": "00:11:22:33:44:55",
        "next_hop_mac2": "11:22:33:44:55:66"
    }

    ipv6_base = {
        "dut_to_tg_if1_ip": "10::1",
        "dut_to_tg_if2_ip": "11::1",
        "src_ip": "10::2",
        "dst_ip": "12::1",
        "dst_net": "12::",
        "prefix_len": 64,
        "next_hop": "11::2",
        "next_hop1": "11::3",
        "next_hop2": "11::4",
        "next_hop_mac1": "00:11:22:33:44:55",
        "next_hop_mac2": "11:22:33:44:55:66"
    }

    if ip_version == "ipv4":
        variables.update(ipv4_base)
    elif ip_version == "ipv6":
        variables.update(ipv6_base)
    else:
        raise ValueError("IP version must be either IPv4 or IPv6.")

    # route configuration used in tests
    tables_cfg = {
        "table1": {
            "description": "single hop ipv4",
            "destination-prefix":
                "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
            "next-hop": {
                "next-hop-address" : ipv4_base["next_hop"],
                "outgoing-interface": out_interface
            },
            "vpp-ipv4-unicast-routing:vpp-ipv4-route": {}
        },
        "table2": {
            "description": "multi hop ipv4",
            "destination-prefix":
                "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
            "next-hop":{
                "next-hop-list": {
                    "next-hop": [
                        {
                            "index": "1",
                            "next-hop-address": ipv4_base["next_hop1"],
                            "outgoing-interface": out_interface,
                            "weight": "1"
                        },
                        {
                            "index": "2",
                            "next-hop-address": ipv4_base["next_hop2"],
                            "outgoing-interface": out_interface,
                            "weight": "1"
                        }
                    ]
                }
            }
        },
        "table3": {
            "description": "blackhole ipv4",
            "destination-prefix":
                "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
            "next-hop": {
                "special-next-hop-enum": "blackhole"
            }
        },
        "table4": {
            "description": "single hop ipv6",
            "destination-prefix":
                "{0}/{1}".format(ipv6_base["dst_net"], ipv6_base["prefix_len"]),
            "next-hop": {
                "next-hop-address": ipv6_base["next_hop"],
                "outgoing-interface": out_interface
            },
            "vpp-ipv6-unicast-routing:vpp-ipv6-route": {}
        },
        "table5": {
            "description": "multi hop ipv6",
            "destination-prefix":
                "{0}/{1}".format(ipv6_base["dst_net"], ipv6_base["prefix_len"]),
            "next-hop":{
                "next-hop-list": {
                    "next-hop": [
                        {
                            "index": "1",
                            "next-hop-address": ipv6_base["next_hop1"],
                            "outgoing-interface": out_interface,
                            "weight": "1"
                        },
                        {
                            "index": "2",
                            "next-hop-address": ipv6_base["next_hop2"],
                            "outgoing-interface": out_interface,
                            "weight": "1"
                        }
                    ]
                }
            }
        },
        "table6": {
            "description": "blackhole ipv6",
            "destination-prefix":
                "{0}/{1}".format(ipv6_base["dst_net"], ipv6_base["prefix_len"]),
            "next-hop":{
                "special-next-hop-enum": "blackhole"
            }
        }
    }

    # expected route operational data
    tables_oper = {
        "table1_oper": {
            "destination-prefix":
                "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
            "next-hop":{
                "next-hop-address": ipv4_base["next_hop"],
                "outgoing-interface": out_interface
            },
            "vpp-ipv4-unicast-routing:vpp-ipv4-route": {}
        },
        "table2_oper": {
            "destination-prefix":
                "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
            "next-hop":{
                "next-hop-list": {
                    "next-hop": [
                        {
                            "index": "2",
                            "next-hop-address": ipv4_base["next_hop2"],
                            "outgoing-interface": out_interface,
                            "vpp-ipv4-unicast-routing:weight": 1
                        },
                        {
                            "index": "1",
                            "next-hop-address": ipv4_base["next_hop1"],
                            "outgoing-interface": out_interface,
                            "vpp-ipv4-unicast-routing:weight": 1
                        }
                    ]
                }
            },
            "vpp-ipv4-unicast-routing:vpp-ipv4-route": {}
        },
        "table3_oper": {
            "destination-prefix":
                "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
            "next-hop":{
                "special-next-hop-enum": "blackhole"
            },
            "vpp-ipv4-unicast-routing:vpp-ipv4-route": {}
        },
        "table4_oper": {
            "destination-prefix":
                "{0}/{1}".format(ipv6_base["dst_net"],
                                 ipv6_base["prefix_len"]),
            "next-hop":{
                "next-hop-address": ipv6_base["next_hop"],
                "outgoing-interface": out_interface
            },
            "vpp-ipv6-unicast-routing:vpp-ipv6-route": {}
        },
        "table5_oper": {
            "destination-prefix":
                "{0}/{1}".format(ipv6_base["dst_net"],
                                 ipv6_base["prefix_len"]),
            "next-hop":{
                "next-hop-list": {
                    "next-hop": [
                        {
                            "index": "2",
                            "next-hop-address": ipv6_base["next_hop2"],
                            "outgoing-interface": out_interface,
                            "vpp-ipv6-unicast-routing:weight": 1
                        },
                        {
                            "index": "1",
                            "next-hop-address": ipv6_base["next_hop1"],
                            "outgoing-interface": out_interface,
                            "vpp-ipv6-unicast-routing:weight": 1
                        }
                    ]
                }
            },
            "vpp-ipv6-unicast-routing:vpp-ipv6-route": {}
        },
        "table6_oper": {
            "destination-prefix":
                "{0}/{1}".format(ipv6_base["dst_net"],
                                 ipv6_base["prefix_len"]),
            "next-hop":{
                "special-next-hop-enum": "blackhole"
            },
            "vpp-ipv6-unicast-routing:vpp-ipv6-route": {}
        }
    }

    for item in tables_oper.values():
        if "next-hop-list" in item.keys():
            item["next-hop-list"]["next-hop"].sort()

    variables.update(tables_cfg)
    variables.update(tables_oper)
    return variables