aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/Storage/NameTableStoreTest.php
Commit message (Collapse)AuthorAgeFilesLines
* Add namespace to remaining parts of Wikimedia\ObjectCacheJames D. Forrester2024-09-271-1/+1
| | | | | Bug: T353458 Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
* nametablestore: simplify NameTableStore::acquireId() and update commentsAaron Schulz2024-09-241-14/+21
| | | | | | | | | | | | | Make store() handle cache purging upon new ID insertion and fetching of the winning ID when raced out. This avoids the reloadMap() call. Remove connection flag hack in reloadMap() given 0cb0f0ba7. Remove comments about retryStore() logic removed in 505bd8e70f. Clean up return types for the ID:name arrays. Change-Id: Ic57eb5e2b59da67c6511b935d9e68ffb595028fa
* Storage: Remove transaction cancel callback from NameTableStoreAmir Sarabadani2024-08-301-152/+0
| | | | | | | | | | | | | | What it's trying to achieve can be done much simpler by just making an out of transaction connection via setting CONN_TRX_AUTOCOMMIT flag. Removing this allows us to get rid of a large portion of transaction management in rdbms library as this is the only place that uses cancel callbacks. Split out of I3cb1e30611b83c0 Bug: T372169 Change-Id: Idad029b6da6b09e084d466d282ef1145ebd8fe73
* Add namespace to the root classes of ObjectCacheEbrahim Byagowi2024-07-101-3/+3
| | | | | | | | | And deprecated aliases for the the no namespaced classes. ReplicatedBagOStuff that already is deprecated isn't moved. Bug: T353458 Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* Tests: Replace "db" with getDb methodWandji692024-06-301-2/+2
| | | | | Bug: T316841 Change-Id: Ie6b08125b76d2d4b7a30375357dcb90aaa0189c1
* rdbms: Introduce IDatabaseForOwnerAmir Sarabadani2024-05-241-1/+0
| | | | | | | | Similar to LBForOwner, moving several internal methods there to fully hide it from outside of rdbms. Bug: T363839 Change-Id: I7a46d0e77d8865c6ed81ed351cb7fee0f9eda9cb
* Test: Replace db filed usages with getDb() in MediaWikiIntegrationTestCaseLarissa Gaulia2024-05-031-13/+15
| | | | | Bug: T316841 Change-Id: I41d50abecd2448f5be73b46d765ac35b2e8b4b68
* tests: Use IDatabase for mocking instead of DBConnRefUmherirrender2024-05-021-4/+4
| | | | | | DBConnRef is internal, use of IDatabase interface is more common Change-Id: Id7649d0723a936cebc7e5a40bf826e38220acee5
* tests: Migrate to IDatabase::newInsertQueryBuilderUmherirrender2024-04-141-1/+8
| | | | | | | | | Changed some inserts to use multi-row insert for small performance benefit where possible and not already used. InsertQueryBuilder does not return a value, deprecated since 1.33 Bug: T353219 Change-Id: I2380ebc8ec8db178dd790247aefbdd798b6d62ff
* tests: Remove explicit clean up for database testsUmherirrender2024-01-201-3/+0
| | | | | | Now done via ChangedTablesTracker Change-Id: Ia72616b31e67c55347c1e80b4474d61bcd0fecdd
* Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessaryJames D. Forrester2023-11-211-5/+0
| | | | | Bug: T342301 Change-Id: I5ea01f7ee103570165261bde0965c5b65e04c369
* Use short callable syntax for build-in functions like "lcfirst"thiemowmde2023-10-181-12/+2
| | | | | | | | While we can wrap these in an additional `fn ()` we can also use "lcfirst" directly. Function names encoded as strings are valid callables in PHP. Change-Id: I966046d5e357b409c57a9bff8a4a5737c1e22b03
* Bump codesniffer to 42.0.0Amir Sarabadani2023-09-271-3/+3
| | | | | | Most noisily, this enables MediaWiki.Arrays.OneSpaceInlineArray. Change-Id: I8ab11399c67ce7e3ab1b6249b591452774393428
* Make MediaWikiIntegrationTestCase::addCoreDBData a noopDaimona Eaytoy2023-09-051-4/+0
| | | | | | | | | | | | | The method should never be called directly, so make it throw an exception. Nonetheless, mark it as deprecated and detect overrides in the constructor, so that anyone who tries to override this method will see a warning. Fix the few tests that were relying on the existence of the test page. Bug: T342428 Depends-On: Ic64ded5e2c0b59e7c888ece9566076058a125be4 Change-Id: I308617427309815062d54c14f3438cab31b08a73
* mark various anonymous functions as staticReedy2023-08-221-3/+3
| | | | Change-Id: Iefe896769359f0d32e52bf20aa03e1c3715d5074
* Mass migrate Database::insert calls to InsertQueryBuilderAmir Sarabadani2023-08-071-0/+3
| | | | | | | Done automatically based on a php parser written on top of ANTLR4 Bug: T335377 Change-Id: Ie8fabc594edab18e55cb1d5bbf573762106e3d71
* tests: Make some PHPUnit data providers staticTim Starling2023-03-241-3/+3
| | | | | | | | | | | | | Just methods where adding "static" to the declaration was enough, I didn't do anything with providers that used $this. Initially by search and replace. There were many mistakes which I found mostly by running the PHPStorm inspection which searches for $this usage in a static method. Later I used the PHPStorm "make static" action which avoids the more obvious mistakes. Bug: T332865 Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
* Storage: Migrate NameTableStore to SelectQueryBuilderAmir Sarabadani2022-12-161-0/+2
| | | | | Bug: T311866 Change-Id: If3d8d2017999d138cfd5cee0c8e0ad8eedf34e44
* Storage: Remove using LoadBalancer::getConnectionRef in NameTableStoreAmir Sarabadani2022-08-081-2/+2
| | | | | | It's deprecated and being phased out and breaking Wikibase I951ab99ae7. Change-Id: I6c151aeb58aba057012775bfeedbe04917d6380c
* Replace trivial usa of mock builder with createMock() shortcutThiemo Kreuz2022-07-151-3/+1
| | | | | | | | | | | createMock() does the same, but is much easier to read. A small difference is that some of the replacements made in this patch didn't use disableOriginalConstructor() before. In case this was relevant we should see the respective test fail. If not we can save some CPU cycles and skip these constructors. Change-Id: Ib98fb06e0fe753b7a53cb087a47e1159515a8ad5
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-4/+3
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* Remove passing markTestSkippedIfDbType or add commentUmherirrender2022-01-221-1/+1
| | | | | | | | | It seems some tests are fixed in the meantime without removing the skipped part for this. Bug: T195807 Follow-Up: I58261dd70eea3581803987a4a7739c7d55558f42 Change-Id: Ie883b7056cdd0cb6bec81c2f7e4ed54177b4ecb2
* rdbms: Add more return typehintsDaimona Eaytoy2021-09-071-16/+6
| | | | | | | See full rationale at I59068cfed10aabf6c6002f9e9312a6ef6e7e9441. Using IDatabase for now instead of DBConnRef for better BC. Change-Id: Ie75aaf46ba91779e8706b10efeefa9580857f489
* build: Updating dependencieslibraryupgrader2021-07-221-1/+1
| | | | | | | | | | | | | | 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
* Don't pass unneeded variables into anonymous functionsDannyS7122021-07-131-1/+1
| | | | Change-Id: Iad4d1dc4727828f9e0120c8bf99dc245a29ee14d
* Add some missing __METHOD__ parameters to database callsDannyS7122021-06-071-1/+2
| | | | | | Plus fix a typo Change-Id: I8ca326990559ea80254ce0cef2ed204590716679
* Remove meaningless ->expects( $this->any() ) from all testsThiemo Kreuz2021-04-231-2/+1
| | | | | | | | | | | | | | | It is not entirely meaningless. It might be an indicator that the number of calls to a method is intentionally unlimited. This is similar to e.g. an @inheritDoc PHPDoc comment that marks a method as being "intentionally undocumented". However, what's the meaning of being "intentionally unconstrained"? Let's just not have any constraint then. I feel all these ->expects( $this->any() ) bloat the test code so much that it's never worth it. Change-Id: I9925e7706bd03e1666f6eb0b284cb42b0dd3be23
* Tests: Mark more more closures as staticUmherirrender2021-02-091-5/+5
| | | | | | | Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208 Bug: T274036 Change-Id: I695873737167a75f0d94901fa40383a33984ca55
* Fix incomplete/bogus PHPDoc tags in various testsThiemo Kreuz2021-01-141-2/+2
| | | | | | | | | | | Most of these are found by the not yet released I10559d8. I remove the type MockObject in some cases when the calling code really does not need to know if he get's a mock or the real thing. However, I do this only in places that are very closely related to the fixes. Change-Id: I26a4c3c5a8ae141bf56161b52b54bce7e68f2e30
* More misc test cleanupDannyS7122020-12-241-1/+1
| | | | | | | | | * parent::setUp() should be first, and ::tearDown() should be last * Move tests that directly extend PHPUnit\Framework\TestCase to /unit Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
* Storage: Disable NameTableStoreTest case that fails on sqliteTimo Tijhof2020-07-291-0/+3
| | | | | | | | To unblock T246358. Bug: T246358 Bug: T259085 Change-Id: Icddb6eae411eed5658ba942b2271fc6469659251
* MediaWikiTestCase to MediaWikiIntegrationTestCaseaddshore2020-06-301-2/+2
| | | | | | | | | | | | | 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
* Fix visibility of setUp/tearDownThiemo Kreuz2020-06-161-1/+1
| | | | Change-Id: I636be48eb9f713680abac35d46091f7b49374696
* Replace all call_user_func(_array) in all testsThiemo Kreuz2020-06-061-1/+1
| | | | | | | | | | | | | There is native support for all of this now in PHP, thanks to changes and additions that have been made in later versions. There should be no need any more to ever use call_user_func() or call_user_func_array(). Reviewing this should be fairly easy: Because this patch touches exclusivly tests, but no production code, there is no such thing as "insufficent test coverage". As long as CI goes green, this should be fine. Change-Id: Ib9690103687734bb5a85d3dab0e5642a07087bbc
* tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-301-1/+1
| | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* Merge "NameTableStore: ensure consistency upon rollback."jenkins-bot2019-10-101-3/+162
|\
| * NameTableStore: ensure consistency upon rollback.daniel2019-10-101-3/+163
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This ensures consistent behavior when an ID for a name is first acquired within a transaction that is rolled back. The documentation for acquireId now reads: @note If called within a transaction, there is a chance for the acquired ID to be lost if the transaction is rolled back. A best effort is made to re-insert the mapping after a rollback, and consistency of the cache with the database table is ensured by re-loading the map after a failed transaction. However, there is no guarantee that an ID returned by this method is valid outside the transaction in which it was produced. This means that calling code should not retain the return value beyond the scope of a transaction, but rather call acquireId() again after the transaction is complete. In some rare cases, this may produce an ID different from the first call. Bug: T224949 Change-Id: I6d05e4112a649675bfb9083cab2d1bbe394e65b3
* | Update tests to use PHPUnit 6 class namesMax Semenik2019-10-061-1/+2
|/ | | | | Bug: T192167 Change-Id: I42b0c8908b4968b95b08f861a40af18dc79fa0a1
* Make NameTableStore use LoadBalancer::getConnectionRef()Aaron Schulz2019-08-251-2/+5
| | | | | | | | This method handles reuseConnection() calls, disallows writes to DB_REPLICA role handles, is more consistent with wfGetDB(), and is more efficient with I540b08920997c5. Change-Id: I8edaef0ea4718414e2004fad04afca8ec5797669
* rdbms: Document varargs for IDatabase::buildLikeUmherirrender2019-06-181-30/+18
| | | | | | | | | This is needed in order for Phan not to consider calls to IDatabase::buildLike as invalid. Interestingly, it does not consider calls to Database::buildLike invalid. Bug: T191668 Change-Id: I0e027f5ec66d20b1d11e3441086001f6a751e1f5
* Alter two uses of hasOrMadeRecentMasterChanges() for consistencyAaron Schulz2019-04-231-0/+8
| | | | | | | | | | | | Rather than have the behavior vary and possibly break code or tests when small changes happen, make User/NameTableStore more explicit about when cache key purges happens. This should reduce problems with certain fragile tests, such as those that could be affected by 03908112635f when --use-normal tables is not used. Ideally, any fragility should be ironed out of effected code. Change-Id: Ibe5d1bb4bece2526bc0da99648f7ba73bdc0ffa5
* Get rid of unnecessary func_get_args() and friendsAryeh Gregor2019-04-121-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | HHVM does not support variadic arguments with type hints. This is mostly not a big problem, because we can just drop the type hint, but for some reason PHPUnit adds a type hint of "array" when it creates mocks, so a class with a variadic method can't be mocked (at least in some cases). As such, I left alone all the classes that seem like someone might like to mock them, like Title and User. If anyone wants to mock them in the future, they'll have to switch back to func_get_args(). Some of the changes are definitely safe, like functions and test classes. In most cases, func_get_args() (and/or func_get_arg(), func_num_args() ) were only present because the code was written before we required PHP 5.6, and writing them as variadic functions is strictly superior. In some cases I left them alone, aside from HHVM compatibility: * Forwarding all arguments to another function. It's useful to keep func_get_args() here where we want to keep the list of expected arguments and their meanings in the function signature line for documentation purposes, but don't want to copy-paste a long line of argument names. * Handling deprecated calling conventions. * One or two miscellaneous cases where we're basically using the arguments individually but want to use them as an array as well for some reason. Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
* tests: Mock the time in NameTableStoreTest to avoid failures if they run slowlyAaron Schulz2019-04-101-1/+8
| | | | | Bug: T220626 Change-Id: I4f8e0321f540b9ff48f3297a1ca0c6196c99ecf8
* objectcache: optimize WAN cache key updates during HOLDOFF_TTLAaron Schulz2019-03-041-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid the ADD operation spam from all threads trying to access a tombstoned key by checking the interim value cache timestamp. This also avoids the GET/CAS spam from threads that manage to get the mutex. If a single thread repeatedly accesses the same tombstoned value in rapid succession, there will significantly less cache operation spam. Do the same for cache updates to keys in the holdoff state due to "check keys" or the "touchedCallback" function. Relatedly, fix getWithSetCallback() to disregard interim values set prior to or at the same time as the latest delete() call. This can slightly reduce the chance of the cache being behind replica DBs for a second. It also avoids unit test failures were a series of deletes and cache access happen at the same timestamp (via time injection or regular system time calls). In addition: * Add PASS_BY_REF flag with backwards compatibility to avoid bloating the signature of get()/getMulti() with the new tombstone information needed for the above changes. * Avoid confusing pass-by-reference in getInterimValue() and fix use of incorrect $asOf parameter. * Move some more logic into setInterimValue(). * Update some comments regarding broadcasted operations that were not true for the currently assumed mcrouter setup. * Rename $cValue => $curValue and $versioned => $needsVersion for better readability. Bug: T203786 Change-Id: I0eb3f9b697193d39a70dd3c0967311ad7e194f20
* Don't reset name tables between test runs.daniel2018-08-231-0/+22
| | | | | | | | | | | | | | | | Resetting the content_model and slot_role tables between test runs requires the corresponding NameTabelStore instances to be reset as well. We may however have many of them, buried in various services. There is no easy way to reset them consistently. Letting information in these tables persist between tests seems harmless. Tests that need these tables reset can simply add them to the tablesUsed array. This is needed for unit tests to work with the new MCR schema. Bug: T198561 Change-Id: I63e61e1ab74e00c20930a83d3a3f5df53092a197
* Disable PHPUnit tests that fail under postgresKunal Mehta2018-08-011-0/+3
| | | | | | | | So we can make the job voting, preventing other tests from regressing. These tests can be re-enabled whenever they're made to pass. Bug: T195807 Change-Id: I58261dd70eea3581803987a4a7739c7d55558f42
* Introduce argument for insert callback in NameTableStoreAmir Sarabadani2018-06-141-2/+19
| | | | | | | | This will be useful in cases we need to define more data when inserting a new row Bug: T193868 Change-Id: Ib5c2da2ef951e0bc782847ff8bd4606681ee2196
* Fix testGetMap_twoValues() failures for sqliteAaron Schulz2018-04-131-1/+1
| | | | Change-Id: I3f42208d8e42ba923d4b08bb7efe15f871165899
* [MCR] NameTableStoreaddshore2018-03-021-0/+298
General purpose cached store for things like: - content_models (id,name) - slot_roles (id,name) And in the future possibly namespaces & content_formats as mentioned at: https://www.mediawiki.org/wiki/Multi-Content_Revisions/Schema_Migration#Name_tables Bug: T188518 Change-Id: Ia550ef7fe30af25ac3fee5ac8a89d032544563bf