|
| 1 | +'use strict'; |
| 2 | +const { expect } = require('chai'); |
| 3 | +const { withClient } = require('../../integration/shared'); |
| 4 | + |
| 5 | +// TODO(NODE-3880): These tests are not fully implemented per the spec |
| 6 | +describe('Atlas Data Lake - prose', function () { |
| 7 | + it( |
| 8 | + '1. Test that the driver properly constructs and issues a killCursors command to Atlas Data Lake.', |
| 9 | + /** |
| 10 | + * For this test, configure an APM listener on a client and execute a query on the test.driverdata collection |
| 11 | + * that will leave a cursor open on the server (e.g. specify batchSize=2 for a query that would match 3+ documents). |
| 12 | + * Drivers MAY iterate the cursor if necessary to execute the initial find command but MUST NOT iterate further to avoid executing a getMore. |
| 13 | + * |
| 14 | + * Observe the CommandSucceededEvent event for the find command and extract the cursor's ID and namespace from the response document's cursor.id |
| 15 | + * and cursor.ns fields, respectively. Destroy the cursor object and observe a CommandStartedEvent and CommandSucceededEvent for the killCursors command. |
| 16 | + * |
| 17 | + * Assert that the cursor ID and target namespace in the outgoing command match the values from the find command's CommandSucceededEvent. |
| 18 | + * When matching the namespace, note that the killCursors field will contain the collection name and the database may be inferred from either |
| 19 | + * the $db field or accessed via the CommandStartedEvent directly. |
| 20 | + * |
| 21 | + * Finally, assert that the killCursors CommandSucceededEvent indicates that the expected cursor was killed in the cursorsKilled field. |
| 22 | + * |
| 23 | + * Note: this test assumes that drivers only issue a killCursors command internally when destroying a cursor that may still exist on the server. |
| 24 | + * If a driver constructs and issues killCursors commands in other ways (e.g. public API), this test MUST be adapted to test all such code paths. |
| 25 | + */ |
| 26 | + withClient('mongodb://mhuser:pencil@localhost', function (client, done) { |
| 27 | + const db = client.db('admin'); |
| 28 | + db.command({ killCursors: 'kill_cursor_collection' }, err => { |
| 29 | + expect(err).to.not.exist; |
| 30 | + done(); |
| 31 | + }); |
| 32 | + }) |
| 33 | + ); |
| 34 | + |
| 35 | + it( |
| 36 | + '2. Test that the driver can establish a connection with Atlas Data Lake without authentication.', |
| 37 | + /** |
| 38 | + * For these tests, create a MongoClient using a valid connection string without auth credentials and execute a ping command. |
| 39 | + */ |
| 40 | + withClient('mongodb://localhost', function (client, done) { |
| 41 | + expect(client).to.exist; |
| 42 | + done(); |
| 43 | + }) |
| 44 | + ); |
| 45 | + |
| 46 | + it( |
| 47 | + '3a. Test that the driver can establish a connection with Atlas Data Lake with authentication. (SCRAM-SHA-1)', |
| 48 | + /** |
| 49 | + * For these tests, create a MongoClient using a valid connection string with SCRAM-SHA-1 and credentials |
| 50 | + * from the drivers-evergreen-tools ADL configuration and execute a ping command. |
| 51 | + */ |
| 52 | + withClient( |
| 53 | + 'mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-1', |
| 54 | + function (client, done) { |
| 55 | + const db = client.db('admin'); |
| 56 | + db.command({ killCursors: 'kill_cursor_collection' }, err => { |
| 57 | + expect(err).to.not.exist; |
| 58 | + done(); |
| 59 | + }); |
| 60 | + } |
| 61 | + ) |
| 62 | + ); |
| 63 | + |
| 64 | + it( |
| 65 | + '3b. Test that the driver can establish a connection with Atlas Data Lake with authentication. (SCRAM-SHA-256)', |
| 66 | + /** |
| 67 | + * Repeat the authentication test using SCRAM-SHA-256. |
| 68 | + */ |
| 69 | + withClient( |
| 70 | + 'mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-256', |
| 71 | + function (client, done) { |
| 72 | + const db = client.db('admin'); |
| 73 | + db.command({ killCursors: 'kill_cursor_collection' }, err => { |
| 74 | + expect(err).to.not.exist; |
| 75 | + done(); |
| 76 | + }); |
| 77 | + } |
| 78 | + ) |
| 79 | + ); |
| 80 | +}); |
0 commit comments