mirror of https://github.com/grafana/grafana.git
Provisioning: Use commit only once mode in bulk delete (#108759)
Use commit only once mode in bulk delete
This commit is contained in:
parent
a2698dc3b5
commit
6af1bfe21b
|
|
@ -46,9 +46,12 @@ func (w *Worker) Process(ctx context.Context, repo repository.Repository, job pr
|
|||
return w.deleteFiles(ctx, rw, progress, opts, paths...)
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("Delete from Grafana %s", job.Name)
|
||||
stageOptions := repository.StageOptions{
|
||||
PushOnWrites: false,
|
||||
Timeout: 10 * time.Minute,
|
||||
Mode: repository.StageModeCommitOnlyOnce,
|
||||
CommitOnlyOnceMessage: msg,
|
||||
PushOnWrites: false,
|
||||
Timeout: 10 * time.Minute,
|
||||
}
|
||||
|
||||
err := w.wrapFn(ctx, repo, stageOptions, fn)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,10 @@ func TestDeleteWorker_ProcessNotReaderWriter(t *testing.T) {
|
|||
mockWrapFn := repository.NewMockWrapWithStageFn(t)
|
||||
|
||||
mockWrapFn.On("Execute", mock.Anything, mockRepo, mock.MatchedBy(func(opts repository.StageOptions) bool {
|
||||
return !opts.PushOnWrites && opts.Timeout == 10*time.Minute
|
||||
return !opts.PushOnWrites &&
|
||||
opts.Timeout == 10*time.Minute &&
|
||||
opts.Mode == repository.StageModeCommitOnlyOnce &&
|
||||
opts.CommitOnlyOnceMessage == "Delete from Grafana "+job.Name
|
||||
}), mock.Anything).Return(errors.New("delete job submitted targeting repository that is not a ReaderWriter"))
|
||||
|
||||
mockProgress.On("SetTotal", mock.Anything, 1).Return()
|
||||
|
|
@ -145,7 +148,10 @@ func TestDeleteWorker_ProcessDeleteFilesSuccess(t *testing.T) {
|
|||
mockWrapFn := repository.NewMockWrapWithStageFn(t)
|
||||
|
||||
mockWrapFn.On("Execute", mock.Anything, mockRepo, mock.MatchedBy(func(opts repository.StageOptions) bool {
|
||||
return !opts.PushOnWrites && opts.Timeout == 10*time.Minute
|
||||
return !opts.PushOnWrites &&
|
||||
opts.Timeout == 10*time.Minute &&
|
||||
opts.Mode == repository.StageModeCommitOnlyOnce &&
|
||||
opts.CommitOnlyOnceMessage == "Delete from Grafana "+job.Name
|
||||
}), mock.Anything).Return(func(ctx context.Context, repo repository.Repository, stageOptions repository.StageOptions, fn func(repository.Repository, bool) error) error {
|
||||
return fn(mockRepo, false)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue