-
Notifications
You must be signed in to change notification settings - Fork 457
Fix flaky maxSubmitRetries test #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -509,25 +509,32 @@ describe('client submit', function() { | |
}); | ||
|
||
it('submits fail above the backend.maxSubmitRetries threshold', function(done) { | ||
var backend = this.backend; | ||
this.backend.maxSubmitRetries = 0; | ||
var doc = this.backend.connect().get('dogs', 'fido'); | ||
var doc2 = this.backend.connect().get('dogs', 'fido'); | ||
doc.create({age: 3}, function(err) { | ||
if (err) return done(err); | ||
doc2.fetch(function(err) { | ||
if (err) return done(err); | ||
var count = 0; | ||
var cb = function(err) { | ||
count++; | ||
if (count === 1) { | ||
if (err) return done(err); | ||
} else { | ||
expect(err).ok(); | ||
done(); | ||
var docCallback; | ||
var doc2Callback; | ||
backend.use('commit', function (request, callback) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I and future contributors (like future you!) would appreciate it if you added some comments here about why this is needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
if (request.op.op[0].na === 2) docCallback = callback; | ||
if (request.op.op[0].na === 7) doc2Callback = callback; | ||
|
||
if (docCallback && doc2Callback) { | ||
docCallback(); | ||
} | ||
}; | ||
doc.submitOp({p: ['age'], na: 2}, cb); | ||
doc2.submitOp({p: ['age'], na: 7}, cb); | ||
}); | ||
doc.submitOp({p: ['age'], na: 2}, function (error) { | ||
if (error) return done(error); | ||
doc2Callback(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can move this up to just below Having the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. But isn't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (That could be mitigated by putting back the old shared callback with a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Got it, you want to sequence the actual commits so you know 1 goes before 2. Makes sense, thanks for explaining! |
||
}); | ||
doc2.submitOp({p: ['age'], na: 7}, function (error) { | ||
expect(error).ok(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping another note for the future, this is to work around the circular dependency issue between sharedb and sharedb-mingo-memory:
#226 (comment)
I'm OK with this workaround for now to unblock the tests as the workaround is isolated to Travis, until we figure out a better solution in the linked issue above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, maybe it's better to get the #226 merged first, as it also updates the Travis config's Node versions to reflect latest + LTE versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Happy to wait and rebase. Would just be nice to get this through to unblock other PRs.