Page MenuHomePhabricator

API unit tests assume repeatable ordering of output
Closed, ResolvedPublic

Description

When testing on PostgreSQL:

  1. ApiQueryBasicTest::testGenerator

Failed asserting that two strings are equal.

  • Expected

+++ Actual
@@ @@
-'AQBT-All'
+'AQBT-Categories'

/usr/home/saper/test/mytest/tests/phpunit/includes/api/query/ApiQueryTestBase.php:143
/usr/home/saper/test/mytest/tests/phpunit/includes/api/query/ApiQueryTestBase.php:141
/usr/home/saper/test/mytest/tests/phpunit/includes/api/query/ApiQueryTestBase.php:141
/usr/home/saper/test/mytest/tests/phpunit/includes/api/query/ApiQueryTestBase.php:141
/usr/home/saper/test/mytest/tests/phpunit/includes/api/query/ApiQueryTestBase.php:105
/usr/home/saper/test/mytest/tests/phpunit/includes/api/query/ApiQueryTestBase.php:100
/usr/home/saper/test/mytest/tests/phpunit/includes/api/query/ApiQueryBasicTest.php:299
/usr/home/saper/test/mytest/tests/phpunit/MediaWikiTestCase.php:123
/usr/home/saper/test/mytest/tests/phpunit/MediaWikiPHPUnitCommand.php:80
/usr/home/saper/test/mytest/tests/phpunit/MediaWikiPHPUnitCommand.php:64
/usr/home/saper/test/mytest/tests/phpunit/phpunit.php:119

Looks like that list of pages returned by API is okay, only the order is different:
Request: generator=links&titles=AQBT-Links&action=query

Expected:
Array
(

[query] => Array
    (
        [pages] => Array
            (
                [1] => Array
                    (
                        [pageid] => 1
                        [ns] => 0
                        [title] => AQBT-All
                    )

                [2] => Array
                    (
                        [pageid] => 2
                        [ns] => 0
                        [title] => AQBT-Categories
                    )

                [4] => Array
                    (
                        [pageid] => 4
                        [ns] => 0
                        [title] => AQBT-Templates
                    )

            )

    )

)

Result:
Array
(

[query] => Array
    (
        [pages] => Array
            (
                [109] => Array
                    (
                        [pageid] => 109
                        [ns] => 0
                        [title] => AQBT-Categories
                    )

                [108] => Array
                    (
                        [pageid] => 108
                        [ns] => 0
                        [title] => AQBT-All
                    )

                [111] => Array
                    (
                        [pageid] => 111
                        [ns] => 0
                        [title] => AQBT-Templates
                    )

            )

    )

)

Not sure if order of page titles returned by API should be guaranteed? Should we test for it?


Version: 1.23.0
Severity: minor

Details

Reference
bz57976

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:16 AM
bzimport set Reference to bz57976.
bzimport added a subscriber: Unknown Object (MLST).

I suspect that the rewrite of the assertResult function in Gerrit change 99156 may have fixed this too. Could you check that?

Yes, gerrit charge 99156 made output of all seven tests of tests/phpunit/includes/api/query/ApiQueryBasicTest.php suspiciously green :)

Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.