Page MenuHomePhabricator

Automated browser tests cannot create pages on the Beta Cluster as anonymous user in RelatedArticles tests
Closed, ResolvedPublic

Description

All builds since #40 have failed for the same reason.

The key part of the report is:

Edit failed: Error: Error returned by API: Wikipedia has restricted the ability to create new pages. You can go back and edit an existing page, or [[Special:UserLogin|log in or create an account]].

It is not possible to create a new page as an anonymous user on the Beta Cluster which is the reason for the problem.

Suggested Fixes

As I commented in T176315#3626845, it looks like the failing test doesn't log in before trying to create/edit the Related Articles 1 page.

Use @zeljkofilipin's snippet from T162256#3588456 to login on line 12 of tests/selenium/specs/readmore.js.


[0]
Failed
 
chrome.ReadMore2."before all" hook4 (from readmore2)
 
Failing for the past 4 builds (Since Failed#40 )
Took 0.17 sec.
add description
Error Message

Edit failed: Error: Error returned by API: Wikipedia has restricted the ability to create new pages. You can go back and edit an existing page, or [[Special:UserLogin|log in or create an account]].
Standard Error
        
Error: Edit failed: Error: Error returned by API: Wikipedia has restricted the ability to create new pages. You can go back and edit an existing page, or [[Special:UserLogin|log in or create an account]].
     at Context.<anonymous> (extensions/RelatedArticles/tests/selenium/specs/readmore.js:13:11)
     at node_modules/nodemw/lib/bot.js:514:16
     at Request._callback (node_modules/nodemw/lib/api.js:219:5)
     at Request.self.callback (node_modules/request/request.js:186:22)
     at emitTwo (events.js:106:13)
     at Request.emit (events.js:191:7)
     at Request.<anonymous> (node_modules/request/request.js:1163:10)
     at emitOne (events.js:96:13)
     at Request.emit (events.js:188:7)
     at IncomingMessage.<anonymous> (node_modules/request/request.js:1085:12)
     at IncomingMessage.g (events.js:292:16)

Alternatively the EditPage in core should be using the "Selenium user" account - not the current user.

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 20 2017, 1:28 PM
phuedx renamed this task from Tests cannot create pages to Automated browser tests cannot create pages on the Beta Cluster.Sep 20 2017, 4:14 PM
phuedx updated the task description. (Show Details)

@zeljkofilipin @hashar: Has the Beta Cluster been locked down since 16th September?

This should be fixed now per T176222#3624781 onwards. I've started a new build.

It looks like these tests don't login before trying to edit the Related Articles 1 page.

Jdlrobson closed this task as Resolved.Sep 22 2017, 9:49 PM
Jdlrobson claimed this task.
Jdlrobson added a subscriber: Jdlrobson.

This is fixed now.

phuedx reopened this task as Open.Sep 25 2017, 10:07 AM
phuedx updated the task description. (Show Details)

Unfortunately, this isn't fixed.

phuedx removed Jdlrobson as the assignee of this task.Sep 25 2017, 10:09 AM
phuedx triaged this task as High priority.
phuedx added a project: good first bug.
phuedx moved this task from Needs Prioritization to Upcoming on the Readers-Web-Backlog board.
phuedx added a subscriber: ovasileva.

/cc @ovasileva

Also, I've added the good first bug project tag assuming that the suggested fix is what's necessary.

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptSep 25 2017, 10:09 AM

Change 380505 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/core@master] API edits should use the Selenium user

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

Use @zeljkofilipin's snippet from T162256#3588456 to login on line 12 of tests/selenium/specs/readmore.js.

This shouldn't be necessary. We are using apiEdit and I would expect that in Selenium to behave just like Ruby - and use a specific user to do editing rather than the current user in the test.

@zeljkofilipin is the patch above sane?

Jdlrobson updated the task description. (Show Details)
Jdlrobson renamed this task from Automated browser tests cannot create pages on the Beta Cluster to Automated browser tests cannot create pages on the Beta Cluster as anonymous user in RelatedArticles tests.Sep 25 2017, 1:49 PM
phuedx updated the task description. (Show Details)EditedSep 25 2017, 1:52 PM
This comment has been deleted.

@Jdlrobson: Why isn't this task easy? What did I miss?

@phuedx this requires expertise of both the Ruby and Node stack and knowledge of how the browser tests in the various environments are configured. We'll want to provide the same API in Node as we do in Ruby to make migration from Ruby to Node as easy as possible. I believe this is best addressed by someone in the Release Engineering team. I'm not sure if and how similar tests are run in core. Given RelatedArticles is one of the early adopters (only adopter?) this is a kink that need ironing out.

My patch is only a guess and untested in our test environments and I expect @zeljkofilipin would be best suited to fix this.

👍 Just so long as there's an explanation given.

Change 381948 had a related patch set uploaded (by Zfilipin; owner: Zfilipin):
[mediawiki/core@master] Selenium tests should log in before creating pages

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

Change 380505 abandoned by Zfilipin:
API edits should use the Selenium user

Reason:
Implemented in https://gerrit.wikimedia.org/r/#/c/381948/

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

Change 381948 merged by jenkins-bot:
[mediawiki/core@master] Selenium tests should log in before creating pages

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

