-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix windows ci tests #2144
Merged
Merged
Fix windows ci tests #2144
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ee88d30
move commandline args to global conftest
tstadel 30a2aec
correct test exclude paths
tstadel c7a71e0
Update Documentation & Code Style
github-actions[bot] 960a38a
exclude test_generator_pipeline_with_translator from windows ci
tstadel a993e2f
exclude further oom tests
tstadel e72843d
enable log_cli
tstadel File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def pytest_addoption(parser): | ||
parser.addoption("--document_store_type", action="store", default="elasticsearch, faiss, memory, milvus, weaviate") | ||
|
||
|
||
def pytest_generate_tests(metafunc): | ||
# Get selected docstores from CLI arg | ||
document_store_type = metafunc.config.option.document_store_type | ||
selected_doc_stores = [item.strip() for item in document_store_type.split(",")] | ||
|
||
# parametrize document_store fixture if it's in the test function argument list | ||
# but does not have an explicit parametrize annotation e.g | ||
# @pytest.mark.parametrize("document_store", ["memory"], indirect=False) | ||
found_mark_parametrize_document_store = False | ||
for marker in metafunc.definition.iter_markers("parametrize"): | ||
if "document_store" in marker.args[0]: | ||
found_mark_parametrize_document_store = True | ||
break | ||
# for all others that don't have explicit parametrization, we add the ones from the CLI arg | ||
if "document_store" in metafunc.fixturenames and not found_mark_parametrize_document_store: | ||
metafunc.parametrize("document_store", selected_doc_stores, indirect=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Out of curiosity, why this part of
conftest.py
needed to be moved to the root folder?rest_api
andui
tests don't really use document store's parametrization and I'm sure pytest can deal withconftest.py
s in subfolders...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.
Yes, unfortunately pytest doesn't. conftest.py only works with the package on the same level. So the --document_store_type option works perfectly with all tests within haystack's test folder. But in rest_api's and ui's test folder the addoption from conftest.py is not available and thus the cmd option is not available resulting in an error. In windows ci we always call pytest for any test file no matter where it lies with the document_store_type option.
By putting it into the package root, addoption is available in subpackages too.
Alternatives to that would be:
A) is pretty stupid and introduces duplicate code that currently has no functionality inside the subpackages tests confusing anybody who takes a look at it
B) is rather clumsy as we have to check the relative file paths and besides that I think this option is intended to be global anyway
The con of the current approach of course is that there's a conftest.py floating around in the root folder.
I also found that issue where the same problem is addressed, but I couldn't find any other solution.
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 think for now it's the best solution, thanks for the explanation. When we're gonna refactor the tests we will try to find a cleaner way to filter document store tests that does not require that piece of code 🙂