Skip to content

Commit

Permalink
Merge branch 'main' into vsukhin/feature/rerun-test-worklow
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Feb 13, 2025
2 parents 09a6238 + e2fbabf commit 38182b4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/repository/testworkflow/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ func (r *MongoRepository) Init(ctx context.Context, id string, data InitData) er
_, err := r.Coll.UpdateOne(ctx, bson.M{"id": id}, bson.M{"$set": map[string]interface{}{
"namespace": data.Namespace,
"signature": data.Signature,
"runnerId": data.RunnerID,
"runnerid": data.RunnerID,
}})
return err
}
Expand All @@ -678,10 +678,10 @@ func (r *MongoRepository) Assign(ctx context.Context, id string, prevRunnerId st
"$and": []bson.M{
{"id": id},
{"result.status": bson.M{"$in": bson.A{testkube.QUEUED_TestWorkflowStatus, testkube.RUNNING_TestWorkflowStatus, testkube.PAUSED_TestWorkflowStatus}}},
{"$or": []bson.M{{"runnerId": prevRunnerId}, {"runnerId": newRunnerId}, {"runnerId": nil}}},
{"$or": []bson.M{{"runnerid": prevRunnerId}, {"runnerid": newRunnerId}, {"runnerid": nil}}},
},
}, bson.M{"$set": map[string]interface{}{
"runnerId": newRunnerId,
"runnerid": newRunnerId,
}})
if err != nil {
return false, err
Expand All @@ -702,7 +702,7 @@ func (r *MongoRepository) GetUnassigned(ctx context.Context) (result []testkube.
cursor, err := r.Coll.Find(ctx, bson.M{
"$and": []bson.M{
{"result.status": testkube.QUEUED_TestWorkflowStatus},
{"$or": []bson.M{{"runnerId": ""}, {"runnerId": nil}}},
{"$or": []bson.M{{"runnerid": ""}, {"runnerid": nil}}},
},
}, opts)
if err != nil {
Expand All @@ -722,17 +722,17 @@ func (r *MongoRepository) AbortIfQueued(ctx context.Context, id string) (ok bool
"$and": []bson.M{
{"id": id},
{"result.status": bson.M{"$in": bson.A{testkube.QUEUED_TestWorkflowStatus, testkube.RUNNING_TestWorkflowStatus, testkube.PAUSED_TestWorkflowStatus}}},
{"$or": []bson.M{{"runnerId": ""}, {"runnerId": nil}}},
{"$or": []bson.M{{"runnerid": ""}, {"runnerid": nil}}},
},
}, bson.M{"$set": map[string]interface{}{
"result.status": testkube.ABORTED_TestWorkflowStatus,
"result.predictedStatus": testkube.ABORTED_TestWorkflowStatus,
"statusAt": ts,
"result.finishedAt": ts,
"result.predictedstatus": testkube.ABORTED_TestWorkflowStatus,
"statusat": ts,
"result.finishedat": ts,
"result.initialization.status": testkube.ABORTED_TestWorkflowStatus,
"result.initialization.errorMessage": "Aborted before initialization.",
"result.initialization.finishedAt": ts,
//"result.totalDurationMs": ts.Sub(scheduledAt).Milliseconds(),
"result.initialization.errormessage": "Aborted before initialization.",
"result.initialization.finishedat": ts,
//"result.totaldurationms": ts.Sub(scheduledAt).Milliseconds(),
}})
if err != nil {
return false, err
Expand Down
4 changes: 4 additions & 0 deletions pkg/testworkflows/testworkflowexecutor/prepared.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ func (e *IntermediateExecution) SetSequenceNumber(number int32) *IntermediateExe
return e
}

func (e *IntermediateExecution) SequenceNumber() int32 {
return e.execution.Number
}

func (e *IntermediateExecution) SetError(header string, err error) *IntermediateExecution {
// Keep only the 1st error
if !e.execution.Result.IsFinished() {
Expand Down
3 changes: 3 additions & 0 deletions pkg/testworkflows/testworkflowexecutor/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ func (s *scheduler) Schedule(ctx context.Context, sensitiveDataHandler Sensitive
// Generating the execution name
if intermediate[i].Name() == "" {
name := fmt.Sprintf("%s-%d", intermediate[i].WorkflowName(), number)
if len(intermediate) > 1 {
name = fmt.Sprintf("%s-%d-%d", intermediate[i].WorkflowName(), intermediate[0].SequenceNumber(), i+1)
}
intermediate[i].SetName(name)

// Edge case: Check for local duplicates, if there is no clash between static and auto-generated one
Expand Down

0 comments on commit 38182b4

Please sign in to comment.