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 marker for case insensitive test collection by component and importance #15005

Merged

Conversation

shweta83
Copy link
Contributor

@shweta83 shweta83 commented May 8, 2024

Problem Statement

We need case insensitive test collection component-wise

Solution

Added marker for component-wise test collection
result:
pytest tests/foreman/ --component auditlog
collected 5434 items / 5426 deselected / 8 selected

tests/foreman/api/test_audit.py ✓✓✓                                                                                                38% ███▊      
 tests/foreman/ui/test_audit.py ✓✓✓✓✓                                                                                              100% ██████████

=======================================================

Related Issues

@shweta83 shweta83 added CherryPick PR needs CherryPick to previous branches 6.12.z Introduced in or relating directly to Satellite 6.12 AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 labels May 8, 2024
@shweta83 shweta83 requested a review from a team as a code owner May 8, 2024 19:44
@shweta83
Copy link
Contributor Author

shweta83 commented May 8, 2024

trigger: test-robottelo
pytest: tests/foreman/ --component alternatecontentsources --collect-only

@shweta83 shweta83 requested a review from jyejare May 8, 2024 19:45
@shweta83
Copy link
Contributor Author

shweta83 commented May 9, 2024

pytest tests/foreman/ --component auditlog

@@ -191,8 +191,8 @@ def pytest_collection_modifyitems(items, config):
# Add marker starting at smallest docstring scope
# only add the mark if it hasn't already been applied at a lower scope
doc_component = component_regex.findall(docstring)
if doc_component and 'component' not in item_mark_names:
item.add_marker(pytest.mark.component(doc_component[0]))
if doc_component and 'CaseComponent' not in item_mark_names:

Choose a reason for hiding this comment

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

why did you change the component to CaseComponent. we are adding component as marker to the test not CaseComponent. Or did I missed anything here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It searches for CaseComponent docstring in the test.

Choose a reason for hiding this comment

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

@jyejare I think it should be component right ? CaseComponent would not be a right marker to check as it it will not be there. As the we are adding the component marker.

Copy link
Member

Choose a reason for hiding this comment

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

@shweta83 Here @omkarkhatavkar is right we are adding a keypair of component=<somcomponent> to the the test item.

In below compoenent not in item_mark_names verifies that the component marker is not already added to the item.

if doc_component and 'component' not in item_mark_names:

@jyejare
Copy link
Member

jyejare commented May 13, 2024

@shweta83 Please revisit the tests are not collecting. Please let me know if u need the help.

@shweta83
Copy link
Contributor Author

trigger: test-robottelo
pytest: pytest tests/foreman/ --component auditlog

@shweta83
Copy link
Contributor Author

@shweta83 Please revisit the tests are not collecting. Please let me know if u need the help.

It was working well on my local setup. I need to check what's the issue running on CI.

@shweta83
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/ --component auditlog

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6919
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/ --component auditlog --external-logging
Test Result : ======== 8 passed, 5442 deselected, 5563 warnings in 1140.10s (0:19:00) ========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label May 14, 2024
@shweta83
Copy link
Contributor Author

shweta83 commented May 14, 2024

@shweta83 Please revisit the tests are not collecting. Please let me know if u need the help.

Tests are collected as expected. I messed up in running previous PRT which failed the test collection.

@@ -164,7 +164,7 @@ def pytest_collection_modifyitems(items, config):
# split the option string and handle no option, single option, multiple
# config.getoption(default) doesn't work like you think it does, hence or ''
importance = [i for i in (config.getoption('importance') or '').split(',') if i != '']
Copy link
Member

Choose a reason for hiding this comment

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

Mind doing the same to importance, while at it?

Suggested change
importance = [i for i in (config.getoption('importance') or '').split(',') if i != '']
importance = [i.lower() for i in (config.getoption('importance') or '').split(',') if i != '']
  • update the commit message

@shweta83 shweta83 force-pushed the add_component_wise_marker_case_sensitive branch from 8b56245 to a7f2734 Compare May 15, 2024 06:57
@shweta83 shweta83 changed the title Add marker for case insensitive test collection component-wise Add marker for case insensitive test collection by component and importance May 15, 2024
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label May 15, 2024
@shweta83
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/ --component auditlog

Copy link
Member

@jyejare jyejare left a comment

