Skip to content

Apply GCU changes to the appropriate namespace scope for each suite#16065

Merged
qiluo-msft merged 6 commits intosonic-net:masterfrom
okaravasi:master-gcu_patch_namespace_scope
Jan 27, 2025
Merged

Apply GCU changes to the appropriate namespace scope for each suite#16065
qiluo-msft merged 6 commits intosonic-net:masterfrom
okaravasi:master-gcu_patch_namespace_scope

Conversation

@okaravasi
Copy link
Copy Markdown
Contributor

@okaravasi okaravasi commented Dec 13, 2024

Description of PR

For GCU test suites, configuration changes applied via patches sometimes target a specific ASIC namespace or apply globally to the card (localhost), depending on the feature functionality.

With the recent merged PR #14098, configuration changes are now applied to both localhost and all ASIC namespaces for all multi-ASIC platforms by default, which is incorrect.

Examples:

Configuration paths like /BGP_NEIGHBOR/ should apply only to the ASIC namespace.
Paths like /SYSLOG_SERVER/ should apply only to the localhost namespace.
This PR addresses the issue by introducing a missing flag for "asic_specific" configurations. It adapts the calls appropriately in each test suite based on the targeted configuration scope (ASIC namespace or localhost).

Summary:
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405

Approach

What is the motivation for this PR?

How did you do it?

How did you verify/test it?

Ran vs-kvm tests.

Attaching sample results for test_portchannel.py and test_eth_interface.py:

image
image

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).

@okaravasi okaravasi marked this pull request as ready for review December 13, 2024 17:06
@okaravasi
Copy link
Copy Markdown
Contributor Author

Hello @judyjoseph @xincunli-sonic Could you please also review the changes?

I have updated the suite calls to use the function format_json_patch_for_multiasic with the appropriate flags to ensure the behavior aligns with the feature functionality.

However, upon reviewing the overall usage of the function from the test suits, it always ends up returning without applying any changes. My question is:
Do we still want to call this function, or would it be better to remove it entirely?

It appears that no test suite is currently capable of applying patch changes to both localhost and all ASIC namespaces based on the function's format.

