Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
avillega committed Feb 27, 2025
1 parent c69b946 commit 10064a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 47 deletions.
4 changes: 2 additions & 2 deletions test/dst/bc_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ func ValidateTasksWithSameRootPromiseId(model *Model, reqTime int64, _ int64, re
completedOn := reqT.CompletedOn
if p != nil &&
p.State != promise.Pending {
if reqT.Mesg.Type == message.Invoke && *p.CompletedOn < *reqT.CreatedOn {
if reqT.Mesg.Type == message.Invoke && *p.CompletedOn <= *reqT.CreatedOn {
return model, fmt.Errorf("Invocation for a promise that is alredy completed.")
} else if *p.CompletedOn >= *reqT.CreatedOn {
} else if *p.CompletedOn > *reqT.CreatedOn {
state = task.Completed
completedOn = util.ToPointer[int64](*p.CompletedOn)
}
Expand Down
38 changes: 0 additions & 38 deletions test/dst/dst.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,44 +187,6 @@ func (d *DST) Run(r *rand.Rand, api api.API, aio aio.AIO, system *system.System)
Input: &Req{Op, reqTime, req, nil},
Output: &Res{Op, resTime, res, err},
})

// Warning:
// A CreatePromiseAndTask request applies to two partitions, the
// promise partition and the task partition. Merging the
// partitions results in long checking time, so as a workaround
// we create an independent CreatePromise request. The mapping
// of requests to partitions is as follows:
// CreatePromise -> p partition
// CreatePromiseAndTask -> t partition
if req.Kind == t_api.CreatePromiseAndTask {
j++

req = &t_api.Request{
Kind: t_api.CreatePromise,
Tags: req.Tags,
CreatePromise: req.CreatePromiseAndTask.Promise,
}

if res != nil {
res = &t_api.Response{
Kind: t_api.CreatePromise,
Tags: res.Tags,
CreatePromise: &t_api.CreatePromiseResponse{
Status: res.CreatePromiseAndTask.Status,
Promise: res.CreatePromiseAndTask.Promise,
},
}
}

ops = append(ops, porcupine.Operation{
ClientId: int(j % d.config.MaxReqsPerTick),
Call: reqTime,
Return: resTime,
Input: &Req{Op, reqTime, req, nil},
Output: &Res{Op, resTime, res, err},
})
}

j++
},
})
Expand Down
13 changes: 6 additions & 7 deletions test/dst/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ func (v *Validator) ValidateCreatePromise(model *Model, reqTime int64, resTime i
}

func (v *Validator) ValidateCreatePromiseAndTask(model *Model, reqTime int64, resTime int64, req *t_api.Request, res *t_api.Response) (*Model, error) {
// Do NOT validate the create promise, as a workaround we create a
// "duplicate" CreatePromise request and map the requests as
// follows:
// CreatePromise -> p partition
// CreatePromiseAndTask -> t partition

switch res.CreatePromiseAndTask.Status {
case t_api.StatusCreated:
if model.tasks.get(res.CreatePromiseAndTask.Task.Id) != nil {
Expand All @@ -144,7 +138,12 @@ func (v *Validator) ValidateCreatePromiseAndTask(model *Model, reqTime int64, re
model.tasks.set(res.CreatePromiseAndTask.Task.Id, res.CreatePromiseAndTask.Task)
}

return model, nil
promiseRes := &t_api.CreatePromiseResponse{
Status: res.CreatePromiseAndTask.Status,
Promise: res.CreatePromiseAndTask.Promise,
}

return v.validateCreatePromise(model, reqTime, resTime, req.CreatePromiseAndTask.Promise, promiseRes)
}

func (v *Validator) validateCreatePromise(model *Model, reqTime int64, resTime int64, req *t_api.CreatePromiseRequest, res *t_api.CreatePromiseResponse) (*Model, error) {
Expand Down

0 comments on commit 10064a9

Please sign in to comment.