Fix a task chain bug

This commit is contained in:
simon987 2019-02-24 13:34:13 -05:00
parent ab040ae040
commit ce5344d9c7
4 changed files with 57 additions and 2 deletions

4
jenkins/Jenkinsfile vendored
View File

@ -4,6 +4,10 @@ remote.host = 'localhost'
remote.user = 'simon'
remote.identityFile = '/var/lib/jenkins/.ssh/id_rsa'
remote.knownHosts = '/var/lib/jenkins/.ssh/known_hosts'
remote.allowAnyHosts = true
remote.retryCount = 3
remote.retryWaitSec = 3
logLevel = 'FINER'
pipeline {
agent none

View File

@ -113,7 +113,8 @@ BEGIN
priority, retries, max_retries, status, recipe)
VALUES (old.hash64, chain, NULL, old.max_assign_time, NULL,
old.verification_count, old.priority, 0, old.max_retries, 1,
old.recipe);
old.recipe)
ON CONFLICT DO NOTHING;
end if;
end if;
RETURN OLD;

View File

@ -881,6 +881,55 @@ func TestTaskGetUnauthorized(t *testing.T) {
}
}
func TestTaskChainCausesConflict(t *testing.T) {
p1 := createProjectAsAdmin(api.CreateProjectRequest{
Name: "testtaskchainconflict",
CloneUrl: "testtaskchainconfflict",
Public: false,
}).Content.Id
p2 := createProjectAsAdmin(api.CreateProjectRequest{
Name: "testtaskchainconflict2",
CloneUrl: "testtaskchainconfflict2",
Public: false,
Chain: p1,
}).Content.Id
w := genWid()
requestAccess(api.CreateWorkerAccessRequest{
Project: p1,
Assign: true,
Submit: true,
}, w)
requestAccess(api.CreateWorkerAccessRequest{
Project: p2,
Assign: true,
Submit: true,
}, w)
acceptAccessRequest(p1, w.Id, testAdminCtx)
acceptAccessRequest(p2, w.Id, testAdminCtx)
createTask(api.SubmitTaskRequest{
Project: p2,
Recipe: " ",
Hash64: 1,
}, w)
createTask(api.SubmitTaskRequest{
Project: p1,
Recipe: " ",
Hash64: 1,
}, w)
tid := getTaskFromProject(p2, w).Content.Task.Id
resp := releaseTask(api.ReleaseTaskRequest{
TaskId: tid,
Result: storage.TR_OK,
}, w)
if resp.Ok != true {
t.Error()
}
}
func createTask(request api.SubmitTaskRequest, worker *storage.Worker) (ar api.JsonResponse) {
r := Post("/task/submit", request, worker, nil)
UnmarshalResponse(r, &ar)

View File

@ -113,7 +113,8 @@ BEGIN
priority, retries, max_retries, status, recipe)
VALUES (old.hash64, chain, NULL, old.max_assign_time, NULL,
old.verification_count, old.priority, 0, old.max_retries, 1,
old.recipe);
old.recipe)
ON CONFLICT DO NOTHING;
end if;
end if;
RETURN OLD;