Uploaded image for project: 'PHP Driver: Library'
  1. PHP Driver: Library
  2. PHPLIB-457

Audit and implement any missing change stream spec prose tests

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      The following prose tests are not implemented:

      ChangeStream will automatically resume one time on a resumable error (including not master) with the initial pipeline and options, except for the addition/update of a resumeToken.

      We do not have a test that asserts the resuming aggregate uses the same options and pipeline as the original command. Additionally, we do not have a test for a "not master" error, although that could be easily mocked with a fail point (no need to trigger an actual failover).

      ChangeStream will not attempt to resume on any error encountered while executing an aggregate command.

      Can be implemented by configuring a fail point on aggregate and expecting an exception when executing the Watch operation.

      ChangeStream will perform server selection before attempting to resume, using initial readPreference

      Testing this may require opening a change stream against a secondary server (e.g. passing secondary read preference to Watch), triggering a resumable error (e.g. killing the cursor on that server, or configuring a fail point), and then verifying that the change stream is still opened against a secondary after resuming. An easy way to test this may be reaching into the inner iterator to obtain the underlying MongoDB\Driver\Cursor and calling getServer().

      The killCursors command sent during the "Resume Process" must not be allowed to throw an exception.

      I'm not sure how to test this, but we already trust libmongoc to ignore errors when attempting to kill a cursor. See CDRIVER-2943 and PHPLIB-409.

      For a ChangeStream under these conditions...

      Most of the various tests at the end of the list of prose tests should already be implemented, but we should confirm. In particular, the tests for defaulting to the startAfter or resumeAfter option may need to be tested.

            andreas.braun@mongodb.com Andreas Braun
            jmikola@mongodb.com Jeremy Mikola
            0 Vote for this issue
            1 Start watching this issue