Skip to content

Commit

Permalink
feature: add functionality to retrieve console information (#16249)
Browse files Browse the repository at this point in the history
Summary:
Added functionality to retrieve console information from testbed devices in spytest framework. This enables access to console details (IP, port, protocol) for test cases and debugging purposes.

Approach
What is the motivation for this PR?
To provide easy access to device console information within spytest framework, which helps in debugging and monitoring test cases that require console access.

How did you do it?
Added new method get_console() in framework.py to access testbed console info
Implemented get_console_info() in infra.py as a utility function
Added get_console() in testbed.py to retrieve console IP, port, and protocol from device info

How did you verify/test it?
By running spytest with a testbed configuration that includes console information and verifying the returned console details match the configuration.
  • Loading branch information
gupurush authored Jan 2, 2025
1 parent 1d153c8 commit dc05ac2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions spytest/spytest/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -3932,6 +3932,9 @@ def get_config_profile(self):
profile = profile or self.cfg.config_profile
profile = profile or "na"
return profile.lower()

def get_console(self, dut):
return self._context._tb.get_console(dut)

def get_device_type(self, dut):
return self._context._tb.get_device_type(dut)
Expand Down
4 changes: 4 additions & 0 deletions spytest/spytest/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ def get_mgmt_ip(dut):
return getwa().get_mgmt_ip(dut)


def get_console_info(dut):
return getwa().get_console(dut)


def get_datastore(dut, name, scope="default"):
return getwa().get_datastore(dut, name, scope)

Expand Down
11 changes: 11 additions & 0 deletions spytest/spytest/testbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,17 @@ def get_ts(self, dut):
return rv["ts"]
return None

def get_console(self, dut, default=""):
dinfo = self.get_device_info(dut)
rv = SpyTestDict()
if not dinfo:
return default
if dinfo["console"]:
rv.ip = dinfo["console"].ip
rv.port = dinfo["console"].port
rv.protocol = dinfo["console"].protocol
return rv

def get_rps(self, dut):
"""
Returns RPS details read from testbed file for given DUT
Expand Down

0 comments on commit dc05ac2

Please sign in to comment.