Page MenuHomePhabricator

Add response validation check to end-to-end testing on Page & History MW REST API endpoints
Closed, ResolvedPublic3 Estimated Story Points

Description

Description

We perform end-to-end testing as part of the CI pipeline process using Mocha. For every endpoint in the MediaWiki REST API, we need to add a check that verifies the returned response matches the public API specifications. This will allow us to automatically detect, capture, and surface instances where the endpoint behavior does not match what is documented in the response body, which increases API stability, improving the MW API developer experience.

Problem statement

The main defense that we have against spec deviation is ensuring that undocumented changes don’t make it into production in the first place. We need to catch variation in the spec vs actual endpoint behavior as part of the release process as a way to ensure documentation accuracy and prevent accidental changes. By introducing spec validation as part of end-to-end testing for every endpoint, we can improve stability for our API.

Conditions of acceptance

  • Reference https://phabricator.wikimedia.org/T376341 for the implementation pattern.
  • Update Mocha tests to utilize the reusable methods for fetching JSON schema response and comparing it against the php response using the validation method for all remaining MW REST API endpoints: https://www.mediawiki.org/wiki/API:REST_API/Reference#
    • History
      • GET /page/{title}/history
      • GET /page/{title}/history/counts/{type}
      • GET /revision/{id}
      • GET /revision/{id}/html
      • GET /revision/{id}/with_html
      • GET /revision/{id}/bare
      • GET revision/{from}/compare/{to}
    • Page/Content.v1
      • POST /page
      • GET /page/{title}
      • PUT /page/{title}
      • GET /page/{title}/html
      • GET /page/{title}/with_html
      • GET /page/{title}/bare
  • Perform updates that force the test to fail; verify that it will trigger a CI error.
  • Verify that the test works across different HTTP responses for each endpoint.
  • Demonstrate the functionality to the team.

Event Timeline

BPirkle triaged this task as Medium priority.Oct 10 2024, 3:20 PM

Change #1092860 had a related patch set uploaded (by Atieno; author: Atieno):

[mediawiki/core@master] REST: Revision: Validate responses against response schemas in tests

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

Change #1098543 had a related patch set uploaded (by Atieno; author: Atieno):

[mediawiki/core@master] REST: PageHistory: Validate responses against response schemas in tests

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

HCoplin-WMF changed the task status from Open to In Progress.Dec 4 2024, 8:23 PM
HCoplin-WMF moved this task from Backlog to In Progress on the MediaWiki-API-Platform-Team board.
HCoplin-WMF renamed this task from Add response validation check to end-to-end testing on all remaining MW REST API endpoints to Add response validation check to end-to-end testing on Page & History MW REST API endpoints.Dec 18 2024, 10:52 PM
HCoplin-WMF updated the task description. (Show Details)

Change #1098543 had a related patch set uploaded (by BPirkle; author: Atieno):

[mediawiki/core@master] REST: PageHistory: Validate responses against response schemas in tests

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

Remaining work:

HCoplin-WMF set the point value for this task to 3.Jan 14 2025, 4:38 PM

Noting here -- we actually have a separate ticket for transform here: https://phabricator.wikimedia.org/T382456

This ticket is no longer blocked; transform can be removed from scope.

Change #1092860 merged by jenkins-bot:

[mediawiki/core@master] REST: Content/v1: Validate responses against response schemas in tests

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

Change #1110784 had a related patch set uploaded (by BPirkle; author: Atieno):

[mediawiki/core@master] REST: RevisionCompare: Validate responses against response schemas in tests

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

Change #1110784 had a related patch set uploaded (by Atieno; author: Atieno):

[mediawiki/core@master] REST: RevisionCompare: Validate responses against response schemas in tests

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

Change #1110784 merged by jenkins-bot:

[mediawiki/core@master] REST: RevisionCompare: Validate responses against response schemas in tests

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

Change #1110806 had a related patch set uploaded (by Arlolra; author: Atieno):

[mediawiki/core@master] REST: Transform: Validate responses against response schemas in tests

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

Change #1110806 merged by jenkins-bot:

[mediawiki/core@master] REST: Transform: Validate responses against response schemas in tests

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