Commit graph

55 commits

Author SHA1 Message Date
Kunal Mehta
e0193327bd Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag errors
Change-Id: I936c3f5fca1a0061f215e80469f5d882cb32ee29
2018-05-23 16:23:42 -07:00
Aaron Schulz
f8c2486d15 rdbms: rename CONN_TRX_AUTO constant to CONN_TRX_AUTOCOMMIT
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
2018-04-12 13:01:52 -07:00
Umherirrender
69dbaf3f88 build: Updating mediawiki/mediawiki-codesniffer to 17.0.0
Change-Id: Ib494b47c54fe6354d166055b1e1b31d3583bb992
2018-03-29 21:53:10 +02:00
Umherirrender
63d96c15fd build: Updating mediawiki/mediawiki-codesniffer to 16.0.0
Change-Id: I59b59f79bbf3ce4feff3b3a20c1c31bc16370531
2018-02-17 13:29:13 +01:00
Umherirrender
45da581551 Use ::class to resolve class names in tests
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
2018-01-26 22:49:13 +01:00
Aaron Schulz
14ee3f2107 rdbms: specify DB name and table prefix even for the local domain
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
2018-01-16 17:06:52 +00:00
Kunal Mehta
75160bdd3b Use MediaWikiCoversValidator for tests that don't use MediaWikiTestCase
Change-Id: I8c4de7e9c72c9969088666007b54c6fd23f6cc13
2018-01-01 08:28:02 +00:00
Kunal Mehta
356c6ae993 Add @covers tags to jobqueue tests
Change-Id: I030634ac87139011e5b3d461064a8c10f10cea84
2017-12-27 17:47:30 +00:00
mainframe98
70e92cdad5 Fix additional usage of incorrect case
Courtesy of the PhpStorm inspection Case mismatch in method call or
class usage.

Bug: T166759
Change-Id: I27c53658b99048fa0dd8f9d6ef1398620386e1cc
2017-12-15 11:58:11 +01:00
Aaron Schulz
83bf5105d8 Try to avoid bogus JobTest failures for PHP 7
Change-Id: I07b4bd796a668fef83ebb3e2824ccc608781a6e8
2017-12-02 00:36:58 +00:00
Timo Tijhof
9a65a14da6 jobs: Remove ClearUserWatchlistJob 'batchSize' option
Use $wgUpdateRowsPerQuery instead, and use its value at run-time
instead of inside the job parameters. Also helps with deduplication
if batchSize is changed.

Change-Id: Ifef25a3ae5ae2418359a41eba05778613fbb548f
2017-11-30 12:36:36 -08:00
addshore
989ba87562 Introduce ClearUserWatchlistJob
Change-Id: Icea573a10078ea3f09dc2e4e9fdc737bf639935d
2017-11-28 17:11:40 +00:00
Thiemo Mättig
1f2ff32cca Family name of Thiemo changed
Change-Id: I5477d02111e53790e858624c4b7c4f09dbc418fa
2017-11-14 13:59:15 +01:00
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00
Lucas Werkmeister
a57252a1f5 Allow callback functions for creating jobs
$wgJobClasses can now specify a factory function for creating a job,
instead of a class to be instantiated directly. This makes it possible
to inject services in a job constructor, and register a factory function
that calls the constructor with default services.

This follows Ieb85493a7765 and Ia2107dc5af78, which introduced factory
functions for API modules and special pages.

Change-Id: I0461e59da2a8fa6681e3b1fcdfc38bfed7f3ac32
2017-05-09 19:26:13 +02:00
Timo Tijhof
447ce7e39a phpunit: Avoid use of deprecated getMock for PHPUnit 5 compat
The default will remain PHPUnit 4.x due to PHP 5.5 support.

But, we should allow developers to run tests with newer PHPUnit
versions which are noticably faster (especially for code coverage
reports).

* <https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-5.4.0>
  PHPUnit 5 deprecates the getMock() shortcut for getMockBuilder()->getMock().
  It instead introduces the shortcut createMock() which has better defaults
  than getMockBuilder(). For example, it sets 'disableArgumentCloning' and
  other things by default.

  Going forward, code should either use getMockBuilder directly and configure
  it using the setter methods (instead of the confusing variadic arguments
  of getMock) or simply use the new minimalistic createMock method. This patch
  backports the createMock method to MediaWikiTestCase so that we can start
  using it.

Change-Id: I091c0289b21d2b1c876adba89529dc3e72b99af2
2017-04-06 00:44:32 +00:00
jenkins-bot
db6f2b033a Merge "CatWatch don't show the number of pages transcluded" 2016-04-14 14:10:12 +00:00
addshore
573e8c1bc5 CatWatch don't show the number of pages transcluded
Providing the perfectly correct number of pages
that have acctually been added to or removed from a
category is extermly hard.

