Skip to content
Merged
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
24 changes: 21 additions & 3 deletions tests/route/test_route_perf.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import pytest
import json
import logging
import time
from datetime import datetime
from tests.common.utilities import wait_until
from tests.common import config_reload
from tests.common.helpers.assertions import pytest_assert

CRM_POLL_INTERVAL = 1
CRM_DEFAULT_POLL_INTERVAL = 300

pytestmark = [
pytest.mark.topology('any'),
Expand Down Expand Up @@ -50,6 +55,18 @@ def reload_dut(duthost, request):
logging.info("Reloading config..")
config_reload(duthost)

@pytest.fixture(scope="module", autouse=True)
def set_polling_interval(duthost):
""" Set CRM polling interval to 1 second """
wait_time = 2
duthost.command("crm config polling interval {}".format(CRM_POLL_INTERVAL))
logger.info("Waiting {} sec for CRM counters to become updated".format(wait_time))
time.sleep(wait_time)
yield
duthost.command("crm config polling interval {}".format(CRM_DEFAULT_POLL_INTERVAL))
logger.info("Waiting {} sec for CRM counters to become updated".format(wait_time))
time.sleep(wait_time)

def prepare_dut(duthost, intf_neighs):
for intf_neigh in intf_neighs:
# Set up interface
Expand Down Expand Up @@ -179,8 +196,10 @@ def test_perf_add_remove_routes(duthost, request, ip_versions):
intf_neighs, str_intf_nexthop = generate_intf_neigh(NUM_NEIGHS, ip_versions)

route_tag = "ipv{}_route".format(ip_versions)
used_routes_count = duthost.get_crm_resources().get("main_resources").get(route_tag).get("used")
avail_routes_count = duthost.get_crm_resources().get("main_resources").get(route_tag).get("available")
used_routes_count = duthost.get_crm_resources().get("main_resources").get(route_tag, {}).get("used")
avail_routes_count = duthost.get_crm_resources().get("main_resources").get(route_tag, {}).get("available")
pytest_assert(avail_routes_count, "CRM main_resources data is not ready within adjusted CRM polling time {}s".\
format(CRM_POLL_INTERVAL))
num_routes = min(avail_routes_count, set_num_routes)
logger.info("IP route utilization before test start: Used: {}, Available: {}, Test count: {}"\
.format(used_routes_count, avail_routes_count, num_routes))
Expand All @@ -205,4 +224,3 @@ def test_perf_add_remove_routes(duthost, request, ip_versions):
logger.info('Time to del %d ipv%d routes is %.2f seconds.' % (num_routes, ip_versions, time_del))
finally:
cleanup_dut(duthost, intf_neighs)