Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add route flow counter related test cases #5134

Closed

Conversation

Junchao-Mellanox
Copy link
Contributor

HLD:
sonic-net/SONiC#908

Change-Id: I4b9b1dd1c5372645c67511ddcc667b99f427d556

Description of PR

Summary:
Added test cases for route flow counter feature

Type of change

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

Back port request

  • 201911

Approach

What is the motivation for this PR?

Add route flow counter related test cases

How did you do it?

  1. Add new test case file test_route_flow_counter.py to covers basic function of this feature
  2. Add check in test_vnet_vxlan.py to cover VNET route
  3. Add check in test_bgp_speaker.py to cover BGP route
  4. Add check in test_static_route.py to cover static route

How did you verify/test it?

Run the test cases

Any platform specific information?

N/A

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

N/A

Documentation

Change-Id: I4b9b1dd1c5372645c67511ddcc667b99f427d556
@Junchao-Mellanox Junchao-Mellanox requested a review from a team as a code owner February 14, 2022 02:00
@lgtm-com
Copy link

lgtm-com bot commented Feb 14, 2022

This pull request introduces 1 alert when merging 5469367 into 8b81dc8 - view on LGTM.com

new alerts:

  • 1 for Unused import

keboliu
keboliu previously approved these changes Feb 14, 2022
Change-Id: I70d4fdd3160e7a31dfca66d829491b19630adc92
@Junchao-Mellanox
Copy link
Contributor Author

The failure is expected because some the feature PRs are still in review.

Conflicts:
	tests/vxlan/test_vnet_vxlan.py

Change-Id: Ia9bc3b3523c6c3f547a745ed1530fb7c143bac45
@liat-grozovik
Copy link
Collaborator

@roysr-nv could you please review?

Copy link
Contributor

@roy-sror roy-sror left a comment

Choose a reason for hiding this comment

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

Hi Junchao,

Apart from the specific comments, I have some general notes:

  1. Please use allure steps.
  2. I suggest to combine test_update_route_pattern and test_add_remove_route - I don't see any reason to cover it separately.
  3. in the new route flow tests - please make sure that cleanup is done in any case, even if exception is thrown during the test execution.
  4. Can you please share the test runtime.

tests/flow_counter/flow_counter_utils.py Outdated Show resolved Hide resolved
tests/flow_counter/flow_counter_utils.py Show resolved Hide resolved
support_route_flow_counter = True
elif support == 'false':
support_route_flow_counter = False
return support_route_flow_counter is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we simply return the variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. get_route_flow_counter_capability is a callback of wait_until, the return value indicates that whether wait_until need continue running. If we return the support_route_flow_counter, there could be case that: support_route_flow_counter is False and wait_until will continue running until timeout.

Copy link
Contributor

Choose a reason for hiding this comment

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

how about raising an exception if the value is None? wait_until should return False in that case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The semantic here is to "wait support_route_flow_counter until there is a value", so I support "return support_route_flow_counter is not None" just matches the semantic.

tests/route/test_route_flow_counter.py Outdated Show resolved Hide resolved
tests/route/test_route_flow_counter.py Outdated Show resolved Hide resolved
tests/bgp/test_bgp_speaker.py Outdated Show resolved Hide resolved
tests/flow_counter/flow_counter_utils.py Outdated Show resolved Hide resolved
tests/flow_counter/flow_counter_utils.py Outdated Show resolved Hide resolved
dut.command('counterpoll flowcnt-route interval {}'.format(interval))


def set_route_flow_counter_pattern(dut, route_pattern, max_match_count=30):
Copy link
Contributor

Choose a reason for hiding this comment

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

To me it seems more readable to get another parameter- VRF, rather than encapsulating it in the route pattern string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, using VRF and prefix here makes this function more readable. However, I would like to keep this based on two reasons:

  1. Most of case VRF is none(default VRF)
  2. If we use VRF and prefix, the caller has to use a tuple (, ) to represent the route pattern, it increases unneeded complexity of caller side. And a tuple is not so readable.

