@@ -100,8 +100,6 @@ exports['Correctly receive the APM events for an insert using custom operationId
100
100
101
101
var validateExpecations = function ( test , expectation , results ) {
102
102
if ( expectation . command_started_event ) {
103
- // console.log("---------------------------- validate command_started_event")
104
- // console.dir(expectation)
105
103
// Get the command
106
104
var obj = expectation . command_started_event ;
107
105
// Unpack the expectation
@@ -110,50 +108,27 @@ var validateExpecations = function(test, expectation, results) {
110
108
var commandName = obj . command_name ;
111
109
// Get the result
112
110
var result = results . starts . shift ( ) ;
113
- // console.dir(results)
114
- // console.log("---------------------------- validate command_started_event 1 RESULT")
115
- // console.log(JSON.stringify(result, null, 2))
116
- // console.log("---------------------------- validate command_started_event 2 EXPECTED")
117
- // console.log(JSON.stringify(obj, null, 2))
118
- // // Validate the test
111
+ // Validate the test
119
112
test . equal ( commandName , result . commandName )
120
113
} else if ( expectation . command_succeeded_event ) {
121
- // console.log("---------------------------- validate command_succeeded_event")
122
114
var obj = expectation . command_succeeded_event ;
123
115
// Unpack the expectation
124
116
var reply = obj . reply ;
125
117
var databaseName = obj . database_name ;
126
118
var commandName = obj . command_name ;
127
119
// Get the result
128
120
var result = results . successes . shift ( ) ;
129
- // console.dir(results)
130
- // console.log("---------------------------- validate command_succeeded_event 1 RESULT")
131
- // console.log(JSON.stringify(result, null, 2))
132
- // console.log("---------------------------- validate command_succeeded_event 2 EXPECTED")
133
- // console.log(JSON.stringify(obj, null, 2))
134
-
135
-
136
121
// Validate the test
137
122
test . equal ( commandName , result . commandName ) ;
138
- // console.dir(result)
139
- // console.dir(reply[0])
140
- // console.dir(result.reply.result)
141
123
test . deepEqual ( reply [ 0 ] , result . reply . result ) ;
142
- // console.dir(obj)
143
- // console.dir(result)
144
124
} else if ( expectation . command_failed_event ) {
145
- // console.log("---------------------------- validate command_failed_event")
146
125
var obj = expectation . command_failed_event ;
147
126
// Unpack the expectation
148
127
var reply = obj . reply ;
149
128
var databaseName = obj . database_name ;
150
129
var commandName = obj . command_name ;
151
130
// Get the result
152
131
var result = results . failures . shift ( ) ;
153
- // console.log("---------------------------- validate command_failed_event 1")
154
- // console.dir(results)
155
- // console.dir(expectation)
156
-
157
132
// Validate the test
158
133
test . equal ( commandName , result . commandName ) ;
159
134
}
@@ -164,28 +139,19 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
164
139
var failures = [ ] ;
165
140
var starts = [ ] ;
166
141
167
- // console.log("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
168
- // console.log("*****************************************************************************************")
169
- // console.log("*****************************************************************************************")
170
- // console.log("*****************************************************************************************")
171
-
172
142
// Get the operation
173
143
var operation = test . operation ;
174
144
175
145
// Set up the listeners
176
146
listener . on ( 'started' , function ( event ) {
177
- // console.log("################################################ started")
178
- // console.log(JSON.stringify(event, null, 2))
179
147
starts . push ( event ) ;
180
148
} ) ;
181
149
182
150
listener . on ( 'succeeded' , function ( event ) {
183
- // console.log("################################################ successes")
184
151
successes . push ( event ) ;
185
152
} ) ;
186
153
187
154
listener . on ( 'failed' , function ( event ) {
188
- // console.log("################################################ failed")
189
155
failures . push ( event ) ;
190
156
} ) ;
191
157
@@ -196,29 +162,6 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
196
162
_listener . removeAllListeners ( 'failed' ) ;
197
163
}
198
164
199
- // // Set up the test expectations
200
- // test.expectations.forEach(function(x) {
201
- // if(x.command_started_event) {
202
- // listener.once('started', function(event) {
203
- // console.log("################################################ started")
204
- // console.log(JSON.stringify(event, null, 2))
205
- // starts.push(event);
206
- // });
207
- // } else if(x.command_succeeded_event) {
208
- // listener.once('succeeded', function(event) {
209
- // // console.log("################################################ successes")
210
- // successes.push(event);
211
- // });
212
- // } else if(x.command_failed_event) {
213
- // listener.once('failed', function(event) {
214
- // // console.log("################################################ failed")
215
- // failures.push(event);
216
- // });
217
- // }
218
- // });
219
-
220
- // console.log("------------------------------- operation.name :: " + operation.name)
221
-
222
165
// Get the command name
223
166
var commandName = operation . name ;
224
167
// Get the arguments
@@ -233,8 +176,18 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
233
176
// Unpack the operation
234
177
if ( args . filter ) {
235
178
params . push ( args . filter ) ;
236
- } else if ( args . deletes ) {
179
+ }
180
+
181
+ if ( args . deletes ) {
237
182
params . push ( args . deletes ) ;
183
+ }
184
+
185
+ if ( args . document ) {
186
+ params . push ( args . document ) ;
187
+ }
188
+
189
+ if ( args . update ) {
190
+ params . push ( args . update ) ;
238
191
}
239
192
240
193
// Find command is special needs to executed using toArray
@@ -253,9 +206,6 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
253
206
cursor = cursor . limit ( args . limit ) ;
254
207
}
255
208
256
- // console.log("----------------------------------------- args")
257
- // console.dir(args)
258
-
259
209
// Execute find
260
210
cursor . toArray ( function ( err , r ) {
261
211
// Validate the expectations
@@ -273,6 +223,7 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
273
223
} ) ;
274
224
} else {
275
225
params . push ( function ( err , result ) {
226
+
276
227
// Validate the expectations
277
228
test . expectations . forEach ( function ( x , index ) {
278
229
validateExpecations ( assert , x , {
@@ -290,39 +241,6 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
290
241
// Execute the operation
291
242
collection [ commandName ] . apply ( collection , params ) ;
292
243
}
293
-
294
- // // Execute the test
295
- // if(operation.name == 'count') {
296
- // var args = operation.arguments || {};
297
- // // Get the database instance
298
- // var db = client.db(scenario.database_name);
299
- // // Get the collection
300
- // var collection = db.collection(scenario.collection_name);
301
- // // Parameters
302
- // var params = [];
303
-
304
- // // Unpack the operation
305
- // if(args.filter) {
306
- // params.push(args.filter);
307
- // }
308
-
309
- // params.push(function(err, result) {
310
- // // Validate the expectations
311
- // test.expectations.forEach(function(x, index) {
312
- // validateExpecations(assert, x, {
313
- // successes: successes, failures: failures, starts: starts
314
- // });
315
- // });
316
-
317
- // // Finish the operation
318
- // callback();
319
- // });
320
-
321
- // // Execute the operation
322
- // collection.count.apply(collection, params);
323
- // } else if(operation.name == 'deleteOne') {
324
-
325
- // }
326
244
}
327
245
328
246
var executeTests = function ( assert , client , listener , scenario , tests , callback ) {
@@ -379,10 +297,6 @@ exports['Correctly run all JSON APM Tests'] = {
379
297
return JSON . parse ( fs . readFileSync ( __dirname + '/apm/' + x ) ) ;
380
298
} ) ;
381
299
382
- // scenarios = scenarios.slice(2, 3)
383
- // scenarios = scenarios.slice(0, 3)
384
- scenarios = scenarios . slice ( 3 , 4 )
385
-
386
300
// Get the methods
387
301
var MongoClient = require ( '../..' ) ;
388
302
var listener = require ( '../../' ) . instrument ( ) ;
0 commit comments