|
| 1 | +description: "poc-change-streams" |
| 2 | + |
| 3 | +schemaVersion: "1.0" |
| 4 | + |
| 5 | +createEntities: |
| 6 | + # Entities for creating changeStreams |
| 7 | + - client: |
| 8 | + id: &client0 client0 |
| 9 | + useMultipleMongoses: false |
| 10 | + observeEvents: [ commandStartedEvent ] |
| 11 | + # Original tests do not observe getMore commands but only because event |
| 12 | + # assertions ignore extra events. killCursors is explicitly ignored. |
| 13 | + ignoreCommandMonitoringEvents: [ getMore, killCursors ] |
| 14 | + - database: |
| 15 | + id: &database0 database0 |
| 16 | + client: *client0 |
| 17 | + databaseName: &database0Name change-stream-tests |
| 18 | + - collection: |
| 19 | + id: &collection0 collection0 |
| 20 | + database: *database0 |
| 21 | + collectionName: &collection0Name test |
| 22 | + # Entities for executing insert operations |
| 23 | + - client: |
| 24 | + id: &client1 client1 |
| 25 | + useMultipleMongoses: false |
| 26 | + - database: |
| 27 | + id: &database1 database1 |
| 28 | + client: *client1 |
| 29 | + databaseName: &database1Name change-stream-tests |
| 30 | + - database: |
| 31 | + id: &database2 database2 |
| 32 | + client: *client1 |
| 33 | + databaseName: &database2Name change-stream-tests-2 |
| 34 | + - collection: |
| 35 | + id: &collection1 collection1 |
| 36 | + database: *database1 |
| 37 | + collectionName: &collection1Name test |
| 38 | + - collection: |
| 39 | + id: &collection2 collection2 |
| 40 | + database: *database1 |
| 41 | + collectionName: &collection2Name test2 |
| 42 | + - collection: |
| 43 | + id: &collection3 collection3 |
| 44 | + database: *database2 |
| 45 | + collectionName: &collection3Name test |
| 46 | + |
| 47 | +initialData: |
| 48 | + - collectionName: *collection1Name |
| 49 | + databaseName: *database1Name |
| 50 | + documents: [] |
| 51 | + - collectionName: *collection2Name |
| 52 | + databaseName: *database1Name |
| 53 | + documents: [] |
| 54 | + - collectionName: *collection3Name |
| 55 | + databaseName: *database2Name |
| 56 | + documents: [] |
| 57 | + |
| 58 | +tests: |
| 59 | + - description: "Executing a watch helper on a MongoClient results in notifications for changes to all collections in all databases in the cluster." |
| 60 | + runOnRequirements: |
| 61 | + - minServerVersion: "3.8.0" |
| 62 | + topologies: [ replicaset ] |
| 63 | + operations: |
| 64 | + - name: createChangeStream |
| 65 | + object: *client0 |
| 66 | + arguments: |
| 67 | + pipeline: [] |
| 68 | + saveResultAsEntity: &changeStream0 changeStream0 |
| 69 | + - name: insertOne |
| 70 | + object: *collection2 |
| 71 | + arguments: |
| 72 | + document: { x: 1 } |
| 73 | + - name: insertOne |
| 74 | + object: *collection3 |
| 75 | + arguments: |
| 76 | + document: { y: 1 } |
| 77 | + - name: insertOne |
| 78 | + object: *collection1 |
| 79 | + arguments: |
| 80 | + document: { z: 1 } |
| 81 | + - name: iterateUntilDocumentOrError |
| 82 | + object: *changeStream0 |
| 83 | + expectResult: |
| 84 | + operationType: insert |
| 85 | + ns: |
| 86 | + db: *database1Name |
| 87 | + coll: *collection2Name |
| 88 | + fullDocument: |
| 89 | + _id: { $$type: objectId } |
| 90 | + x: 1 |
| 91 | + - name: iterateUntilDocumentOrError |
| 92 | + object: *changeStream0 |
| 93 | + expectResult: |
| 94 | + operationType: insert |
| 95 | + ns: |
| 96 | + db: *database2Name |
| 97 | + coll: *collection3Name |
| 98 | + fullDocument: |
| 99 | + # Original tests did not include _id, but matching now only permits |
| 100 | + # extra keys for root-level documents. |
| 101 | + _id: { $$type: objectId } |
| 102 | + y: 1 |
| 103 | + - name: iterateUntilDocumentOrError |
| 104 | + object: *changeStream0 |
| 105 | + expectResult: |
| 106 | + operationType: insert |
| 107 | + ns: |
| 108 | + db: *database1Name |
| 109 | + coll: *collection1Name |
| 110 | + fullDocument: |
| 111 | + _id: { $$type: objectId } |
| 112 | + z: 1 |
| 113 | + expectEvents: |
| 114 | + - client: *client0 |
| 115 | + events: |
| 116 | + - commandStartedEvent: |
| 117 | + command: |
| 118 | + aggregate: 1 |
| 119 | + cursor: {} |
| 120 | + pipeline: |
| 121 | + - $changeStream: |
| 122 | + allChangesForCluster: true |
| 123 | + # Some drivers may send a default value for fullDocument |
| 124 | + # or omit it entirely (see: SPEC-1350). |
| 125 | + fullDocument: { $$unsetOrMatches: default } |
| 126 | + commandName: aggregate |
| 127 | + databaseName: admin |
| 128 | + |
| 129 | + - description: "Test consecutive resume" |
| 130 | + runOnRequirements: |
| 131 | + - minServerVersion: "4.1.7" |
| 132 | + topologies: [ replicaset ] |
| 133 | + operations: |
| 134 | + - name: failPoint |
| 135 | + object: testRunner |
| 136 | + arguments: |
| 137 | + client: *client0 |
| 138 | + failPoint: |
| 139 | + configureFailPoint: failCommand |
| 140 | + mode: { times: 2 } |
| 141 | + data: |
| 142 | + failCommands: [ getMore ] |
| 143 | + closeConnection: true |
| 144 | + - name: createChangeStream |
| 145 | + object: *collection0 |
| 146 | + arguments: |
| 147 | + batchSize: 1 |
| 148 | + pipeline: [] |
| 149 | + saveResultAsEntity: *changeStream0 |
| 150 | + - name: insertOne |
| 151 | + object: *collection1 |
| 152 | + arguments: |
| 153 | + document: { x: 1 } |
| 154 | + - name: insertOne |
| 155 | + object: *collection1 |
| 156 | + arguments: |
| 157 | + document: { x: 2 } |
| 158 | + - name: insertOne |
| 159 | + object: *collection1 |
| 160 | + arguments: |
| 161 | + document: { x: 3 } |
| 162 | + - name: iterateUntilDocumentOrError |
| 163 | + object: *changeStream0 |
| 164 | + expectResult: |
| 165 | + operationType: insert |
| 166 | + ns: |
| 167 | + db: *database1Name |
| 168 | + coll: *collection1Name |
| 169 | + fullDocument: |
| 170 | + _id: { $$type: objectId } |
| 171 | + x: 1 |
| 172 | + - name: iterateUntilDocumentOrError |
| 173 | + object: *changeStream0 |
| 174 | + expectResult: |
| 175 | + operationType: insert |
| 176 | + ns: |
| 177 | + db: *database1Name |
| 178 | + coll: *collection1Name |
| 179 | + fullDocument: |
| 180 | + _id: { $$type: objectId } |
| 181 | + x: 2 |
| 182 | + - name: iterateUntilDocumentOrError |
| 183 | + object: *changeStream0 |
| 184 | + expectResult: |
| 185 | + operationType: insert |
| 186 | + ns: |
| 187 | + db: *database1Name |
| 188 | + coll: *collection1Name |
| 189 | + fullDocument: |
| 190 | + _id: { $$type: objectId } |
| 191 | + x: 3 |
| 192 | + expectEvents: |
| 193 | + - client: *client0 |
| 194 | + events: |
| 195 | + - commandStartedEvent: |
| 196 | + command: |
| 197 | + aggregate: *collection1Name |
| 198 | + cursor: { batchSize: 1 } |
| 199 | + pipeline: |
| 200 | + - $changeStream: |
| 201 | + fullDocument: { $$unsetOrMatches: default } |
| 202 | + commandName: aggregate |
| 203 | + databaseName: *database1Name |
| 204 | + # The original test only asserted the first command, since expected |
| 205 | + # events were only an ordered subset. This file does ignore getMore |
| 206 | + # commands but we must expect the subsequent aggregate commands, since |
| 207 | + # each failed getMore will resume. While doing so we can also assert |
| 208 | + # that those commands include a resume token. |
| 209 | + - &resumingAggregate |
| 210 | + commandStartedEvent: |
| 211 | + command: |
| 212 | + aggregate: *collection1Name |
| 213 | + cursor: { batchSize: 1 } |
| 214 | + pipeline: |
| 215 | + - $changeStream: |
| 216 | + fullDocument: { $$unsetOrMatches: default } |
| 217 | + resumeAfter: { $$exists: true } |
| 218 | + commandName: aggregate |
| 219 | + databaseName: *database0Name |
| 220 | + - *resumingAggregate |
0 commit comments