Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/everflow/templates/acl_rule_persistent-del.json
1 change: 1 addition & 0 deletions tests/everflow/templates/acl_rule_persistent.json.j2
47 changes: 29 additions & 18 deletions tests/everflow/test_everflow_testbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def copy_acstests_directory(ptfhost):
there is no return value, there is no point in passing it into the functions.
"""
ptfhost.copy(src="acstests", dest="/root")
ptfhost.copy(src="ptftests", dest="/root")

@pytest.fixture(scope='module')
def setup_info(duthost, testbed):
Expand Down Expand Up @@ -214,22 +215,26 @@ def setup_mirror_session(self, duthost):
session_dst_ip = "2.2.2.2"
session_ttl = "1"
session_dscp = "8"
session_gre = 0x6558

session_prefixlens = ["24", "32"]
session_prefixes = []
for prefixlen in session_prefixlens:
session_prefixes.append(str(ipaddress.IPNetwork(session_dst_ip + "/" + prefixlen).network) + "/" + prefixlen)

if "mellanox" == duthost.facts["asic_type"]:
duthost.command('config mirror_session add {} {} {} {} {} 0x8949'.format(session_name, session_src_ip, session_dst_ip, session_dscp, session_ttl))
else:
duthost.command('config mirror_session add {} {} {} {} {}'.format(session_name, session_src_ip, session_dst_ip, session_dscp, session_ttl))
session_gre = 0x8949
elif "barefoot" == duthost.facts["asic_type"]:
session_gre = 0x22EB

duthost.command('config mirror_session add {} {} {} {} {} {}'.format(session_name, session_src_ip, session_dst_ip, session_dscp, session_ttl, session_gre))

yield {'session_name' : session_name,
'session_src_ip' : session_src_ip,
'session_dst_ip' : session_dst_ip,
'session_ttl' : session_ttl,
'session_dscp' : session_dscp,
'session_gre' : session_gre,
'session_prefixes': session_prefixes
}

Expand Down Expand Up @@ -477,14 +482,10 @@ def test_everflow_case5(self, duthost, setup_info, setup_mirror_session, dest_po
cir 100 cbs 100 red_packet_action drop")

# Add Mirror Session with Policer aqttached to it.
if "mellanox" == duthost.facts["asic_type"]:
duthost.command('config mirror_session add TEST_POLICER_SESSION {} {} {} {} 0x8949 --policer TEST_POLICER'.format(
setup_mirror_session['session_src_ip'], setup_mirror_session['session_dst_ip'],
setup_mirror_session['session_dscp'], setup_mirror_session['session_ttl']))
else:
duthost.command('config mirror_session add TEST_POLICER_SESSION {} {} {} {} --policer TEST_POLICER'.format(
setup_mirror_session['session_src_ip'], setup_mirror_session['session_dst_ip'],
setup_mirror_session['session_dscp'], setup_mirror_session['session_ttl']))
duthost.command('config mirror_session add TEST_POLICER_SESSION {} {} {} {} {} --policer TEST_POLICER'.format(
setup_mirror_session['session_src_ip'], setup_mirror_session['session_dst_ip'],
setup_mirror_session['session_dscp'], setup_mirror_session['session_ttl'],
setup_mirror_session['session_gre']))

# Add ACL rule to match on DSCP and action as mirror
mirror_action = "MIRROR_INGRESS_ACTION" if self.mirror_type() == 'ingress' else "MIRROR_EGRESS_ACTION"
Expand Down Expand Up @@ -559,7 +560,7 @@ def setup_acl_table(self, duthost, setup_info, setup_mirror_session):
def acl_stage(self):
return 'ingress'

def mirror_type(self):
def mirror_type(self):
return 'ingress'

class TestEverflowIngressAclEgressMirror(BaseEverflowTest):
Expand All @@ -586,7 +587,7 @@ def setup_acl_table(self, duthost, setup_info, setup_mirror_session):
def acl_stage(self):
return 'ingress'

def mirror_type(self):
def mirror_type(self):
return 'egress'

class TestEverflowEgressAclIngressMirror(BaseEverflowTest):
Expand All @@ -601,8 +602,10 @@ def setup_acl_table(self, duthost, setup_info, setup_mirror_session):
duthost.host.options['variable_manager'].extra_vars.update({'acl_table_name' : "EVERFLOW_EGRESS"})

duthost.template(src=os.path.join(TEMPLATE_DIR, EVERFLOW_TABLE_RULE_CREATE_TEMPLATE), dest=os.path.join(DUT_RUN_DIR, EVERFLOW_TABLE_RULE_CREATE_FILE))



# Remove default SONiC Everflow table (since SONiC allows only one mirror table)
duthost.command("config acl remove table EVERFLOW")

duthost.command("config acl add table EVERFLOW_EGRESS MIRROR --description EVERFLOW_EGRESS --stage=egress")
duthost.command("config acl add table EVERFLOW_DSCP MIRROR_DSCP --description EVERFLOW_EGRESS_TEST --stage=egress")
duthost.command('acl-loader update full {} --session_name={} --mirror_stage=egress'.format((os.path.join(DUT_RUN_DIR, EVERFLOW_TABLE_RULE_CREATE_FILE)),setup_mirror_session['session_name']))
Expand All @@ -615,10 +618,13 @@ def setup_acl_table(self, duthost, setup_info, setup_mirror_session):
duthost.command("config acl remove table EVERFLOW_DSCP")
duthost.shell("rm -rf {}".format(DUT_RUN_DIR))

# Add default SONiC Everflow table back
duthost.command("config acl add table EVERFLOW MIRROR --description EVERFLOW --stage=ingress")

def acl_stage(self):
return 'egress'

def mirror_type(self):
def mirror_type(self):
return 'ingress'

class TestEverflowEgressAclEgressMirror(BaseEverflowTest):
Expand All @@ -633,8 +639,10 @@ def setup_acl_table(self, duthost, setup_info, setup_mirror_session):


duthost.template(src=os.path.join(TEMPLATE_DIR, EVERFLOW_TABLE_RULE_CREATE_TEMPLATE), dest=os.path.join(DUT_RUN_DIR, EVERFLOW_TABLE_RULE_CREATE_FILE))



# Remove default SONiC Everflow table (since SONiC allows only one mirror table)
duthost.command("config acl remove table EVERFLOW")

duthost.command("config acl add table EVERFLOW_EGRESS MIRROR --description EVERFLOW_EGRESS --stage=egress")
duthost.command("config acl add table EVERFLOW_DSCP MIRROR_DSCP --description EVERFLOW_EGRESS_TEST --stage=egress")
duthost.command('acl-loader update full {} --session_name={} --mirror_stage=egress'.format((os.path.join(DUT_RUN_DIR, EVERFLOW_TABLE_RULE_CREATE_FILE)),setup_mirror_session['session_name']))
Expand All @@ -647,6 +655,9 @@ def setup_acl_table(self, duthost, setup_info, setup_mirror_session):
duthost.command("config acl remove table EVERFLOW_DSCP")
duthost.shell("rm -rf {}".format(DUT_RUN_DIR))

# Add default SONiC Everflow table back
duthost.command("config acl add table EVERFLOW MIRROR --description EVERFLOW --stage=ingress")

def acl_stage(self):
return 'egress'

Expand Down