Comment thread tests/common/gu_utils.py Outdated
- For changes that are host-specific (applied only to the localhost namespace and not
to ASIC namespaces), the function returns without any formatting.
"""
if is_asic_specific or is_host_specific:
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.

if is_asic_specific or is_host_specific:

From code, these two variables should be no difference between asic and host, per discussed offline, we could add an variable that indicates the patch contains namespace already.

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.

Based on similar logic as the flag is_host_specific, which makes zero changes to the patch, I have added a new flag is_asic_specific to again ensure zero changes to the patch.

In such cases, there is an assumption that the function format_json_patch_for_multiasic has already been called with the namespace included in the patch path. This must be ensured by each test suite file that invokes this function.

Comment thread tests/bgp/test_bgp_bbr.py
…count all differnet use cases based on where the chaneg is applied. Adapted the calls of this function to test suites files. Handled the localhost only and all asic namespaces only. Next commit to handle specific asic namespaces changes that require more changes
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

…h_interface.py, test_ip_bgp.py, test_pfcwd_status.py) where changes apply only to a specific ASIC namespace. In these cases, the function 'format_json_patch_for_multiasic' is not called, and the JSON formatting is handled within the respective test suite files. Helper functions were also updated, where necessary, to include the namespace prefix when issuing CLI commands or making database calls.
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@okaravasi
Copy link
Copy Markdown
Contributor Author

Hello @xincunli-sonic @judyjoseph Could you please re-review the changes?

What I have done:

  1. Refactored function format_json_patch_for_multiasic to format the json patch based on below use cases.

    • Case 1: Apply changes only to /localhost namespace.
      format_json_patch_for_multiasic(duthost, json_data, is_host_specific=True)
    • Case 2: Apply changes only to all available ASIC namespaces (e.g., /asic0, /asic1).
      format_json_patch_for_multiasic(duthost, json_data, is_asic_specific=True)
    • Case 3: Apply changes to one specific ASIC namespace (e.g., /asic0).
      format_json_patch_for_multiasic(duthost, json_data, is_asic_specific=True, asic_namespaces='asic0')
    • Case 4: Apply changes to both /localhost and all ASIC namespaces.
      format_json_patch_for_multiasic(duthost, json_data)
  2. Adapted the call of above function in all test suite files so that it is called with proper flags based on which namespace the patch change should be applied.

  3. Especially for suites

    • test_eth_interface.py
    • test_ip_bgp.py
    • test_pfcwd_status.py

    where changes apply only to a specific ASIC namespace (e.g. Case 3 from above) I made changes to the test suites so that JSON formatting is handled within the respective test suite files.
    Helper functions were also updated, where necessary, to include the namespace prefix when issuing CLI commands or making database calls.

Copy link
Copy Markdown
Contributor

@xincunli-sonic xincunli-sonic left a comment

Choose a reason for hiding this comment

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

LGTM

@okaravasi
Copy link
Copy Markdown
Contributor Author

Hi @xincunli-sonic @judyjoseph

Some suites require additional changes as they perform database calls to fetch values used in validation to confirm that the applied patch succeeded. These changes were not considered in the initial PR that got merged.

However, I did not include these changes neither in this PR because the current focus is on fixing the JSON patch scope application. Adding them here would make the PR much larger and harder to manage.

These changes are included in the separate Test PRs I have created per GCU suite.

  • Shall I integrate the validation-related changes into this PR,
  • Shall I update the separate test PRs per GCU suite to include the extra changes there
  • or would it be better to create one single new PR that gathers these same-logic changes all together for all the gcu suites?

The required changes are as follows:
For any database calls like the example below, we need to loop through each ASIC namespace if the platform is multi-ASIC. This is because the current JSON patch formatting applies changes to all ASIC namespaces wherever supported:

cmds = 'sonic-db-cli CONFIG_DB keys "BGP_MONITORS|*" | xargs -r sonic-db-cli CONFIG_DB del'

Please advise on the preferred approach

Thanks,
Olympia

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@okaravasi
Copy link
Copy Markdown
Contributor Author

@StormLiangMS Could you please review?

@qiluo-msft qiluo-msft merged commit db2df14 into sonic-net:master Jan 27, 2025
nnelluri-cisco pushed a commit to nnelluri-cisco/sonic-mgmt that referenced this pull request Mar 15, 2025
…onic-net#16065)

Description of PR
For GCU test suites, configuration changes applied via patches sometimes target a specific ASIC namespace or apply globally to the card (localhost), depending on the feature functionality.

With the recent merged PR sonic-net#14098, configuration changes are now applied to both localhost and all ASIC namespaces for all multi-ASIC platforms by default, which is incorrect.

Examples:

Configuration paths like /BGP_NEIGHBOR/ should apply only to the ASIC namespace.
Paths like /SYSLOG_SERVER/ should apply only to the localhost namespace.
This PR addresses the issue by introducing a missing flag for "asic_specific" configurations. It adapts the calls appropriately in each test suite based on the targeted configuration scope (ASIC namespace or localhost).

Approach
How did you verify/test it?
Ran vs-kvm tests.

Attaching sample results for test_portchannel.py and test_eth_interface.py:
@BYGX-wcr
Copy link
Copy Markdown
Contributor

@okaravasi , your changes on some files seem to be not correct. For example, in generic_config_updater/test_valn_interface.py, the DUT is always single-ASIC. In such a case, the format_json_patch_for_multiasic will return an empty list.

@BYGX-wcr
Copy link
Copy Markdown
Contributor

nvm, I misread the code. Your change is fine.

@mssonicbld
Copy link
Copy Markdown
Collaborator

@okaravasi PR conflicts with 202505 branch

@r12f
Copy link
Copy Markdown
Collaborator

r12f commented Jul 3, 2025

hi @okaravasi , do you mind to help manual pick this PR to 202412?

@okaravasi
Copy link
Copy Markdown
Contributor Author

okaravasi commented Jul 10, 2025

@okaravasi PR conflicts with 202505 branch

@mssonicbld It seems PR changes are already included in 2025, that's why there is conflict in cherry-picking.
There should be there because PR was merged in master before 2025 branch was created.
Commit is also visible in 2025 git log :

commit db2df148ed793d5292acc60588120d13d3b6fade
Author: Olympia Karavasili Arapogianni <[email protected]>
Date:   2025-01-27 22:26:01 +0100

    Apply GCU changes to the appropriate namespace scope for each suite (#16065)
    
    Description of PR
    For GCU test suites, configuration changes applied via patches sometimes target a specific ASIC namespace or apply globally to the card (localhost), depending on the feature functionality.
    
    With the recent merged PR #14098, configuration changes are now applied to both localhost and all ASIC namespaces for all multi-ASIC platforms by default, which is incorrect.
    
    Examples:
    
    Configuration paths like /BGP_NEIGHBOR/ should apply only to the ASIC namespace.
    Paths like /SYSLOG_SERVER/ should apply only to the localhost namespace.
    This PR addresses the issue by introducing a missing flag for "asic_specific" configurations. It adapts the calls appropriately in each test suite based on the targeted configuration scope (ASIC namespace or localhost).
    
    Approach
    How did you verify/test it?
    Ran vs-kvm tests.
    
    Attaching sample results for test_portchannel.py and test_eth_interface.py:

@okaravasi
Copy link
Copy Markdown
Contributor Author

hi @okaravasi , do you mind to help manual pick this PR to 202412?

@r12f Created PR Azure/sonic-mgmt.msft#527

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants