Skip to content

Commit b3b446b

Browse files
committed
Configure trusted vni in test cases
1 parent c430255 commit b3b446b

5 files changed

Lines changed: 83 additions & 0 deletions

File tree

test/test-cases/functional/ptf/sai_dash_utils.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Thrift SAI interface basic DASH utils.
1717
"""
1818

19+
import functools
1920
from sai_thrift.sai_headers import *
2021
from sai_base_test import *
2122

@@ -471,6 +472,22 @@ def configure_underlay(self, *neighbors, add_routes=True):
471472
#if add_routes is True:
472473
# self.route_create(neighbor.ip_prefix, nhop)
473474

475+
def global_trusted_vni_create(self, vni):
476+
"""
477+
Create outband CA PA mapping
478+
"""
479+
480+
global_trusted_vni_entry = sai_thrift_global_trusted_vni_entry_t(switch_id=self.switch_id,
481+
vni_range=sai_thrift_u32_range_t(min=vni, max=vni))
482+
sai_thrift_create_global_trusted_vni_entry(self.client, global_trusted_vni_entry)
483+
self.assertEqual(self.status(), SAI_STATUS_SUCCESS)
484+
self.add_teardown_obj(self.global_trusted_vni_remove, global_trusted_vni_entry)
485+
486+
return global_trusted_vni_entry
487+
488+
def global_trusted_vni_remove(self, global_trusted_vni_entry):
489+
sai_thrift_remove_global_trusted_vni_entry(self.client, global_trusted_vni_entry)
490+
474491

475492
class VnetApiEndpoints(VnetAPI):
476493
"""
@@ -1520,3 +1537,22 @@ def update_tcp_pkt(pkt, seq, ack, tcp_flag=None):
15201537

15211538
pkt.getlayer("TCP").seq = seq
15221539
pkt.getlayer("TCP").ack = ack
1540+
1541+
def configureTrustedVni(func):
1542+
@functools.wraps(func)
1543+
def wrapper_configureTrustedVni(self):
1544+
value = func(self)
1545+
1546+
vni_set = set()
1547+
tx_hosts = ["tx_host", "tx_host_1", "tx_host_2", "tx_host_3", "tx_host_4"]
1548+
for name in tx_hosts:
1549+
host = getattr(self, name, None)
1550+
if host and host.client:
1551+
vni_set.add(host.client.vni)
1552+
1553+
for vni in list(vni_set):
1554+
self.global_trusted_vni_create(vni)
1555+
1556+
return value
1557+
1558+
return wrapper_configureTrustedVni

test/test-cases/functional/ptf/saidashacl.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ def setUpSwitch(self):
150150
self.create_entry(sai_thrift_create_direction_lookup_entry, sai_thrift_remove_direction_lookup_entry,
151151
self.dle, action=SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION)
152152

153+
self.gtve = sai_thrift_global_trusted_vni_entry_t(switch_id=self.switch_id,
154+
vni_range=sai_thrift_u32_range_t(min=self.outbound_vni, max=self.outbound_vni))
155+
self.create_entry(sai_thrift_create_global_trusted_vni_entry, sai_thrift_remove_global_trusted_vni_entry,
156+
self.gtve)
157+
153158
self.in_v4_stage1_acl_group_id = self.create_obj(
154159
sai_thrift_create_dash_acl_group, sai_thrift_remove_dash_acl_group, ip_addr_family=SAI_IP_ADDR_FAMILY_IPV4)
155160
self.in_v4_stage2_acl_group_id = self.create_obj(

test/test-cases/functional/ptf/saidashdpapp_sanity.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ def configureVnet(self):
4646
action=SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION)
4747
assert(status == SAI_STATUS_SUCCESS)
4848

49+
self.gtve = sai_thrift_global_trusted_vni_entry_t(switch_id=self.switch_id,
50+
vni_range=sai_thrift_u32_range_t(min=self.outbound_vni, max=self.outbound_vni))
51+
status = sai_thrift_create_global_trusted_vni_entry(self.client, self.gtve)
52+
assert(status == SAI_STATUS_SUCCESS)
53+
4954
self.in_acl_group_id = sai_thrift_create_dash_acl_group(self.client,
5055
ip_addr_family=self.sai_ip_addr_family)
5156
assert (self.in_acl_group_id != SAI_NULL_OBJECT_ID)
@@ -322,6 +327,7 @@ def tearDown(self):
322327
status &= sai_thrift_remove_vnet(self.client, self.vnet)
323328
status &= sai_thrift_remove_dash_acl_group(self.client, self.out_acl_group_id)
324329
status &= sai_thrift_remove_dash_acl_group(self.client, self.in_acl_group_id)
330+
status &= sai_thrift_remove_global_trusted_vni_entry(self.client, self.gtve)
325331
status &= sai_thrift_remove_direction_lookup_entry(self.client, self.dle)
326332
status &= sai_thrift_remove_vip_entry(self.client, self.vpe)
327333
status &= sai_thrift_remove_route_entry(self.client, self.pa_route_entry)

