-
Notifications
You must be signed in to change notification settings - Fork 10
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
Hierarchical based exhaustive sort #119
base: master
Are you sure you want to change the base?
Conversation
Please add logs and from future maintainability context, u may want to define what exhaustive sort means by providing a sample |
I am not sure what is the feature here . |
I have added more description and an example output log. |
thanks for the context. we need more testing :
|
while copy_of_items: | ||
param = extract_params(copy_of_items[0]) | ||
if param: | ||
param_pattern = f"[{param}" | ||
matching_items = [item for item in copy_of_items if param_pattern in item.nodeid] | ||
sorted_items.extend(matching_items) | ||
copy_of_items = [item for item in copy_of_items if item not in matching_items] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am lost here. This is copy of an array and sort is performed over items. I get that the genral sorting algorithms wont apply. But what is 671.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The while loop is supposed to go on until the copy is completely empty. Matching items are the items being added into the sorted array (line 670). After that, I am removing all the matching items from the copy which I have added into the sorted array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I.e, in line 671 I am removing those items.
if config.option.exhaustive_sort: | ||
log.info("Exhaustive sorting of TCs enabled") | ||
sorted_items = custom_exhaustive_sort(items) | ||
if len(sorted_items) == len(items): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in which cases this will never be true ? this should sort anyway.
is it for the non-fixture things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't found a case where it will not be true but I added it just in case as a roll back to default order if the sorting misbehaves or fails resulting in lesser number or duplication of test cases in the sorted array.
seems fine , Jatin. We need test logs for several options I suggested. Ping me for any help. Post that it is good to go. |
No tests done and closed. |
Description
This pull request enhances the pytest plugin by introducing the --exhaustive-sort option, designed to optimize test case execution order for improved efficiency. When collecting test cases, pytest traditionally organizes them class-wise per parameter set (eg. of parameter set: [l3vpn-6pe-6vpe-common_setup_transport0]) , leading to potential redundancy in setup and teardown operations.
The newly added custom_exhaustive_sort method, utilized in the pytest_collection_modifyitems function, addresses this inefficiency. It reorders test cases hierarchically, ensuring that all test cases for a given parameter set are exhausted before moving on to the next set. This approach optimizes execution time by minimizing redundant setup and teardown operations.
Example 1:
Command used:
Simple example File: simple_example(.py).txt
Log: simple_example.log
File structure:
Before Sorting: (pytest generated order)
After Sorting:
This optimization is particularly beneficial when dealing with large test suites, as it reduces the overall execution time.
Example 2:
An example output is also attached for reference where this sorting method was run on a cafyap file.
Command used:
Log:
l3vpn_intra_as_ap.log