jenkins-bot has submitted this change and it was merged.

Change subject: Revert "Make prefer-recent tests must more consistent"
......................................................................


Revert "Make prefer-recent tests must more consistent"

This seemed to be working, but is now causing repeated 
failures in cindy.  The concept seems sound, reevaluate
why its failing now.

This reverts commit 5a7c942e65ecdb1fcbb9c042b0eca19055cfe0fc.

Change-Id: I155e367334dd19a59342d3482793cabfa90e0315
---
M includes/BuildDocument/PageDataBuilder.php
M includes/CirrusSearch.php
M includes/Searcher.php
M tests/browser/features/prefer_recent_api.feature
M tests/browser/features/step_definitions/search_steps.rb
M tests/browser/features/support/hooks.rb
M tests/jenkins/Jenkins.php
7 files changed, 19 insertions(+), 76 deletions(-)

Approvals:
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/BuildDocument/PageDataBuilder.php 
b/includes/BuildDocument/PageDataBuilder.php
index 36704bf..0545854 100644
--- a/includes/BuildDocument/PageDataBuilder.php
+++ b/includes/BuildDocument/PageDataBuilder.php
@@ -50,7 +50,6 @@
                // All content types have a language
                $this->doc->add( 'language',
                        $this->title->getPageLanguage()->getCode() );
-               $this->hackTimestamp();
 
                return $this->doc;
        }
@@ -144,26 +143,5 @@
                if ( $wikibaseItem !== false ) {
                        $this->doc->add( 'wikibase_item', $wikibaseItem );
                }
-       }
-
-       /**
-        * Check the page's text for timestamp hacking requests if they are 
enabled. Which should only be during testing.
-        */
-       private function hackTimestamp() {
-               global $wgCirrusSearchAllowTimeHacking;
-
-               if ( !isset( $wgCirrusSearchAllowTimeHacking ) ||
-                               !$wgCirrusSearchAllowTimeHacking ) {
-                       return;
-               }
-               $text = $this->content->getTextForSearchIndex();
-               if ( !$text ) {
-                       return;
-               }
-               $matches = array();
-               if ( !preg_match( '/timehack=(.+?)Z/', $text, $matches ) ) {
-                       return;
-               }
-               $this->doc->set( 'timestamp', wfTimestamp( TS_ISO_8601, 
$matches[ 1 ] ) );
        }
 }
diff --git a/includes/CirrusSearch.php b/includes/CirrusSearch.php
index fb1c019..9002048 100644
--- a/includes/CirrusSearch.php
+++ b/includes/CirrusSearch.php
@@ -127,10 +127,6 @@
                                if ( $request->getVal( 
'cirrusHighlightAltTitleWithPostings' ) === 'no' ) {
                                        $highlightingConfig ^= 
FullTextResultsType::HIGHLIGHT_ALT_TITLES_WITH_POSTINGS;
                                }
-                               $overrideNow = $request->getVal( 'now' );
-                               if ( $overrideNow ) {
-                                       $searcher->overrideNow( $overrideNow );
-                               }
                        }
                        if ( $this->namespaces && !in_array( NS_FILE, 
$this->namespaces ) ) {
                                $highlightingConfig ^= 
FullTextResultsType::HIGHLIGHT_FILE_TEXT;
diff --git a/includes/Searcher.php b/includes/Searcher.php
index c5df088..38439cc 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -12,11 +12,9 @@
 use Language;
 use MediaWiki\Logger\LoggerFactory;
 use MWNamespace;
-use MWTimestamp;
 use RequestContext;
 use SearchResultSet;
 use Status;
-use TimestampException;
 use Title;
 use UsageException;
 use User;
@@ -209,11 +207,6 @@
         * advanced highlighting (e.g. match_phrase_prefix for regular quoted 
strings).
         */
        private $nonTextHighlightQueries = array();
-
-       /**
-        * @var false|string override of the current time
-        */
-       private $overrideNow = false;
 
        /**
         * Constructor
@@ -1610,7 +1603,7 @@
                                'decayConstant' => $decayConstant,
                                'decayPortion' => 
$this->preferRecentDecayPortion,
                                'nonDecayPortion' => 1 - 
$this->preferRecentDecayPortion,
-                               'now' => $this->now(),
+                               'now' => time() * 1000
                        );
 
                        // e^ct where t is last modified time - now which is 
negative
@@ -1834,26 +1827,5 @@
                        $pairs['{' . $key . '}'] = $value;
                }
                return strtr( $input, $pairs );
-       }
-
-       /**
-        * Now in millseconds since epoch.
-        */
-       private function now() {
-               try {
-                       $t = new MWTimestamp( $this->overrideNow );
-               } catch ( TimestampException $e ) {
-                       $t = new MWTimestamp();
-               }
-               // MWTimestamp only has second precision which should be fine.
-               // But Elasticsearch wants to do everything in milliseconds.
-               return intval( $t->getTimestamp() ) * 1000;
-       }
-
-       /**
-        * Override the current time used in prefer-recent:.
-        */
-       public function overrideNow( $overrideNow ) {
-               $this->overrideNow = $overrideNow;
        }
 }
diff --git a/tests/browser/features/prefer_recent_api.feature 
b/tests/browser/features/prefer_recent_api.feature
index 1da3401..8885558 100644
--- a/tests/browser/features/prefer_recent_api.feature
+++ b/tests/browser/features/prefer_recent_api.feature
@@ -1,21 +1,22 @@
 @clean @api @prefer_recent
 Feature: Searches with prefer-recent
