Skip to content

Commit 2d33f90

Browse files
author
Kristina Chodorow
committed
chunk tests
1 parent 7266093 commit 2d33f90

File tree

4 files changed

+50
-7
lines changed

4 files changed

+50
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*~
2+
*.log

handlers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pymongo import Connection, json_util
22
from pymongo.son import SON
3-
from pymongo.errors import ConnectionFailure
3+
from pymongo.errors import ConnectionFailure, OperationFailure
44

55
import re
66
import json
@@ -57,8 +57,12 @@ def _cmd(self, args, out):
5757
temp[pair['key']] = pair['value']
5858
cmd = temp
5959

60-
result = connection.admin._command(cmd)
61-
out(json.dumps(result, default=json_util.default))
60+
try:
61+
result = connection.admin._command(cmd)
62+
out(json.dumps(result, default=json_util.default))
63+
except OperationFailure as err:
64+
out('{"ok" : 0, "msg" : "operation failed but you\'ll never know why."}')
65+
6266

6367

6468
def _mongos(self, args, out):

scripts/mongoose.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ Mongoose.Collection = function(db, collection) {
390390
* Enables sharding on this collection. The collection's database must have
391391
* sharding enabled before it can be enabled on the collection.
392392
*
393-
* @param {object} key the field on which to shard
393+
* @param {object} key the field or fields on which to shard, e.g., {"x" : 1}
394394
* @param {boolean} [unique] if the shard key should be unique
395395
* @param {function} [callback] optional function to call when a response is
396396
* received.

test/tests.js

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,21 @@ m.setMongos(testSetMongos);
7272
var testGetConfig = function(msg) {
7373
test("get config", function() {
7474
expect(2);
75-
75+
7676
equals(msg.configserver, "localhost:20000");
7777
equals(msg.isdbgrid, 1);
78+
7879
});
7980
};
8081
m.getConfig(testGetConfig);
8182

83+
8284
var addShards = true;
8385

8486
var testGetShards0 = function(msg) {
8587
test("get shards 0", function() {
8688
expect(1);
87-
89+
8890
// no shards yet
8991
ok(msg.shards.constructor == Array);
9092
if (msg.shards.length == 2) {
@@ -94,6 +96,10 @@ var testGetShards0 = function(msg) {
9496
};
9597
m.getShards(testGetShards0);
9698

99+
100+
101+
102+
97103
module("Mongoose Shards");
98104

99105
shard0 = new Mongoose.Shard(m, "localhost:10000");
@@ -198,7 +204,7 @@ var testMoveDB = function(msg) {
198204
}
199205

200206
var testGetDBs2 = function(msg) {
201-
test("get dbs", function() {
207+
test("get dbs 2", function() {
202208
expect(2);
203209

204210
equals(msg.dbs.constructor, Array);
@@ -222,6 +228,7 @@ shard1.getDatabases(testGetDBs2);
222228

223229

224230

231+
225232
module("Mongoose Collections");
226233

227234
c = new Mongoose.Collection(db, "bar");
@@ -231,4 +238,34 @@ test("instance vars", function() {
231238
equals(c.ns, "foo.bar");
232239
});
233240

241+
var testShardColl = function(msg) {
242+
test("shard collection", function() {
243+
244+
});
245+
};
246+
c.shard({"_id" : 1}, true, testShardColl);
247+
c.shard({"x" : 1}, false, testShardColl);
248+
249+
var testSplitChunk = function(msg) {
250+
test("split chunk", function() {
251+
252+
});
253+
}
254+
c.split({"find" : {"x" : 1}}, testSplitChunk);
255+
256+
var testMoveChunk = function(msg) {
257+
test("move chunk", function() {
258+
259+
});
260+
}
261+
262+
263+
var testGetVersion = function(msg) {
264+
test("version", function() {
265+
expect(0);
266+
267+
});
268+
}
269+
c.version(testGetVersion);
234270

271+
Mongoose.debug = false;

0 commit comments

Comments
 (0)