Skip to content

Refine the logic of matching conditional mark.#16930

Merged
wangxin merged 3 commits intosonic-net:masterfrom
yutongzhang-microsoft:yutongzhang/change_conditional_mark
Feb 26, 2025
Merged

Refine the logic of matching conditional mark.#16930
wangxin merged 3 commits intosonic-net:masterfrom
yutongzhang-microsoft:yutongzhang/change_conditional_mark

Conversation

@yutongzhang-microsoft
Copy link
Contributor

@yutongzhang-microsoft yutongzhang-microsoft commented Feb 12, 2025

Description of PR

In PR #14395, we optimized the matching rule for conditional marks by considering all potential matches. If a mark is unique among these matches, it is applied to the test case. Otherwise, the longest matching entry is used.

In this PR, we further refine this logic by ensuring that the longest match where the condition is true is used. This means that if the conditions of the longest matching entry are false, we will consider the next longest matching entry.

Summary:
Fixes # (issue)

Type of change

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

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405
  • 202411

Approach

What is the motivation for this PR?

In PR #14395, we optimized the matching rule for conditional marks by considering all potential matches. If a mark is unique among these matches, it is applied to the test case. Otherwise, the longest matching entry is used.

In this PR, we further refine this logic by ensuring that the longest match where the condition is true is used. This means that if the conditions of the longest matching entry are false, we will consider the next longest matching entry.

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
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yutongzhang-microsoft yutongzhang-microsoft changed the title Change the logic of conditional mark Refine the logic of matching conditional mark. Feb 13, 2025
Copy link
Contributor

@congh-nvidia congh-nvidia left a comment

Choose a reason for hiding this comment

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

LGTM

@yutongzhang-microsoft yutongzhang-microsoft marked this pull request as ready for review February 18, 2025 09:05
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@wangxin wangxin merged commit 1c05a32 into sonic-net:master Feb 26, 2025
17 checks passed
@yutongzhang-microsoft yutongzhang-microsoft deleted the yutongzhang/change_conditional_mark branch February 26, 2025 08:31
wangxin pushed a commit that referenced this pull request Mar 4, 2025
What is the motivation for this PR?
This PR is based on PR #16930. After changing the logic of conditional marks, we need to add unit test to make sure it works as expected.

How did you do it?

How did you verify/test it?
yutongzhang@sonic_mgmt:/data/sonic-mgmt$ python -m pytest --noconftest --capture=no tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py -v -s

tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_1 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_2 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_3 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_contradicting_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_defalut_logic_operation PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_duplicated_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_empty_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_logic_operation_and PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_logic_operation_or PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_no_matches PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_partly_false_conditions_in_longest_entry PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_true_conditions_in_longest_entry PASSED
nissampa pushed a commit to nissampa/sonic-mgmt_dpu_test that referenced this pull request Mar 4, 2025
What is the motivation for this PR?
In PR sonic-net#14395, we optimized the matching rule for conditional marks by considering all potential matches. If a mark is unique among these matches, it is applied to the test case. Otherwise, the longest matching entry is used.

In this PR, we further refine this logic by ensuring that the longest match where the condition is true is used. This means that if the conditions of the longest matching entry are false, we will consider the next longest matching entry.

How did you do it?
How did you verify/test it?
nissampa pushed a commit to nissampa/sonic-mgmt_dpu_test that referenced this pull request Mar 4, 2025
What is the motivation for this PR?
This PR is based on PR sonic-net#16930. After changing the logic of conditional marks, we need to add unit test to make sure it works as expected.

How did you do it?

How did you verify/test it?
yutongzhang@sonic_mgmt:/data/sonic-mgmt$ python -m pytest --noconftest --capture=no tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py -v -s

tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_1 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_2 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_3 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_contradicting_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_defalut_logic_operation PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_duplicated_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_empty_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_logic_operation_and PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_logic_operation_or PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_no_matches PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_partly_false_conditions_in_longest_entry PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_true_conditions_in_longest_entry PASSED
wangxin pushed a commit that referenced this pull request Mar 5, 2025
…7317)

What is the motivation for this PR?
In PR #16930, we refined the logic of conditional marking to ensure that the longest matching entry with a True condition is prioritized. If the condition for the longest match is False, we then consider the next longest match.

However, there is a special case where the longest match has a False condition, but we still want to adopt this False condition instead of falling back to shorter matches. For example, in a skip scenario:

Shorter matching entries have True conditions, meaning the test should be skipped.
The longest matching entry has a False condition, meaning the test should not be skipped.
In this case, we actually want to respect the longest match and not skip the test.
To address this, this PR introduces a new key, use_longest. When use_longest is set to True, only the conditions of the longest matching entry will be used, ensuring the intended behavior in such edge cases.

