Skip to content

Cisco conversion testing#21386

Closed
augusdn wants to merge 2 commits intosonic-net:masterfrom
augusdn:cisco_conversion
Closed

Cisco conversion testing#21386
augusdn wants to merge 2 commits intosonic-net:masterfrom
augusdn:cisco_conversion

Conversation

@augusdn
Copy link
Copy Markdown
Contributor

@augusdn augusdn commented Nov 21, 2025

Description of PR

Summary:
This pull request introduces comprehensive support for Cisco device conversion testing, focusing on enabling robust test infrastructure for devices transitioning from vendor OS (such as Cisco IOS XR) to SONiC OS. The main changes include the addition of conversion-specific pytest configuration and fixtures, enhancements to the CiscoHost class for file transfer and interactive command execution, and the introduction of shared assets and documentation files.

Cisco conversion test infrastructure:

  • Added a new tests/cisco/conftest.py with custom pytest fixtures and configuration for conversion tests, including mock SONiC fixtures, Cisco device access (ciscohost), and proxy environment variable handling. This supports testing devices before and during migration to SONiC.
  • Introduced minimal __init__.py files in tests/cisco/, tests/cisco/files/, and tests/cisco/files/common/ to document and initialize the new test directories. [1] [2] [3]

Enhancements to Cisco device abstraction:

  • Improved the CiscoHost class in tests/common/devices/cisco.py to support:
    • SFTP file transfer via a new copy method using Paramiko, addressing Ansible module limitations on Cisco XR.
    • Interactive SSH command execution with a new exec_interactive method, enabling automation of commands requiring user prompts.
    • File deletion with confirmation handling via a new delete_file method.
    • More flexible Ansible module dispatching, supporting both standard and network modules with appropriate connection settings. [1] [2]
    • Use of WarningPolicy for SSH host key handling, improving test safety.

Supporting changes:

  • Updated imports in tests/common/devices/sonic.py and tests/common/devices/cisco.py to provide access to the new interactive SSH helper. [1] [2]

These changes collectively provide a robust foundation for conversion testing, allowing for seamless operation on Cisco devices regardless of their current OS state.

What's included:

  • tests/cisco/test_xr2sonic.py — Main test with a 6-stage migration flow:
    - Stage 0: Download & transfer artifacts (SONiC image, firmware, migration scripts, minigraphs, vouchers)
    - Stage 1: Intermediate XR upgrade
    - Stage 2: Ownership Voucher (OV) installation
    - Stage 3: Authenticated Variable (AV) install + RP SONiC migration
    - Stage 4: Line Card (LC) migration
    - Stage 5: Post-migration validation
    - By default stops after Stage 0 for safety; use --full-migration to run all stages
  • tests/cisco/conftest.py — Fixtures for Cisco device access (ciscohost, duthost), mock duthosts, and proxy configuration
  • tests/common/devices/cisco.py — Extended CiscoHost with SFTP file transfer (copy()), interactive SSH command execution, and XR-specific helpers
  • tests/common/devices/sonic.py — Added exec_interactive() to SonicHost for interactive command execution (used post-RP-migration)
  • tests/common/helpers/interactive_ssh.py — Paramiko-based interactive SSH utility for pattern-matching command flows

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505

Approach

What is the motivation for this PR?

How did you do it?

How did you verify/test it?

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@augusdn augusdn force-pushed the cisco_conversion branch from 7361867 to afc8b18 Compare March 5, 2026 07:54
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@augusdn augusdn force-pushed the cisco_conversion branch from afc8b18 to 9de5460 Compare March 5, 2026 08:18
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@augusdn augusdn force-pushed the cisco_conversion branch from 9de5460 to 0542ec4 Compare March 5, 2026 08:19
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@augusdn augusdn marked this pull request as ready for review April 9, 2026 05:06
@augusdn augusdn changed the title [DRAFT] conversion testing Cisco conversion testing Apr 9, 2026
Comment thread tests/common/devices/cisco.py Outdated
try:
# Use Paramiko SFTP to transfer the file
ssh_client = SSHClient()
ssh_client.set_missing_host_key_policy(AutoAddPolicy())
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.

fixed

Comment thread tests/common/helpers/interactive_ssh.py Outdated

try:
ssh_client = SSHClient()
ssh_client.set_missing_host_key_policy(AutoAddPolicy())
if ssh_client:
try:
ssh_client.close()
except Exception:
Comment thread tests/common/devices/sonic.py Dismissed
output += chunk.decode('utf-8', errors='ignore')
if debug:
log.debug(f"Final read: received {len(chunk)} bytes")
except (socket.timeout, Exception):
Comment thread tests/common/devices/sonic.py
Comment thread tests/cisco/conftest.py Outdated
Comment thread tests/common/devices/cisco.py
@cyw233
Copy link
Copy Markdown
Contributor

cyw233 commented Apr 9, 2026

Please also fill in the PR description to include more details

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

augusdn added 2 commits April 30, 2026 20:58
conversion testing

Signed-off-by: Augustine Lee <augustinelee@microsoft.com>
@augusdn augusdn force-pushed the cisco_conversion branch from 06903b1 to ccb1bd7 Compare May 1, 2026 03:59
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@augusdn augusdn closed this May 1, 2026
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.

4 participants