Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/oonimkall/taskmodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package oonimkall

import (
"context"
"encoding/json"
"io"

"github.com/ooni/probe-cli/v3/internal/model"
Expand Down Expand Up @@ -259,6 +260,10 @@ type settings struct {
// requires input and you provide no input.
Inputs []string `json:"inputs,omitempty"`

// InputsExtra contains OPTIONAL opaque per-input richer-input config
// index-aligned with Inputs.
InputsExtra []json.RawMessage `json:"inputs_extra,omitempty"`

// LogLevel contains the logs level. See https://git.io/Jv4Rv
// for the names of the available log levels.
LogLevel string `json:"log_level,omitempty"`
Expand Down
7 changes: 4 additions & 3 deletions pkg/oonimkall/taskrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,10 @@ func (r *runnerForTask) Run(rootCtx context.Context) {
// TODO(https://github.com/ooni/probe/issues/2766): to correctly load Web Connectivity targets
// here we need to honour the relevant check-in settings.
},
Session: sess,
StaticInputs: r.settings.Inputs,
SourceFiles: []string{},
Session: sess,
StaticInputs: r.settings.Inputs,
StaticInputsConfig: r.settings.InputsExtra,
SourceFiles: []string{},
})
loadCtx, loadCancel := context.WithTimeout(rootCtx, 30*time.Second)
defer loadCancel()
Expand Down
35 changes: 35 additions & 0 deletions pkg/oonimkall/taskrunner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package oonimkall

import (
"context"
"encoding/json"
"errors"
"testing"
"time"
Expand Down Expand Up @@ -399,6 +400,40 @@ func TestTaskRunnerRun(t *testing.T) {
assertReducedEventsLike(t, expect, reduced)
})

t.Run("passes inputs_extra to the target loader as StaticInputsConfig", func(t *testing.T) {
runner, emitter := newRunnerForTesting()

// configure per-input richer-input config on the settings
inputsExtra := []json.RawMessage{
json.RawMessage(`{"provider":"riseupvpn"}`),
}
runner.settings.Inputs = []string{"openvpn://x.corp/1.1.1.1"}
runner.settings.InputsExtra = inputsExtra

fake := fakeSuccessfulDeps()

// capture the loader config and short-circuit by failing the load
var gotConfig *model.ExperimentTargetLoaderConfig
fake.Builder.MockNewTargetLoader = func(config *model.ExperimentTargetLoaderConfig) model.ExperimentTargetLoader {
gotConfig = config
return &mocks.ExperimentTargetLoader{
MockLoad: func(ctx context.Context) ([]model.ExperimentTarget, error) {
return nil, errors.New("stop here")
},
}
}
runner.newSession = fake.NewSession

_ = runAndCollect(runner, emitter)

if gotConfig == nil {
t.Fatal("the target loader was never created")
}
if diff := cmp.Diff(inputsExtra, gotConfig.StaticInputsConfig); diff != "" {
t.Fatal(diff)
}
})

t.Run("with failure opening report", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulDeps()
Expand Down
Loading