merged master
[lhc/web/wiklou.git] / tests / phpunit / includes / filerepo / FileBackendTest.php
index 61507f5..0b36bf1 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 
 /**
+ * @group medium
+ * ^---- causes phpunit to use a higher timeout threshold
+ * 
  * @group FileRepo
  * @group FileBackend
  */
@@ -243,6 +246,8 @@ class FileBackendTest extends MediaWikiTestCase {
                $props2 = $this->backend->getFileProps( array( 'src' => $dest ) );
                $this->assertEquals( $props1, $props2,
                        "Source and destination have the same props ($backendName)." );
+
+               $this->assertBackendPathsConsistent( array( $dest ) );
        }
 
        public function provider_testStore() {
@@ -330,6 +335,8 @@ class FileBackendTest extends MediaWikiTestCase {
                $props2 = $this->backend->getFileProps( array( 'src' => $dest ) );
                $this->assertEquals( $props1, $props2,
                        "Source and destination have the same props ($backendName)." );
+
+               $this->assertBackendPathsConsistent( array( $source, $dest ) );
        }
 
        public function provider_testCopy() {
@@ -419,6 +426,8 @@ class FileBackendTest extends MediaWikiTestCase {
                        "Source file does not exist accourding to props ($backendName)." );
                $this->assertEquals( true, $props2['fileExists'],
                        "Destination file exists accourding to props ($backendName)." );
+
+               $this->assertBackendPathsConsistent( array( $source, $dest ) );
        }
 
        public function provider_testMove() {
@@ -504,6 +513,8 @@ class FileBackendTest extends MediaWikiTestCase {
                $props1 = $this->backend->getFileProps( array( 'src' => $source ) );
                $this->assertFalse( $props1['fileExists'],
                        "Source file $source does not exist according to props ($backendName)." );
+
+               $this->assertBackendPathsConsistent( array( $source ) );
        }
 
        public function provider_testDelete() {
@@ -595,6 +606,8 @@ class FileBackendTest extends MediaWikiTestCase {
                                $this->backend->getFileSize( array( 'src' => $dest ) ),
                                "Destination file $dest has original size according to props ($backendName)." );
                }
+
+               $this->assertBackendPathsConsistent( array( $dest ) );
        }
 
        /**
@@ -1137,26 +1150,6 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->tearDownFiles();
                $this->doTestDoOperations();
                $this->tearDownFiles();
-
-               $this->backend = $this->singleBackend;
-               $this->tearDownFiles();
-               $this->doTestDoOperations2();
-               $this->tearDownFiles();
-
-               $this->backend = $this->multiBackend;
-               $this->tearDownFiles();
-               $this->doTestDoOperations2();
-               $this->tearDownFiles();
-
-               $this->backend = $this->singleBackend;
-               $this->tearDownFiles();
-               $this->doTestDoOperationsFailing();
-               $this->tearDownFiles();
-
-               $this->backend = $this->multiBackend;
-               $this->tearDownFiles();
-               $this->doTestDoOperationsFailing();
-               $this->tearDownFiles();
        }
 
        private function doTestDoOperations() {
@@ -1232,8 +1225,20 @@ class FileBackendTest extends MediaWikiTestCase {
                        "Correct file SHA-1 of $fileC" );
        }
 
+       public function testDoOperationsPipeline() {
+               $this->backend = $this->singleBackend;
+               $this->tearDownFiles();
+               $this->doTestDoOperationsPipeline();
+               $this->tearDownFiles();
+
+               $this->backend = $this->multiBackend;
+               $this->tearDownFiles();
+               $this->doTestDoOperationsPipeline();
+               $this->tearDownFiles();
+       }
+
        // concurrency orientated
-       private function doTestDoOperations2() {
+       private function doTestDoOperationsPipeline() {
                $base = $this->baseStorePath();
 
                $fileAContents = '3tqtmoeatmn4wg4qe-mg3qt3 tq';
@@ -1319,6 +1324,18 @@ class FileBackendTest extends MediaWikiTestCase {
                        "Correct file SHA-1 of $fileC" );
        }
 
+       public function testDoOperationsFailing() {
+               $this->backend = $this->singleBackend;
+               $this->tearDownFiles();
+               $this->doTestDoOperationsFailing();
+               $this->tearDownFiles();
+
+               $this->backend = $this->multiBackend;
+               $this->tearDownFiles();
+               $this->doTestDoOperationsFailing();
+               $this->tearDownFiles();
+       }
+
        private function doTestDoOperationsFailing() {
                $base = $this->baseStorePath();
 
@@ -1822,6 +1839,13 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->backend->clean( array( 'dir' => "$base/$container", 'recursive' => 1 ) );
        }
 
+       function assertBackendPathsConsistent( array $paths ) {
+               if ( $this->backend instanceof FileBackendMultiWrite ) {
+                       $status = $this->backend->consistencyCheck( $paths );
+                       $this->assertGoodStatus( $status, "Files synced: " . implode( ',', $paths ) );
+               }
+       }
+
        function assertGoodStatus( $status, $msg ) {
                $this->assertEquals( print_r( array(), 1 ), print_r( $status->errors, 1 ), $msg );
        }