Skip to content

Commit 1d4354c

Browse files
committed
Passing APM test suite
1 parent ce69407 commit 1d4354c

File tree

3 files changed

+15
-101
lines changed

3 files changed

+15
-101
lines changed

test/functional/apm/insertOne.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"command_succeeded_event": {
4040
"reply": [
4141
{
42-
"ok": 1
42+
"ok": 1, "n": 1
4343
}
4444
],
4545
"command_name": "insert",

test/functional/apm/updateOne.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"command_succeeded_event": {
6464
"reply": [
6565
{
66-
"ok": 1
66+
"ok": 1, "nModified": 1, "n": 1
6767
}
6868
],
6969
"command_name": "update",

test/functional/apm_tests.js

Lines changed: 13 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ exports['Correctly receive the APM events for an insert using custom operationId
100100

101101
var validateExpecations = function(test, expectation, results) {
102102
if(expectation.command_started_event) {
103-
// console.log("---------------------------- validate command_started_event")
104-
// console.dir(expectation)
105103
// Get the command
106104
var obj = expectation.command_started_event;
107105
// Unpack the expectation
@@ -110,50 +108,27 @@ var validateExpecations = function(test, expectation, results) {
110108
var commandName = obj.command_name;
111109
// Get the result
112110
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
119112
test.equal(commandName, result.commandName)
120113
} else if(expectation.command_succeeded_event) {
121-
// console.log("---------------------------- validate command_succeeded_event")
122114
var obj = expectation.command_succeeded_event;
123115
// Unpack the expectation
124116
var reply = obj.reply;
125117
var databaseName = obj.database_name;
126118
var commandName = obj.command_name;
127119
// Get the result
128120
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-
136121
// Validate the test
137122
test.equal(commandName, result.commandName);
138-
// console.dir(result)
139-
// console.dir(reply[0])
140-
// console.dir(result.reply.result)
141123
test.deepEqual(reply[0], result.reply.result);
142-
// console.dir(obj)
143-
// console.dir(result)
144124
} else if(expectation.command_failed_event) {
145-
// console.log("---------------------------- validate command_failed_event")
146125
var obj = expectation.command_failed_event;
147126
// Unpack the expectation
148127
var reply = obj.reply;
149128
var databaseName = obj.database_name;
150129
var commandName = obj.command_name;
151130
// Get the result
152131
var result = results.failures.shift();
153-
// console.log("---------------------------- validate command_failed_event 1")
154-
// console.dir(results)
155-
// console.dir(expectation)
156-
157132
// Validate the test
158133
test.equal(commandName, result.commandName);
159134
}
@@ -164,28 +139,19 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
164139
var failures = [];
165140
var starts = [];
166141

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-
172142
// Get the operation
173143
var operation = test.operation;
174144

175145
// Set up the listeners
176146
listener.on('started', function(event) {
177-
// console.log("################################################ started")
178-
// console.log(JSON.stringify(event, null, 2))
179147
starts.push(event);
180148
});
181149

182150
listener.on('succeeded', function(event) {
183-
// console.log("################################################ successes")
184151
successes.push(event);
185152
});
186153

187154
listener.on('failed', function(event) {
188-
// console.log("################################################ failed")
189155
failures.push(event);
190156
});
191157

@@ -196,29 +162,6 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
196162
_listener.removeAllListeners('failed');
197163
}
198164

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-
222165
// Get the command name
223166
var commandName = operation.name;
224167
// Get the arguments
@@ -233,8 +176,18 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
233176
// Unpack the operation
234177
if(args.filter) {
235178
params.push(args.filter);
236-
} else if(args.deletes) {
179+
}
180+
181+
if(args.deletes) {
237182
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);
238191
}
239192

240193
// Find command is special needs to executed using toArray
@@ -253,9 +206,6 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
253206
cursor = cursor.limit(args.limit);
254207
}
255208

256-
// console.log("----------------------------------------- args")
257-
// console.dir(args)
258-
259209
// Execute find
260210
cursor.toArray(function(err, r) {
261211
// Validate the expectations
@@ -273,6 +223,7 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
273223
});
274224
} else {
275225
params.push(function(err, result) {
226+
276227
// Validate the expectations
277228
test.expectations.forEach(function(x, index) {
278229
validateExpecations(assert, x, {
@@ -290,39 +241,6 @@ var executeOperation = function(assert, client, listener, scenario, test, callba
290241
// Execute the operation
291242
collection[commandName].apply(collection, params);
292243
}
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-
// }
326244
}
327245

328246
var executeTests = function(assert, client, listener, scenario, tests, callback) {
@@ -379,10 +297,6 @@ exports['Correctly run all JSON APM Tests'] = {
379297
return JSON.parse(fs.readFileSync(__dirname + '/apm/' + x));
380298
});
381299

382-
// scenarios = scenarios.slice(2, 3)
383-
// scenarios = scenarios.slice(0, 3)
384-
scenarios = scenarios.slice(3, 4)
385-
386300
// Get the methods
387301
var MongoClient = require('../..');
388302
var listener = require('../../').instrument();

0 commit comments

Comments
 (0)