test/test-cases/functional/ptf/saidashvnet.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def runTest(self):
3838
self.l3UnderlayHost1toHost2RoutingTest()
3939
self.l3UnderlayHost2toHost1RoutingTest()
4040

41+
@configureTrustedVni
4142
def configureTest(self):
4243
"""
4344
Setup DUT in accordance with test purpose
@@ -137,6 +138,7 @@ def runTest(self):
137138
self.vnet2VnetInboundRoutingTest(tx_equal_to_rx=True)
138139
self.vnet2VnetInboundNegativeTest()
139140

141+
@configureTrustedVni
140142
def configureTest(self):
141143
"""
142144
Setup DUT in accordance with test purpose
@@ -268,6 +270,7 @@ class Vnet2VnetInboundDecapSinglePortTest(Vnet2VnetInboundDecapPaValidateSingleP
268270
Verifies positive and negative scenarios
269271
"""
270272

273+
@configureTrustedVni
271274
def configureTest(self):
272275
"""
273276
Setup DUT overlay in accordance with test purpose
@@ -397,6 +400,7 @@ def runTest(self):
397400
self.vnet2VnetInboundRoutingPositiveTest(tx_equal_to_rx=True)
398401
self.vnet2VnetInboundRoutingNegativeTest()
399402

403+
@configureTrustedVni
400404
def configureTest(self):
401405
"""
402406
Setup DUT in accordance with test purpose
@@ -582,6 +586,7 @@ def runTest(self):
582586

583587
self.vnet2VnetInboundRoutingPositiveTest(tx_equal_to_rx=True)
584588

589+
@configureTrustedVni
585590
def configureTest(self):
586591
"""
587592
Setup DUT in accordance with test purpose
@@ -777,6 +782,7 @@ def runTest(self):
777782
self.vnet2VnetInboundRoutingPositiveTest(tx_equal_to_rx=True)
778783
self.vnet2VnetInboundRoutingNegativeTest()
779784

785+
@configureTrustedVni
780786
def configureTest(self):
781787
"""
782788
Setup DUT in accordance with test purpose
@@ -949,6 +955,7 @@ def runTest(self):
949955

950956
self.vnet2VnetInboundRoutingPositiveTest(tx_equal_to_rx=True)
951957

958+
@configureTrustedVni
952959
def configureTest(self):
953960
"""
954961
Setup DUT in accordance with test purpose
@@ -1128,6 +1135,7 @@ def runTest(self):
11281135

11291136
self.vnet2VnetInboundRoutingTest(tx_equal_to_rx=True)
11301137

1138+
@configureTrustedVni
11311139
def configureTest(self):
11321140
"""
11331141
Setup DUT in accordance with test purpose
@@ -1251,6 +1259,7 @@ def runTest(self):
12511259

12521260
self.vnet2VnetInboundRoutingTest(tx_equal_to_rx=True)
12531261

1262+
@configureTrustedVni
12541263
def configureTest(self):
12551264
"""
12561265
Setup DUT in accordance with test purpose
@@ -1383,6 +1392,7 @@ def runTest(self):
13831392
self.eni_set_admin_state(self.eni_id, "up")
13841393
self.vnet2VnetEniUpTrafficTest(tx_equal_to_rx=True)
13851394

1395+
@configureTrustedVni
13861396
def configureTest(self):
13871397
"""
13881398
Setup DUT overlay in accordance with test purpose
@@ -1463,6 +1473,7 @@ def runTest(self):
14631473
self.vnet2VnetOutboundRoutingTest(tx_equal_to_rx=True)
14641474
self.vnet2VnetOutboundNegativeTest()
14651475

1476+
@configureTrustedVni
14661477
def configureTest(self):
14671478
"""
14681479
Setup DUT in accordance with test purpose
@@ -1535,6 +1546,7 @@ class Vnet2VnetOutboundRouteVnetDirectSinglePortOverlayIpv6Test(Vnet2VnetOutboun
15351546
def setUp(self):
15361547
super(Vnet2VnetOutboundRouteVnetDirectSinglePortOverlayIpv6Test, self).setUp(overlay_ipv6=True)
15371548

1549+
@configureTrustedVni
15381550
def configureTest(self):
15391551
"""
15401552
Setup DUT in accordance with test purpose
@@ -1635,6 +1647,7 @@ def runTest(self):
16351647
self.vnet2VnetOutboundRoutingTest(tx_equal_to_rx=True)
16361648
self.vnet2VnetOutboundNegativeTest()
16371649

1650+
@configureTrustedVni
16381651
def configureTest(self):
16391652
"""
16401653
Setup DUT in accordance with test purpose
@@ -1713,6 +1726,7 @@ class Vnet2VnetOutboundRouteVnetSinglePortOverlayIpv6Test(Vnet2VnetOutboundRoute
17131726
def setUp(self):
17141727
super(Vnet2VnetOutboundRouteVnetSinglePortOverlayIpv6Test, self).setUp(overlay_ipv6=True)
17151728

1729+
@configureTrustedVni
17161730
def configureTest(self):
17171731
"""
17181732
Setup DUT in accordance with test purpose
@@ -1823,6 +1837,7 @@ def runTest(self):
18231837
self.eni_set_admin_state(self.eni_id, "up")
18241838
self.vnet2VnetEniUpTrafficTest(tx_equal_to_rx=True)
18251839

1840+
@configureTrustedVni
18261841
def configureTest(self):
18271842
"""
18281843
Setup DUT in accordance with test purpose
@@ -1910,6 +1925,7 @@ def runTest(self):
19101925
self.outboundRouteDirectTest(tx_equal_to_rx=True)
19111926
self.outboundRouteDirectNegativeTest()
19121927

1928+
@configureTrustedVni
19131929
def configureTest(self):
19141930
"""
19151931
Setup DUT in accordance with test purpose
@@ -1978,6 +1994,7 @@ class Vnet2VnetOutboundRouteDirectSinglePortOverlayIpv6Test(Vnet2VnetOutboundRou
19781994
def setUp(self):
19791995
super(Vnet2VnetOutboundRouteDirectSinglePortOverlayIpv6Test, self).setUp(overlay_ipv6=True)
19801996

1997+
@configureTrustedVni
19811998
def configureTest(self):
19821999
"""
19832000
Setup DUT in accordance with test purpose
@@ -2076,6 +2093,7 @@ def runTest(self):
20762093
self.vnet2VnetOutboundRoutingTest(tx_equal_to_rx=True)
20772094
self.vnet2VnetOutboundNegativeTest()
20782095

2096+
@configureTrustedVni
20792097
def configureTest(self):
20802098
"""
20812099
Setup DUT in accordance with test purpose
@@ -2218,6 +2236,7 @@ class Vnet2VnetSingleOutboundRouteMultipleCa2PaSinglePortIpv6Test(Vnet2VnetSingl
22182236
def setUp(self):
22192237
super(Vnet2VnetSingleOutboundRouteMultipleCa2PaSinglePortIpv6Test, self).setUp(overlay_ipv6=True)
22202238

2239+
@configureTrustedVni
22212240
def configureTest(self):
22222241
"""
22232242
Setup DUT in accordance with test purpose
@@ -2372,6 +2391,7 @@ def runTest(self):
23722391
self.vnet2VnetOutboundDstVnetIdTrueTest(tx_equal_to_rx=True)
23732392
self.vnet2VnetOutboundDstVnetIdFalseTest(tx_equal_to_rx=True)
23742393

2394+
@configureTrustedVni
23752395
def configureTest(self):
23762396
"""
23772397
Setup DUT in accordance with test purpose
@@ -2459,6 +2479,7 @@ class Vnet2VnetOutboundDstVnetIdRouteVnetSinglePortOverlayIpv6Test(Vnet2VnetOutb
24592479
def setUp(self):
24602480
super(Vnet2VnetOutboundDstVnetIdRouteVnetSinglePortOverlayIpv6Test, self).setUp(overlay_ipv6=True)
24612481

2482+
@configureTrustedVni
24622483
def configureTest(self):
24632484
"""
24642485
Setup DUT in accordance with test purpose
@@ -2570,6 +2591,7 @@ def runTest(self):
25702591
self.vnet2VnetOutboundDstVnetIdTrueTest(tx_equal_to_rx=True)
25712592
self.vnet2VnetOutboundDstVnetIdFalseTest(tx_equal_to_rx=True)
25722593

2594+
@configureTrustedVni
25732595
def configureTest(self):
25742596
"""
25752597
Setup DUT in accordance with test purpose
@@ -2642,6 +2664,7 @@ class Vnet2VnetOutboundDstVnetIdRouteVnetDirectSinglePortOverlayIpv6Test(Vnet2Vn
26422664
def setUp(self):
26432665
super(Vnet2VnetOutboundDstVnetIdRouteVnetDirectSinglePortOverlayIpv6Test, self).setUp(overlay_ipv6=True)
26442666

2667+
@configureTrustedVni
26452668
def configureTest(self):
26462669
"""
26472670
Setup DUT in accordance with test purpose
@@ -2758,6 +2781,7 @@ def runTest(self):
27582781
self.outboundHost3toHost1Test(tx_equal_to_rx=True)
27592782
self.inboundHost1toHost3Test(tx_equal_to_rx=True)
27602783

2784+
@configureTrustedVni
27612785
def configureTest(self):
27622786
"""
27632787
Setup DUT in accordance with test purpose
@@ -2901,6 +2925,7 @@ class Vnet2VnetInboundOutboundMultipleConfigsSinglePortOverlayIpv6Test(Vnet2Vnet
29012925
with underlay config (neighbour + next hop) but without underlay routes
29022926
"""
29032927

2928+
@configureTrustedVni
29042929
def configureTest(self):
29052930
"""
29062931
Setup DUT in accordance with test purpose
@@ -3054,6 +3079,7 @@ def runTest(self):
30543079
self.outboundEni1Test(tx_equal_to_rx=True)
30553080
self.outboundEni2Test(tx_equal_to_rx=True)
30563081

3082+
@configureTrustedVni
30573083
def configureTest(self):
30583084
"""
30593085
Setup DUT in accordance with test purpose
@@ -3228,6 +3254,7 @@ class Vnet2VnetOutboundMultipleEniSameIpPrefixSinglePortOverlayIpv6Test(Vnet2Vne
32283254
def setUp(self):
32293255
super(Vnet2VnetOutboundMultipleEniSameIpPrefixSinglePortOverlayIpv6Test, self).setUp(overlay_ipv6=True)
32303256

3257+
@configureTrustedVni
32313258
def configureTest(self):
32323259
"""
32333260
Setup DUT in accordance with test purpose
@@ -3410,6 +3437,7 @@ def runTest(self):
34103437
self.singleEniToOutboundVm2Test(tx_equal_to_rx=True)
34113438
self.singleEniToOutboundVm3Test(tx_equal_to_rx=True)
34123439

3440+
@configureTrustedVni
34133441
def configureTest(self):
34143442
"""
34153443
Setup DUT in accordance with test purpose
@@ -3564,6 +3592,7 @@ class Vnet2VnetOutboundSingleEniMultipleIpPrefixSinglePortOverlayIpv6Test(Vnet2V
35643592
def setUp(self):
35653593
super(Vnet2VnetOutboundSingleEniMultipleIpPrefixSinglePortOverlayIpv6Test, self).setUp(overlay_ipv6=True)
35663594

3595+
@configureTrustedVni
35673596
def configureTest(self):
35683597
"""
35693598
Setup DUT in accordance with test purpose
@@ -3708,6 +3737,7 @@ def runTest(self):
37083737

37093738
self.vnet2VnetOutboundRouteVnetTest(tx_equal_to_rx=True)
37103739

3740+
@configureTrustedVni
37113741
def configureTest(self):
37123742
"""
37133743
Setup DUT in accordance with test purpose

test/test-cases/functional/ptf/saidashvnet_sanity.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ def configureVnet(self):
5454
action=SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION)
5555
assert(status == SAI_STATUS_SUCCESS)
5656

57+
self.gtve = sai_thrift_global_trusted_vni_entry_t(switch_id=self.switch_id,
58+
vni_range=sai_thrift_u32_range_t(min=self.outbound_vni, max=self.outbound_vni))
59+
status = sai_thrift_create_global_trusted_vni_entry(self.client, self.gtve)
60+
assert(status == SAI_STATUS_SUCCESS)
61+
5762
self.in_acl_group_id = sai_thrift_create_dash_acl_group(self.client,
5863
ip_addr_family=self.sai_ip_addr_family)
5964
assert (self.in_acl_group_id != SAI_NULL_OBJECT_ID)
@@ -278,6 +283,7 @@ def tearDown(self):
278283
status &= sai_thrift_remove_vnet(self.client, self.vnet)
279284
status &= sai_thrift_remove_dash_acl_group(self.client, self.out_acl_group_id)
280285
status &= sai_thrift_remove_dash_acl_group(self.client, self.in_acl_group_id)
286+
status &= sai_thrift_remove_global_trusted_vni_entry(self.client, self.gtve)
281287
status &= sai_thrift_remove_direction_lookup_entry(self.client, self.dle)
282288
status &= sai_thrift_remove_vip_entry(self.client, self.vpe)
283289
if self.configured:

0 commit comments

Comments
 (0)