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