How did you do it?
To address this, this PR introduces a new key, use_longest. When use_longest is set to True, only the conditions of the longest matching entry will be used, ensuring the intended behavior in such edge cases.

How did you verify/test it?
Add unit test test cases
nnelluri-cisco pushed a commit to nnelluri-cisco/sonic-mgmt that referenced this pull request Mar 15, 2025
What is the motivation for this PR?
In PR sonic-net#14395, we optimized the matching rule for conditional marks by considering all potential matches. If a mark is unique among these matches, it is applied to the test case. Otherwise, the longest matching entry is used.

In this PR, we further refine this logic by ensuring that the longest match where the condition is true is used. This means that if the conditions of the longest matching entry are false, we will consider the next longest matching entry.

How did you do it?
How did you verify/test it?
nnelluri-cisco pushed a commit to nnelluri-cisco/sonic-mgmt that referenced this pull request Mar 15, 2025
What is the motivation for this PR?
This PR is based on PR sonic-net#16930. After changing the logic of conditional marks, we need to add unit test to make sure it works as expected.

How did you do it?

How did you verify/test it?
yutongzhang@sonic_mgmt:/data/sonic-mgmt$ python -m pytest --noconftest --capture=no tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py -v -s

tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_1 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_2 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_3 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_contradicting_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_defalut_logic_operation PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_duplicated_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_empty_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_logic_operation_and PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_logic_operation_or PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_no_matches PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_partly_false_conditions_in_longest_entry PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_true_conditions_in_longest_entry PASSED
nnelluri-cisco pushed a commit to nnelluri-cisco/sonic-mgmt that referenced this pull request Mar 15, 2025
…nic-net#17317)

What is the motivation for this PR?
In PR sonic-net#16930, we refined the logic of conditional marking to ensure that the longest matching entry with a True condition is prioritized. If the condition for the longest match is False, we then consider the next longest match.

However, there is a special case where the longest match has a False condition, but we still want to adopt this False condition instead of falling back to shorter matches. For example, in a skip scenario:

Shorter matching entries have True conditions, meaning the test should be skipped.
The longest matching entry has a False condition, meaning the test should not be skipped.
In this case, we actually want to respect the longest match and not skip the test.
To address this, this PR introduces a new key, use_longest. When use_longest is set to True, only the conditions of the longest matching entry will be used, ensuring the intended behavior in such edge cases.

How did you do it?
To address this, this PR introduces a new key, use_longest. When use_longest is set to True, only the conditions of the longest matching entry will be used, ensuring the intended behavior in such edge cases.

How did you verify/test it?
Add unit test test cases
OriTrabelsi pushed a commit to OriTrabelsi/sonic-mgmt that referenced this pull request Apr 1, 2025
What is the motivation for this PR?
This PR is based on PR sonic-net#16930. After changing the logic of conditional marks, we need to add unit test to make sure it works as expected.

How did you do it?

How did you verify/test it?
yutongzhang@sonic_mgmt:/data/sonic-mgmt$ python -m pytest --noconftest --capture=no tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py -v -s

tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_1 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_2 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_all_false_conditions_in_matching_path_3 PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_contradicting_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_defalut_logic_operation PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_duplicated_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_empty_conditions PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_logic_operation_and PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_logic_operation_or PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_no_matches PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_partly_false_conditions_in_longest_entry PASSED
tests/common/plugins/conditional_mark/unit_test/unittest_find_all_matches.py::TestFindAllMatches::test_true_conditions_in_longest_entry PASSED
OriTrabelsi pushed a commit to OriTrabelsi/sonic-mgmt that referenced this pull request Apr 1, 2025
…nic-net#17317)

What is the motivation for this PR?
In PR sonic-net#16930, we refined the logic of conditional marking to ensure that the longest matching entry with a True condition is prioritized. If the condition for the longest match is False, we then consider the next longest match.

However, there is a special case where the longest match has a False condition, but we still want to adopt this False condition instead of falling back to shorter matches. For example, in a skip scenario:

Shorter matching entries have True conditions, meaning the test should be skipped.
The longest matching entry has a False condition, meaning the test should not be skipped.
In this case, we actually want to respect the longest match and not skip the test.
To address this, this PR introduces a new key, use_longest. When use_longest is set to True, only the conditions of the longest matching entry will be used, ensuring the intended behavior in such edge cases.

How did you do it?
To address this, this PR introduces a new key, use_longest. When use_longest is set to True, only the conditions of the longest matching entry will be used, ensuring the intended behavior in such edge cases.

How did you verify/test it?
Add unit test test cases
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