Rather than providing data that is most likely wrong
and a bit useless ONLY provide a link to Special:WhatLinksHere.

This touches on the following bugs and may mean that
some of them don't need to be thought about any further.

Bug: T126855
Bug: T126407
Bug: T126139
Change-Id: Ida06d822d1955091595c17c9c6c2968a40a93bcd
2016-04-14 09:22:49 +01:00
Erik Bernhardson
afc3b5a120 Track which web request created a job
We currently push a request id into structured logging (monolog/
logstash) to allow seeing all logs that were triggered by the same
request. This extends that to pass the id through jobs so jobs triggered
by a web request also share the same id and can be tracked together.
This web request id will follow jobs both directly created by a request,
and jobs created by those jobs.

This should give us some more visibility when debugging into what
started a particular job, and if a large number of jobs blowing up the
job queue are somehow related.

Change-Id: Iedbd031e6e9bb18fd6f7b923c8c305102255ab4b
2016-04-13 10:41:13 -07:00
Aaron Schulz
4a28737c32 Make Job::toString() handle array parameters better
Previously it would result in array(x) in fairly simple cases.

Change-Id: I6bfe67faa45835babb2c7e259b5cd158e0f0a649
2016-03-16 03:45:35 -07:00
daniel
a8995619c1 Avoid rebuilding database fixtures for every test run
This reduces the runtime of database-bound tests by about 40%
(on my system, from 4:55 to 2:47; results from Jenkins are
inconclusive).

The basic idea is to call addCoreDBData() only once, and have
a addDBDataOnce() that is called once per test class, not for
every test method lie addDBData() is. Most tests could be
trivially be changed to implement addDBDataOnce() instead of
addDBData(). The ones for which this did not work immediately
were left out for now. A closer look at the tests that still
implement addDBData() may reveal additional potential for
improvement.

TODO: Once this is merged, try to change addDBData() to
addDBDataOnce() where possible in extensions.

Change-Id: Iec4ed4c8419fb4ad87e6710de808863ede9998b7
2016-03-10 23:44:34 +00:00
addshore
b102435731 Add CategoryMembershipChangeJobTest
Change-Id: Ia04bb85260be7d2aaaf171a2c886633b66ee6e77
2016-02-29 23:25:32 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
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
2016-02-17 01:33:00 -08:00
addshore
044f6418b1 Switch name to username in @author tags
From now on I will simply use addshore
everywhere to keep things uniform...

Change-Id: Iaf441b2d7a67a12c20529f0e9c7b47819f4abfae
2016-01-27 10:59:31 +01:00
Thiemo Mättig
793dbbb870 More complete, more straightforward JobQueueMemoryTest
I created a basic test yesterday to cover two bugs. Now the test covers
all public methods. I was also able to get rid of the test double.

Change-Id: I53110280e3ef7b7a72d175b11b7fc4ccf1d648b3
2016-01-15 10:28:30 +01:00
Thiemo Mättig
1910da184e Do not return null reference in JobQueueMemory
See Ia5b7a96 and the unrelated error raised there.
https://integration.wikimedia.org/ci/job/mwext-testextension-zend/19682/consoleFull

By writing this simple test I not only found one but two issues.

Bug: T123539
Change-Id: I17ed5b69992aa98ab2384b7a6aafc96b0fcba1ce
2016-01-14 19:19:55 +01:00
Aaron Schulz
ec351986e5 Remove JobQueue::setTestingPrefix() hack
The tests are only run on dev install and only touch the
null queue anyway.

Change-Id: I441a2a4605a9e2984142485b022dd524ff819360
2015-12-10 17:20:10 -08:00
Aaron Schulz
6fe2f48df7 Add per-partition JobQueueRedis aggregation
* 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
2015-12-10 23:59:59 +00:00
Timo Tijhof
3b35719e74 tests: Remove unused $wgMemc resets
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
2015-12-06 18:06:08 +00:00
Aaron Schulz
247610aea0 Various JobQueue test tweaks
* 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
2015-11-09 21:24:34 -08:00
Antoine Musso
7fff25afc1 Remove useless sleep() in JobQueueTest
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
2014-10-24 14:31:00 +02:00
addshore
f960c2434b Add tests for Job::toString
Change-Id: I00f41808af42a198a1e45a93201dd7bb3e4d9c2c
2014-09-23 21:57:31 +01:00
addshore
892a992ab8 Remove MediaWikiPHPUnitCommand
All functionality has been moved to other places

