Documentation
¶
Index ¶
- Constants
- Variables
- func CheckReferences(spec *Spec) error
- func ClosedModelWarning(spec Spec) (string, bool)
- func DeclaredShare(spec Spec, index int) float64
- func DescribeMessaging(settings *messaging.Settings) []string
- func EnvironmentVariable(text string) (string, bool)
- func ExpandFromEnv(text string) string
- func FixedStepWarnings(spec Spec) []string
- func GateWarnings(spec Spec) []string
- func Interpolate(text string, vars map[string]string) string
- func IsEnvironmentName(name string) bool
- func MixOrder(spec Spec) []int
- func ReadSeed(declared string) (int64, string, error)
- func ReferencedFields(spec Spec) map[string][]string
- func RenamedStepKey(key string) (string, bool)
- func RenamedTopKey(key string) (string, bool)
- func SeedsFromEnvironment(spec Spec) map[string]string
- func UnresolvedEnvironment(text string) []string
- type ArrivalModel
- type Assertion
- type AssertionKind
- type Auth
- type AuthKind
- type Capture
- type CaptureOrigin
- type Change
- type Check
- type CheckKind
- type ConsumePolicy
- type DataSource
- type Generator
- type LoadPlan
- type Operator
- type Phase
- type PhaseKind
- type SLORule
- type SLOScope
- type ScenarioError
- type Spec
- type Step
Constants ¶
const FormatVersion = "2"
Variables ¶
var ( TopKeys = []string{"name", "target", "requires", "variables", "auth", "tls", "messaging", "data", "load", "scenario", "slo"} StepKeys = []string{"name", "weight", "capture", "expect"} )
Listed here because the published schema is tested against them: a key that exists on only one side becomes autocomplete the parser refuses.
var KnownRequirements = []string{"kafka", "amqp", "mqtt", "credential"}
KnownRequirements is the closed list on purpose: an unknown name would be declared, printed and never checked by anyone, which is worse than not declaring it.
Functions ¶
func CheckReferences ¶
CheckReferences applies the undeclared-variable rule to the built scenario instead of to the YAML text, which is what makes it reach the scenario written in Go. The rule and the message are the same ones the YAML path uses; what the YAML path adds is the line and the column (ADR 0002).
Without this a Go scenario accepted a ${name} that resolves from nowhere, while the same scenario in YAML was refused — one rule with two answers depending on which public wrote it.
func ClosedModelWarning ¶
The rate is shown at three response times because that is the whole point: in the closed model it is the target that decides the load, so a single number would be the very promise this model cannot keep.
func DeclaredShare ¶
DeclaredShare e a proporcao que o arquivo pediu para aquele passo. Sem mix, todo passo roda em toda iteracao e a proporcao e 1.
func DescribeMessaging ¶
DescribeMessaging is what the report is allowed to print about the broker.
func EnvironmentVariable ¶
EnvironmentVariable answers whether the text is only a reference, and gives the name back. The DSL asks the same question the YAML parser asks, so both audiences refuse a literal secret by the same rule.
func ExpandFromEnv ¶
func FixedStepWarnings ¶
A7 of the audit: a literal path never goes through interpolation, so it never enters the observed-variety check. The run hits the same URL thousands of times, the target answers from cache, and nothing in the report says so — exactly the blind spot ADR 0007 closes for data that does vary.
func GateWarnings ¶
GateWarnings reports what a declared gate leaves out. A scenario with several steps and only step rules approves each piece and says nothing about the wait the user actually feels, which is the sum of them.
func IsEnvironmentName ¶ added in v0.6.0
IsEnvironmentName responde se o nome segue a convencao de variavel de ambiente — MAIUSCULA — que decide o que vem de ${…} do ambiente e nao do arquivo. Um lugar so, para a interface recusar o mesmo que a expansao ignora.
func MixOrder ¶
MixOrder devolve, para cada posicao de um ciclo, o indice do passo que roda ali. O ciclo se repete: a iteracao N executa a alternativa da posicao N % len(ordem). Devolve nil quando nao ha mix.
A ordem intercala em vez de agrupar. Sessenta chamadas de uma operacao seguidas de trinta de outra teriam a proporcao certa no fim e uma carga que nenhum sistema recebe: durante os primeiros sessenta segundos a operacao cara nao existe, e o alvo aquece um caminho so.
func ReadSeed ¶
ReadSeed le "semente: 42" e "semente: ${SEMENTE:-42}", devolvendo o valor que vai rodar e a variavel de ambiente de onde ele veio.
Semente fixa no arquivo faz o CI rodar sempre o mesmo caso, e um caso que passa mil vezes nao prova mais nada depois da primeira. Deixar a semente vir do ambiente e o que permite variar; guardar de onde ela veio e o que permite voltar ao caso que falhou — sem isso, variar e so perder a execucao.
func ReferencedFields ¶
ReferencedFields lists, per data source, the fields the scenario reads from it. A CSV declares its columns in the file, so the check that the column exists can only happen once the file is open — and until it did, a column that was not there interpolated to nothing and the request went out with a blank in the middle of the path.
func RenamedStepKey ¶ added in v0.6.0
func RenamedTopKey ¶ added in v0.6.0
Asked before printing "unknown key": the old format is not a typo, and the suggestion by proximity would send the reader to fix eleven keys by hand.
func SeedsFromEnvironment ¶
SeedsFromEnvironment mapeia fonte para a variavel de ambiente que decidiu a semente dela. Fonte com semente escrita no arquivo fica de fora: nao ha o que exportar para repetir.
func UnresolvedEnvironment ¶
UnresolvedEnvironment lista as variaveis de ambiente que o texto ainda referencia e o ambiente nao tem.
Types ¶
type ArrivalModel ¶
type ArrivalModel string
const ( OpenArrival ArrivalModel = "open" ClosedArrival ArrivalModel = "closed" )
type Assertion ¶
type Assertion struct {
Kind AssertionKind
Target string
Operator Operator
Value string
Description string
Line int
}
func ParseComparison ¶
type AssertionKind ¶
type AssertionKind string
const ( AssertStatus AssertionKind = "status" AssertBodyContains AssertionKind = "bodyContains" AssertJSON AssertionKind = "json" AssertRegex AssertionKind = "regex" AssertHeader AssertionKind = "header" )
type Capture ¶
type Capture struct {
Variable string
Origin CaptureOrigin
Expression string
Required bool
Default string
Line int
}
func ParseCapture ¶
ParseCapture is node-free because the Go DSL comes through here too: two readings of the same expression would mean a capture that works for one audience and fails for the other.
type CaptureOrigin ¶
type CaptureOrigin string
const ( CaptureJSON CaptureOrigin = "json" CaptureHeader CaptureOrigin = "header" CaptureCookie CaptureOrigin = "cookie" CaptureRegex CaptureOrigin = "regex" CaptureBody CaptureOrigin = "body" CaptureStatus CaptureOrigin = "status" )
type Change ¶ added in v0.6.0
type ConsumePolicy ¶
type ConsumePolicy string
const ( ConsumeSequential ConsumePolicy = "sequential" ConsumeRandom ConsumePolicy = "random" ConsumeCircular ConsumePolicy = "circular" ConsumeUniquePerUser ConsumePolicy = "uniquePerUser" )
type DataSource ¶
type DataSource struct {
Name string
File string
Consume ConsumePolicy
Seed int64
// Name of the environment variable the seed came from, empty when it was
// written in the file. Reproducing a run means knowing which seed ran and
// where it came from, and there is no way to know that later.
SeedFrom string
Fields map[string]Generator
Records int
Line int
}
func (DataSource) Synthetic ¶
func (dataSource DataSource) Synthetic() bool
func (DataSource) UsesSeed ¶
func (source DataSource) UsesSeed() bool
A semente so muda o que sai de uma fonte que usa aleatoriedade: sintetica sempre, e CSV so quando o consumo e aleatorio. Publicar uma semente que nao muda nada seria ruido no bloco que a pessoa le para reproduzir.
type Generator ¶
PerUse is off by default: the same generated value has to hold for the whole iteration, which is what an idempotency key needs — the same transactionId in two requests, a new one on the next iteration. Wanting a new value at every substitution is the rare case, so it is declared.
func ParseGenerator ¶
type LoadPlan ¶
type Phase ¶
func (Phase) InitialRate ¶
type SLORule ¶
type SLORule struct {
Scope SLOScope
Step string
Metric string
Operator Operator
Limit float64
Unit string
Text string
Line int
}
func ParseSLORule ¶
type ScenarioError ¶
func (ScenarioError) Error ¶
func (scenarioError ScenarioError) Error() string
type Spec ¶
type Spec struct {
FormatVersion string
Name string
Target string
Requires []string
// Names referenced as ${NOME} that only the environment can supply and that
// were not in it when the file was read. Not part of what the file says —
// part of what the machine had — so the DSL does not carry it.
MissingEnvironment []string
Vars map[string]string
Auth *Auth
Messaging *messaging.Settings
// TLS of the HTTP target. Kafka and AMQP declare theirs inside 'messaging';
// HTTP had nowhere to say it, and homologation behind a private CA could not
// be tested at all.
TLS *messaging.TLS
Data []DataSource
Load LoadPlan
Steps []Step
SLO []SLORule
}
func (Spec) HasMix ¶
HasMix diz se o cenario declara mix. Sem mix, todo passo roda em toda iteracao, que e o comportamento que sempre existiu.
func (*Spec) ResolveWith ¶ added in v0.6.0
ResolveWith injeta valores que nao vieram do arquivo — o ambiente, ou um valor que a interface guarda so na memoria da sessao. O arquivo mantem ${NOME} e nunca o literal, entao a recusa de credencial no arquivo fica intacta: isto e o mesmo "de onde, nao qual" que a variavel de ambiente ja e. Ver ADR 0021.
Vars vira um mapa novo para nao alterar o do chamador, e o nome deixa de contar como ausente — sem isso a execucao seria recusada por falta de uma variavel que a sessao acabou de fornecer.
Credencial de broker vai para o campo de conexao, nao para os Vars: e de la que o cliente a le. Pos-la nos Vars limparia o aviso e ainda falharia ao conectar.
func (*Spec) SessionCredentials ¶ added in v0.6.0
SessionCredentials sao as variaveis que faltam e que o campo de sessao entrega: as de HTTP pelos Vars do runtime, as de broker no campo de conexao.
type Step ¶
type Step struct {
Name string
Protocol string
Config protocol.Config
// Weight of the alternative in the mix. Zero when the scenario declares no
// mix, and then every step runs on every iteration. See ADR 0016.
Weight int
Checks []Check
Captures []Capture
Assertions []Assertion
Line int
}