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
12 changes: 11 additions & 1 deletion tests/vxlan/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
NUM_INTF_PER_VNET_KEY,
TEMPLATE_DIR
)
from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_on_duts # noqa F401
from tests.common.config_reload import config_reload

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -307,7 +309,7 @@ def vnet_test_params(duthost, request):


@pytest.fixture(scope="module")
def minigraph_facts(duthosts, rand_one_dut_hostname, tbinfo):
def minigraph_facts(duthosts, rand_one_dut_hostname, tbinfo, backup_and_restore_config_db_on_duts): # noqa F811
"""
Fixture to get minigraph facts
Args:
Expand Down Expand Up @@ -347,3 +349,11 @@ def vnet_config(minigraph_facts, vnet_test_params, scaled_vnet_params):
return yaml.safe_load(
safe_open_template(
join(TEMPLATE_DIR, "vnet_config.j2")).render(combined_args))


@pytest.fixture(scope="module", autouse=True)
def restore_config_by_config_reload(duthosts, rand_one_dut_hostname):
yield
duthost = duthosts[rand_one_dut_hostname]
logger.info("Restore config after running tests")
config_reload(duthost, safe_reload=True)
14 changes: 2 additions & 12 deletions tests/vxlan/test_vxlan_bfd_tsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa F401
from tests.ptf_runner import ptf_runner
from tests.common.vxlan_ecmp_utils import Ecmp_Utils
from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_on_duts # noqa F401
from tests.common.config_reload import config_reload
Logger = logging.getLogger(__name__)
ecmp_utils = Ecmp_Utils()
Expand Down Expand Up @@ -70,8 +69,7 @@ def fixture_setUp(duthosts,
rand_one_dut_hostname,
minigraph_facts,
tbinfo,
encap_type,
backup_and_restore_config_db_on_duts): # noqa F811
encap_type):
'''
Setup for the entire script.
The basic steps in VxLAN configs are:
Expand Down Expand Up @@ -233,22 +231,14 @@ def fixture_setUp(duthosts,
ecmp_utils.stop_bfd_responder(data['ptfhost'])


@pytest.fixture(scope="module", autouse=True)
def restore_config_by_config_reload(duthosts, rand_one_dut_hostname, localhost):
yield
duthost = duthosts[rand_one_dut_hostname]

config_reload(duthost, safe_reload=True)


def is_vnet_route_configured_on_asic(duthost, dest):
'''
Function to check if a VNET route to dest is configured on ASIC DB.
A VNET route to dest must be configured on ASIC DB before running
PTF tests.
'''
result = duthost.shell(f"sonic-db-cli ASIC_DB KEYS \
'ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY*{dest}*'")["stdout_lines"]
'ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY*{dest}*'")["stdout_lines"] # noqa: E231
return bool(result)


Expand Down
1 change: 0 additions & 1 deletion tests/vxlan/test_vxlan_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from functools import reduce

from tests.common.helpers.assertions import pytest_assert
from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_on_duts # noqa F401
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa: F401
from tests.common.vxlan_ecmp_utils import Ecmp_Utils
from tests.vxlan.test_vxlan_ecmp import ( # noqa: F401
Expand Down
13 changes: 1 addition & 12 deletions tests/vxlan/test_vxlan_ecmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@

from tests.common.helpers.assertions import pytest_assert
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa F401
from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_on_duts # noqa F401
from tests.common.config_reload import config_reload
from tests.common.utilities import wait_until
from tests.ptf_runner import ptf_runner
from tests.common.vxlan_ecmp_utils import Ecmp_Utils
Expand Down Expand Up @@ -142,8 +140,7 @@ def fixture_setUp(duthosts,
rand_one_dut_hostname,
minigraph_facts,
tbinfo,
encap_type,
backup_and_restore_config_db_on_duts): # noqa F811
encap_type): # noqa F811
'''
Setup for the entire script.
The basic steps in VxLAN configs are:
Expand Down Expand Up @@ -342,14 +339,6 @@ def fixture_setUp(duthosts,
setup_crm_interval(data['duthost'], int(data['original_crm_interval']))


@pytest.fixture(scope="module", autouse=True)
def restore_config_by_config_reload(duthosts, rand_one_dut_hostname, localhost):
yield
duthost = duthosts[rand_one_dut_hostname]

config_reload(duthost, safe_reload=True)


@pytest.fixture(scope="module")
def default_routes(setUp, encap_type):
vnet = list(setUp[encap_type]['vnet_vni_map'].keys())[0]
Expand Down
Loading