-
Notifications
You must be signed in to change notification settings - Fork 37
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 to handle REJECTED_TIMEDOUT #224
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #224 +/- ##
==========================================
+ Coverage 63.94% 64.23% +0.28%
==========================================
Files 92 92
Lines 9653 9622 -31
==========================================
+ Hits 6173 6181 +8
+ Misses 3043 3002 -41
- Partials 437 439 +2 ☔ View full report in Codecov by Sentry. |
@dfarr Please let me know if that is what you have in mind. I had to do some changes to the generator and model. Let me know if any suggestions. Thanks! |
@@ -58,7 +58,7 @@ func (d *DST) Run(r *rand.Rand, api api.API, aio aio.AIO, system *system.System, | |||
generator.AddRequest(generator.GenerateCreatePromise) | |||
model.AddResponse(t_api.CreatePromise, model.ValidatCreatePromise) | |||
case t_api.CompletePromise: | |||
generator.AddRequest(generator.GenerateCancelPromise) | |||
generator.AddRequest(generator.GenerateCompletePromise) |
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.
Nice catch!
Looks good @favalos! I left a few comments, the main thing is to not permit a request to timeout a promise, only the server can time out a promise. |
Thanks for the clarification @dfarr, I completed the changes accordingly. Let me know if any other comments. |
test/dst/model.go
Outdated
@@ -268,7 +269,13 @@ func (m *Model) ValidateCompletePromise(t int64, req *t_api.Request, res *t_api. | |||
pm.promise = res.CompletePromise.Promise | |||
return nil | |||
case t_api.StatusCreated: | |||
if res.CompletePromise.Promise.State != promise.Canceled { | |||
if req.CompletePromise.State.In(promise.Resolved) && res.CompletePromise.Promise.State != promise.Resolved { |
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.
if req.CompletePromise.State.In(promise.Resolved) && res.CompletePromise.Promise.State != promise.Resolved { | |
if req.CompletePromise.State == promise.Resolved && res.CompletePromise.Promise.State != promise.Resolved { |
test/dst/model.go
Outdated
if req.CompletePromise.State.In(promise.Resolved) && res.CompletePromise.Promise.State != promise.Resolved { | ||
return fmt.Errorf("unexpected state %s after resolve promise", res.CompletePromise.Promise.State) | ||
} | ||
if req.CompletePromise.State.In(promise.Rejected) && res.CompletePromise.Promise.State != promise.Rejected { |
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.
if req.CompletePromise.State.In(promise.Rejected) && res.CompletePromise.Promise.State != promise.Rejected { | |
if req.CompletePromise.State == promise.Rejected && res.CompletePromise.Promise.State != promise.Rejected { |
test/dst/model.go
Outdated
if req.CompletePromise.State.In(promise.Rejected) && res.CompletePromise.Promise.State != promise.Rejected { | ||
return fmt.Errorf("unexpected state %s after reject promise", res.CompletePromise.Promise.State) | ||
} | ||
if req.CompletePromise.State.In(promise.Canceled) && res.CompletePromise.Promise.State != promise.Canceled { |
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.
if req.CompletePromise.State.In(promise.Canceled) && res.CompletePromise.Promise.State != promise.Canceled { | |
if req.CompletePromise.State == promise.Canceled && res.CompletePromise.Promise.State != promise.Canceled { |
test/dst/model.go
Outdated
@@ -252,9 +252,10 @@ func (m *Model) ValidateCompletePromise(t int64, req *t_api.Request, res *t_api. | |||
switch res.CompletePromise.Status { | |||
case t_api.StatusOK: | |||
if pm.completed() { | |||
if !pm.idempotencyKeyForCompleteMatch(res.CompletePromise.Promise) { | |||
if !(!req.CompletePromise.Strict && pm.promise.State == promise.Timedout) && |
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.
I'm finding this if statement a little hard to follow, so I plugged it into a program that simplifies boolean expressions. To me the result is a little easier to understand, let me know what you think.
!(!req.CompletePromise.Strict && pm.promise.State == promise.Timedout)
&& !pm.idempotencyKeyForCompleteMatch(res.CompletePromise.Promise)
a = req.CompletePromise.Strict
b = pm.promise.State == promise.Timedout
c = pm.idempotencyKeyForCompleteMatch(res.CompletePromise.Promise)
!(!a && b) && !c
!c && !(!a && b) put c first (I find this a little easier to read)
~c ∧ ~(~a ∧ b) convert to boolean algebra
~c ∧ (a ∨ ~b) an equivalent expression
!c && (a || !b) convert back to go code, and finally put back in substitutions
!pm.idempotencyKeyForCompleteMatch(res.CompletePromise.Promise)
&& (req.CompletePromise.Strict || pm.promise.State != promise.Timedout)
Here is the equivalency proof, and here are the corresponding truth tables for both expressions:
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.
Sweet! Yes, that looks much better.
Thanks for the detailed explanation.
Let me know if any other comments. |
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.
🎉
Thanks so much again @favalos ! |
Changes to handle #206.