Skip to content

Commit

Permalink
[DASH] New test cases for dash acl tag (sonic-net#11559)
Browse files Browse the repository at this point in the history
- What is the motivation for this PR?
Add new test cases for dash acl tag feature

- How did you do it?
All new test cases are added to the test_dash_acl.py and dash_acl.py.
For the scale test case, need to do some improvement in the dash acl test infra and dash gnmi utils to allow applying massive configurations through gnmi and shorten the config time.

The improvements are:
1. Separate the gnmi command into multiple commands if it is too long, for there is a limitation in the length of command.
2. Directly copy the updates to ptf instead of to dut. Since we are now using gnmi, no need to copy the config to dut, this will greatly reduce the config time.
3. Tar the update files before copying them to save great time.

Note:
For the scale test case, only test 4096 tags with 1 IP address in each, due to issue [DPU][ACL][scale] The DPU doesn't support the scale of 4k tags with 24k IPs in each sonic-buildimage#17714.

- How did you verify/test it?
Run the test cases on DPU testbed, all passed.

- Any platform specific information?
Only for dpu.

- Supported testbed topology if it's a new test case?
Only for dpu topology.
  • Loading branch information
congh-nvidia authored Feb 25, 2024
1 parent eb02252 commit d6bf2ae
Show file tree
Hide file tree
Showing 10 changed files with 695 additions and 61 deletions.
4 changes: 2 additions & 2 deletions tests/dash/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def dash_config_info(duthost, config_facts, minigraph_facts):


@pytest.fixture(scope="function")
def apply_config(duthost, ptfhost, skip_config, skip_cleanup):
def apply_config(localhost, duthost, ptfhost, skip_config, skip_cleanup):
configs = []
op = "SET"

Expand All @@ -155,7 +155,7 @@ def _apply_config(config_info):
dest_path = "/tmp/{}.json".format(config)
render_template_to_host(template_name, duthost, dest_path, config_info, op=op)
if ENABLE_GNMI_API:
apply_gnmi_file(duthost, ptfhost, dest_path)
apply_gnmi_file(localhost, duthost, ptfhost, dest_path)
else:
apply_swssconfig_file(duthost, dest_path)

Expand Down
4 changes: 4 additions & 0 deletions tests/dash/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@
ACL_DST_ADDR = "dst_addr"
ACL_SRC_PORT = "src_port"
ACL_DST_PORT = "dst_port"
ACL_SRC_TAG = "src_tag"
ACL_DST_TAG = "dst_tag"
ACL_PROTOCOL = "protocol"
ACL_TAG = "acl_tag"
ACL_PREFIX_LIST = "prefix_list"
11 changes: 6 additions & 5 deletions tests/dash/crm/test_dash_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def default_crm_facts(duthost, set_polling_interval):


@pytest.fixture(scope="class")
def apply_resources_configs(default_crm_facts, duthost, ptfhost):
def apply_resources_configs(default_crm_facts, localhost, duthost, ptfhost):
"""
Apply CRM configuration before run test
:param default_crm_facts: CRM resources data collected before apply config
Expand All @@ -74,12 +74,12 @@ def apply_resources_configs(default_crm_facts, duthost, ptfhost):
src_path = os.path.join(os.path.abspath(""), "dash/crm/files/{}".format(config))
duthost.copy(src=src_path, dest=config)
pytest.crm_res_cleanup_required = True
apply_gnmi_file(duthost, ptfhost, set_config)
apply_gnmi_file(localhost, duthost, ptfhost, set_config)

yield set_config, del_config

if pytest.crm_res_cleanup_required:
apply_gnmi_file(duthost, ptfhost, del_config)
apply_gnmi_file(localhost, duthost, ptfhost, del_config)

duthost.shell("rm -f {}".format(set_config))
duthost.shell("rm -f {}".format(del_config))
Expand Down Expand Up @@ -108,9 +108,10 @@ def cleanup(duthost):
class TestDashCRM:

@pytest.fixture(autouse=True)
def setup(self, duthost, ptfhost, default_crm_facts, apply_resources_configs):
def setup(self, localhost, duthost, ptfhost, default_crm_facts, apply_resources_configs):
self.duthost = duthost
self.ptfhost = ptfhost
self.localhost = localhost
self.default_crm_facts = default_crm_facts
self.crm_facts = self.duthost.get_crm_facts()
self.set_config, self.del_config = apply_resources_configs
Expand Down Expand Up @@ -302,7 +303,7 @@ def test_dash_crm_cleanup(self):
"""
Validate that after cleanup CRM resources - CRM output the same as it was before test case(without config)
"""
apply_gnmi_file(self.duthost, self.ptfhost, self.del_config)
apply_gnmi_file(self.localhost, self.duthost, self.ptfhost, self.del_config)
pytest.crm_res_cleanup_required = False

time.sleep(CRM_UPDATE_TIME)
Expand Down
Loading

0 comments on commit d6bf2ae

Please sign in to comment.