Commit graph

216 commits

Author SHA1 Message Date
Aaron Schulz
c1e1512698 rdbms: improve LoadBalancer connection pool reuse (ii)
Make DBConnRef enforce the DB domain selected during its lifetime
and allow more nested and successive use of the same connection handle
via DBConnRef. This can avoid extra connections in some cases where
getConnection()/getConnectionRef() is used.

Also:
* Reduce the number of connection pools arrays from six to two
* Merge getLocalConnection()/getForeignConnection() into one method
* Expand various related code comments

Since LoadBalancer::getReadOnlyReason() no longer user the local domain
but rather DOMAIN_ANY, it should not result in "USE" errors if the local
domain does not have a database on the server.

This version of the patch removes the unused reuseConnectionInternal()
method (the method was previously added back to the patch by mistake).

Bug: T226595
Change-Id: I62502f4de4f86a54f25be1699c4d1a1c1baee60b
2022-10-18 17:23:44 -07:00
jenkins-bot
8d808457a1 Merge "Revert "rdbms: improve LoadBalancer connection pool reuse"" 2022-09-29 13:10:18 +00:00
Ladsgroup
4edae94817 Revert "rdbms: improve LoadBalancer connection pool reuse"
This reverts commit 76be4dca81.

Reason for revert: Caused T318904

Bug: T318904
Change-Id: I92f23205b4d62f69c0f27af40f972f104d1a7a7c
2022-09-29 12:12:14 +00:00
Umherirrender
89b2d11a0d tests: Use Title::makeTitle instead of Title::newFromText
Avoid parsing known titles in tests to improve performance

Change-Id: Ie240eb42479d19714e64cc4606e26073fadc2e13
2022-09-23 21:53:11 +02:00
Aaron Schulz
76be4dca81 rdbms: improve LoadBalancer connection pool reuse
Make DBConnRef enforce the DB domain selected during its lifetime
and allow more nested and successive use of the same connection handle
via DBConnRef. This can avoid extra connections in some cases where
getConnection()/getConnectionRef() is used.

Also:
* Reduce the number of connection pools arrays from six to two
* Merge getLocalConnection()/getForeignConnection() into one method
* Expand various related code comments

Bug: T226595
Depends-On: If808cbab429d41e1f2289683533e4a781a4bdf5e
Change-Id: I540b08920997c57cad6445ddb09d8e663eaf4714
2022-09-23 10:53:58 +10:00
Kosta Harlan
9748113b1f MediaWikiIntegrationTestCase: Add redirect table to list of tables to truncate
Change-Id: I5e40e6adfe51e2c86c30dff05916c1c2adcfbbf5
2022-09-20 11:19:02 +00:00
jenkins-bot
aafa2e0b04 Merge "tests: Replace deprecated WikiPage::factory" 2022-09-09 16:25:08 +00:00
Aaron Schulz
7a1bb4011d unittests: add MediaWikiIntegrationTestCase::getDb()
When tests use code that uses getConnection() to foreign domains, it changes the
DB domain of the "db" member field, which can break assertions. Use of this new
method can avoid that problem by using DBConnRef.

Bug: T316841
Change-Id: Ia0f3cf49c79affb7189801852ac7e9ec67933a3c
2022-09-06 23:24:38 +00:00
Umherirrender
6555923b08 tests: Replace deprecated WikiPage::factory
Bug: T297688
Change-Id: Ic84d491c5603f3590e26cb56a305508b2b0ca109
2022-09-02 19:34:02 +00:00
daniel
79746fbd35 ParsoidOutputAccess: support target language.
When parsing content for page creation, we need to be able to pass the
page language explicitly. This patch allows the language to be looped
through from ParsoidHTMLHelper via ParsoidOutputAccess into Parsoid
itself.

Change-Id: I1bbf9c2180de2d91679edbc9d73adfe44075dde3
2022-09-02 14:00:40 +00:00
jenkins-bot
c17df8ff78 Merge "tests/api: Add TestUser::getAuthority and use it" 2022-08-19 16:35:47 +00:00
jenkins-bot
706d479075 Merge "tests/api: Use MediaWikiIntegrationTestCase::editPage for edits" 2022-08-19 16:35:40 +00:00
jenkins-bot
425303861f Merge "rdbms: add getDomainChangeException() call to DBConnRef::tablePrefix()" 2022-08-10 04:14:28 +00:00
Umherirrender
ef0623ec06 tests/api: Add TestUser::getAuthority and use it
Change-Id: Icfb66f9927c8e67582010a208538b0b5e0ba353f
2022-08-06 23:15:27 +02:00
Umherirrender
6a8f3b4c55 tests/api: Use MediaWikiIntegrationTestCase::editPage for edits
Also improve MediaWikiIntegrationTestCase::editPage by accepting
LinkTarget objects and use services instead of static functions

