Wire option merging for scheduled test executions

Fetch user/domain/service-level plugin options via GetTestPluginOptions
and merge them with schedule-specific options (schedule opts take priority)
before running a test. Previously tests only used schedule.Options.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
nemunaire 2026-02-11 17:21:07 +07:00
commit 11a65fa2ac

View file

@ -624,6 +624,25 @@ func (w *worker) executeTest(item *queueItem) {
return
}
// Merge options: global defaults < user opts < domain/service opts < schedule opts
var domainId, serviceId *happydns.Identifier
switch schedule.TargetType {
case happydns.TestScopeDomain:
domainId = &schedule.TargetId
case happydns.TestScopeService:
serviceId = &schedule.TargetId
}
baseOptions, err := w.scheduler.pluginUsecase.GetTestPluginOptions(schedule.PluginName, &schedule.OwnerId, domainId, serviceId)
if err != nil {
log.Printf("Worker %d: warning, could not fetch plugin options for %s: %v\n", w.id, schedule.PluginName, err)
}
var mergedOptions happydns.PluginOptions
if baseOptions != nil {
mergedOptions = w.scheduler.scheduleUsecase.MergePluginOptions(nil, nil, *baseOptions, schedule.Options)
} else {
mergedOptions = schedule.Options
}
// Prepare metadata
meta := make(map[string]string)
meta["target_type"] = schedule.TargetType.String()
@ -640,7 +659,7 @@ func (w *worker) executeTest(item *queueItem) {
errorChan <- fmt.Errorf("plugin panicked: %v", r)
}
}()
result, err := plugin.RunTest(schedule.Options, meta)
result, err := plugin.RunTest(mergedOptions, meta)
if err != nil {
errorChan <- err
} else {