-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Remove stestr's grouping configuration #6399
Conversation
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.
Thanks a bunch for doing this, I think it's definitely a good step to move to method level parallelism for CI. I do wonder if we'll encounter issues with 2 test methods in a class conflicting with each other (even for just limited resources) but we can tackle that when the time comes.
I left a comment inline about a potential alternative approach for user config tests, I'm personally not a fan of the splitting the config for the tests out into separate files. Other than that it doesn't look .stestr.conf
is actually modified in this PR, was your intent to remove the group_regex
flag in this PR?
test/python/test_user_config.py
Outdated
current_dir = os.path.dirname(os.path.abspath(__file__)) | ||
test_name = str(self.id()).split(".")[-1] | ||
file_path = os.path.join(current_dir, "configurations", test_name + ".conf") | ||
self.config = user_config.UserConfig(file_path) |
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'm not super thrilled about this approach. Personally I find this kind of fragile to have to match the test name with a filename in a relative directory. Also as you mentioned it moves the configuration away from the test code which makes it harder to develop and debug tests here. I do wonder if there is an approach we can use that avoids shared state but also lets us create files.
What about something like:
def setUp(self):
super().setUp()
self.file_path = 'test_%s.conf' % uuid.uuid4()
and then leave tests as they were. That would ensure a unique file_name for each test. The only downside with that approach is there would need to be a cleanup in each test to delete the file for each test (but that was already done before).
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.
Yea I considered using a uuid to create a filename. My gut was sort of against it, but I do not really have any specific reasons for it. I think I just have a hesitation of writing files in a test unless it is necessary. If you are fine with the uuid then that is enough for me to get over it though.
682019d
to
5ae34b5
Compare
Removing the grouping regex in .stestr.conf should allow stestr to pack its test workers better, and therefore improve the speed of test execution. However, pre-existing test cases utilizing non-unique tempfiles began to fail after the configuration change. This commit modifies such tests to pass under these new conditions. This also allows the test suite to properly execute using pytest-xdist. Fixed Qiskit#6105
5ae34b5
to
e80793e
Compare
My intent was to remove the |
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.
LGTM, thanks for the quick update
Removing the grouping regex in .stestr.conf should allow stestr to pack its test workers better, and therefore improve the speed of test execution. However, pre-existing test cases utilizing non-unique tempfiles began to fail after the configuration change. This commit modifies such tests to pass under these new conditions. This also allows the test suite to properly execute using pytest-xdist.
Fixed #6105
Summary
Per #6105 a few tests (TestGateMap and TestUserConfig) were failing when using pytest-xdist. Both tests were reliant on a hardcoded file name "temp.txt", which is the root source of the failures. This pull modifies both to use less brittle file buffers.
I also went ahead and removed the regex found in https://github.com/Qiskit/qiskit-terra/blob/master/.stestr.conf#L3 as discussed in the issue. After correcting the tests I have not seen any issues with the configuration change. I will adjust the merge request if any reviewers are uncomfortable removing it or if it fails in ci checks.
Details and comments
For TestGateMap:
I modified the test so that it utilizes
io.BytesIO
instead of needlessly writing to the problamatic temp file.For TestUserConfig:
I moved the "string" configurations to their own personal files found in test/python/configurations. This might make it a bit harder to tell what the test is testing i.e. in the future devs will have to open the configuration file. However, this avoids the write to the problematic temp file and should create a less brittle test.