Change-Id: I3d036b0837f212d3500159c1d3a3daa4e706882c
2022-08-06 22:21:51 +02:00
Aaron Schulz
3e49c2029e rdbms: add getDomainChangeException() call to DBConnRef::tablePrefix()
This matches the DB domain logic enforcement in the other class methods.

Cleanup several type hints in related code.

Change-Id: I6668852ccebe16349b38b5a793543bd3ec0a35b8
2022-08-03 21:41:09 +00:00
TheSandDoctor
da38639658 Remove deprecated $wgParser
$wgParser, deprecated in 1.32, has been removed.

Bug: T160811
Change-Id: Iaf09d3e158e1fee8c0f541695b6d9b4233033c81
2022-08-03 14:40:16 +02:00
Umherirrender
dee77e59a1 tests: Remove resetServiceForTesting after overrideConfigValues
overrideConfigValues is documented to reset services as well

Change-Id: Ie13a699f6cd912b912d34adb97704bab3cbdff2d
2022-07-27 23:08:27 +02:00
jenkins-bot
1874b90587 Merge "test: installMockMwServices should apply overrides per default." 2022-07-18 20:38:34 +00:00
daniel
7945b5301b test: installMockMwServices should apply overrides per default.
MediaWikiIntegrationTestCase::installMockMwServices() was changed in
I1922d9b903dcafb83691c2d96790f72747eeef9c to no longer apply default
overrides. This was left to overrideMwServices().

This caused parser tests to run without the necessary config overrides,
since it calls installMockMwServices(), but cannot make use of
overrideMwServices().

This changes installMockMwServices() so it will apply the default
overrides when called with no parameters.

Bug: T312709
Change-Id: I898927717ce961d98617a7fcd9c7fa8e19bec412
2022-07-17 17:34:01 +02:00
mainframe98
00eab3cef3 tests: ensure LocalServerObjectCache is reset before redefining
If an extension uses this service somewhere, redefining before
resetting it breaks the tests.

Follows-up: Ia60cb0bc18b235f23d9778da8241f65accfc0d35
Change-Id: Ie930f2bbab3d31831751caa1ca342fd9a023b19b
2022-07-16 12:29:58 +02:00
Umherirrender
bbaa4c25d9 tests: Use MainConfigNames constants on overrideConfigValue
Change-Id: Ieeefb88daf55a976883f6e20ef6881c89a7f7630
2022-07-12 19:34:54 +02:00
Derick Alangi
f00cd03580 tests: Make use of overrideConfig(Value|Values) where needed
As we slowly move away from using globals, overrideConfigValue()
and overrideConfigValues() were introduced as a way to override
test configs between tests.

Under the hood, it just calls setMwGlobals() which resets services,
so take note.

Part 1: Directories covered are: languages/, maintenance/, tests/,
structure/ and includes/Permissions/.

Depends-On: I618b16c6d99c94eb2e7edcf05e888a65f7156754
Change-Id: If56f7d10d79f3a9824a52091a2b544d8653dd7b6
2022-07-11 21:15:26 +01:00
daniel
c6c62e2c8f PHPUnit: enable main object cache in tests
This sets MainCacheType to 'hash', so the main cache is functional
within test cases. Between tests we are already calling ObjectCache::clear,
so the cache will not leak data into other test cases.

It turned out that the way we have been overriding configuration
settings in MediaWikiIntegrationTestCase is insufficient, since the
overrides would only apply in the main Config object, not in global
variables. This means they could not be overwritten with setMwGlobals.
So this patch also changes how we apply config overrides for test setup.

Config overrides that happen during tests work as before.

Depends-On: Ic36e92b73f22fd64e2d0b680d8e900f598158460
Change-Id: Ia60cb0bc18b235f23d9778da8241f65accfc0d35
2022-07-07 16:26:03 +10:00
daniel
bf092744c9 PHPUnit: introduce setMainCache
The main object cache is disabled during testing. Some integration tests
need it though. This provides a clean way to enable it, to replace the hacks
that were used so far.

Note that we may want to enable the main cache during testing soon. When
that happens, this method is still useful to disable the cache in certain
tests, and to set a specific cache instance.

Change-Id: I04ae1bf1b6b2c8f6310acd2edf89459d01a9c870
2022-07-07 16:25:59 +10:00
jenkins-bot
0f75ef7180 Merge "Use HashConfig to override config variables in phpunit tests" 2022-07-07 05:13:52 +00:00
daniel
ac7138d45b Use HashConfig to override config variables in phpunit tests
This implements config overrides with a HashConfig that is layered on
top of the base config, so we can move away from global variables.

