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

Change subject: Send groovy script for updates to limit changes
......................................................................


Send groovy script for updates to limit changes

This should prevent noop updates.  It has a tolerance for incoming_links
as well - if they are within 20% they won't be changed.

Fix selenium_exports_for_vagrant.sh to not reuse browsers - that no longer
works well with new releases of mediawiki_selenium.

Also fix busted hack for to speed up undelaying jobs.  Much faster better now.

Change-Id: I0655f67cfcb47c9f0587a77e789f1160ca5c429b
---
M includes/Updater.php
M tests/browser/selenium_exports_for_vagrant.sh
M tests/jenkins/Jenkins.php
3 files changed, 35 insertions(+), 20 deletions(-)

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



diff --git a/includes/Updater.php b/includes/Updater.php
index 5783e59..e4c01f7 100644
--- a/includes/Updater.php
+++ b/includes/Updater.php
@@ -191,12 +191,10 @@
                $allData = array_fill_keys( Connection::getAllIndexTypes(), 
array() );
                foreach ( $this->buildDocumentsForPages( $pages, $flags ) as 
$document ) {
                        $suffix = Connection::getIndexSuffixForNamespace( 
$document->get( 'namespace' ) );
-                       // $allData[$suffix][] = $this->docToScript( $document 
);
+                       $allData[$suffix][] = $this->docToScript( $document );
                        // To quickly switch back to sending doc as upsert 
instead of script, remove the line above
                        // and switch to the one below:
-                       // -- As you can see we switched back - MVEL was 
freaking out every once in a while and we
-                       // had trouble reproducing it locally.  Faster to just 
turn it off.
-                       $allData[$suffix][] = $document;
+                       // $allData[$suffix][] = $document;
                }
                $count = 0;
                foreach( $allData as $indexType => $data ) {
@@ -362,30 +360,46 @@
        }
 
        private function docToScript( $doc ) {
-               // !!!!!!!!!NOTE!!!!!!!!
-               // This has not been ported to groovy because it is not in 
active use.  Please port if using.
-               $scriptText = <<<MVEL
+               $scriptText = <<<GROOVY
 changed = false;
 
-MVEL;
+GROOVY;
                $params = $doc->getParams();
                foreach ( $doc->getData() as $key => $value ) {
-                       $scriptText .= <<<MVEL
-if ( ctx._source.$key != $key ) {
+                       if ( $key === 'incoming_links' ) {
+                               // incoming links has to be more then 20% 
incorrect before we update it.
+                               $scriptText .= <<<GROOVY
+if ( ctx._source.$key == null ) {
+       thisChanged = true;
+} else if ( $key == 0 ) {
+       thisChanged = ctx._source.$key != 0;
+} else {
+       thisChanged = abs( ctx._source.$key - $key ) / $key > 0.2;
+}
+if ( thisChanged ) {
        changed = true;
        ctx._source.$key = $key;
 }
 
-MVEL;
+GROOVY;
+                       } else {
+                               $scriptText .= <<<GROOVY
+if ( changed || ctx._source.$key != $key ) {
+       changed = true;
+       ctx._source.$key = $key;
+}
+
+GROOVY;
+                       }
                        $params[ $key ] = $value;
                }
-               $scriptText .= <<<MVEL
+               $scriptText .= <<<GROOVY
 if ( !changed ) {
        ctx.op = "none";
 }
 
-MVEL;
-               $script = new \Elastica\Script( $scriptText, $params, 'mvel' );
+GROOVY;
+               $script = new \Elastica\Script( $scriptText, $params, 'groovy' 
);
                if ( $doc->getDocAsUpsert() ) {
                        $script->setUpsert( $doc );
                }
diff --git a/tests/browser/selenium_exports_for_vagrant.sh 
b/tests/browser/selenium_exports_for_vagrant.sh
index 3a3e6be..a0a85f1 100644
--- a/tests/browser/selenium_exports_for_vagrant.sh
+++ b/tests/browser/selenium_exports_for_vagrant.sh
@@ -1,6 +1,6 @@
 export MEDIAWIKI_USER=admin
 export MEDIAWIKI_PASSWORD=vagrant
 export MEDIAWIKI_URL=http://127.0.0.1:8080/wiki/
-export REUSE_BROWSER=true
+export REUSE_BROWSER=false
 export SCREENSHOT_FAILURES=true
 export BROWSER=phantomjs
diff --git a/tests/jenkins/Jenkins.php b/tests/jenkins/Jenkins.php
index 00022c1..116d2f0 100644
--- a/tests/jenkins/Jenkins.php
+++ b/tests/jenkins/Jenkins.php
@@ -1,6 +1,7 @@
 <?php
 namespace CirrusSearch\Jenkins;
 
+use \JobQueueAggregator;
 use \JobQueueGroup;
 
 /**
@@ -75,10 +76,6 @@
 );
 $wgCiteEnablePopups = true;
 
-// Running a ton of jobs every request helps to make sure all the pages that 
are created
-// are indexed as fast as possible.
-$wgJobRunRate = 100;
-
 // Extra helpful configuration but not really required
 $wgShowExceptionDetails = true;
 $wgCirrusSearchShowScore = true;
@@ -103,7 +100,11 @@
        public static function recyclePruneAndUndelayJobs( $special, $subpage ) 
{
                $jobQueue = JobQueueGroup::singleton()->get( 
'cirrusSearchLinksUpdateSecondary' );
                if ( $jobQueue ) {
-                       $jobQueue->recyclePruneAndUndelayJobs();
+                       $count = $jobQueue->recyclePruneAndUndelayJobs();
+                       if ( $count ) {
+                               
JobQueueAggregator::singleton()->notifyQueueNonEmpty( $jobQueue->getWiki(),
+                                       'cirrusSearchLinksUpdateSecondary' );
+                       }
                }
        }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0655f67cfcb47c9f0587a77e789f1160ca5c429b
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to