jenkins-bot has submitted this change and it was merged.
Change subject: Added read affinity tests for FileBackendMultiWrite
......................................................................
Added read affinity tests for FileBackendMultiWrite
Change-Id: I1407273175396d4d3631531ff0ca0afa3009913e
---
M tests/phpunit/includes/filebackend/FileBackendTest.php
1 file changed, 50 insertions(+), 0 deletions(-)
Approvals:
Gilles: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/phpunit/includes/filebackend/FileBackendTest.php
b/tests/phpunit/includes/filebackend/FileBackendTest.php
index aaa93ef..2e4942f 100644
--- a/tests/phpunit/includes/filebackend/FileBackendTest.php
+++ b/tests/phpunit/includes/filebackend/FileBackendTest.php
@@ -2392,6 +2392,56 @@
"Scoped unlocking of files succeeded with OK status
($backendName)." );
}
+ public function testReadAffinity() {
+ $be = TestingAccessWrapper::newFromObject(
+ new FileBackendMultiWrite( array(
+ 'name' => 'localtesting',
+ 'wikiId' => wfWikiId() . mt_rand(),
+ 'backends' => array(
+ array( // backend 0
+ 'name' => 'multitesting0',
+ 'class' => 'MemoryFileBackend',
+ 'isMultiMaster' => false,
+ 'readAffinity' => true
+ ),
+ array( // backend 1
+ 'name' => 'multitesting1',
+ 'class' => 'MemoryFileBackend',
+ 'isMultiMaster' => true
+ )
+ )
+ ) )
+ );
+
+ $this->assertEquals(
+ 1,
+ $be->getReadIndexFromParams( array( 'latest' => 1 ) ),
+ 'Reads with "latest" flag use backend 1'
+ );
+ $this->assertEquals(
+ 0,
+ $be->getReadIndexFromParams( array( 'latest' => 0 ) ),
+ 'Reads without "latest" flag use backend 0'
+ );
+
+ $p = 'container/test-cont/file.txt';
+ $be->backends[0]->quickCreate( array(
+ 'dst' => "mwstore://multitesting0/$p", 'content' =>
'cattitude' ) );
+ $be->backends[1]->quickCreate( array(
+ 'dst' => "mwstore://multitesting1/$p", 'content' =>
'princess of power' ) );
+
+ $this->assertEquals(
+ 'cattitude',
+ $be->getFileContents( array( 'src' =>
"mwstore://localtesting/$p" ) ),
+ "Non-latest read came from backend 0"
+ );
+ $this->assertEquals(
+ 'princess of power',
+ $be->getFileContents( array( 'src' =>
"mwstore://localtesting/$p", 'latest' => 1 ) ),
+ "Latest read came from backend1"
+ );
+ }
+
// helper function
private function listToArray( $iter ) {
return is_array( $iter ) ? $iter : iterator_to_array( $iter );
--
To view, visit https://gerrit.wikimedia.org/r/239894
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1407273175396d4d3631531ff0ca0afa3009913e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits