Page MenuHomePhabricator

Add some unit and integration test coverage of the PerformTest API in the MW PHP code
Closed, ResolvedPublic

Description

  • Happy paths
    • Function/implementation/tester as stored persistent objects
    • Function/implementation/tester as inline objects
    • All implementations requested
    • Specific implementations requested
    • All testers requested
    • Specific testers requested
  • Failure paths
    • Running on an unknown ZObject as function
    • Running on a known but non-function ZObject
    • Running on an unknown ZObject as implementation
    • Running on a known but non-implementation ZObject
    • Running on an unknown ZObject as tester
    • Running on a known but non-tester ZObject
    • Implementation raised an error
    • Tester raised an error
    • Response was a failure; expected and actual results are injected
  • Infrastructure failure paths
    • Server not connected
    • Server responded oddly
    • General exception on run

Event Timeline

Jdforrester-WMF created this task.

Change 849120 had a related patch set uploaded (by EWright; author: EWright):

[mediawiki/extensions/WikiLambda@master] Fix flow where expanded implementation is sent to API for perform_test.

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

Change 849120 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Fix flow where expanded implementation is sent to API for perform_test.

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

@Jdforrester-WMF I would slightly push back on classing this and other similar testing-related tickets as "nice-to-haves" rather than launch-blocking. If we intend to launch a stable service, I would argue that having at least a bare minimum of test coverage for each important API method is a requirement.

Change 855980 had a related patch set uploaded (by EWright; author: EWright):

[mediawiki/extensions/WikiLambda@master] Support receipt of JSON testers in the perform_test API method.

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

Change 855980 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Support receipt of JSON testers in the perform_test API method.

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

Change 857025 had a related patch set uploaded (by Jforrester; author: Jforrester):

[mediawiki/extensions/WikiLambda@master] ApiPerformTestTest: Annotate some other methods tested

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

Change 857025 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] ApiPerformTestTest: Annotate some other methods tested

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

Change 863287 had a related patch set uploaded (by EWright; author: EWright):

[mediawiki/extensions/WikiLambda@master] Add some more cases to ApiPerformTestTest.php.

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

Change 863287 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Add some more cases to ApiPerformTestTest.php.

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

Thanks James for updating the checklist. I think also " Running on an unknown ZObject as tester" is done - see L242: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/WikiLambda/+/refs/heads/master/tests/phpunit/integration/API/ApiPerformTestTest.php#242. I've updated the checklist.

Also, would you mind clarifying what is meant by the item "Response was a failure"? If you mean just that the test fails (returns false), several of the existing test cases cover this.

In T312290#8439353, @EWright-WMF wrote:

Thanks James for updating the checklist. I think also " Running on an unknown ZObject as tester" is done - see L242: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/WikiLambda/+/refs/heads/master/tests/phpunit/integration/API/ApiPerformTestTest.php#242. I've updated the checklist.

Oh, yes, sorry, wrote out the new ones per your update and didn't double-check. Indeed.

In T312290#8439355, @EWright-WMF wrote:

Also, would you mind clarifying what is meant by the item "Response was a failure"? If you mean just that the test fails (returns false), several of the existing test cases cover this.

I think I meant that when the result is 'false' then it also asserts that an expected and actual value were returned.

Thanks - I'll work on that now.

Change 863377 had a related patch set uploaded (by EWright; author: EWright):

[mediawiki/extensions/WikiLambda@master] Fix injection of expected and actual values into perform_test result.

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

In T312290#8439418, @EWright-WMF wrote:

Thanks - I'll work on that now.

Brill.

Change 863377 merged by EWright:

[mediawiki/extensions/WikiLambda@master] Fix injection of expected and actual values into perform_test result.

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

Regarding the remaining tasks:

Server not connected
Server responded oddly
General exception on run

It's not obvious to me how to test these. I think we'd need to be able to mock out the Orchestrator, but:

a. Our API integration tests hit an actual MW instance - I don't know how would I set up a test to hit a MW instance that targets a mock Orchestrator
b. I also can't find any examples of simpler unit tests for our API methods that just mock out all the dependencies

If anyone could point me an example of one of the above that I could imitate that would be great.

Change 881446 had a related patch set uploaded (by Jforrester; author: Jforrester):

[mediawiki/extensions/WikiLambda@master] tests: Check that an error occurs in ApiPerformTest when the orchestrator isn't present

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

Change 881446 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] tests: Check that an error occurs in ApiPerformTest when the orchestrator isn't present

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

Change 881867 had a related patch set uploaded (by EWright; author: EWright):

[mediawiki/extensions/WikiLambda@master] Throw error when get 404 from orchestrator.

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

Jdforrester-WMF updated the task description. (Show Details)

I think we can declare this Resolved. Great work!

Change 881867 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Throw error when get 404 from orchestrator.

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