rdbms: Bump TransactionProfiler log entries to WARNING
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / rdbms / TransactionProfilerTest.php
index cb18fb3..25613fe 100644 (file)
@@ -3,10 +3,16 @@
 use Wikimedia\Rdbms\TransactionProfiler;
 use Psr\Log\LoggerInterface;
 
+/**
+ * @covers \Wikimedia\Rdbms\TransactionProfiler
+ */
 class TransactionProfilerTest extends PHPUnit_Framework_TestCase {
+
+       use MediaWikiCoversValidator;
+
        public function testAffected() {
                $logger = $this->getMockBuilder( LoggerInterface::class )->getMock();
-               $logger->expects( $this->exactly( 3 ) )->method( 'info' );
+               $logger->expects( $this->exactly( 3 ) )->method( 'warning' );
 
                $tp = new TransactionProfiler();
                $tp->setLogger( $logger );
@@ -21,7 +27,7 @@ class TransactionProfilerTest extends PHPUnit_Framework_TestCase {
        public function testReadTime() {
                $logger = $this->getMockBuilder( LoggerInterface::class )->getMock();
                // 1 per query
-               $logger->expects( $this->exactly( 2 ) )->method( 'info' );
+               $logger->expects( $this->exactly( 2 ) )->method( 'warning' );
 
                $tp = new TransactionProfiler();
                $tp->setLogger( $logger );
@@ -36,7 +42,7 @@ class TransactionProfilerTest extends PHPUnit_Framework_TestCase {
        public function testWriteTime() {
                $logger = $this->getMockBuilder( LoggerInterface::class )->getMock();
                // 1 per query, 1 per trx, and one "sub-optimal trx" entry
-               $logger->expects( $this->exactly( 4 ) )->method( 'info' );
+               $logger->expects( $this->exactly( 4 ) )->method( 'warning' );
 
                $tp = new TransactionProfiler();
                $tp->setLogger( $logger );
@@ -50,7 +56,7 @@ class TransactionProfilerTest extends PHPUnit_Framework_TestCase {
 
        public function testAffectedTrx() {
                $logger = $this->getMockBuilder( LoggerInterface::class )->getMock();
-               $logger->expects( $this->exactly( 1 ) )->method( 'info' );
+               $logger->expects( $this->exactly( 1 ) )->method( 'warning' );
 
                $tp = new TransactionProfiler();
                $tp->setLogger( $logger );
@@ -63,7 +69,7 @@ class TransactionProfilerTest extends PHPUnit_Framework_TestCase {
        public function testWriteTimeTrx() {
                $logger = $this->getMockBuilder( LoggerInterface::class )->getMock();
                // 1 per trx, and one "sub-optimal trx" entry
-               $logger->expects( $this->exactly( 2 ) )->method( 'info' );
+               $logger->expects( $this->exactly( 2 ) )->method( 'warning' );
 
                $tp = new TransactionProfiler();
                $tp->setLogger( $logger );
@@ -75,7 +81,7 @@ class TransactionProfilerTest extends PHPUnit_Framework_TestCase {
 
        public function testConns() {
                $logger = $this->getMockBuilder( LoggerInterface::class )->getMock();
-               $logger->expects( $this->exactly( 2 ) )->method( 'info' );
+               $logger->expects( $this->exactly( 2 ) )->method( 'warning' );
 
                $tp = new TransactionProfiler();
                $tp->setLogger( $logger );
@@ -89,7 +95,7 @@ class TransactionProfilerTest extends PHPUnit_Framework_TestCase {
 
        public function testMasterConns() {
                $logger = $this->getMockBuilder( LoggerInterface::class )->getMock();
-               $logger->expects( $this->exactly( 2 ) )->method( 'info' );
+               $logger->expects( $this->exactly( 2 ) )->method( 'warning' );
 
                $tp = new TransactionProfiler();
                $tp->setLogger( $logger );
@@ -106,36 +112,36 @@ class TransactionProfilerTest extends PHPUnit_Framework_TestCase {
 
        public function testReadQueryCount() {
                $logger = $this->getMockBuilder( LoggerInterface::class )->getMock();
-               $logger->expects( $this->exactly( 2 ) )->method( 'info' );
+               $logger->expects( $this->exactly( 2 ) )->method( 'warning' );
 
                $tp = new TransactionProfiler();
                $tp->setLogger( $logger );
                $tp->setExpectation( 'queries', 2, __METHOD__ );
 
-               $tp->recordQueryCompletion( "SQL 1", microtime( true ) - .01, false, 0 );
-               $tp->recordQueryCompletion( "SQL 2", microtime( true ) - .01, false, 0 );
-               $tp->recordQueryCompletion( "SQL 3", microtime( true ) - .01, false, 0 ); // warn
-               $tp->recordQueryCompletion( "SQL 4", microtime( true ) - .01, false, 0 ); // warn
+               $tp->recordQueryCompletion( "SQL 1", microtime( true ) - 0.01, false, 0 );
+               $tp->recordQueryCompletion( "SQL 2", microtime( true ) - 0.01, false, 0 );
+               $tp->recordQueryCompletion( "SQL 3", microtime( true ) - 0.01, false, 0 ); // warn
+               $tp->recordQueryCompletion( "SQL 4", microtime( true ) - 0.01, false, 0 ); // warn
        }
 
        public function testWriteQueryCount() {
                $logger = $this->getMockBuilder( LoggerInterface::class )->getMock();
-               $logger->expects( $this->exactly( 2 ) )->method( 'info' );
+               $logger->expects( $this->exactly( 2 ) )->method( 'warning' );
 
                $tp = new TransactionProfiler();
                $tp->setLogger( $logger );
                $tp->setExpectation( 'writes', 2, __METHOD__ );
 
-               $tp->recordQueryCompletion( "SQL 1", microtime( true ) - .01, false, 0 );
-               $tp->recordQueryCompletion( "SQL 2", microtime( true ) - .01, false, 0 );
-               $tp->recordQueryCompletion( "SQL 3", microtime( true ) - .01, false, 0 );
-               $tp->recordQueryCompletion( "SQL 4", microtime( true ) - .01, false, 0 );
+               $tp->recordQueryCompletion( "SQL 1", microtime( true ) - 0.01, false, 0 );
+               $tp->recordQueryCompletion( "SQL 2", microtime( true ) - 0.01, false, 0 );
+               $tp->recordQueryCompletion( "SQL 3", microtime( true ) - 0.01, false, 0 );
+               $tp->recordQueryCompletion( "SQL 4", microtime( true ) - 0.01, false, 0 );
 
                $tp->transactionWritingIn( 'srv1', 'db1', '123' );
-               $tp->recordQueryCompletion( "SQL 1w", microtime( true ) - .01, true, 2 );
-               $tp->recordQueryCompletion( "SQL 2w", microtime( true ) - .01, true, 5 );
-               $tp->recordQueryCompletion( "SQL 3w", microtime( true ) - .01, true, 3 );
-               $tp->recordQueryCompletion( "SQL 4w", microtime( true ) - .01, true, 1 );
+               $tp->recordQueryCompletion( "SQL 1w", microtime( true ) - 0.01, true, 2 );
+               $tp->recordQueryCompletion( "SQL 2w", microtime( true ) - 0.01, true, 5 );
+               $tp->recordQueryCompletion( "SQL 3w", microtime( true ) - 0.01, true, 3 );
+               $tp->recordQueryCompletion( "SQL 4w", microtime( true ) - 0.01, true, 1 );
                $tp->transactionWritingOut( 'srv1', 'db1', '123', 1, 1 );
        }
 }