+  @expect_failure
   Scenario Outline: Recently updated articles are prefered if prefer-recent: 
is specified
-    Given I api search for PreferRecent First OR Second OR Third
-      And PreferRecent Second Second is the first api search result
-    When I api search with now set to 1970-01-01T01:00:00Z for 
prefer-recent:<options> PreferRecent First OR Second OR Third
+    When I api search for PreferRecent First OR Second OR Third
+    Then PreferRecent Second Second is the first api search result
+    When I api search for prefer-recent:<options> PreferRecent First OR Second 
OR Third
     Then PreferRecent Third is the first api search result
   Examples:
     |   options   |
     | 1,.001      |
     | 1,0.001     |
-    | 1,.005      |
-    | .9,.01      |
+    | 1,.0001     |
+    | .99,.0001   |
+    | .99,.001    |
 
+  @expect_failure
   Scenario Outline: You can specify prefer-recent: in such a way that being 
super recent isn't enough
-    Given I api search for PreferRecent First OR Second OR Third
-      And PreferRecent Second Second is the first api search result
-    When I api search with now set to 1970-01-01T01:00:00Z for 
prefer-recent:<options> PreferRecent First OR Second OR Third
+    When I api search for prefer-recent:<options> PreferRecent First OR Second 
OR Third
     Then PreferRecent Second Second is the first api search result
   Examples:
     |  options  |
diff --git a/tests/browser/features/step_definitions/search_steps.rb 
b/tests/browser/features/step_definitions/search_steps.rb
index cf4187d..484e605 100644
--- a/tests/browser/features/step_definitions/search_steps.rb
+++ b/tests/browser/features/step_definitions/search_steps.rb
@@ -25,17 +25,13 @@
   @didyoumean_options[varname] = value
 end
 # rubocop:disable LineLength
-# rubocop:disable ParameterLists
-# The plan to fix the line length is to break this into multiple steps that 
builds an instance variable and another
-# step that triggers the search using the instance variable.
-When(/^I api search( with disabled incoming link weighting)?(?: with now set 
to (.+Z))?(?: with offset (\d+))?(?: in the (.*) language)?(?: in namespaces? 
(\d+(?: \d+)*))? for (.*)$/) do |incoming_links, now, offset, lang, namespaces, 
search|
+When(/^I api search( with disabled incoming link weighting)?(?: with offset 
(\d+))?(?: in the (.*) language)?(?: in namespaces? (\d+(?: \d+)*))? for 
(.*)$/) do |incoming_links, offset, lang, namespaces, search|
   begin
     options = {
       sroffset: offset,
       srnamespace: (namespaces || "0").split(/ /),
       uselang: lang,
-      cirrusBoostLinks: incoming_links ? "no" : "yes",
-      now: now
+      cirrusBoostLinks: incoming_links ? "no" : "yes"
     }
     options = options.merge(@didyoumean_options) if defined?@didyoumean_options
 
diff --git a/tests/browser/features/support/hooks.rb 
b/tests/browser/features/support/hooks.rb
index 1265f3d..90317a3 100644
--- a/tests/browser/features/support/hooks.rb
+++ b/tests/browser/features/support/hooks.rb
@@ -312,10 +312,14 @@
 prefer_recent = false
 Before("@prefer_recent") do
   unless prefer_recent
+    # These are updated per process instead of per test because of the 20 
second wait
+    # Note that the scores have to be close together because 20 seconds 
doesn't mean a whole lot
     steps %(
-      Given a page named PreferRecent First exists with contents 
timehack=1970-01-01T00:00:00Z
-      And a page named PreferRecent Second Second exists with contents 
timehack=1970-01-01T00:00:00Z
-      And a page named PreferRecent Third exists with contents 
timehack=1970-01-01T00:10:00Z
+      Given a page named PreferRecent First exists with contents %{epoch}
+      And a page named PreferRecent Second Second exists with contents %{epoch}
+      And wait 20 seconds
+      And a page named PreferRecent Third exists with contents %{epoch}
+      And wait 10 seconds
         )
   end
   prefer_recent = true
diff --git a/tests/jenkins/Jenkins.php b/tests/jenkins/Jenkins.php
index 9719852..43b7486 100644
--- a/tests/jenkins/Jenkins.php
+++ b/tests/jenkins/Jenkins.php
@@ -67,7 +67,6 @@
 $wgCiteEnablePopups = true;
 $wgExtraNamespaces[ 760 ] = 'Mó';
 
-
 // Extra helpful configuration but not really required
 $wgShowExceptionDetails = true;
 
@@ -80,9 +79,6 @@
 $wgAPIModules['cirrus-freeze-writes'] = 
'CirrusSearch\Api\FreezeWritesToCluster';
 // Bring the ElasticWrite backoff down to between 2^-1 and 2^3 seconds during 
browser tests
 $wgCirrusSearchWriteBackoffExponent = -1;
-
-// Just for testing, allow the page's text to override the timestamp.
-$wgCirrusSearchAllowTimeHacking = true;
 
 class Jenkins {
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/232855
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I155e367334dd19a59342d3482793cabfa90e0315
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org>
Gerrit-Reviewer: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: DCausse <dcau...@wikimedia.org>
Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org>
Gerrit-Reviewer: Manybubbles <never...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to