Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
phpunit
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
16 Jul 2014 at 18:36 UTC
Updated:
4 Sep 2015 at 12:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sunComment #2
sunComment #4
larowlan*awesome*
Comment #5
mile23::hands prize::
Comment #6
sunHm. PIFR/testbot and/or Drush seems to have a problem with one of the changes.
Most likely related to stream wrapper URI support adjustments - which are required to remove
DRUPAL_ROOTfrom getting prefixed to all local filesystem paths, because they arevfs://URIs in kernel tests.I already expected PIFR to blow up (or to take hours to complete due to the way phpunit tests are currently spawned), but this error comes unexpected. Even thought the effective testbot CLI output doesn't look like it, I suspect that Drush attempts to install Drupal in a wrong filesystem directory (since no longer absolute). Needs further investigation.
Comment #7
mile23Drush is good.
Dependency on Drush is bad.
Comment #8
wim leersAmazing! Magnificent. Wow.
Comment #9
sunThe error occurs way before any tests are run. First challenge was to figure out whether this is a OS error, PHP error, Drush error, or Drupal error… ;) Found it:
http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Core/Config/Insta...
Guess this requires to actually install Drush locally and try out the command
drush --verbose --debug site-installComment #10
sunCreated #2318191: [meta] Database tests fail on SQLite for the SQLite Database driver fixes.
Comment #11
nick_schuch commentedSo. Much. Awesome.
As a part of BrowserTestBase we started migrating alot of the asserts over to PHPUnit and implemented it as the runner. Looks like Im overlapping alot with your work.
https://twitter.com/sanic1989/status/497249190074781698
Left a tell on IRC, looking to have a chat about what steps I should be taking from here.
Comment #12
berdirHow are we going to run tests like the Database tests against multiple database backends if we're forcing it down to sqlite here? Fixing all the broken sqlite tests and discovering them is great, but how do we ensure that they continue to work against mysql and postgreSQL too?
Comment #13
sunFundamentally, that's the realm of component-specific unit tests - i.e., the Database component itself provides functionality for different backends, so the Database component (and only that) needs a way to run its test suite against different backends. All other tests are irrelevant. Implicit test coverage is irrelevant; it means nothing else but missing test coverage. Only explicit test coverage matters. Hence, it's a matter of running ~30 test classes of the Database component against multiple backends.
Achieving that would be fairly straightforward on Travis-CI. Drupal, however, has a multitude of ways for executing PHPUnit currently, which makes it exceptionally hard to implement and adopt one of the usual/common approaches. And even if that was implemented already, the QA/testbot environments would have to supply and support all backends first, and a compatible way to transfer credentials for each backend into the PHP environment second.
I don't think this issue should be held up by that, because (1) SQLite represents a most minimal subset/denominator of ANSI SQL backends, so queries that work against it will work against others (which is not the case vice-versa), (2) The actual/active SQL backend is irrelevant for all kernel tests (except of the Database component tests themselves), (3) Web tests are still executed against MySQL, and lastly (4) In the worst case, we can simply do not convert the Database component tests (for now), so they are still executed via Simpletest/MySQL (or to be precise, whichever database is used by the "parent site").
If anything, then this issue will only pave the way towards testing of alternative backends in the long run. In any case, for >99% of all kernel tests the SQL backend does not matter, as long as there is a backend. Conceptually the same as swapping out a storage service with an in-memory implementation.
Comment #14
larowlanYesterday @nick_schuch showed me a working prototype of a new container-based testbot using Jenkins and Travis CI's runner component with this patch.
It was over my head so I'll leave it to him to better describe what he's done, but it was pretty nice to see it run through using travis config but on private hardware.
Comment #15
nick_schuch commentedFollowing on from #13 and #14...
Roughly a week ago myself, @larowlan and @grom358 had a chat with @sun about some work that we were doing with an "Acceptence test base" running on Mink and PHPUnit. During this chat @sun pointed us to this story and the work that he had been doing, it's freaking awesome by the way. I noticed that this was being tested with TravisCI.
Over the weekend I found the following project while looking through the TravisCI github repo: https://github.com/travis-ci/travis-build. At the time I did not think of core and thought of how I could bring it into my PreviousNext workflow, Im now using it for Puppet unit tests and deployments. The workflow for this is 1) Mount the files into a containers that has travis-build 2) Run travis-build 3) Tear it down afterwards. This was a huge win for me.
Yesterday I had a crazy idea, how hard would it be to bring this into core. Being a part of the DrupalCI group I didn't want to stand on any toes, but wanted to experiment and see if I could take @sun's repo/branch and run it on Jenkins with this travis project. It was a success, but I didn't have anything PHP packed away, so what I have now is:
* 1 x Base Docker container that installs PHPENV, Composer and Travis build.
* 1 x PHP 5.4 Docker container.
* 1 x PHP 5.5 Docker container.
While the travis-build project could only run the "env, before_script, script....." commands, I saw the need for something that builds a little script to run all the permutations (PHP 5.4 + Mysql + Postgres and PHP 5.5 + Mysql + Postgres). So I wrote a little "compiler" as a proof of concept, all it does is 1) Read the .travis.yml file 2) Return a bash script with Docker commands that link services (containers).
The work I have done so far can be found here: https://github.com/nickschuch/docker-drupal
A link to the build (just running PHP 5.4): http://107.170.87.127:8080/job/travisci/70/console
A link to @sun's travis build (to show that my Jenkins build produces the exact same result): https://travis-ci.org/sun/drupal/builds/31851982
Comment #16
sun@nick_schuch: OMG. That's pure awesomeness. +1,000,000 for re-using proven open-source technology. Let's move this into a dedicated issue?
Comment #17
mile23@nick_schuch: Pretty cool. :-) Standing on toes isn't such a bad thing. Please ping jthorson about it if you haven't already.
Comment #18
nick_schuch commentedThanks guys!
I have left tells to @jthorson and @ricardoamaro on IRC with the link to this issue. We have our weekly meetings so wil bring it up there if I don't here from them prior.
Comment #19
mile23Needs re-roll. Sad to say.
Comment #20
dawehnerWorked on a reroll for fun, but this is certainly in not the best state.
Note: The patchsize might be reduced that much because the changes to phpunit got revereted (I assume that all the changes upstream got in again).
Comment #21
daffie commentedFor the testbot
Comment #23
dawehnerjust some work.
Comment #24
jibranComment #26
tim.plunkettComment #27
dawehnerJust posting some general progress.
Comment #28
daffie commentedCONCAT_WSis fixed in #2427311: SQLite does not natively support CONCAT_WS().Comment #29
daffie commentedHow to continue with this issue:
Drupal\simpletest\KernelTestBaseis not going to make it in this stage of Drupal 8. Creating a parallel classDrupal\simpletest\KernelUnitTestBaseand moving the actual kernel-tests in follow-ups is the only viable solution at this point in the Drupal 8 core development.Comment #30
dawehner@daffie
In general, have a look at https://www.drupal.org/core/beta-changes#unfrozen ... if we think this is an improvement and speed development up, I think its
worth to rip out the existing api. Note: This patch still includes the old class, so you could use it, if needed.
Comment #31
daffie commented@dawehner: I thought that a change like this issue was not allowed any more. Nice to hear. :) Can you reply to my second point. #2318191: [meta] Database tests fail on SQLite is almost finished, so do we need SQLite to pass all tests or only the database ones.
Comment #32
dawehnerSome work, now many tests are running again (17 fails in 400 running of 1131 tests), it just needs time.
Comment #33
daffie commentedFor the testbot
Comment #36
dawehnerA couple of test fixes in the meantime, many of them actually reduce the patch size, as they have been rebase conflicts.
Comment #38
dawehnerWorked on quite additional test coverage.
Note: Personally I'm not sure wether we want to add the log checking as part of the patch. One thing I did in the recent interdiff,
is to remove the requirement to set the expected logs, but just make it optional to check it.
In total we are with that done to:
@berdir
Currently focused on the tests but I really think we should be able to run them via SQL as well.
Comment #40
dawehnerAs far as I see the remaining failures are all caused by some kind of missing deterministic sort order of
Config\DatabaseStorage::listAll()here is some various cleanups and bug fixes.
Comment #42
dawehnerHere is an initial piece of code which allows you to (optionally) specify a different db connection than the one used by default, which is some form of sqlite.
In order to do that, at least for now, you have to specify an environment variable:
(which can also be done in phpstorm, just in case someone is interested).
Due to using the same prefix as simpletest we can leverage the cleanup functionality of simpletest itself, in case needed.
@berdir
Do you think something like that would be okay?
Comment #43
kim.pepperComment #45
dawehnerFixed the DB connection test.
Comment #46
daffie commentedWhen #2363341: Throw exception in Drupal::service() and friends, if container not initialized yet. lands the patch needs updating.
Comment #47
daffie commentedA first look. Will do more reviewing later. Good work dawehner! :)
We are currently at PHPUnit 4.4
These two parts are also in #2428695: SQLite date handling is wrongly implemented and arguments handling needs override. If we get that committed this patch get a bit smaller. Also the critical issue #2318191: [meta] Database tests fail on SQLite is then fixed.
Do we need this in this issue?
Comment #48
daffie commentedSome more reviewing
Can we create a child issue for the stream wrapper/vfs stuff?
These lines are also added in #2232861: Create BrowserTestBase for web-testing on top of Mink.
Maybe we can also create a child issue for the Drupal/Core/DrupalKernel stuff.
Comment #49
dawehner@daffie
Thank you for your reviews!
So to be clear, there are more failing tests than just the DB tests itself for sqlite. I think we really should solve them as well.
In general, sure, we should extract many of those tiny fixes into subissues, but continuously work on this issue, to have the big picture available.
Comment #50
daffie commented@dawehner: There is a problem with PHPUnit tests and the database connection. The run-tests.sh script creates a database connection and then executes the phpunit command. The problem is that the database connection is lost after calling the phpunit command. #2232861: Create BrowserTestBase for web-testing on top of Mink has the same problem.
Comment #51
daffie commented@dawenher: So we should create an issue for SQLite like #2157455: [Meta] Make Drupal 8 work with PostgreSQL or remove support from core before release.
Comment #52
jibranSo we have
see the full travis result here https://travis-ci.org/jibran/drupal/builds/51709661
Comment #53
daffie commented#2363341: Throw exception in Drupal::service() and friends, if container not initialized yet. has landed. These lines can now be replaced by:
Comment #54
dawehnerJust a reroll with the fixes in #53 and some work on various tests.
Comment #56
dawehnerAfter talking a bit with @alexpott we decided to NOT convert all existing tests over but rather migrate over them.
The only tests which are left:
Comment #58
dawehnerThis should maybe at least get the installer working again.
Comment #60
dawehnerComment #61
neclimdulThis is a big tricky patch to review. Couple quick observations.
This is a weird comment on an untouched file. There are a couple issues looking at slow YAML problems already so I'm not sure its needed. The reference to kernel tests is the sort of thing that would stick around and be cruft long after it was fixed anyways.
undocumented todo and a trailing whitespace.
Comment #62
neclimdul4.5 is the latest stable and core has 4.4.2 so this is at the least outdated
Why are we adding a travis file?
Comment #63
dawehnerThank you @neclimdul
All of those are valid points, let's clean things up.
Comment #64
wim leersCould we add some short docs explaining why these are conditionally defined?
I can imagine why, but we don't want future readers of this code be left wondering why.
Is this change really necessary?
The changes in these files look like they could be done in a child issue. That'd make this patch itself simpler, too.
Another child issue, as also requested in #48.
A reference to KTB in the kernel? That seems weird.
Good catch, but could also be in a child issue.
What would the fix for this look like?
Nit: s/php/PHP/
Nit: 2 instead of 1 \n.
Wow. That sounds like a big DX win for KTB tests!
These begin with verbs, but they're properties, not methods.
s/hierarchy/class hierarchy/
Could use a comment.
No suggestions (is fine), just wanted to say that this looks like dark magic :)
\o/
A @todo and a commented line. Not sure if they're related?
Nit: s/overriden/overridden/
Nit: typehint to string.
Nit: 80 cols, s/sqlite/SQLite/
Patchwork?
That PR was merged a long time ago, so we should be able to fix this todo.
Nit: string[]
I think this can be resolved now also?
Clever!
But let's change it to
string|string[]?That sounds pretty scary, but it's harmless, right? Because if a module is not in the active module list, its hooks aren't invoked etc.?
Wow.
KTBTestboth extends and testsKTB. Not sure what to think of that :DComment #65
phenaproximaRegarding point 26 in #64 -- IIRC, BrowserTestBaseNG (#2232861: Create BrowserTestBase for web-testing on top of Mink) does the same thing, and it seems to work OK :)
Comment #66
dawehnerThank you for your review!
Well yeah, we load bootstrap.inc for the tests, which conflicts with the constants defined by bootstrap.php of our phpunit configuration.
Its needed for VFS support. For example the call to tempnam() doesn't support any kind of streamwrappers.
Well, setContainer() is called by KernelTestBase ... I doubt we can skip that :P
Note: phpunit calls seiralize/unserialize for its internal static magic handling ... which causes the needs for those changes.
Well, I think its fair to document the case of having an already initialized container without a booted one.
... We have some basic test coverage of drupal_render() in the new KernelTestBaseTest ... and they fail due to this bug.
#2208429: Extension System, Part III: ExtensionList, ModuleExtensionList and ProfileExtensionList added a todo.
Same black magic as UnitTestCase :)
We can clean things up here quite a bit.
Rewrote the comment.
Good catch!
We still don't have an interface for QueueFactory, but yeah I think we could partially skip this from the patch, if really needed.
Well yeah. Just imagine some testcode calling $this->enableModules() ... $this->disableModules()
Note: This code is coming from the old KernelTestBase
Comment #67
wim leerss/Move/Change/
WOOT! :)
?
TRUE!
Yes, not questioning that. Just saying we could split it off. Perhaps not worth it for such a tiny fix though.
Overall: what's necessary to push this to the finish line (i.e. get it committed)? Resolve the @todos? Can those be done in follow-ups? Should they?
Comment #70
dawehnerWell, sure, you could say that. I indeed splitted up a lot in the meantime, see #2304461-56: KernelTestBaseTNG™. My idea was to keep those changes which would be needed for many other converted tests, so those conversions could happen in parallel.
Comment #71
dawehnerAdded all the tests we have to convert to the other issue.
Comment #72
kim.pepperRTBC+1 from me, but I think we need Wim and/or neclimdul to review the changes.
Comment #73
dawehnerI think getting feedback from berdir or alexpott would be great.
Comment #74
jibranVery nice work on the patch @dawehner. I went through all the patch mostly I found nits.
More then 80 chars. Is it still pending?
I think we can revert that or make it one line.
Are these still pending?
Another @todo.
Comment #75
dawehnerLast time I checked, this was the case, see :
Oh right, just check the next line of the diff, it points to the corresponding issue already :)]
I killed 2 of them, as they are obvious, the other one is still valid.
Still valid, because this could speed up some things a bit, if we don't install config by default.
Comment #77
dawehnerLet's fix it.
Comment #78
amateescu commentedJust a silly question: was 'verbose="true"' removed intentionally?
Comment #79
dawehnerYes, because @jibran asked for. This was reverted to the status of core.
Comment #80
alexpottI think all the new PHPUnit driven KernelTestBase tests will need to use the
@runTestsInSeparateProcessesannotation since they all potentially load code and this preserves test isolation.See https://phpunit.de/manual/current/en/appendixes.annotations.html#appendi...
Comment #81
alexpottMaybe we can use
https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.preserveGlobalStateto not have this awkwardnessComment #82
fgmAt the same time, running phpunit tests in separate process has a very high cost in terms of test time (quite often an order of magnitude), which may not always be necessary : most tests should not need it.
Comment #83
dawehner@alexpott
I don't see the point why we need to mark all of them like that? If a test causes problem, as it loads code, we can still mark it.
Then we would also have the information that the test is dangerous.
Well, if we set this, we pass over all the various global crap, which we want to avoid, no matter whether its in a separate process or not.
Comment #84
alexpottBut Kernel tests have different modules loaded and you can't unload code. A kernel test is not a unit test.
Comment #85
alexpottAnd if a kernel test does not load any module code it does not need to be a kernel test.
Comment #86
dawehnerAlright.
... I think we should opt the setting in for every test which causes issues, but let's see what happens if we enable it for the two tests we have.
Comment #88
jibranThere are two in complete tests here https://travis-ci.org/jibran/drupal/builds/51709661.
1) Drupal\Tests\migrate_drupal\Unit\source\d6\NodeRevisionByNodeTypeTest::testRetrieval
FakeSelect does not support multiple source identifiers, can not test.
2) Drupal\Tests\migrate_drupal\Unit\source\d6\NodeRevisionTest::testRetrieval
FakeSelect does not support multiple source identifiers, can not test.
Comment #89
dawehnerSo is it in HEAD and nobody cared forever.
Comment #90
jibranI really don't have an answer to that.
Comment #91
pfrenssenThere is an issue for those two incomplete tests: #2299795: Fix migrate NodeRevisionTest & NodeRevisionByNodeTypeTest. Wouldn't that actually be critical?
Comment #92
vijaycs85#89 it's because marked explicitly as incomplete:
and
We need #2299795: Fix migrate NodeRevisionTest & NodeRevisionByNodeTypeTest
Comment #93
dawehnerTo be clear, we don't need that at all here, the testbot ignores that now, so will it in the future.
Let's please focus on this issue.
Comment #94
mile23Incomplete tests are not critical.
+1 on #81 in spirit... Not sure we should use separate processes, however. The solution is that we shouldn't do things this way. :-) We should make an object similar to Symfony's Client class which encapsulates the kernel and all its dependencies. Then saying $client = NULL solves the problem. However, since we're basically making a SimpleTest compatibility layer we can't really do that.
Some stuff:
Create a separate bootstrap file which defines these constants, and other constants needed by both testing systems and the front controller and other systems. As bootstrap.inc is eroded away in favor of OOP, the bootstrap you create here will grow.
(The problem with bootstrap.inc is that it defines both constants and functions. Separate these concerns.)
+1 on a separate suite. -1 on having it in a Kernel directory per the @todo. Instead use or whatever better file suffix you'd like.
This makes me happier than you can understand.
Is there an issue for this, either way? That is: Either to invoke preHandle() or finalize the deprecation of legacy dependencies?
Comment #95
neclimdul1) #2459155: Remove REQUEST_TIME from bootstrap.php
Comment #96
dawehnerThank you for the great feedback @mile23!
Can you explain why you dislike a separate directory? Note: We already have the unit tests in
tests/src/Unit/...for modules,why should we not follow that scheme for kernel tests? I think its also a great idea in general to make it clear that things aren't unit tests but more integration tests. Doing that as part of the namespace seems to be, at least for me, a good solution for the problem.
Well, feel free to create one, I'm not aware of one yet.
Comment #97
dawehnerLet's give the reroll a try.
Comment #99
dawehnerLet's fix failures!
Comment #100
neclimdulIf you do lets go for the later rather then the former. preHandle() is connect to handle() not to boot() as is suggested by the name so lets not change that. boot's responsibility is suppose to be the most basic of tasks, mostly just getting a container. You should be able to boot a kernel and interact with that container without triggering those heavy legacy processing or doing any significant "bootstrapping". IMHO, anything in preHandle() is de facto deprecated as all "bootstrap" behaviors should be in the container going forward.
Comment #101
xanow00t!
As requested before in #64 and #81, could this be documented or worked around? E.g. in which (valid) cases would this constant already exist?
It is unclear why this check is performed, especially because
DrupalKernel::serviceProviderClassesdoes not sufficiently document its structure.Is this just a warning to inform people about the order of actions that are to be taken by them, or should we document
DrupalKernelInterface::boot()that is throws an exception if no container is set?I wonder if the introduction of a second queue factory warrants the introduction of a
QueueFactoryInterfaceas well.Does this apply to any stream path?
IIRC, we use
@todoand not@fixmein Drupal.Really lovely :)
This comes across a little confusing, because this is in
KernelTestBase. I think this needs at least a better definition of what constitutes kernel tests, like do they use or test the kernel?Comment #102
dawehnerIt would be great to streamline all that!
I hope you don't want to do that before this issue, given the explained fact that KTB does the same already. Here is a follow up: #2467021: Make it possible to just use Kernel::boot() and not require preHandle
Thank you @xano for you review! I'm ghat that is not a academic project but rather something people actually care about.
Ha, here is a typo!
Now, we at least for now, don't need that any longer. We might have to convert more uses of DRUPAL_ROOT once we do more tests.
Alright, let's document it.
Well, I think if someone does, its pretty obvious that it happens, isn't it?
Let's open an issue for that: #2467039: Add a QueueFactoryInterface
Well, ... its every non local stream wrapper, and VFS is kinda not a local stream wrapper.
Good point. @fixme is about something which blocks the commit.
Yeah, most of the patch is coming from sun, also that really nice solution!
What about rewriting the documentation in that way?
Comment #103
xanoSome documentation improvements.
Comment #104
dawehnerThank you @xano!
Comment #105
neclimdulReroll. go go functional tests!
Comment #106
neclimdulI'm not sure if run-test will pick up these tests after the run but i think it might. Worth a shot.
Comment #107
neclimdulI'm getting :memory: files in my filesystem. not sure this is working as intended.
Comment #108
dawehner@amateescu just explained me what is going on:
... in previous versions of the patch though, we did not executed subprocesses for tests. Now we though do, due to the request of alexpott.
Given that we should remove that :memory: bit.
... even more, alexpott required us to always specify the database ... as everything else would be too much magic. Instead we should
add a handbook page on drupal.org how to setup your IDE / phpunit to run theme properly, by specifying the environment variable.
Comment #109
wim leerss/for allowing/to allow
Does comment #108 mean this can/should be removed from the patch?
Nit: missing leading backslash.
Nit: This todo could be clarified: will this be solved as part of that linked issue, or is that merely an explanation of why this is necessary?
Interesting that this doesn't get assigned to anything.
Kinda strange that core cares about a specific contrib module?
Nit: s/need/must/
s/Back-up/Back up/
s/array()/[]/
s/createFromRequest/createFromRequest()/
This looks also affected by the
:memory:stuff in #108.s/array()/string[]/
Again #108-related.
Follow-up? Here?
Again #108-related.
_theme()doesn't exist anymore.Nit: could call the service directly.
Follow-up or here?
Comment #110
dawehnerRewrote the database handling to not have a default DB anymore but rather always require a SIMPLETEST_DB_URL to be set.
Removed it from the patch, we can come back to those memory implementations later again.
IMHO that todo explains it. ModuleInstaller() calls to system_rebuild_module_data() which is part of system.module. What is hard to understand here?
Its how it is.
Feel free to open up an issue for that, its in core already ...
What about removing the todos? Here is a follow up: #2480055: Provide a config specific kerneltestbaseNG base class
Comment #111
Crell commentedHoly Carp, this issue!
If this is actually needed, just use ContainerAwareInterface/ContainerAwareTrait. Interfaces can extend interfaces just fine.
Comment #112
mile23Might want to wait on this, I think: #2389811: Move all the logic out of index.php (again)
Comment #113
dawehnerInteresting idea ...
As we are just interfering with the way how the container is build, this should not affect that particular issue.
Comment #116
dawehnerThe patch is green ...
Comment #117
larowlanShould this also update the global Drupal singleton?
Can we/should we limit this to an interface? e.g (is_object($class) && $class instanceof SomeInterface)
:) one day
Should we align this with the SIMPLETEST_DB_URL used by BrowserTestBase? Alternatively a followup to make it to the line with the convention here.
love it
c/p error?
Missing docblock
Anyway we avoid these new uses of DRUPAL_ROOT?
Can we document why we went with private - to prevent someone inadvertently changing it later?
Is there a reason we went with self here and not static? Would a child-class ever want to change the implementation?
Early reference used a different environment variable - is this intended? If so can we document the difference.
<3<3<3 this doco
Should we check if $modules contains 'path' before doing this? Does this mean we can't test path with this base class. If so, should we document that.
This will be ignored, see PhpassHashedPassword::enforceLog2Boundaries which is called in PhpassHashedPassword::__construct - maybe we should create a sub-class with a different enforceLog2Boundaries method?
Should we move this to a trait instead of duplicating (already exists on TestBase)?
This is duplicated from elsewhere too - should we have a trait?
Referenced PR is closed - so do we need to update this - or do we need a new reference?
This contradicts itself. If the class no longer exists - why are we checking for it?
Does this predate PSR3?
nit - most of the methods here need {@inheritdoc} but meh
Comment #118
dawehnerDoesn't
Drupal\Core\DrupalKernel::initializeContaineralready do that, which is part ofDrupalKernel::boot()Well, it would be one of two interfaces potentially, but sure, let's check it.
Ups right, well, tests passed locally because I still had the right env variable setup, and testbot uses run-tests.sh which passes the stuff along differently.
yes.
Sure we can fix that.
Well, i'm pretty sure I know why this approach was chosen in the first patch of sun. We want to ensure that Drupal runs with the limited setup code needed and not more.
Every additional needed dependencies should be part of the container / be done in clean ways so in case you would have to override it, we would sacrifice the future of having a specific limited amount of code to setup Drupal but instead
would end up again with more / unspecified setup code.
Well, not if you just call it from a private method anyway ...
There is no difference ... just a user error.
This is a direct c&p from the old kernel test base.
What about moving this into its own component? This could be useful for itself.
At least the method name just exists one, do you know where its coming from?
Not sure
Good catch, well with that we talked about old versions of PHPUNIT, let's replace the usages with trigger_error directly as well.
Well the problem is that PSR3 uses different constants as pretty much everything else, well for now this is not needed as part of the patch, as we removed the logger integration.
We also don't need it for now ...
Comment #119
jibranForm https://travis-ci.org/jibran/drupal/jobs/61527372 PR is at https://github.com/jibran/drupal/pull/1
Comment #120
dawehnerOh wow, thank you @jibran!
Comment #121
jibranAll good now https://travis-ci.org/jibran/drupal/jobs/61595149
Comment #122
jibran#118 didn't fail. Is it alarming? Do we need a follow up to fix it?
Comment #123
dawehnerWell, I fear you are right, those tests seems to be ignored at the moment by testbot, seriously, how did that changed
Comment #124
dawehner... this problem got introduced by #2304461-106: KernelTestBaseTNG™ the only patch without an interdiff :( :( :( The general change wasn't bad, functional tests also had its new place for \Drupal ...
Anyway figured it out now.
Comment #127
jibranReroll
Comment #128
jibranComment #130
jibranSo, I messed up the reroll :(
We need a beta evaluation and change notice.
Comment #131
dawehner@msonnabaum and myself discussed the process isolation a bit. Given that its a flag in phpunit itself, you can set it locally to run tests faster (I hope this is the right).
@jibran
Thank you for your try to reroll.
Tried at well, and now its at least green
Comment #132
dawehnerHa, and this time with a patch.
Comment #134
dawehnerFixed the failure by applies changes to KernelTestBase to thew new one.
Comment #135
jibranInterdiff is from #2465887-21: Extract the install/uninstall functionality to a ThemeInstaller :(
Comment #136
tim.plunkettThis is kinda odd to me, but I guess it works.
Nice use of traits here and elsewhere.
Side-note: everytime I read "org\bovigo" I think of "Oingo Boingo". Anyone else?
If you reroll, this second line should be indented 2 more spaces.
+1
TestTestTest
Weird that you remove one, but not the other four instances of that...
I know this is the same name as regular KTB, but it's really installModules()
Nice!
Ooh what is this syntax?
Missing @return docs
Also, shouldn't we put a note on \Drupal\simpletest\KernelTestBase pointing to the new one, and perhaps deprecating it?
Still needs a CR.
Comment #137
tim.plunkettAddressing my own review with @dawehner at the DrupalCon LA sprint.
4) Fixed
7) This is a bad change. Without that flag, an element could be run through getInfo() multiple times (for example in FormBuilder and Renderer), and I've restored this behavior.
10) Used standard syntax instead
11) Fixed
Since these are reverts and docs fixes only from me, I feel comfortable RTBC-ing this. @dawehner is writing the CR right now.
Comment #138
dawehnerAdded a change record, tim, you have the honor for the final patch
Comment #140
dawehnerQuick reroll
Comment #141
alexpottNot used
Is this discussed anywhere on issue? I think it is an open question which LTS version of Drupal 8 we should have all the Simpletest based kernel test base tests converted. How tricky do we imagine this will be?
Not used
Does not exist
None of this is used
Nice - I didn't know this was possible - we should have a followup to do the same for BrowserTestBase. And @dawehner thank you for leaving this in. Regardless of the debate about whether this is correct the fact that run-tests.sh runs every test in a separate process means that at least this is making the PHPUnit runner behave the same way.
Is there a followup already existing?
Untested and unused.
Comment #142
hussainwebAddressing 1, 3, 4, and 5.
About 8: It seems this method is copied verbatim from
\Drupal\simpletest\TestBase. I couldn't find a test for the method in that class as well. If I am not wrong, since this class is meant to be an equivalent, I am not entirely sure of removing this method. I guess it still needs tests. I am still switching to Needs review to trigger the testbot. Feel free to switch back.Comment #143
dawehnerThank you @hussainweb for fixing the review!
Thank you @alexpott for reviewing this patch!
Well yeah I don't care about the concrete version, but you can always push it to a higher version in the future, can't you? You threw out that particular version number ...
Well, have a look at the earlier versions of the patch, there are some stuff needed but not too much.
Yeah, let's simply tell people how they can speed up their tests locally by factor 3.
No :P
You could move it to a a common trait. But yeah I don't think that this issue should be responsible for adding test coverage for it.
There we go: #2494735: add $runTestInSeparateProcess = TRUE for BrowserTestBase
Comment #144
fabianx commentedBefore we do get this in, we should be addressing some of chx' concerns on PHPUnit as a test runner in general - especially regarding debuggability (#2469731-5: Document when to use BrowserTestBase).
Some have been related to how mocks work - which is less important for integration tests.
But one strong point was how assert* works and I agree with that.
Could we have one common base class that both our UnitTestCase and KernelTestBase NG base classes derive from and then create some issues to increase the debuggability of assert*() by providing our own similar functions as overrides?
Apologies if this is already done, have not checked the patch too much, yet.
Could we open an upstream issue if PHPUnit could change to native namespacing (PSR-0 / PSR4). It is currently severely polluting our class map ...
I am just ensuring those arguments are not forgotten before we deprecate the simpletest way.
Comment #145
dawehner@hussainweb
Do you want to address the other points according to my comment?
Feel free to open up an actual issue for that. IMHO this does not belong here and can be done independently from it.
Comment #146
dawehnerRegarding that point there seems to be an issue: https://github.com/sebastianbergmann/phpunit/issues/1137 ... It seems to be an issue for PHPUnit 5.0.x
Comment #147
fabianx commented#145: I checked now:
What does belong here is that we don't extend KernelTestBase from \Unit_Test_Case, but from our own base class.
If we can change the "parent" class later and introduce an intermediate class, then no problem, just ensuring it won't block us in the future.
Comment #148
fabianx commentedOpened #2495607: Improve PHPUnit debuggability and performance I think we might be able to get quite some performance improvements from this, too :).
Comment #149
dawehnerWell for sure, bringing in an intermediate subclass is by no means an API change.
Can we please now focus back and get the patch in?
Comment #150
dawehnerCreated one: #2496109: Replace all usages to deprecated methods on KernelTestBase(NG)
Let's remove it for now and add it back, when we convert the tests
I think the feedback of alexpott got addressed, so back to RTBC?
Comment #151
tim.plunkettThe only thing that wasn't 100% resolved was the promise of "will be removed before Drupal 8.2.x".
This is our first time referring to 8.[1-9].x in the code base, I think it's a realistic goal.
I don't think saying "will be removed before Drupal 8.y.x" is a fair thing to do :) and no real reason to wait until 9.0.x.
Comment #152
alexpottBye bye DRUPAL_ROOT <3
There are still 3 usages of glob iterator in core.
This change looks extremely dodgy and dangerous change.
I think we should prevent changing the container once it is set no or the kernel is booted?
Lets optimise for the regular
class_exists($class)code path by putting it first.(obviously) can be removed. If it so obvious why comment? :)
Yay! Can we get a followup to use this in BrowserTestBase please?
Lots and lots of space! Also you've implemented the Trait but not removed the methods - weird.
Why can't we still just enable the system module?
Tests with no assertions fail with strict PHPUnit testing
d.o issue?
Is this two strategies for the same thing?
Why is this necessary - and clashes will happen so what's will go wrong? In TestBaseTest we ensure that this is unique.
This feels like this is duplicated code. Yep we can use
Database::convertDbUrlToConnectionInfo()- no? Ah it looks like that is already being used - so this can be removed :)This code already exists in BrowserTestBase. Maybe KernelTestBase and BrowserTestBase should share a common base class... what with the random stuff there seems to be a case for this.
Shall we trigger a warning ala Symfony to help users migrate?
Something else that could be shared with BrowserTestBase - it does not currently have this functionality.
Hmmm really? Should we be supporting these - and if so until when if it is 8.0.0 then well they should never exist.
Let's do this then.
Comment #153
fabianx commented#152.4: Agree, if we need a new container in the kernel, we should boot a new kernel instead and use that, IMHO.
Comment #154
dawehnerRemoved the other instances.
Let's revert that and see how much breaks.
Sure, let's do that.
Totally fair point. I hate when people use straightforward, obviously, and what not.
There we go: #2499199: Use RandomGeneratorTrait in BrowserTestBase
Probably caused by some random merge misstake ...
Good point, let's move that into a protected static method.
Oh yeah that API function was added rather recently.
Let's try to not introduce too much hierarchy but instead use a Trait as well ...
Decided to go with a follow up for that. For example DRUPAL_ROOT vs. $this->root etc. ... #2499207: Unify BrowserTestBase::changeDatabasePrefix() and KernelTestbase::getDatabaseConnectionInfo() into a DataBaseTestTrait
+1
Well, see it as BC layer as well ... i think this will make it easier to convert the existing tests ... :)
Comment #156
dawehnerLet's fix it.
Comment #158
dawehnerBack to green.
Comment #159
jibranNits more then 80 chars.
Comment #160
dawehnerThere we go.
Comment #161
jibranAll is well at https://github.com/jibran/drupal/pull/1. Found #2454439-112: [META] Support PHP 7 while testing ;-).
Let's get @alexpott's feedback on this.
Comment #164
jibranComment #165
alexpottIs this BC layer actually worth it? We're saying that we're going to remove before 8.0.0 but nothing is going to use it by then...
Same for this...
And this... perhaps it makes sense to leave them in till 9.0 - i dunno. The only thing i do know is that adding it now and removing before 8.0.0 makes no sense.
Comment #168
dawehnerWell, it makes it easier to convert existing tests because we throw some helpful information ... What about not promising anything via @deprecated and always throw an
\Exceptionand then remove it at some point before 8.0.x?Comment #169
jibranI think removing this all together is a good idea we can update the change record to mention these changes.
Comment #172
dawehnerRemoved the BC layers, as alex requested ...
Went with 8.2.x to be more in parallel with the old KernelTestBase
Adapted the PR
Also fixed the failing test ... thank you @jibran for the resending :)
Comment #173
jibranThanks for the fixes patch looks good now.
Comment #174
dawehnerJust some ordinary rerolling.
Comment #175
alexpottComment #176
hitesh-jain commentedComment #177
hitesh-jain commentedRerolled the patch to Latest Release.
Comment #178
fabianx commentedComment #179
hitesh-jain commentedLet the Test Request on the new Reroll patch be completed . Changing to Needs review.
Comment #180
jibranIt can be completed after the RTBC as well. Thanks for the reroll.
Comment #181
jibranIt can be completed after the RTBC as well. Thanks for the reroll.
Comment #182
neetu morwani commentedComment #183
neetu morwani commentedComment #184
hussainwebI almost set this to 'Needs Review' because there seems to be a significant difference in size between patches in #174 and #177. I applied and generated a patch using
-Mwhich showed the changes clearer, and it is indeed RTBC. I am just leaving a note for anyone who finds the same issue in the patch.Comment #185
dawehnerThank you @hussainweb that you mentioned it.
Just for completion here is also a small variant of the patch.
Git is not bad ...
Comment #187
phenaproximaComment #188
dawehnerRerolled
The interdiff shows the conflict resolution.
Comment #189
jibranBack to RTBC.
Comment #190
jibranPHPUnit tests results https://travis-ci.org/jibran/drupal/builds/69380185 all green.
Comment #191
fabianx commentedRTBC + 1
Comment #193
jibranComment #194
naveenvalechaFirst Thanks to jibran for helping me in IRC with this issue and for the nice tips :)
local tests result
Comment #195
jibranI believe $is_recursive_call is not defined so we can remove that from the call.
Comment #196
naveenvalechaMinor fix as specified by @jibran in #195
Note : The attached interdiff in this comment is of #194 and #196
Comment #197
jibranThanks for the reroll @naveenvalecha. This looks good.
Comment #199
dawehner+1 for the fixes ...
Comment #201
amateescu commentedYARR! (reroll for a small patch context change)
Comment #202
naveenvalechaRTBC +1 Bot showed green https://www.drupal.org/node/2408985#comment-10096548
Comment #203
alexpottI think we need to consider the release implications of committing this. At the very least the change notice be updated to say that we should not do any conversions until 8.0.0 is out in the same way that https://www.drupal.org/node/2469723 does for BrowserTestBase. The current CR could do with some finessing, also I think we need to identify old CR's to update. We also need to set expectations for what people do with new patches once this patch has been committed.
Comment #204
dawehnerWell, the difference though is that KTBNG actually implements all of KernelTestBase, unless BrowserTestBase which does not do that.
I am totally fine with updating existing CR's and what not, but waiting, I am not convinced by that.
Comment #205
dawehner@alexpott and myself talked about this.
We come to the follow conclusion:
Comment #207
phenaproximaFixing the test failure...
Comment #208
jibranPerfect back to RTBC.
Comment #211
tim.plunkettComment #213
dawehnerWelcome to the next month.
Comment #215
dawehnerResolved the next conflict.
Comment #217
neclimdulThe rest of the #2538260: Set CURLOPT_SAFE_UPLOAD to TRUE in Simpletest's CURL options diff. should be green again.
Comment #218
phenaproximaNice.
Comment #220
dawehnerWhat about committing it one day?
Comment #221
catchfwiw I think this is fine with caveats in #203 - i.e. commit it now so it's available, don't do mass conversions until after 8.0.0 is tagged. The testing system is unfrozen during beta and there's zero disruption here if we don't convert all the things.
Comment #222
dawehnerCritical fix to the issue title.
Comment #223
phenaproximaIt works!
Comment #224
alexpottSaving the credit field.
Comment #225
alexpottSo I'm not sure that #12 has ever been properly answered. Atm we're able to run the simpletest kernel test base classes against sqlite, mysql and postgres - this finds bugs. This class only runs against sqlite. Which also makes sqlite required for running the test suite. This is a new requirement.
Comment #226
alexpottIf we enable string PHPunit these tests will fail no? There's no assertion. in either of these tests.
Comment #227
alexpott@dawehner have you successful debugged a test we this option on?
Comment #228
dawehner@alex
This will always work, because you don't have an HTTP request in the middle. As long you said the corresponding environment variables you don't have problems with getting that information into xdebug. I tried it out, by changing my usual workflow of starting with "xdebug on".
Comment #229
dawehnerThis was obviously just a test ;)
Comment #230
alexpottSo the xdebug thing I commented on is something in my PHP5.6 environment. So the only remaining question for me is the point @Berdir raised in #12 and I repeated in #225.
Comment #231
dawehnerSorry for not answering the question, totally forgot about it.
This statement is no longer true with the patches since quite a while. You have to set the SIMPLETEST_DB environment variable.
This is how I run the tests for example:
Comment #232
alexpottDrupal\KernelTests\KernelTestBaseTest
Also I think perhaps we should move AssertLegacyTrait and KernelTestBase to Drupal\KernelTests since Drupal\Tests is the preserve of unit testing.
Currently checking out #231. But I think
SIMPLETEST_DBneeds documenting somewhere (I might have missed it)Comment #233
alexpottI can confirm that #231 is correct - with a
SIMPLETEST_DBwith a mysql connection it is using mysql.Comment #234
dawehnerWell, this patch is doing exactly the same as BrowserTestBase which is throwing an exception:
Let's change the CR to include a simple snippet, see https://www.drupal.org/node/2489956/revisions/view/8692550/8787981
Moved also the files around.
Comment #235
alexpottThanks @dawehner I think this is ready :)
Comment #236
benjy commentedooo, exciting! Great work.
Comment #237
benjy commentedBack to RTBC
Comment #238
alexpottWith BrowserTestBase and now this we can move away from Simpletest during the 8.x cycle. Nice work everyone, especially @dawehner for sticking with it. Committed d582139 and pushed to 8.0.x. Thanks!
Comment #240
dawehnerThank you sun for the initial heroic work.
Comment #241
fgmThis is great. Thanks all for pushing it to completion.
Comment #242
xanoShould we update the change record to encourage people to add
@coversannotations as part of straight conversions?Also, and I may be wrong here, I am getting errors during
KernelTestBase::setUp(), becauseFileCacheFactory::setPrefix()is never called. I couldn't find anything about this in the patch, so maybe there's something wrong in my code. Does this ring a bell?Comment #243
wim leersCongratulations and many thanks to sun & dawehner!
Comment #244
dawehnerStraight conversions are straight conversions. Adding additional stuff is not a straight conversion anymore ...
It doesn't do for me, feel free to research it.
Comment #245
xanoI opened #2553033: KernelTestBase does not install contrib dependencies on testbots for a bug I found when using this in contrib.
Comment #246
alexpottDiscovered #2553533: KernelTestBaseTNG™ is not cleaning up after itself
Comment #247
chx commentedI do not even need to write anything, these two still apply:
#2469731-5: Document when to use BrowserTestBase
#2232861-273: Create BrowserTestBase for web-testing on top of Mink
Comment #248
mile23Added: #2554185: Tests should skip if they don't have a dependency, not fail.
Comment #249
klausi@Xano: did you ever find out what the "InvalidArgumentException: Required prefix configuration is missing" from FileCache is about? This happens during test setUp(), experiencing it when trying to port the Rules kernel tests.
Comment #250
xanoFileCacheFactoryrequires a prefix to be set. This normally happens during a kernel bootstrap. I did a quick look throughKernelTestBaseand it looks like the kernel is never bootstrapped directly. However,::getCompiledContainerBuilder()can bootstrap the kernel, but this method is only called for tests run in isolation. See::bootKernel(), line 318.Comment #251
dawehnerSee #2553661: KernelTestBase fails to set up FileCache which depends on #2553533: KernelTestBaseTNG™ is not cleaning up after itself
Comment #252
klausiOK, got this now working with a small FileCache hack for Rules: https://github.com/fago/rules/pull/224/files
Comment #253
dawehner@klausi
Yeah sorry that we did not enabled any module in the tests, well, this was chosen as we should not convert any test. Clear mistake, to not even try it out once.