Skip to content
Closed
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
34 changes: 34 additions & 0 deletions tests/everflow/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pytest
import logging


@pytest.fixture(autouse=True, scope="module")
def setup_recycle_port(duthosts, tbinfo):
"""Setup recycle port ip address on t2 topo"""
rec_intf = {}
if "t2" in tbinfo['topo']['name']:
for duthost in duthosts.frontend_nodes:
rec_intf[duthost.hostname] = {}
for asic in duthost.asics:
output = duthost.command("show ip interfaces -n {} -d all".format(asic.namespace))['stdout_lines']
if 'Ethernet-Rec' not in output:
rec_intf[duthost.hostname][asic.namespace] = 1
cmd = "sudo config interface -n {ns} ip add Ethernet-Rec{rec} 1.1.1.{an}/32".format(
ns=asic.namespace,
rec=asic.asic_index,
an=asic.asic_index + 1)
logging.info(cmd)
duthost.command(cmd)
duthost.command("sudo config save -y")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to do config save?

Copy link
Contributor

@tcusto tcusto Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that fixture is module scope it should be safe to remove.

yield
if "t2" in tbinfo['topo']['name']:
for duthost in duthosts.frontend_nodes:
for asic in duthost.asics:
if rec_intf[duthost.hostname][asic.namespace]:
cmd = "sudo config interface -n {ns} ip remove Ethernet-Rec{rec} 1.1.1.{an}/32".format(
ns=asic.namespace,
rec=asic.asic_index,
an=asic.asic_index + 1)
logging.info(cmd)
duthost.command(cmd)
duthost.command("sudo config save -y")
Loading