Choose a reason for hiding this comment

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

ACK pending comments.

@@ -191,8 +191,8 @@ def pytest_collection_modifyitems(items, config):
# Add marker starting at smallest docstring scope
# only add the mark if it hasn't already been applied at a lower scope
doc_component = component_regex.findall(docstring)
if doc_component and 'component' not in item_mark_names:
item.add_marker(pytest.mark.component(doc_component[0]))
if doc_component and 'CaseComponent' not in item_mark_names:
Copy link
Member

Choose a reason for hiding this comment

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

@shweta83 Here @omkarkhatavkar is right we are adding a keypair of component=<somcomponent> to the the test item.

In below compoenent not in item_mark_names verifies that the component marker is not already added to the item.

if doc_component and 'component' not in item_mark_names:

if doc_component and 'component' not in item_mark_names:
item.add_marker(pytest.mark.component(doc_component[0]))
if doc_component and 'CaseComponent' not in item_mark_names:
item.add_marker(pytest.mark.component(doc_component[0].lower()))
doc_importance = importance_regex.findall(docstring)
if doc_importance and 'importance' not in item_mark_names:
item.add_marker(pytest.mark.importance(doc_importance[0]))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
item.add_marker(pytest.mark.importance(doc_importance[0]))
item.add_marker(pytest.mark.importance(doc_importance[0].lower()))

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6932
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/ --component auditlog --external-logging
Test Result : ======== 8 passed, 5445 deselected, 5563 warnings in 900.26s (0:15:00) =========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label May 15, 2024
@shweta83 shweta83 force-pushed the add_component_wise_marker_case_sensitive branch from a7f2734 to 87ba96b Compare May 17, 2024 07:18
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label May 17, 2024
@shweta83
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/ --component auditlog

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6982
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/ --component auditlog --external-logging
Test Result : ======== 8 passed, 5461 deselected, 5583 warnings in 1092.40s (0:18:12) ========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label May 17, 2024
@jyejare jyejare merged commit 3fa1539 into SatelliteQE:master May 30, 2024
11 checks passed
github-actions bot pushed a commit that referenced this pull request May 30, 2024
…rtance (#15005)

Collect tests with case insensitive component marker

(cherry picked from commit 3fa1539)
github-actions bot pushed a commit that referenced this pull request May 30, 2024
…rtance (#15005)

Collect tests with case insensitive component marker

(cherry picked from commit 3fa1539)
github-actions bot pushed a commit that referenced this pull request May 30, 2024
…rtance (#15005)

Collect tests with case insensitive component marker

(cherry picked from commit 3fa1539)
github-actions bot pushed a commit that referenced this pull request May 30, 2024
…rtance (#15005)

Collect tests with case insensitive component marker

(cherry picked from commit 3fa1539)
jyejare pushed a commit that referenced this pull request Jun 2, 2024
… and importance (#15233)

Add marker for case insensitive test collection by component and importance (#15005)

Collect tests with case insensitive component marker

(cherry picked from commit 3fa1539)

Co-authored-by: Shweta Singh <[email protected]>
jyejare pushed a commit that referenced this pull request Jun 19, 2024
…rtance (#15005)

Collect tests with case insensitive component marker

(cherry picked from commit 3fa1539)
jyejare pushed a commit that referenced this pull request Jun 19, 2024
…rtance (#15005)

Collect tests with case insensitive component marker

(cherry picked from commit 3fa1539)
jyejare pushed a commit that referenced this pull request Jun 19, 2024
… and importance (#15231)

Add marker for case insensitive test collection by component and importance (#15005)

Collect tests with case insensitive component marker

(cherry picked from commit 3fa1539)

Co-authored-by: Shweta Singh <[email protected]>
jyejare pushed a commit that referenced this pull request Jun 19, 2024
… and importance (#15232)

Add marker for case insensitive test collection by component and importance (#15005)

Collect tests with case insensitive component marker

(cherry picked from commit 3fa1539)

Co-authored-by: Shweta Singh <[email protected]>
jyejare pushed a commit to jyejare/robottelo that referenced this pull request Oct 19, 2024
…rtance (SatelliteQE#15005)

Collect tests with case insensitive component marker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.12.z Introduced in or relating directly to Satellite 6.12 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing CherryPick PR needs CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants