-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
@dataProvider tests parallelization in functional mode #154
Conversation
sormy
commented
Feb 13, 2015
- @dataProvider support
- --filter support (functional mode only)
- --max-batch-size support (functional mode only)
- print progress as vanilla phpunit
- print progress without blank lines on windows default console
- dump process command line for debug purposes if process do not return any results
- one failed vanilla test: PHPUnitTest::testStopOnFailurePreventsStartingFurtherTestsAfterFailure
- no auto tests for new features for now
* @dataProvider support * --filter support (functional mode only) * --max-batch-size support (functional mode only) * print progress as vanilla phpunit * print progress without blank lines on windows default console * dump process command line for debug purposes if process do not return any results * one failed vanilla test: PHPUnitTest::testStopOnFailurePreventsStartingFurtherTestsAfterFailure * no auto tests for new features for now
Just to note, one failed test marked as skipped because it seems like problem on test side (fix test) and not in code. Failed test is related to stop-on-failure feature. Previously it stops after method execution, now it stops after batch execution which can have more then one method. |
Phew, thanks a lot. It's going to take some time to review this because this pr includes a couple of changes at once. You added a lot of code but I don't see any new tests, which is probably a bad sign. Would be nice if you could add some ... or a lot... . Maybe some tests could help to debug it because at least the output contains a bug: I took a testsuite that looked like this:
Then I added a dataProvider with 200 data sets to one of the methods which looks like this in phpunit:
And the current brianium/paratest master looks like this:
Not exactly the same but consistent. (it looks the same if you omit the Then I updated to sormy/paratest and it looked like this:
There are 240 tests but it 393 tests are displayed. The total test count increases, too. When I omit I'm not yet sure what the max-batch-size does, but it has an influence on the output:
Would be nice if you could extend the readme somehow to make the max-batch-size option more clear. Does it only apply to dataProviders? Edit: and with some tests, you could start refactoring some overextended methods which have become pretty hard to read like SuiteLoader::getMethodBatches . Some method extractions could point out your intent. |
Thanks, it's just initial attempt to get feature work. We have suite which test DICOM stack with over 4000 tests which works for me exactly as phpunit and speedup is around 2x (18 min vs 38 min) on my macbook 2013. If you can write fail test for your example it will be perfect! Big max-batch-size can broke phpunit, because command line became too huge or regular expression became too hard to be parsed without changing php's pcre settings. |
Julian, it seems like new code have problems with dependent tests. Could you try run on your end something without dependent tests? |
If you mean without an |
Ok, I found problem and fixed it. Also I added tests. Need your feedback before refactor code. |
Also, I don't know what scrutinizer means: 1 failure condition was met by this inspection: issues.new.exists |
In my test scenario:
Difference related to 2 incomplete tests and speedup is 2.35x on mobile core i7 with 2 cores |
About scrutinizer: take a look here https://scrutinizer-ci.com/g/brianium/paratest/inspections/91f9f970-f009-404d-a5c6-8114eb97fb4a and you see that the code quality of a couple of classes has decreased (but that didn't cause the failure) and that you introduced 82 new issues. An issue is something like a PSR violation. And PSR2 is the coding standard we stick to (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md PSR2 implicitly includes PSR1, which includes PSR0). Unfortunately, these new issues doesn't actually seem to be introduced by you. Scrutinizer shows
and I can't find any issue that is ~11h old. The PHPAnalyzer Changelog has nothing important in it but I guess that scrutinizer marks every issue as new because of the new analyzer version. So I will merge this PR even if scrutinizer screams about these new issues. The classes that got worse can be beautified with a small refactoring which you already mentioned. I'm sorry to say that you have to wait until tomorrow for feedback from me on your new code because I am handicapped today. But is looks good. Meanwhile you could take a look at the testStopOnFailurePreventsStartingFurtherTestsAfterFailure. Maybe it is enough to add a |
No problem, will wait for full feedback. |
$this->path = $suitePath; | ||
$this->name = $name; | ||
$this->path = $testPath; | ||
$this->filters = (array)$filters; |
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.
what is this cast to array for?
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.
for compatibility with other code (tests), which can pass string (one filter) instead of array.
note on scrutinizer: feedback: stuff that should be fixed:
stuff to be discussed:
Again, thanks for your effort! This a much appreciated and often requested feature. But this process is neccessary to keep some quality standard for the project. And if you think what I'm saying is bs, I'm always to constructive feedback ;) |
* Functional mode is on => Functional mode is ON. * refactoring to simplify code * PSR-related fixes * docblock comments fixes * method visibility fixes * implemented printing skipped and incomplete tests as skipped on console when group and group-exclude options are not passed to paratest * dataset-related optimizations by default disabled and can be activated with max-batch-size set, so this version of paratest works the same as vanilla paratest * max batch size is 0 by default * enabled auto test: PHPUnitTest::testStopOnFailurePreventsStartingFurtherTestsAfterFailure() * TestMethod::prepareOptions() fix to get the same behaviour as vanilla paratest when max-batch-size set to 0 * functional mode with working group and group-exclude filters * added assert then process command line length acceptable by operating system, only for windows for now * readme fixes to decribe max-batch-size option
default max-batch-size set to 0 and paratest works in that case the same as before my modifications
done
keep, implemented skipped/incomplete reporting as skipped for situations where group/group-exclude options are not passed to paratest
did some work to make code better
done
only functional tests at least for now waiting for your feedback |
new code base produce the following result in my test scenario, you can compare with my previous comment.
|
To wrap this up here, I understand if you don't have time to close the last gaps. If you leave it at this state, I will of course merge it anyways but would fix the last "comments" myself before releasing it. |
I don't know project code rules, so I'm coding based on my experience.
Let's merge that when you will have no any unresolved questions regarding my code. |
I'm just trying to keep the contribution experience as enjoyable as possible while keeping an eye on the quality, which is - to some extend - subjective. About the todos: most pull-requests at paratest are about features people want/need or changes they have to make in order to do subsequent pull-requests (which then are related to their features). Thats probably normal for an open source project but as a result, not many people will address any todo they stumble upon. As a result, if it is possible to create a consistent solution with reasonable effort, I would always prefer such a solution over a todo. If it is not possible with reasonable effort, then let's leave the todo where it is. It always leaves the question "who is going to address it?". (With consistent I mean: because group and group-exclude are commented out, they need the It's not that TODOs are always a bad thing. The todo for the maximum command size for example is helpful because it gives an hint on how to implement this ( So for your list:
PS: about the max-batch-size: I'm not sure if --max-batch-size=0 is the optimal default value from a performance point of view. Probably it's not but currently it's for the sake of BC. We are driving towards a 1.0.0 release and thats the point where we could do a complete makeover of the default values. But that has to be based on real data (like a testrun for every bug php-project on github with differen parameter sets) and not only a feeling that it may be more performant in some cases. |
julianseeger, you are right regarding useless comments, I need either make them more addressed to problem or remove them if everything works fine without them. |
I would like to find a time to try to fix group, group-exclude and skipped/incomplete print support or leave to in right place to make this changeset complete |
Any progress here? |
Sorry Julian. I think I will have time on Saturday to complete everything and prepare for merge. |
* README usage section fixes * Fixes for inline docs based on Code Review * Options refactoring to do not use @ * --filter option in non functional mode will raise exception * incomple/skipped functional tests for default test mode
* --group/--exclude-group fixes * code refactoring to make code less complex * removed unused function arguments
Ok, Julian, I think, I'm done =) Could you please check if everything is ok. |
I didn't go through all >1k loc of the change but it looked good before and the open points are addressed. Oh and there will be a separate issue about the PHP5.3 support. Thanks for addressing the compatibility issues, I hope we can get rid of that soon. |
@dataProvider tests parallelization in functional mode
@sormy @julianseeger does this also address the issue (without -f option), that classes with dataproviders does not output correct % numbers of passed tests? at the moment I see my test repeatly come from 79% to 99% and back to 79% when using @dataProvider If not I will try to debug this on my side but feedback at first would be nice :) |
In non-functional mode it will work the same as before. Actually, I think that if we add a different types of parallelization (per test method, per test case, per test file, per test suite) for functional mode then we can completely remove non-functional mode and get good percentage during test execution. Paratest in non-functional mode do not try to look into tests and estimate amount of tests and it's the reason why it works like it works. |
@chbiel yes. With functional mode and max-batch-size > 0, this feature is activated and progress is tracked for methods*dataproviders. So there should be no incorrect progress because of dataProviders. @sormy In most cases, per test file and per test case should be the same and thats what non-functional mode does. per test method is functional-mode + max-batch-size=0. per dataProvider is functional + max-batch-size > 0. And per suite does not exist because it is so high level, that you can probably achieve this more easily by using per testcase concurrency or just use your build-tool to execute multiple commands concurrently. Maybe we should always use this new feature to get always correct progress and split parsing / execution. Your input is welcome on what the default should be and what options/combinations should be offered to make the use easier (and make the "optimizing speed" section of the readme intuitive). The current state is based on backwards compatibility. By default, nothing should have changed in the last releases. But when optimizing, you can turn of -f and --batch-max-size and look what does the job best. From my experience, you have like a 50% chance that data-provider-concurrency inceases or significally decreases performance (depends on thinks like bootstrapping and array-caches) and about a 80% chance to have a better performance in functional mode over non-functional. So there are no best options for everyone. |