Change-Id: I6b6b0ef846bc63108c4dff9e17098432fd9d1697
2014-08-02 21:35:34 +00:00
Siebrand Mazeland
896bda7c85 Pass phpcs-strict on some test files (7/11)
Change-Id: Ia0ceea60e7ef43959f868378f3fcd463a3adf782
2014-04-24 18:27:12 +00:00
Aaron Schulz
94c37ffb96 Revert "Revert "Removed useless JobQueue return values""
Made the obvious update to a caller missed in the change.

This reverts commit c76d5a95c1.

Change-Id: I67400ba5b9fc7de16c9f9d5075c488c5e58cea9e
2014-04-16 11:22:31 -07:00
Reedy
c76d5a95c1 Revert "Removed useless JobQueue return values"
This reverts commit bc8c89d2df.

Bug: 64007

Change-Id: I4b4dbe4637dc50cd4630ef19d54f01efba10e138
2014-04-16 17:41:53 +00:00
Aaron Schulz
bc8c89d2df Removed useless JobQueue return values
* This are already totally redundant to the use of exceptions

Change-Id: Ia706ac0122a7dd7f418e2dc2d3bd36e9a0252c25
2014-04-02 17:56:05 -07:00
addshore
fd15274dcd Cleanup RefreshLinksPartitionTest
Change-Id: I9c8e66b7370f8ea8d9b4f8843718b29e992b1180
2014-01-25 14:15:42 +01:00
umherirrender
5ca5672aac Fixed spacing
- Place commas correct
- Moved comments
- Add space after if/foreach/catch
- Reformat some conditions
- Removed trailing spaces/tabs

Change-Id: I40ccda72c418c4a33fcd675773cb08d971510cdb
2013-12-01 20:58:51 +01:00
Aaron Schulz
721731f43c Improved partitioning scheme for refreshLinks jobs
* The changes refreshLinks to handle both per-title (leaf) and backlink jobs.
  The base job now splits into some leaf jobs and a remaining partition job.
  The partition job does the same until there are only a small number
  of backlinks in the remaining range (so only leaf jobs are added).
  Since the leaf jobs are pushed first, this works well for FIFO queues
  to avoid bloating the queue. This also improves per-title job
  de-duplication, which isQueueDeprioritized() pretty much killed.
* The refreshLinks2 class is no longer used for new jobs.
* Fix process cache bug with JobQueueGroup::push with empty arrays.
* This adds a BacklinksJobUtils with helper functions for partitioning.
* RefreshLinksJob jobs now have a simple version parameter.
* Also moved refreshLinks2Job to its own file.

Change-Id: Id378d47df17248ae02938d5a54ef7ecd29efadbd
2013-11-26 16:02:44 -08:00
addshore
aea1b27db0 @covers tags for more test classes
Change-Id: I19d49c279646a4b4c595700e53b790ba4eb9521e
2013-10-24 20:35:04 +01:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
Aaron Schulz
266e46a5ca [JobQueue] Added a function to delete all jobs from a queue.
Change-Id: Ibad122148bdd2f7baf528929e15bae803fccfeea
2013-05-15 10:59:18 -07:00
Timo Tijhof
4bd5471ca3 docs: Remove odd colons after @todo
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
2013-05-15 06:23:40 +00:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Aaron Schulz
720ba67b5f Added a quick test for getAllQueuedJobs().
Change-Id: Ia39461bc1e2356da1a694bf1898b8ca8e4200ff8
2013-04-09 14:32:20 -07:00
Siebrand Mazeland
6da93fc6f6 Update code formatting
Also update some previous inconsistencies pointed out by Krinkle in change IDs:
* Ide20743a2e84ff68549286120e6cff9d9f396f54
* I811ca957b6588085d67606ebc0cd4033a1e53839

Change-Id: Ife33b931870d0d7e04fcb40974997436d27f528f
2013-03-27 14:15:11 +01:00
jenkins-bot
b3d9004342 Merge "Tests: Use more setMwGlobals" 2013-03-22 19:15:03 +00:00
Timo Tijhof
b36d883017 Tests: Make phpunit providers "public static".
Follows-up I9d2b148e57 (including phpunit/languages this time).

Bug: 46434
Change-Id: I30e5efcd88c516121c454676bd7a18f9b7c8fca6
2013-03-22 03:12:37 +01:00
umherirrender
ff3485ec99 Tests: Use more setMwGlobals
Change some tests to use setMwGlobals to have restoring of globals after
the test.
This also removes some save/restore code, which is not needed, due to
the automatically restoring on tearDown with setMwGlobals.

Change-Id: I8d2ac9f6cc14f0bd4ee8eb851c09f2e71babc6e0
2013-03-21 20:35:44 +01:00