Builds 66 and 67 (post merge of 318948) failed.

New error is:

Error: Logging in failed: Failed
    at Context.<anonymous> (extensions/RelatedArticles/tests/selenium/specs/readmore.js:13:11)
    at logInCallback (node_modules/nodemw/lib/bot.js:172:22)
    at Request._callback (node_modules/nodemw/lib/api.js:213:5)
    at Request.self.callback (node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (node_modules/request/request.js:1163:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (node_modules/request/request.js:1085:12)
    at IncomingMessage.g (events.js:292:16)

@zeljkofilipin Looks like password/username may not be setup?

Build 43 failed with

Error: Edit failed: Error: Error returned by API: Wikipedia has restricted the ability to create new pages. You can go back and edit an existing page, or [[Special:UserLogin|log in or create an account]].

381948 was merged.

Build 66 failed with

Logging in failed: Failed

Change 382459 had a related patch set uploaded (by Zfilipin; owner: Zfilipin):
[mediawiki/core@master] WIP Logging in failed: Failed

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

This issue is still present on RelatedArticles.

@zeljkofilipin I've advised that we do not port over MobileFrontend and Page previews browser tests from Ruby to Node.js until this bug is fixed as the same problem will be present in those rewritten browser tests. We've thus stalled our work on doing that.

@Jdlrobson I am working on this. I was able to reproduce it locally.

Can not reproduce on my machine 😐

$ MEDIAWIKI_PASSWORD=not-the-real-one MEDIAWIKI_USER='Selenium user' MW_SERVER=https://en.wikipedia.beta.wmflabs.org:443 MW_SCRIPT_PATH=/w ./node_modules/.bin/wdio tests/selenium/wdio.conf.jenkins.js --spec extensions/RelatedArticles/tests/selenium/specs/*.js
------------------------------------------------------------------
[chrome #0-0] Session ID: 4766e75fdc62133afff1a1a802552ec5
[chrome #0-0] Spec: /Users/z/Documents/gerrit/mediawiki/vagrant/mediawiki/extensions/RelatedArticles/tests/selenium/specs/readmore.js
[chrome #0-0] Running: chrome
[chrome #0-0]
[chrome #0-0]   ReadMore
[chrome #0-0]
[chrome #0-0]   ReadMore
[chrome #0-0]       ✓ ReadMore is not present on Vector
[chrome #0-0]       ✓ ReadMore is present in Minerva
[chrome #0-0]
[chrome #0-0]
[chrome #0-0] 2 passing (11s)
[chrome #0-0]

Wrote xunit report to [../log/].


2 passing (12.00s)

Looks like the job fails in CI because password is not set up at all. 😵

Change 382459 abandoned by Zfilipin:
WIP Logging in failed: Failed

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

Change 383887 had a related patch set uploaded (by Zfilipin; owner: Zfilipin):
[integration/config@master] WIP selenium-RelatedArticles-jessie needs passwords

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

Change 383887 merged by jenkins-bot:
[integration/config@master] selenium-RelatedArticles-jessie Jenkins jobs needs a password

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

Back to green! 💚

https://integration.wikimedia.org/ci/view/Selenium/job/selenium-RelatedArticles-jessie/

Apologies for the delay, I am not sure how this job was green while I was testing the previous patch, since I have (apparently) never set up the password for Selenium_user. Anyway, fixed now.

zeljkofilipin closed this task as Resolved.Oct 13 2017, 9:14 AM
wmf-config/InitialiseSettings.php
'groupOverrides' => [
    'enwiki' => [
        '*' => [ 'createpage' => false ], // See P2059

P2059 Anonymous users have been prevented from creating new pages since 2005!

The title may be a little misleading. The goal wasn't for anonymous
editors to create pages but rather for the agent in the test not to be the
user used to create fixtures.

To address this we got an authenticated and dedicated user to create the
fixtures so that an anonymous user could act as the agent in a test

@Jdlrobson sorry, @hashar's comment is a bit out of context.

Context: the two of us were talking recently, how around September 16 (T176315#3622189) something changed in the configuration of beta cluster (or maybe only English Wikipedia) and anonymous users were no longer able to create pages. That broke RelatedArticles Selenium tests, for example. (But not only that.) He took a look at the configuration, and according to it, anonymous users were not able to create pages since 2005. But then, it was clearly possible, since RelatedArticles were creating pages without logging in until September 16. 🤔

That's the reason he left a comment here. I will create a separate task to investigate what happened.

Well the page is just a stub. Once it's created it doesn't get deleted... the test does not create a page so wouldn't fail if it was not possible.

Well the page is just a stub. Once it's created it doesn't get deleted... the test does not create a page so wouldn't fail if it was not possible.

I am not sure I have understood you correctly. The test does create a page (if it does not exist).

 before( function () {
   // Create page needed for the tests
   browser.call( function () {
     let content = '{{#related:related_articles_2}}';
     return EditPage.apiEdit( name, content );
   } );
} );

https://phabricator.wikimedia.org/diffusion/ERAR/browse/master/tests/selenium/specs/readmore.js;93a3d9c0db4d6f21a41c8623f0009a418ce906ad$11-17