[MediaWiki-commits] [Gerrit] mediawiki...CirrusSearch[master]: Initial RequestLogger tests

2016-10-20 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Initial RequestLogger tests
..


Initial RequestLogger tests

These tests don't seem particularly amazing, but they should
provide some ability to see that the refactor of request logging
works as expected and still generates the same output for some
sets of inputs.

These test cases obviously don't workout all the various options
that could exist, failure cases, etc, but its better than nothing.
More test cases can fairly easily be added if we find there are
corner cases that need to be tested.

Change-Id: If15f280d1bf0b8f8df30b9c25f2bcd4e860aee0a
---
M includes/CompletionSuggester.php
M includes/Connection.php
M includes/RequestLogger.php
A tests/unit/RequestLoggerTest.php
A tests/unit/fixtures/requestLogging/completion_basic_001.expected
A tests/unit/fixtures/requestLogging/completion_basic_001.request
A tests/unit/fixtures/requestLogging/completion_basic_001.response
A tests/unit/fixtures/requestLogging/completion_basic_002.expected
A tests/unit/fixtures/requestLogging/completion_basic_002.request
A tests/unit/fixtures/requestLogging/completion_basic_002.response
A tests/unit/fixtures/requestLogging/findNamespace_001.expected
A tests/unit/fixtures/requestLogging/findNamespace_001.request
A tests/unit/fixtures/requestLogging/findNamespace_001.response
A tests/unit/fixtures/requestLogging/findNamespace_002.expected
A tests/unit/fixtures/requestLogging/findNamespace_002.request
A tests/unit/fixtures/requestLogging/findNamespace_002.response
A tests/unit/fixtures/requestLogging/fulltext_basic_001.expected
A tests/unit/fixtures/requestLogging/fulltext_basic_001.request
A tests/unit/fixtures/requestLogging/fulltext_basic_001.response
A tests/unit/fixtures/requestLogging/fulltext_basic_002.expected
A tests/unit/fixtures/requestLogging/fulltext_basic_002.request
A tests/unit/fixtures/requestLogging/fulltext_basic_002.response
A tests/unit/fixtures/requestLogging/fulltext_basic_003.expected
A tests/unit/fixtures/requestLogging/fulltext_basic_003.request
A tests/unit/fixtures/requestLogging/fulltext_basic_003.response
A tests/unit/fixtures/requestLogging/fulltext_basic_004.expected
A tests/unit/fixtures/requestLogging/fulltext_basic_004.request
A tests/unit/fixtures/requestLogging/fulltext_basic_004.response
A tests/unit/fixtures/requestLogging/fulltext_interwiki_001.expected
A tests/unit/fixtures/requestLogging/fulltext_interwiki_001.request
A tests/unit/fixtures/requestLogging/fulltext_interwiki_001.response
A tests/unit/fixtures/requestLogging/fulltext_otherindex_001.expected
A tests/unit/fixtures/requestLogging/fulltext_otherindex_001.request
A tests/unit/fixtures/requestLogging/fulltext_otherindex_001.response
A tests/unit/fixtures/requestLogging/get_001.expected
A tests/unit/fixtures/requestLogging/get_001.request
A tests/unit/fixtures/requestLogging/get_001.response
A tests/unit/fixtures/requestLogging/get_002.expected
A tests/unit/fixtures/requestLogging/get_002.request
A tests/unit/fixtures/requestLogging/get_002.response
A tests/unit/fixtures/requestLogging/get_003.expected
A tests/unit/fixtures/requestLogging/get_003.request
A tests/unit/fixtures/requestLogging/get_003.response
43 files changed, 2,303 insertions(+), 14 deletions(-)

Approvals:
  Cindy-the-browser-test-bot: Looks good to me, but someone else must approve
  DCausse: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/CompletionSuggester.php b/includes/CompletionSuggester.php
