Skip to content

Commit 983e84d

Browse files
authored
feat: add atomic operation for setting resource aggregations (#6301)
1 parent ce82d64 commit 983e84d

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

pkg/cloud/data/testworkflow/execution.go

+4
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,7 @@ func (r *CloudRepository) GetUnassigned(ctx context.Context) (result []testkube.
206206
func (r *CloudRepository) AbortIfQueued(ctx context.Context, id string) (bool, error) {
207207
return false, errors.New("not supported")
208208
}
209+
210+
func (r *CloudRepository) UpdateResourceAggregations(ctx context.Context, id string, resourceAggregations *testkube.TestWorkflowExecutionResourceAggregationsReport) error {
211+
return errors.New("not supported")
212+
}

pkg/repository/testworkflow/interface.go

+2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ type Repository interface {
9595
UpdateReport(ctx context.Context, id string, report *testkube.TestWorkflowReport) (err error)
9696
// UpdateOutput updates list of output references in the execution result
9797
UpdateOutput(ctx context.Context, id string, output []testkube.TestWorkflowOutput) (err error)
98+
// UpdateResourceAggregations updates the summary of resource metrics
99+
UpdateResourceAggregations(ctx context.Context, id string, resourceAggregations *testkube.TestWorkflowExecutionResourceAggregationsReport) (err error)
98100
// DeleteByTestWorkflow deletes execution results by workflow
99101
DeleteByTestWorkflow(ctx context.Context, workflowName string) error
100102
// DeleteAll deletes all execution results

pkg/repository/testworkflow/mock_repository.go

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/repository/testworkflow/mongo.go

+5
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ func (r *MongoRepository) UpdateOutput(ctx context.Context, id string, refs []te
392392
return
393393
}
394394

395+
func (r *MongoRepository) UpdateResourceAggregations(ctx context.Context, id string, resourceAggregations *testkube.TestWorkflowExecutionResourceAggregationsReport) (err error) {
396+
_, err = r.Coll.UpdateOne(ctx, bson.M{"id": id}, bson.M{"$set": bson.M{"resourceaggregations": resourceAggregations}})
397+
return
398+
}
399+
395400
func composeQueryAndOpts(filter Filter) (bson.M, *options.FindOptions) {
396401
query := bson.M{}
397402
opts := options.Find()

0 commit comments

Comments
 (0)