Documentation
¶
Index ¶
- Constants
- func ArgBool(args map[string]any, key string) bool
- func ArgDuration(args map[string]any, key string, def time.Duration) time.Duration
- func ArgInt(args map[string]any, key string, def int) int
- func ArgMap(args map[string]any, key string) map[string]any
- func ArgString(args map[string]any, key string) string
- func ArgStrings(args map[string]any, key string) []string
- func Normalize(v any) any
- func RegisterExpectation(name string, check ExpectationCheck)
- func RegisterOps(category string, ops map[string]OpHandler)
- func RegisterPollingOp(category, op string)
- func Run(t *testing.T, dir string, opts Options)
- func StringForm(v any) string
- type CoreTarget
- type Counted
- type Env
- type ExpectationCheck
- type Factories
- type Factory
- type OpHandler
- type Options
- type Report
- type Scenario
- type ScenarioResult
- type Status
- type Step
- type StepResult
Constants ¶
const ( DefaultPollStepTimeout = 60 * time.Second DefaultPollStepInterval = time.Second )
Default polling of ops registered with RegisterPollingOp (step args "timeoutMs" and "intervalMs" override them).
Variables ¶
This section is empty.
Functions ¶
func ArgDuration ¶
ArgDuration returns args[key] (milliseconds) as a duration (def when absent).
func ArgStrings ¶
ArgStrings returns args[key] as a string slice (nil when absent).
func RegisterExpectation ¶
func RegisterExpectation(name string, check ExpectationCheck)
RegisterExpectation adds a custom expectation key.
func RegisterOps ¶
RegisterOps adds op handlers for a category. Category files call it from init().
func RegisterPollingOp ¶
func RegisterPollingOp(category, op string)
RegisterPollingOp marks an op of a category as polling: its step is repeated every "intervalMs" (default 1 s) until the op succeeds and its expectations pass, or until "timeoutMs" (default 60 s) is over; then the last failure is reported. It suits reads of backends that index asynchronously (tracing listServices).
func StringForm ¶
StringForm returns every printable form of v joined: %v, %+v, %#v, %s and JSON.
Types ¶
type CoreTarget ¶
type CoreTarget interface {
Health(ctx context.Context) (oidc.HealthStatus, error)
Ping(ctx context.Context) (time.Duration, error)
ServerVersion(ctx context.Context) (string, error)
Close() error
}
CoreTarget is what the "core" scenarios exercise (*oidc.Client implements it).
type Counted ¶
type Counted interface {
ConformanceCount() int
}
Counted lets an op result report its own size for "count"/"minCount" (for example a trace reports its number of spans).
type Env ¶
type Env struct {
// Run is the random 8-char lowercase id of this scenario run (${run}).
Run string
// Prefix is the provider prefix with ${run} expanded (${prefix}).
Prefix string
// ServiceName is the tracing service name (${serviceName}).
ServiceName string
// Scenario is the scenario being executed.
Scenario *Scenario
// Target is the value built by the category factory.
Target any
// Vars holds ${name} substitutions (run, prefix, serviceName and saved step results).
Vars map[string]string
// contains filtered or unexported fields
}
Env is the per-scenario environment handed to factories and op handlers.
func (*Env) AddCleanup ¶
func (e *Env) AddCleanup(fn func())
AddCleanup registers fn to run (last in, first out) after the scenario.
func (*Env) ExpandValue ¶
ExpandValue expands variables in every string inside v, including object keys (maps and slices recursively).
type ExpectationCheck ¶
ExpectationCheck evaluates one custom expectation key (for example "tree").
type Factories ¶
Factories maps a category ("core", "secrets", "logging", "tracing") to its factory.
type Factory ¶
Factory builds the target of one category for one scenario run. Register cleanups (closing clients) with env.AddCleanup.
func CoreFactory ¶
func CoreFactory(fn func(ctx context.Context) (CoreTarget, error)) Factory
CoreFactory adapts a client constructor to a Factory; the client is closed after the scenario.
type OpHandler ¶
OpHandler executes one scenario op against env.Target. args already have variables expanded. The result is checked against the step's expectations.
type Options ¶
type Options struct {
// Categories to run. Empty means every category that has a factory.
Categories []string
// Factories per category.
Factories Factories
// Capabilities the target declares (write, versions, delete, query, ...).
Capabilities []string
// Prefix for secret names; default "grow-conformance/${run}/".
Prefix string
// ServiceName for tracing scenarios; default "grow-conformance".
ServiceName string
// ScenarioTimeout bounds one scenario; default 5 minutes.
ScenarioTimeout time.Duration
// Only restricts the run to these scenario ids (empty = all).
Only []string
}
Options configures a conformance run.
type Report ¶
type Report struct {
Results []ScenarioResult `json:"results"`
Passed int `json:"passed"`
Failed int `json:"failed"`
Skipped int `json:"skipped"`
}
Report is the outcome of RunScenarios.
func RunScenarios ¶
RunScenarios runs the selected scenarios in dir and returns a report. It returns an error only when the scenarios cannot be loaded.
type Scenario ¶
type Scenario struct {
ID string `json:"id"`
Category string `json:"category"`
Description string `json:"description"`
Requires []string `json:"requires"`
Steps []Step `json:"steps"`
// BatchOptions is the raw "batchOptions" object (logging); factories apply it.
BatchOptions json.RawMessage `json:"batchOptions,omitempty"`
// File is the path the scenario was loaded from.
File string `json:"-"`
}
Scenario is one conformance scenario file (conformance/scenarios/*.json).
func LoadScenarios ¶
LoadScenarios reads every *.json scenario in dir, sorted by id.
type ScenarioResult ¶
type ScenarioResult struct {
ID string `json:"id"`
Category string `json:"category"`
File string `json:"file"`
Status Status `json:"status"`
Reason string `json:"reason,omitempty"`
Steps []StepResult `json:"steps,omitempty"`
Duration time.Duration `json:"durationNs"`
}
ScenarioResult reports one scenario.
func RunScenario ¶
func RunScenario(ctx context.Context, sc *Scenario, opts Options) (res ScenarioResult)
RunScenario executes one scenario.