index ff385f1..80c659c 100644
--- a/includes/CompletionSuggester.php
+++ b/includes/CompletionSuggester.php
@@ -222,14 +222,11 @@
$profiles, $text ) {
$description = "{queryType} search for 
'{query}'";
$this->start( $description, $logContext );
-   $this->logContext['timing']['start'] = 
microtime( true );
try {
$result = $index->request( "_suggest", 
Request::POST, $suggest, $queryOptions );
-   
$this->logContext['timing']['end-comp-req'] = microtime( true );
if( $result->isOk() ) {
$result = 
$this->postProcessSuggest( $result, $profiles );
}
-   $this->logContext['timing']['done'] = 
microtime( true );
return $this->success( $result );
} catch ( 
\Elastica\Exception\ExceptionInterface $e ) {
return $this->failure( $e );
@@ -428,7 +425,6 @@
$data = $response->getData();
unset( $data['_shards'] );
 
-   $this->logContext['timing']['mark1'] = microtime

[MediaWiki-commits] [Gerrit] mediawiki...CirrusSearch[master]: Initial RequestLogger tests

2016-10-03 Thread EBernhardson (Code Review)
EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/313931

Change subject: Initial RequestLogger tests
..

Initial RequestLogger tests

These tests don't seem particularly amazing, but they should
provide some ability to see that the refactor of request logging
works as expected and still generates the same output for some
sets of inputs.

These test cases obviously don't workout all the various options
that could exist, failure cases, etc, but its better than nothing.
Testing everything from this high of level would be incredibly verbose.

Maybe this should be re-worked to use fixtures like the searchText
instead of trying to spell out the full response/log cycle in the code?

Change-Id: If15f280d1bf0b8f8df30b9c25f2bcd4e860aee0a
---
M includes/CompletionSuggester.php
M includes/Connection.php
M includes/RequestLogger.php
A tests/unit/RequestLogger.php
4 files changed, 278 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/31/313931/1

diff --git a/includes/CompletionSuggester.php b/includes/CompletionSuggester.php
index 1ff38d5..d232693 100644
--- a/includes/CompletionSuggester.php
+++ b/includes/CompletionSuggester.php
@@ -222,14 +222,11 @@
$profiles, $text ) {
$description = "{queryType} search for 
'{query}'";
$this->start( $description, $logContext );
-   $this->logContext['timing']['start'] = 
microtime( true );
try {
$result = $index->request( "_suggest", 
Request::POST, $suggest, $queryOptions );
-   
$this->logContext['timing']['end-comp-req'] = microtime( true );
if( $result->isOk() ) {
$result = 
$this->postProcessSuggest( $result, $profiles );
}
-   $this->logContext['timing']['done'] = 
microtime( true );
return $this->success( $result );
} catch ( 
\Elastica\Exception\ExceptionInterface $e ) {
return $this->failure( $e );
@@ -428,7 +425,6 @@
$data = $response->getData();
unset( $data['_shards'] );
 
-   $this->logContext['timing']['mark1'] = microtime( true );
$limit = $this->getHardLimit();
$suggestionsByDocId = [];
$suggestionProfileByDocId = [];
@@ -462,7 +458,6 @@
}
}
}
-   $this->logContext['timing']['mark2'] = microtime( true );
 
// simply sort by existing scores
uasort( $suggestionsByDocId, function ( SearchSuggestion $a, 
SearchSuggestion $b ) {
@@ -487,7 +482,6 @@
}
 
if ( !empty ( $missingTextDocIds ) ) {
-   $this->logContext['timing']['mark3'] = microtime( true 
);
// Experimental.
//
// Second pass query to fetch redirects.
@@ -505,7 +499,6 @@
$redirResponse = $type->request( '_mget', 'GET',
[ 'ids' => $missingTextDocIds ],
[ '_source_include' => 'redirect' ] );
-   $this->logContext['timing']['mark4'] = 
microtime( true );
if ( $redirResponse->isOk() ) {
$this->logContext['elasticTook2PassMs'] 
= intval( $redirResponse->getQueryTime() * 1000 );
$docs = $redirResponse->getData();
@@ -538,10 +531,8 @@
]
);
}
-   $this->logContext['timing']['mark5'] = microtime( true 
);
}
 
-   $this->logContext['timing']['mark6'] = microtime( true );
$finalResults = array_filter(
$suggestionsByDocId,
function ( SearchSuggestion $suggestion ) {
@@ -570,7 +561,6 @@
];
}
$this->logContext['maxScore'] = $maxScore;
-   $this->logContext['timing']['mark7'] = microtime( true );
 
return new SearchSuggestionSet( $finalResults );
}
diff --git a/includes/Connection.php b/includes/Connection.php
index 035d534..af2a881 100644
--- a/includes/Connection.php
+++ b/includes/Connection.php
@@ -171,6 +171,7 @@
foreach ( $config as $idx => $server ) {