Global variables are still updated using setMwGlobals, for compatibility
with code that is still reading configuration from global variables.

This fixes an issue with the default overrides not being applied to
global variables.

Change-Id: I1922d9b903dcafb83691c2d96790f72747eeef9c
2022-07-07 14:54:06 +10:00
Umherirrender
6629932569 tests: Remove unneeded Title::newFromLinkTarget calls
Use the page identity from RevisionRecord instead

Change-Id: I80550f41645b55278b085968295ed016c212934c
2022-07-05 23:57:30 +02:00
jenkins-bot
bf5806d4ff Merge "tests: Move assertHTMLEquals to the test case trait" 2022-06-24 01:51:57 +00:00
daniel
033060bbaa PHPUnit: introduce overrideConfigValues.
overrideConfigValues() is introduced as a replacement for
setMwGlobals(). Since we are moving away from reading configuration
from global variables, test cases should not use global variables to set
configuration.

Bug: T294739
Change-Id: I9d41045bd13932bd853f53e00322233fc4f1321c
2022-06-21 13:29:29 +02:00
mainframe98
3fd374e974 tests: Move assertHTMLEquals to the test case trait
This allows accessing it in both integration and unit tests.

Bug: T310514
Change-Id: I5c97364cbdc81fe67f156cffb04b252af7ccf6ff
2022-06-13 15:32:57 +00:00
Lucas Werkmeister (WMDE)
acae1c5107 Revert "phpunit: Default to vendor/bin/phpunit, remove suites.xml"
This caused unexpected problems with no obvious fixes. Needs more work.

This reverts commit 7238dff532.

