Skip to content

Commit c703a55

Browse files
committed
Add implicit/explicit session tests
1 parent 472d8f4 commit c703a55

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

source/sessions/driver-sessions.rst

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Driver Sessions Specification
1212
:Status: Accepted (Could be Draft, Accepted, Rejected, Final, or Replaced)
1313
:Type: Standards
1414
:Minimum Server Version: 3.6 (The minimum server version this spec applies to)
15-
:Last Modified: 11-Jan-2018
15+
:Last Modified: 20-Feb-2018
1616

1717
.. contents::
1818

@@ -922,7 +922,21 @@ topologies. It MUST NOT be run against a standalone server.
922922
* A find command from the ``find`` helper method
923923
* An insert command from the ``insert_one`` helper method
924924

925-
3. Test that session argument is for the right client
925+
3. Test explicit and implicit session arguments
926+
* Register a command-started APM listener. If the driver has no APM support, inspect commands in another idiomatic way, such as monkey-patching or a mock server.
927+
* Create ``client1``
928+
* Get ``database`` from ``client1``
929+
* Get ``collection`` from ``database``
930+
* Start ``session`` from ``client1``
931+
* Call ``collection.insertOne(session,...)``
932+
* Assert that the command passed to the command-started listener contained the session ``lsid`` from ``session``.
933+
* Call ``collection.insertOne(,...)`` (*without* a session argument)
934+
* Assert that the command passed to the command-started listener contained a session ``lsid``.
935+
936+
Repeat for:
937+
* All methods that take a session parameter.
938+
939+
4. Test that session argument is for the right client
926940
* Create ``client1`` and ``client2``
927941
* Get ``database`` from ``client1``
928942
* Get ``collection`` from ``database``
@@ -933,7 +947,7 @@ topologies. It MUST NOT be run against a standalone server.
933947
Repeat for:
934948
* All methods that take a session parameter.
935949

936-
4. Test that no further operations can be performed using a session after ``endSession`` has been called
950+
5. Test that no further operations can be performed using a session after ``endSession`` has been called
937951
* Start a ``session``
938952
* End the ``session``
939953
* Call ``collection.InsertOne(session, ...)``
@@ -947,14 +961,14 @@ topologies. It MUST NOT be run against a standalone server.
947961
sufficient to only test the disposal pattern since that ends up calling
948962
``endSession``).
949963

950-
5. Authenticating as multiple users suppresses implicit sessions
964+
6. Authenticating as multiple users suppresses implicit sessions
951965
* Skip this test if your driver does not allow simultaneous authentication with multiple users
952966
* Authenticate as two users
953967
* Call ``findOne`` with no explicit session
954968
* Capture the command sent to the server
955969
* Assert that the command sent to the server does not have an ``lsid`` field
956970

957-
6. Client-side cursor that exhausts the results on the initial query immediately returns the implicit session
971+
7. Client-side cursor that exhausts the results on the initial query immediately returns the implicit session
958972
to the pool.
959973
* Insert two documents into a collection
960974
* Execute a find operation on the collection and iterate past the first document
@@ -963,14 +977,14 @@ to the pool.
963977
* Track the lsid used for the find operation (e.g. with APM) and then do another operation and
964978
assert that the same lsid is used as for the find operation.
965979

966-
7. Client-side cursor that exhausts the results after a ``getMore`` immediately returns the implicit session
980+
8. Client-side cursor that exhausts the results after a ``getMore`` immediately returns the implicit session
967981
to the pool.
968982
* Insert four documents into a collection
969983
* Execute a find operation on the collection with batch size of 2
970984
* Iterate past the first three documents, forcing the final ``getMore`` operation
971985
* Assert that the implicit session is returned to the pool prior to iterating past the last document
972986

973-
8. At the end of every individual functional test of the driver, there SHOULD be an assertion that
987+
9. At the end of every individual functional test of the driver, there SHOULD be an assertion that
974988
there are no remaining sessions checked out from the pool. This may require changes to existing tests to
975989
ensure that they close any explicit client sessions and any unexhausted cursors.
976990

@@ -1067,3 +1081,4 @@ Change log
10671081
:2018-01-10: Note that MongoClient must retain highest clusterTime
10681082
:2018-01-10: Update test plan for drivers without APM
10691083
:2018-01-11: Clarify that sessions require replica sets or sharded clusters
1084+
:2018-02-20: Add implicit/explicit session tests

0 commit comments

Comments
 (0)