MediaWiki development and administration

July 10, 2015

Hacky logging

wfDebug("foo is: $foo", '/tmp/debug.log');

Some kind of updating

vagrant git-update

Integration testing

https://www.mediawiki.org/wiki/Quality_Assurance/Browser_testing/Writing_tests

Get MediaWiki Vagrant:

$ git clone https://gerrit.wikimedia.org/r/mediawiki/vagrant
$ cd vagrant
$ git submodule update --init --recursive
$ ./setup.sh
$ vagrant config nfs_shares off
$ vagrant up

If there's a false detection of a conflict on port 8080, use ps to find the VBoxHeadless process. Kill it, and try again.

Enable the CirrusSearch Vagrant role:

$ vagrant enable-role cirrussearch
$ vagrant provision

Install various things for running the integration tests:

$ vagrant ssh
$ cd /vagrant/mediawiki/extensions/CirrusSearch/tests/browser/
$ sudo gem install bundler
$ bundle install
$ sudo apt-get install xvfb phantomjs

Run the integration tests:

$ vagrant ssh
$ cd /vagrant/mediawiki/extensions/CirrusSearch/tests/browser/
$ source selenium_exports_for_vagrant.sh
$ cucumber features/smoke.feature

This is often needed:

$ vagrant ssh
$ cd /vagrant/mediawiki
$ while true ; do php /vagrant/mediawiki/maintenance/runJobs.php ; sleep 1 ; done

EventLogging

Set up MediaWiki Vagrant.

Enable the EventLogging role:

$ vagrant enable-role eventlogging
$ vagrant provision

Enable the CirrusSearch role:

$ vagrant enable-role cirrussearch
$ vagrant provision

Set up EventLogging debugging:

$ vagrant ssh
$ cd /vagrant/mediawiki/extensions/EventLogging/server/
$ sudo python setup.py install
$ eventlogging-devserver --port 8100 --verbose

Copy the configuration values output by the EventLogging devserver and place them in the LocalSettings.php file:

require_once( "$IP/extensions/EventLogging/EventLogging.php" );
$wgEventLoggingSchemaApiUri = 'http://meta.wikimedia.org/w/api.php';

Set $wgCirrusSearchEnableSearchLogging to true in /mediawiki/extensions/CirrusSearch/CirrusSearch.php.

Set isSampled to true in /mediawiki/extensions/CirrusSearch/resources/loggingSchema/search.js.

CirrusSearch

Run searches against production Elasticsearch

Forward localhost:9900 to elastic1001:9200:

$ ssh bast1001.wikimedia.org -N -L 9900:elastic1001.eqiad.wmnet:9200

Search against localhost:9900 and find the resulting titles:

$ curl -s -XGET localhost:9900/enwiki_general_1415927710/_search -d @search.json |  jq -r '.hits|.hits[]|._source|.title'

See mediawiki/search.json