Skip to content

[crm] Fix test_crm teardown#2212

Merged
yxieca merged 1 commit intosonic-net:masterfrom
lolyu:fix_crm_teardown
Sep 14, 2020
Merged

[crm] Fix test_crm teardown#2212
yxieca merged 1 commit intosonic-net:masterfrom
lolyu:fix_crm_teardown

Conversation

@lolyu
Copy link
Collaborator

@lolyu lolyu commented Sep 14, 2020

Description of PR

If fixtures failed during setup, there will no rep_call attribute for
item. Checking the setup's success first to guarantee this.

Signed-off-by: Longxiang Lyu [email protected]

Summary:
Fixes # (issue)

Type of change

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

Approach

What is the motivation for this PR?

If sanity_check fails before test_crm related test cases, there will be an error complaining there is no rep_call attribute for Item object.

How did you do it?

Check if setup passes before fetching rep_call.

How did you verify/test it?

  • before
________________________________________________________________________ ERROR at setup of test_acl_entry _________________________________________________________________________

localhost = <tests.common.devices.Localhost object at 0x7f7159465310>, duthost = <tests.common.devices.SonicHost object at 0x7f715f6f09d0>
request = <SubRequest 'sanity_check' for <Function test_acl_entry>>
fanouthosts = {u'str-7060cx-32s-16': { os: 'eos', hostname: 'str-7060cx-32s-16', device_type: 'FanoutLeaf' }, u'str-7060cx-32s-17': { os: 'eos', hostname: 'str-7060cx-32s-17', device_type: 'FanoutLeaf' }}
testbed = {'comment': 'prsunny', 'conf-name': 'vms6-t0-7060', 'duts': ['str-a7060cx-acs-1'], 'group-name': 'vms6-4', ...}

    @pytest.fixture(scope="module", autouse=True)
    def sanity_check(localhost, duthost, request, fanouthosts, testbed):
        logger.info("Start pre-test sanity check")
>       pytest.fail("Out of no reason")
E       Failed: Out of no reason

common/plugins/sanity_check/__init__.py:46: Failed
_______________________________________________________________________ ERROR at teardown of test_acl_entry _______________________________________________________________________

item = <Function test_acl_entry>, nextitem = None

    def pytest_runtest_teardown(item, nextitem):
        """ called after ``pytest_runtest_call``.

        :arg nextitem: the scheduled-to-be-next test item (None if no further
                       test item is scheduled).  This argument can be used to
                       perform exact teardowns, i.e. calling just enough finalizers
                       so that nextitem only needs to call setup-functions.
        """
        failures = []
        crm_threshold_name = RESTORE_CMDS.get("crm_threshold_name")
        restore_cmd = "bash -c \"sonic-db-cli CONFIG_DB hset 'CRM|Config' {threshold_name}_threshold_type percentage \
        && sonic-db-cli CONFIG_DB hset 'CRM|Config' {threshold_name}_high_threshold {high} \
        && sonic-db-cli CONFIG_DB hset 'CRM|Config' {threshold_name}_low_threshold {low}\""
>       if not item.rep_call.skipped:
E       AttributeError: 'Function' object has no attribute 'rep_call'

crm/conftest.py:24: AttributeError
============================================================================= 2 error in 8.23 seconds =============================================================================
  • after
________________________________________________________________________ ERROR at setup of test_acl_entry _________________________________________________________________________

localhost = <tests.common.devices.Localhost object at 0x7fa803bd9cd0>, duthost = <tests.common.devices.SonicHost object at 0x7fa809e1a9d0>
request = <SubRequest 'sanity_check' for <Function test_acl_entry>>
fanouthosts = {u'str-7060cx-32s-16': { os: 'eos', hostname: 'str-7060cx-32s-16', device_type: 'FanoutLeaf' }, u'str-7060cx-32s-17': { os: 'eos', hostname: 'str-7060cx-32s-17', device_type: 'FanoutLeaf' }}
testbed = {'comment': 'prsunny', 'conf-name': 'vms6-t0-7060', 'duts': ['str-a7060cx-acs-1'], 'group-name': 'vms6-4', ...}

    @pytest.fixture(scope="module", autouse=True)
    def sanity_check(localhost, duthost, request, fanouthosts, testbed):
        logger.info("Start pre-test sanity check")
>       pytest.fail("Out of no reason")
E       Failed: Out of no reason

common/plugins/sanity_check/__init__.py:46: Failed
============================================================================= 1 error in 9.47 seconds =============================================================================

Any platform specific information?

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

Documentation

If fixtures failed during setup, there will no `rep_call` attribute for
`item`. Checking the setup's success first to guarantee this.

Signed-off-by: Longxiang Lyu <[email protected]>
@lolyu lolyu requested a review from a team September 14, 2020 06:59
@lolyu
Copy link
Collaborator Author

lolyu commented Sep 14, 2020

@yvolynets-mlnx, could please help take a review?

@yxieca
Copy link
Collaborator

yxieca commented Sep 14, 2020

retest vsimage please

@yxieca yxieca merged commit 97a4366 into sonic-net:master Sep 14, 2020
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
13ec600 [generic-config-updater] Add NTP validator (sonic-net#2212)
4fc09b1 [GCU] Handling non-compliant leaf-list with string values (sonic-net#2174)
ac89489 Modify override testcase to cover PORT admin_status (sonic-net#2165)
d7953d2 [GCU] Validate peer_group_range ip_range are correct (sonic-net#2145)
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.

3 participants