Skip to content

Commit df958a9

Browse files
committed
resolve cherry-pick conflict
1 parent 127c750 commit df958a9

11 files changed

+36
-22
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ before_script:
1515
- tar -zxvf mongodb-linux-x86_64-2.6.11.tgz
1616
- mkdir -p ./data/db/27017
1717
- mkdir -p ./data/db/27000
18-
- ./mongodb-linux-x86_64-2.6.11/bin/mongod --fork --nopreallocj --dbpath ./data/db/27017 --syslog --port 27017
18+
- printf "\n--timeout 8000" >> ./test/mocha.opts
19+
- ./mongodb-linux-x86_64-2.6.11/bin/mongod --fork --dbpath ./data/db/27017 --syslog --port 27017
20+
- sleep 3
1921
script:
2022
- npm test
2123
- npm run lint

test/connection.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var Schema = mongoose.Schema;
1818
*/
1919

2020
describe('connections:', function() {
21+
this.timeout(10000);
2122
describe('useMongoClient/openUri (gh-5304)', function() {
2223
it('with mongoose.connect()', function(done) {
2324
var conn = mongoose.connect('mongodb://localhost:27017/mongoosetest', {
@@ -1082,7 +1083,7 @@ describe('connections:', function() {
10821083

10831084
describe('errors', function() {
10841085
it('event fires with one listener', function(done) {
1085-
this.timeout(1000);
1086+
this.timeout(1500);
10861087
var db = start({uri: 'mongodb://whatever23939.localhost/fakeeee?connectTimeoutMS=500', noErrorListener: 1});
10871088
db.on('error', function() {
10881089
// this callback has no params which triggered the bug #759

test/document.test.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,8 @@ describe('document', function() {
13761376
});
13771377

13781378
it('validator should run only once per sub-doc gh-1743', function(done) {
1379+
this.timeout(process.env.TRAVIS ? 8000 : 4500);
1380+
13791381
var count = 0;
13801382
var db = start();
13811383

@@ -1410,18 +1412,21 @@ describe('document', function() {
14101412

14111413

14121414
it('validator should run in parallel', function(done) {
1413-
// we set the time out to be double that of the validator - 1 (so that running in serial will be greater than that)
1414-
this.timeout(1000);
14151415
var db = start();
14161416
var count = 0;
1417+
var startTime, endTime;
14171418

14181419
var SchemaWithValidator = new Schema({
14191420
preference: {
14201421
type: String,
14211422
required: true,
1422-
validate: function validator(value, done) {
1423-
count++;
1424-
setTimeout(done.bind(null, true), 500);
1423+
validate: {
1424+
validator: function validator(value, done) {
1425+
count++;
1426+
if (count === 1) startTime = Date.now();
1427+
else if (count === 4) endTime = Date.now();
1428+
setTimeout(done.bind(null, true), 150);
1429+
}
14251430
}
14261431
}
14271432
});
@@ -1442,6 +1447,7 @@ describe('document', function() {
14421447
m.save(function(err) {
14431448
assert.ifError(err);
14441449
assert.equal(count, 4);
1450+
assert(endTime - startTime < 150 * 4); // serial >= 150 * 4, parallel < 150 * 4
14451451
db.close(done);
14461452
});
14471453
});

test/gh-1408.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ var start = require('./common'),
1010

1111
describe('documents should not be converted to _id (gh-1408)', function() {
1212
it('if an embedded doc', function(done) {
13+
this.timeout(process.env.TRAVIS ? 8000 : 4500);
14+
1315
var db = start();
1416

1517
var PreferenceSchema = new Schema({

test/index.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ describe('mongoose module:', function() {
107107
});
108108

109109
describe('disconnection of all connections', function() {
110+
this.timeout(10000);
111+
110112
describe('no callback', function() {
111113
it('works', function(done) {
112114
var mong = new Mongoose(),

test/model.aggregate.test.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var collection = 'aggregate_' + random();
2323
mongoose.model('Aggregate', userSchema);
2424

2525
describe('model aggregate', function() {
26+
this.timeout(process.env.TRAVIS ? 8000 : 4500);
27+
2628
var group = {$group: {_id: null, maxAge: {$max: '$age'}}};
2729
var project = {$project: {maxAge: 1, _id: 0}};
2830
var db, A, maxAge;
@@ -74,8 +76,6 @@ describe('model aggregate', function() {
7476
});
7577

7678
it('when return promise', function(done) {
77-
this.timeout(4000);
78-
7979
A.aggregate(group, project).then( function(res) {
8080
assert.ok(res);
8181
assert.equal(1, res.length);
@@ -86,8 +86,6 @@ describe('model aggregate', function() {
8686
});
8787

8888
it('with arrays', function(done) {
89-
this.timeout(4000);
90-
9189
A.aggregate([group, project], function(err, res) {
9290
assert.ifError(err);
9391
assert.ok(res);
@@ -99,8 +97,6 @@ describe('model aggregate', function() {
9997
});
10098

10199
it('with Aggregate syntax', function(done) {
102-
this.timeout(4000);
103-
104100
var promise = A.aggregate()
105101
.group(group.$group)
106102
.project(project.$project)
@@ -116,8 +112,6 @@ describe('model aggregate', function() {
116112
});
117113

118114
it('with Aggregate syntax if callback not provided', function(done) {
119-
this.timeout(4000);
120-
121115
var promise = A.aggregate()
122116
.group(group.$group)
123117
.project(project.$project)
@@ -143,8 +137,6 @@ describe('model aggregate', function() {
143137
return done();
144138
}
145139

146-
this.timeout(4000);
147-
148140
var outputCollection = 'aggregate_output_' + random();
149141
A.aggregate()
150142
.group(group.$group)

test/model.create.test.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,23 @@ describe('model', function() {
9999
});
100100

101101
it('creates in parallel', function(done) {
102-
// we set the time out to be double that of the validator - 1 (so that running in serial will be greater than that)
103-
this.timeout(1000);
104102
var db = start(),
105103
countPre = 0,
106104
countPost = 0;
107105

108106
var SchemaWithPreSaveHook = new Schema({
109107
preference: String
110108
});
109+
110+
var startTime, endTime;
111111
SchemaWithPreSaveHook.pre('save', true, function hook(next, done) {
112112
setTimeout(function() {
113113
countPre++;
114+
if (countPre === 1) startTime = Date.now();
115+
else if (countPre === 4) endTime = Date.now();
114116
next();
115117
done();
116-
}, 500);
118+
}, 100);
117119
});
118120
SchemaWithPreSaveHook.post('save', function() {
119121
countPost++;
@@ -139,7 +141,8 @@ describe('model', function() {
139141
assert.ok(doc4);
140142
assert.equal(countPre, 4);
141143
assert.equal(countPost, 4);
142-
done();
144+
assert.ok(endTime - startTime < 4 * 100); // serial: >= 4 * 100 parallel: < 4 * 100
145+
db.close(done);
143146
});
144147
});
145148

test/model.geosearch.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ describe('model', function() {
2222
});
2323

2424
describe('geoSearch', function() {
25+
this.timeout(process.env.TRAVIS ? 8000 : 4500);
26+
2527
it('works', function(done) {
2628
var db = start();
2729
var Geo = getModel(db);

test/model.populate.setting.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ var posts = 'blogposts_' + random(),
2424
*/
2525

2626
describe('model: populate:', function() {
27+
this.timeout(process.env.TRAVIS ? 8000 : 4500);
28+
2729
describe('setting populated paths (gh-570)', function() {
2830
var types = {
2931
ObjectId: DocObjectId,

test/model.populate.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ var DocObjectId = mongoose.Types.ObjectId;
1818
*/
1919

2020
describe('model: populate:', function() {
21+
this.timeout(process.env.TRAVIS ? 8000 : 4500);
22+
2123
var User;
2224
var Comment;
2325
var BlogPost;

0 commit comments

Comments
 (0)