Skip to content

Make test vendor-agnostic with YAML profiles#3147

Open
vaishnavibhat wants to merge 1 commit intoavocado-framework-tests:masterfrom
vaishnavibhat:switch
Open

Make test vendor-agnostic with YAML profiles#3147
vaishnavibhat wants to merge 1 commit intoavocado-framework-tests:masterfrom
vaishnavibhat:switch

Conversation

@vaishnavibhat
Copy link
Copy Markdown
Contributor

Refactored switch_test.py to support multiple switch vendors through YAML-based configuration profiles instead of hardcoded commands.

Changes:

  • switch_test.py: Generic command execution via profiles
  • switch_test.yaml: Added switch_profile parameter
  • Load switch commands from vendor-specific YAML profiles
  • Support dynamic command templates with {port_id} placeholder
  • Add profiles for Cisco, Juniper switches

@vaishnavibhat vaishnavibhat force-pushed the switch branch 6 times, most recently from 6ca4378 to 0c662d1 Compare April 28, 2026 12:08
@vaishnavibhat
Copy link
Copy Markdown
Contributor Author

Tested with Juniper switch :

avocado run switch_test.py -m switch_test.py.data/switch_test.yaml
JOB ID : b4a7eb61d703e4fbf181b923e98f40e8056e5df1
JOB LOG : /root/avocado-fvt-wrapper/results/job-2026-04-28T14.09-b4a7eb6/job.log
(1/1) switch_test.py:SwitchTest.test;run-360b: STARTED
(1/1) switch_test.py:SwitchTest.test;run-360b: PASS (39.71 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML : /root/avocado-fvt-wrapper/results/job-2026-04-28T14.09-b4a7eb6/results.html
JOB TIME : 51.02 s

switch.log

Comment thread io/net/switch_test.py
Login method for remote fc switch
Login method for remote switch
'''
self.tnc = paramiko.SSHClient()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not a problem added by this patch, but can you also add code in cleanup() to close the ssh connection. This will avoid any stale connections once the test exists

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not a problem added by this patch, but can you also add code in cleanup() to close the ssh connection. This will avoid any stale connections once the test exists

Add code to "Close SSH connection to switch" in the teardown()

Comment thread io/net/switch_test.py
self.cancel("user should specify port id")

# Load switch profile configuration
profile_name = self.params.get("switch_profile",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is brocade_switch option valid? should it be cisco_switch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is brocade_switch option valid? should it be cisco_switch?

Changed this to juniper_switch to match the switch.yaml

Refactored switch_test.py to support multiple switch vendors through
YAML-based configuration profiles instead of hardcoded commands.

Changes:
- switch_test.py: Generic command execution via profiles
- switch_test.yaml: Added switch_profile parameter
- Load switch commands from vendor-specific YAML profiles
- Support dynamic command templates with {port_id} placeholder
- Add profiles for Cisco, Juniper switches

Signed-off-by: Vaishnavi Bhat <vaishnavi@linux.vnet.ibm.com>
Copy link
Copy Markdown
Contributor

@sacsant sacsant left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants