aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/jobqueue/JobQueueTest.php
Commit message (Collapse)AuthorAgeFilesLines
* Namespace all remaining files in includes/jobqueueJames D. Forrester2025-03-201-1/+6
| | | | | Bug: T353458 Change-Id: I95690a312e356c45dbeed607d32fb0e4626690cf
* Add namespace to remaining parts of Wikimedia\ObjectCacheJames D. Forrester2024-09-271-0/+1
| | | | | Bug: T353458 Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
* tests: Remove unused JobQueueTest::$keyUmherirrender2024-09-051-2/+0
| | | | | | Added unused in 9cc7e6a39a Change-Id: I217b9c906972c1f335e8e7d2b340e86a4d92c5a1
* Add namespace to the root classes of ObjectCacheEbrahim Byagowi2024-07-101-0/+1
| | | | | | | | | And deprecated aliases for the the no namespaced classes. ReplicatedBagOStuff that already is deprecated isn't moved. Bug: T353458 Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* tests: Fix PSR2.Classes.PropertyDeclaration.Multiple errorsTaavi Väänänen2024-04-221-1/+7
| | | | Change-Id: Id4ac60a713391cf6360ff1995f20da94012ac1a0
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-161-1/+1
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Replace more instances of unchecked MWExceptionDaimona Eaytoy2024-01-231-6/+1
| | | | | | | | Most (all?) of the remaining usages are caught somewhere and will be migrated later. Bug: T328220 Change-Id: I5c36693a5361dd75b4f1e7a0bab5ad48626ed75c
* Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessaryJames D. Forrester2023-11-211-2/+0
| | | | | Bug: T342301 Change-Id: I5ea01f7ee103570165261bde0965c5b65e04c369
* JobQueue: Drop getWiki(), deprecated in 1.33James D. Forrester2023-08-241-16/+0
| | | | Change-Id: I38fdaf0cd8ca98534dcbf64e13925138f8174a0d
* Replace usages of deprecated MWExceptionDaimona Eaytoy2023-06-061-1/+1
| | | | | | | Use SPL exceptions instead when the exception is unchecked. Bug: T328220 Change-Id: Ia1e5edc2ef3269a44b670262b78b305d07559829
* objectcache,resourceloader,rdbms,jobqueue: Widen @covers annotationsTimo Tijhof2023-04-101-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follows-up I4c7d826c7ec654b, I1287f3979aba1bf1. We lose useful coverage and spend valuable time keeping these accurate through refactors (or worse, forget to do so). The theoretically "bad" accidental coverage is almost never actually bad. Having said that, I'm not removing them wholesale (yet). I've audited each of these specific files to confirm it is a general test of the specified subject class, and also kept it limited to those specified classes. That's imho more than 100% of the benefit for less than 1% of the cost (more because `@covers` is more valuable than the fragile and corrosive individual private method tracking in tests that inevitably get out of date with no local incentive to keep them up to date). Cases like structure tests keep `@coversNothing` etc and we still don't count coverage of other classes. There may be a handful of large legacy classes where some methods are effectively class-like in complexity and that's why it's good for PHPUnit to offer the precision instrument but that doesn't meant we have to use that by-default for everything. I think best practice is to write good narrow unit tests, that reflect how the code should be used in practice. Not to write bad tests and hide part of its coverage within the same class or even namespace. Fortunately, that's generally what we do already it's just that we also kept these annotations still in many cases. This wastes time to keep methods in sync, time to realize (and fix) when other people inevitably didn't keep them in sync, time to find uncovered code only to realize it is already covered, time for a less experienced engineer to feel obligate to and do write a low quality test to cover the "missing" branch in an unrealistic way, time wasted in on-boarding by using such "bad" tests as example for how to use the code and then having to unlearn it months/years later, loss of telemetry in knowing what code actually isn't propertly tested due to being masked by a bad test, and lost oppertunities to find actually ununused/unreachable code and to think about how to instead structure the code such that maybe that code can be removed. ------ Especially cases like LBFactoryTest.php were getting out of hand, and in GlobalIdGeneratorTest.php we even resorted to reminding people with inline comments to keep tags in sync. Change-Id: I69b5385868cc6b451e5f2ebec9539694968bf58c
* Reorg: Migrate WikiMap to WikiMap/ out of includesAmir Sarabadani2023-02-271-0/+1
| | | | | | | And WikiReference Bug: T321882 Change-Id: I60cf4b9ef02b9d58118caa39172677ddfe03d787
* Avoid deprecated usage of `Job::factory()`Derick Alangi2023-01-251-4/+20
| | | | Change-Id: Ia2b8b71159ed8d387ae31f921ddcfd0d9136118c
* tests: Handle dynamic created properties on test classesUmherirrender2023-01-131-1/+1
| | | | | | | | | - Declare missing properties - Remove unused or avoid set of properties - Add AllowDynamicProperties Bug: T314099 Change-Id: Ie631894f2ffbb616f6dd09851405d681f3eb8fcd
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-1/+1
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* Replace usages of deprecated wfWikiID()Alexander Vorwerk2021-12-211-1/+1
| | | | | | | | The global function wfWikiID() is deprecated since 1.35 and it's usages should be replaced with WikiMap::getCurrentWikiId(). Bug: T298059 Change-Id: I22d96b7aec17323d15a9bc401d4511ad2ee14165
* build: Updating dependencieslibraryupgrader2021-07-221-2/+2
| | | | | | | | | | | | | | composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 The following sniffs now pass and were enabled: * Generic.ControlStructures.InlineControlStructure * MediaWiki.PHPUnit.AssertCount.NotUsed npm: * svgo: 2.3.0 → 2.3.1 * https://npmjs.com/advisories/1754 (CVE-2021-33587) Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
* Hard deprecate JobQueue::getWikiDannyS7122021-04-081-0/+3
| | | | | | Deprecated since 1.33 and unused Change-Id: I1ee72782facc0c0e432128bd9abf5bbb90f59a4b
* More misc test cleanupDannyS7122020-12-241-7/+3
| | | | | | | | | * parent::setUp() should be first, and ::tearDown() should be last * Move tests that directly extend PHPUnit\Framework\TestCase to /unit Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
* MediaWikiTestCase to MediaWikiIntegrationTestCaseaddshore2020-06-301-1/+1
| | | | | | | | | | | | | The name change happened some time ago, and I think its about time to start using the name name! (Done with a find and replace) My personal motivation for doing this is that I have started trying out vscode as an IDE for mediawiki development, and right now it doesn't appear to handle php aliases very well or at all. Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
* build: Bump mediawiki-codesniffer to 31.0.0Daimona Eaytoy2020-05-301-6/+6
| | | | | | | | | Done with `composer fix` and suppressing the rest (i.e. sniffs for global variables, which for core should be suppressed anyway). Additionally, add `-p` to `phpcbf`, as otherwise it just seems stuck. Change-Id: Ide8d6cdd083655891b6d654e78440fbda81ab2bc
* Make use of PHPUnit's assertCount feature where possibleThiemo Kreuz2020-03-021-2/+2
| | | | | | | … and avoid assertEmpty() on arrays, in favor of a much more strict assertSame( [] ). Change-Id: I20266b0b1fc38a3a87666ba1b0793cb2b37d94a9
* Move UIDGenerator code to a service and put it under /libsAaron Schulz2020-02-181-0/+2
| | | | | | All MediaWiki dependencies have been removed or injected. Change-Id: I01c9e96edd6b03496c1595670967ffa5a4069c9d
* Manual fix of the remaining assertInternalType & Co.Daimona Eaytoy2019-12-151-1/+1
| | | | | Bug: T192167 Change-Id: I3b8176745f49b1d4bfe6f36978b7879d546f68a9
* tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-301-2/+2
| | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* Add public as visibility in tests folderUmherirrender2019-10-101-3/+3
| | | | | | | Add public, protected or private to function missing a visibility Enable the tests folder for the phpcs sniff Change-Id: Ibefce76ea9984c47e08c94889ea2eafca7565e2c
* tests: Prefer assertSame() when comparing the integer 0Thiemo Kreuz2019-09-191-19/+19
| | | | | | | assertSame() is guaranteed to not do any type conversion. This can be critical when acciden tially comparing, for example, 0 to 0.0. Change-Id: Iffcc9bda69573623ba14af655dcd697d0fcce525
* Remove unnecessary semi-colonsDerick Alangi2019-06-121-1/+1
| | | | Change-Id: I9eb65bdfbd3aa581effc14ead801b9e89b0359c3
* tests: Remove use of wfRandomString() for test fixturesTimo Tijhof2019-05-061-2/+1
| | | | | | | | | | | | | | | | | | | | | | | This reduces confidence in the test. There is no guruantee that it won't return the same value twice during the duration of a full PHPUnit run of all test suites, whether twice in a row or 20 minutes apart. For a test that needs a string of any kind, use an explicit, consinstent and cheap literal value. For a test that specifically needs some kind of uniqueness compared to something else within the same test case, do so explicitly. Tests that require something globally unique (for some undefined/vague definition of "global") were not found, and should not exist anyway. Also, in libs/objectcache tests, fix order of parameters in some assertions (expected first, then actual), and use assertFalse/assertSame instead of assertEqual for cases where false is expected to remove tolerance of other loosely equal values. Change-Id: Ifc60e88178da471330b94bfbf12e2731d2efc77d
* jobqueue: add GenericParameterJob and RunnableJob interfaceAaron Schulz2019-04-081-2/+2
| | | | | | | | | | Simplify the code of jobs that do not care about titles and removes the direct Title dependency from JobQueue. Remove getTitle() from IJobSpecification itself. Move all the Job::factory calls into a single JobQueue::factoryJob() method. Depends-on: Iee78f4baeca0c0b4d6db073f2fbcc56855114ab0 Change-Id: I9c9d0726d4066bb0aa937665847ad6042ade13ec
* jobqueue: dependency inject more objects into JobQueueAaron Schulz2019-04-041-0/+2
| | | | | | | Also moved some WikiMap/$wgJobClasses checks to JobQueueGroup::pop which is the method callers are supposed to use. Change-Id: I2ab82d8adc4ae1f54697d2935afa2053539cf2db
* Make WikiMap::isCurrentWikiDbDomain() more rigorousAaron Schulz2019-03-291-2/+5
| | | | | | | | | This already requires a DB domain ID, so there is no reason to have hacks for trying to handle a wiki ID being passed in instead. If the provided domain has a schema, it should not simply be ignored in the comparison. Change-Id: I9ced7a46fa05f32843a9a7d17391c5d0576b099c
* Use DB domain in JobQueueGroup and make WikiMap domain ID methods stricterAaron Schulz2018-11-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | Using domains means thats JobQueueDB has the right value to use for calls like LoadBalancer::getConnection(). The full domain includes the schema in the case of Postgres. This makes calls to getConnection() less awkward by not relying on the fallback logic in reallyOpenConnection() for null schemas. Make getWikiIdFromDomain/isCurrentWikiDomain account for the schema if it is both defined and is not simply the generic "mediawiki" schema MediaWiki uses by default. If all wikis use the default schema, the wiki IDs can get by with DB/prefix alone, which various config and methods may be built around. Otherwise, the config callbacks must account for schema and the config must include it in various wiki domain ID lists to properly disambiguate wikis. Also, clean up SiteConfiguration::siteFromDB() since it is not meant to handle schemas unless the callback method was taylored to do so. Finally, add more comments to DefaultSettings.php about already existing limitations of wiki domain IDs and their components. Change-Id: I8d94a650e5c99a19ee50551c5be9544318eb05b1
* rdbms: rename CONN_TRX_AUTO constant to CONN_TRX_AUTOCOMMITAaron Schulz2018-04-121-1/+1
| | | | | | | | | | | | The "AUTO" means AUTOCOMMIT, not "automatic transactions"/DBO_TRX, which is basically the opposite concept. The new name does not suffer from that ambiguity. Keep the old constant as an alias for backwards compatibility. Also remove LoadBalancer comment about non-existing field Change-Id: I63beeb061fc9be73f320308e4d6393b58628b8c8
* Use ::class to resolve class names in testsUmherirrender2018-01-261-2/+2
| | | | | | | This helps to find renamed or misspelled classes earlier. Phan will check the class names Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
* rdbms: specify DB name and table prefix even for the local domainAaron Schulz2018-01-161-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | When LoadBalancer opens new local domain connections, it currently assumes that the domain specified by the server info array is the same. For sanity, make sure that the handle is set to the local domain. The main LBFactory/LoadBalancer use $wgDBname/$wgDBprefix as the local domain, corresponding with wfWikiId(). This relation is set automatically in MWLBFactory. If $wgLBFactoryConf/$wgDBservers is manually configured in a way breaking this correspondance, then it is misconfigured. Fixes made to avoid test failure: * Make sure LoadBalancer::setDomainPrefix() updates the local domain alias member. Also do not bother changing the domain of foreign connections. * Use the right domain ID for the connection array key names in LoadBalancer::openForeignConnection(). * Now that JobQueueTest no longer mistakenly uses the non-test tables, force it to use the main DB_MASTER handle so that it can see the unit test tables even if they are TEMPORARY; such tables are tied to the TCP connection, so separate handles see different temporary tables. Change-Id: I56f8b32fe957f984b8c9753e6db3b20abe96b038
* Convert all array() syntax to []Kunal Mehta2016-02-171-35/+35
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Remove JobQueue::setTestingPrefix() hackAaron Schulz2015-12-101-7/+9
| | | | | | | The tests are only run on dev install and only touch the null queue anyway. Change-Id: I441a2a4605a9e2984142485b022dd524ff819360
* Add per-partition JobQueueRedis aggregationAaron Schulz2015-12-101-0/+19
| | | | | | | | | | | | | | | | | | | * Track queues with non-abandoned jobs per partition server. The s-queuesWithJobs key can easily be queried to see which queues need to have periodic tasks run (or for debugging). * This is requirement for the redis jobchron service to be able to avoid hitting N=(no. types X no. wikis) queues for periodic tasks when only a tiny fraction of those actually have any jobs. For WMF, there are over 30K queues, most of them empty, so doing that can help lower redis-server CPU (or at least make jobchron more responsive). * This also allows for jobchron to manage the aggregator by taking the per-server aggregator sets and merging them. This scales much better as there are only a modest number of these daemons (18 for WMF) but vastly more web thread pushing jobs. This cuts down on the connections to the active aggregator server (the one with the hash table). * Use Lua unpack() more for stylistic consistency. Change-Id: I1549f0edc78cc4004dd887b475dec4c0ebd306c6
* tests: Remove unused $wgMemc resetsTimo Tijhof2015-12-061-2/+0
| | | | | | | | If we really need this we can do it in MediaWikiTestCase, next to the setting of wgMainCacheType. But from what I can see the code being tested here already doesn't use the old $wgMemc. Change-Id: I9e4b2109b2f3c18d8d5551bbadae5711c1d4c0a6
* Various JobQueue test tweaksAaron Schulz2015-11-091-8/+23
| | | | | | | | | | * Remove some getAcquiredCount() assertions when claimTTL=0 as this is not well defined enough (queues may take a few minutes to garbage collect the failed jobs). * Added some tests to make sure push() only de-duplicates among unclaimed jobs. Change-Id: Ie0a5e539095c245dfcc8c160417e12824eb7ab83
* Remove useless sleep() in JobQueueTestAntoine Musso2014-10-241-2/+7
| | | | | | | | | | | | | I noticed JobQueueTest::testRootDeduplication takes ~ 6.5 seconds, which is due to the test method using sleep(1) and being passed the provider provider_queueLists which yields six items. The reason is to have the array returned by Job::newRootJobParams() to have an incread value for 'rootJobTimestamp'. Instead, just copy the previous array of parameters and increment the UNIX timestamp and converting back to TS_MW format. Change-Id: I75066df73f9f92e56b89eb6d928c41e949a2d6a9
* Remove MediaWikiPHPUnitCommandaddshore2014-08-021-2/+2
| | | | | | All functionality has been moved to other places Change-Id: I6b6b0ef846bc63108c4dff9e17098432fd9d1697
* Revert "Revert "Removed useless JobQueue return values""Aaron Schulz2014-04-161-8/+8
| | | | | | | | Made the obvious update to a caller missed in the change. This reverts commit c76d5a95c1dd1c3086461feae8bc1c0b688bde1e. Change-Id: I67400ba5b9fc7de16c9f9d5075c488c5e58cea9e
* Revert "Removed useless JobQueue return values"Reedy2014-04-161-8/+8
| | | | | | | | This reverts commit bc8c89d2df39d64f15770d29874904ebcff2f131. Bug: 64007 Change-Id: I4b4dbe4637dc50cd4630ef19d54f01efba10e138
* Removed useless JobQueue return valuesAaron Schulz2014-04-021-8/+8
| | | | | | * This are already totally redundant to the use of exceptions Change-Id: Ia706ac0122a7dd7f418e2dc2d3bd36e9a0252c25
* @covers tags for more test classesaddshore2013-10-241-2/+17
| | | | Change-Id: I19d49c279646a4b4c595700e53b790ba4eb9521e
* Fix scope on all /phpunit test methodsaddshore2013-10-241-5/+5
| | | | Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
* [JobQueue] Added a function to delete all jobs from a queue.Aaron Schulz2013-05-151-6/+10
| | | | Change-Id: Ibad122148bdd2f7baf528929e15bae803fccfeea
* docs: Remove odd colons after @todoTimo Tijhof2013-05-151-1/+3
| | | | | | | | | | Most were this way already: https://doc.wikimedia.org/mediawiki-core/master/php/html/todo.html Ran a find/replace on the odd ones. Also made them all lower case. Change-Id: I70c6a69344ddebc603e9a1c1d87e3cc4f4f4c560