Returns:
bool: Match if True.
"""
logger.info('Expected stats: {}'.format(expect_stats))
Copy link
Contributor

Choose a reason for hiding this comment

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

here I suggest to exit the function only once(at the end), so we can set the rc and message when needed and return it at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prefer to keep this. There is a "for loop in for loop" in this function, it is hard to use rc in the inner loop.

    for key, value in expect_stats.items():
        if key not in actual_stats:
            return False, 'Failed to find {} in result'.format(key)

        for stats_type, expect_value in value.items():
            if int(expect_value) != int(actual_stats[key][stats_type].replace(',', '')):
                return False, 'Expected {} value of {} is {}, but got {}'.format(stats_type, key, expect_value, actual_stats[key][stats_type])

@Junchao-Mellanox
Copy link
Contributor Author

Junchao-Mellanox commented Apr 26, 2022

Hi Junchao,

Apart from the specific comments, I have some general notes:

  1. Please use allure steps.
  2. I suggest to combine test_update_route_pattern and test_add_remove_route - I don't see any reason to cover it separately.
  3. in the new route flow tests - please make sure that cleanup is done in any case, even if exception is thrown during the test execution.
  4. Can you please share the test runtime.

I will fix 1~3. For item#2, I will remove test_add_remove_route since it is fully covered by test_update_route_pattern. Will update test runtime after all fixes.

Change-Id: Iad925eaf3c605780e9d41802240ba89b8a4dce2f
@Junchao-Mellanox
Copy link
Contributor Author

Hi @roysr-nv, the test run time is about 180 seconds.

Change-Id: I75d88cdd90244de99f832f154716ca6ad001c1b2
@Junchao-Mellanox
Copy link
Contributor Author

Hi @roysr-nv, could you please review again?

@lgtm-com
Copy link

lgtm-com bot commented May 10, 2022

This pull request introduces 2 alerts when merging 5d6cc25 into 71e0833 - view on LGTM.com

new alerts:

  • 2 for Unused import

Change-Id: If6e571d803b7ba8702164f000ac7a0a10919f175
@lgtm-com
Copy link

lgtm-com bot commented May 10, 2022

This pull request introduces 2 alerts when merging 0d7cd5f into 38d6d3a - view on LGTM.com

new alerts:

  • 2 for Unused import

Change-Id: Ia784fc3ad19483fbc84ebd657066c0bce218c273
@lgtm-com
Copy link

lgtm-com bot commented May 12, 2022

This pull request introduces 2 alerts when merging 6f2fe3e into c453cf4 - view on LGTM.com

new alerts:

  • 2 for Unused import

roy-sror
roy-sror previously approved these changes May 12, 2022
Change-Id: I89c90deabd38720136ab2dea5b1eb38283f1bcf2
@lgtm-com
Copy link

lgtm-com bot commented May 13, 2022

This pull request introduces 2 alerts when merging f9278f7 into b2cc638 - view on LGTM.com

new alerts:

  • 2 for Unused import

Change-Id: I7b304d40004ea699c29d61d88b7bd1f64ec63a53
@lgtm-com
Copy link

lgtm-com bot commented May 13, 2022

This pull request introduces 2 alerts when merging e2fe2d8 into 1193c99 - view on LGTM.com

new alerts:

  • 2 for Unused import

@liat-grozovik
Copy link
Collaborator

/azp run Azure.sonic-mgmt

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Junchao-Mellanox
Copy link
Contributor Author

It seems it is not using the latest sonic-utilities.

@Junchao-Mellanox
Copy link
Contributor Author

/azpw run Azure.sonic-mgmt

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-mgmt

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Junchao-Mellanox
Copy link
Contributor Author

/azpw run Azure.sonic-mgmt

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-mgmt

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Junchao-Mellanox
Copy link
Contributor Author

/azpw run Azure.sonic-mgmt

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-mgmt

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

roy-sror
roy-sror previously approved these changes May 19, 2022
@liat-grozovik
Copy link
Collaborator

/azp run Azure.sonic-mgmt

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Junchao-Mellanox
Copy link
Contributor Author

/azpw run Azure.sonic-mgmt

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-mgmt

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lgtm-com
Copy link

lgtm-com bot commented May 26, 2022

This pull request introduces 2 alerts when merging 8e31615 into 99ef5c3 - view on LGTM.com

new alerts:

  • 2 for Unused import

@Junchao-Mellanox
Copy link
Contributor Author

Closed as this PR always use old SONiC image, new PR created: #5736

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.

5 participants