Bug: T310255
Bug: T90875
Change-Id: I3758cbb6d0029b20ec1b0f67dbf2f422031c50ae
2022-06-09 14:15:54 +00:00
Kosta Harlan
7238dff532 phpunit: Default to vendor/bin/phpunit, remove suites.xml
* switch to phpunit.xml.dist instead of suites.xml
* switch composer.json to vendor/bin/phpunit
  * tests/phpunit/phpunit.php is retained but will be removed after CI
    jobs and other references on
    codesearch (https://codesearch.wmcloud.org/search/?q=tests%2Fphpunit%2Fphpunit.php&i=nope&files=&excludeFiles=&repos=)
    are removed
* add a default bootstrap.integration.php; unit tests in
  composer.json use the non-MW bootstrap file (bootstrap.php)
  * Migrate the phpunit.php logic into tests/phpunit/BootstrapIntegrationWrapper.php

Depends-On: I19d560bdcdb2ee914ab055e094841f2b5db8be55
Depends-On: Ib23209fc3b095e3c012ed84ce5c11f8b2d27b898
Co-authored-by: Daimona Eaytoy <daimona.wiki@gmail.com>
Bug: T227900
Bug: T90875
Change-Id: I82045c207738d152d5b0006f353637cfaa40bb66
2022-06-08 18:31:16 +00:00
Amir Sarabadani
24115a8f4c Start clean up of revision_actor_temp table
It is being dropped in production

Bug: T215466
Change-Id: I66b2cb8653252e720c897351065978119f040ba7
2022-05-23 15:37:42 +00:00
daniel
237bbf089f Turn DefaultSettings.php into a deprecated stub
DefaultSettings.php has been replaced by MainConfigSchema.
Loading DefaultSettings.php is deprecated.

Code that needs to have access to configuration defaults should use the
ConfigSchema service object.

Bug: T300129
Change-Id: I7b2c0ca95a78990be1cdb9dd9ace92f6dcf1af15
2022-05-17 16:50:56 +02:00
Amir Sarabadani
a294e715a4 rdbms: Replace getConnection with getLazyConnectionRef
This would simplify the code for its users a lot.

Bug: T255493
Depends-On: I6ab4440a13f4682dd3a6e9cfc6c629222fbeab8a
Change-Id: I6e7544763bde56fc1e19de0358b71ba984a978ca
2022-05-12 07:43:03 +02:00
jenkins-bot
654ccb3a4c Merge "Setup.php: clarify the use of $IP." 2022-05-04 18:10:39 +00:00
daniel
bedd996fe6 Setup.php: clarify the use of $IP.
The global variable $IP has been replaced by the MW_INSTALL_PATH
constant. Clarify the continued use of $IP on Setup.php.

Change-Id: I157abfd9049fb8382da53005a084ab86f47e8d8a
2022-05-03 11:53:05 +02:00
Aryeh Gregor
79fc95d39c Use MainConfigNames instead of string literals, #5
This should be the last of the usages in core, although I'm sure a few
are hiding somehow.

Change-Id: I7bf0b24bf23d3efb4c56a891830bbfe67945e899
2022-04-27 18:46:29 +03:00
Daimona Eaytoy
0a6ec1031a Move wfRequireOnceInGlobalScope to TestSetup
TestSetup seems a nice place for this function. This way, it can also be
reused in the other boostrap file whilst we migrate the entrypoint.
Also, replace the check in MediaWikiIntegrationTestCase with another
constant; this also makes it easier to understand when exactly that code
should run.

Bug: T90875
Change-Id: I7858d982378ab4b6f11c4e9bf955d83d1acbc85d
2022-04-25 12:52:58 +00:00
Aaron Schulz
218b68ed4c rdbms: add $fname parameter to LBFactory::closeAll() for better logging
Change-Id: I2f4b6466c22c89d7515290324e8e2e2f720ada61
2022-04-05 21:39:21 +00:00
Aaron Schulz
0381118090 phpunit: Set $wgSQLMode from DevelopmentSettings instead of MediaWikiIntegrationTestCase (ii)
This reverts commit 17bab86e7a.

Extension failures (ref T304625) have since been fixed.

Bug: T225730
Change-Id: Ia452e076bdce45f1151f970c16837b80813ee08a
2022-04-04 21:36:14 +00:00
Alexander Vorwerk
17bab86e7a Revert "phpunit: Set $wgSQLMode from DevelopmentSettings instead of MediaWikiIntegrationTestCase"
This reverts commit 8a54b5ec38.

Bug: T304625
Change-Id: Id54589603d56aa87b6a1e7d9570ebba5346dd70c
2022-03-24 16:55:02 +00:00
jenkins-bot
b89c59ba9a Merge "phpunit: Set $wgSQLMode from DevelopmentSettings instead of MediaWikiIntegrationTestCase" 2022-03-24 14:51:48 +00:00
Aaron Schulz
8a54b5ec38 phpunit: Set $wgSQLMode from DevelopmentSettings instead of MediaWikiIntegrationTestCase
This avoids a large number of SET query pairs during tests.

Bug: T225730
Change-Id: Ic2729428297162763a772e6a16549ded8de06c01
2022-03-24 09:13:54 +00:00
Aaron Schulz
509614bbda Improve handling of class-level test setup failures in run()
Signal that the test run needs to stop and record the exception via
addError() so that it will be displayed in the output and the exit
code will reflect test failure.

Previously, errors would cause the tests to suddenly stop, and any
buffered output about previous errors, warnings, and failed tests
was lost.

Bug: T292239
Change-Id: I5b2a7bcbb38760fcd10fccfbf000f4a8511f8774
2022-03-21 21:43:07 -07:00
jenkins-bot
5ec380a8f6 Merge "Integration test for extension registration" 2022-03-16 17:05:36 +00:00
Aaron Schulz
7ee3bc9334 Improve ensureMockDatabaseConnection() error message
Bug: T292239
Change-Id: I8f892d0148cbd3f475751d71143ac07a4b3b29d6
2022-03-15 20:07:57 -07:00
daniel
1c7ffcd46a Integration test for extension registration
This adds full integration tests for extension registration, ensuring
that ExtensionProcessor and ExtensionRegistry work together as expected.

The existing tests for ExtensionProcessor and ExtensionRegistry are
converted to "pure" unit tests.

This change is intended to protect against bugs while refactoring
ExtensionProcessor and ExtensionRegistry to better integrate with the
new SettingsBuilder class.

Bug: T297166
Change-Id: I2d9cc373b8a4aa014aef93b0a8e8d83758851783
2022-03-11 21:43:41 +00:00
Tim Starling
1bfa449f8e In BackupDumperPageTest, don't overwrite self::$dbClone
BackupDumperPageTest called MediaWikiIntegrationTestCase::
setupDatabaseWithTestPrefix() on a new private connection, overwriting
self::$dbClone. This can cause a fatal error on shutdown due to
self::$dbClone->destroy() being called after connection close. Hopefully
it also fixes the CI failure observed at I200f90e413b8a725828745f81925b.

Also, the method was documented as returning bool, but in fact it always
returned true.

So, move the responsibility for setting self::$dbClone to the only
caller where that makes sense. Have BackupDumperPageTest call
CloneDatabase::destroy() during test teardown.

Change-Id: I2a4cefe6207c02cc12b906d66f6016440e16b249
2022-03-09 15:49:28 +11:00