Last modified: 2014-02-14 16:28:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T60939, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 58939 - investigate using API to set up test data for browser tests
investigate using API to set up test data for browser tests
Status: RESOLVED FIXED
Product: Wikimedia
Classification: Unclassified
Quality Assurance (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Jeff Hall
:
Depends on:
Blocks: 56057
  Show dependency treegraph
 
Reported: 2013-12-24 17:46 UTC by Chris McMahon
Modified: 2014-02-14 16:28 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Chris McMahon 2013-12-24 17:46:41 UTC
Using a browser to create a new page in a test wiki and to populate that page with test data is prohibitively expensive and takes a long time. 

Using the API to create pages at runtime containing particular text and/or data should be significantly faster and more reliable.
Comment 1 Jeff Hall 2013-12-26 00:21:18 UTC
Building off the work that Aaron Arcos did for Bug 58555, we can use this Python library for Mediawiki interaction:

https://github.com/mwclient/mwclient

…and then create a script as simple as this to create a new wiki article:

import mwclient
site = mwclient.Site('en.wikipedia.beta.wmflabs.org')
site.login('<username>', '<password>')
page = site.Pages['Dune Messiah']
text = page.edit()
page.save(text + u'\nDune Messiah is a book by Frank Herbert.', summary = 'Page created via API call')

While we could also do this via Ruby, it seems that we might want to use Python instead for consistency with the API test(s) that Aaron has already developed.  Added bonus is that the "mwclient" library for Python seems to be actively maintained, while most of the Ruby libraries listed here do not appear to be actively maintained:

http://www.mediawiki.org/wiki/API:Client_code
Comment 2 Gerrit Notification Bot 2013-12-26 18:07:43 UTC
Change 103764 had a related patch set uploaded by Jhall:
WIP Script to create new article with random page title

https://gerrit.wikimedia.org/r/103764
Comment 3 Jeff Hall 2013-12-26 18:51:18 UTC
Changing bug status since task in still WIP.
Comment 4 Jeff Hall 2013-12-26 19:13:27 UTC
I modified a single page file in this WIP Gerrit commit:

https://gerrit.wikimedia.org/r/#/c/103764/

With this modification, when either the "aftv5.feature" or "page_edit.feature" tests are run, the "aftv5_page.rb" script calls a Python script (which in turn calls the Mediawiki API) and creates a new, randomly-named page via that API call.  Each test step from the feature file is then run against that newly-created page.

Note: The Python script does assume that the environment variable API_URL has been defined, so it knows what environment to run against.

A few items we'll want to consider:

1) Python was chosen for the API client calls due to previous API test work done by Aaron Aarcos in Python, but we could almost certainly do the same thing from Ruby (or another language) if there are objections to Python.

2) Per a conversation with Chris, if this initial approach seems fine, then we should also write a script to create a new user login via the API, and modify tests so that they use both the newly-ceated user account and the newly-created wiki article when they run.
Comment 5 Gerrit Notification Bot 2014-01-06 20:12:38 UTC
Change 103764 abandoned by Jhall:
WIP Script to create new article with random page title

Reason:
Abandoning this commit so that I can start fresh on the all-Ruby solution (bye-bye Python).

https://gerrit.wikimedia.org/r/103764
Comment 6 Jeff Hall 2014-01-14 16:17:08 UTC
Resolved via this Gerrit patch set:

https://gerrit.wikimedia.org/r/#/c/106548/
Comment 7 Jon 2014-01-14 23:20:22 UTC
Patch hasn't been merged yet.
Comment 8 Željko Filipin 2014-02-14 11:39:13 UTC
Jeff, is this resolved?
Comment 9 Jeff Hall 2014-02-14 16:28:32 UTC
Yep, this one is resolved, and documentation on the new test setup methods has been added to mediawiki.org:

https://www.mediawiki.org/wiki/Quality_Assurance/Browser_testing/Writing_tests#API-based_test_setup_methods

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links