Documentation ¶
Index ¶
- func Dereference(v string) (bool, string, string)
- func Load(path string, log contract.Logger) contract.Script
- func NoGraph(err error, log contract.Logger) gcontract.Graph
- func NoScript(err error, log contract.Logger) contract.Script
- type ExecutionGraph
- type ExecutionNode
- type Executor
- type NullGraph
- func (g NullGraph) AddEdge(v1 gcontract.NodeID, v2 gcontract.NodeID)
- func (g NullGraph) AddNode(n gcontract.Node)
- func (g NullGraph) AdjacentNodes(nID gcontract.NodeID) gcontract.Nodes
- func (g NullGraph) BFS(n gcontract.NodeID) gcontract.NChannel
- func (g NullGraph) DFS(n gcontract.NodeID, traverse gcontract.TraversalOrder) gcontract.NChannel
- func (g *NullGraph) Len() uint
- func (g NullGraph) Node(nID gcontract.NodeID) gcontract.Node
- func (g NullGraph) Nodes() gcontract.Nodes
- func (g NullGraph) RBFS(n gcontract.NodeID) gcontract.NChannel
- func (g NullGraph) RDFS(n gcontract.NodeID, traverse gcontract.TraversalOrder) gcontract.NChannel
- func (g NullGraph) UpstreamNodes(nID gcontract.NodeID) gcontract.Nodes
- type NullScript
- type OperationDataExpect
- type OperationDataMap
- type OperationDataUse
- type OperationRef
- type Script
- func (script *Script) GetExecutionGraph() gcontract.Graph
- func (script *Script) GetNode(graph gcontract.Graph, opRefID string, op contract.Operation, ...) *ExecutionNode
- func (script *Script) SetupAfterDependency(graph *ExecutionGraph, opRef *OperationRef, opNode *ExecutionNode) error
- func (script *Script) SetupDependencies(graph *ExecutionGraph, srcParams *OperationDataMap, dstParams contract.Set, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dereference ¶
Dereference checks if v is a reference to another operation and returns a ParameterAccess function for it.
Types ¶
type ExecutionGraph ¶
type ExecutionGraph struct { contract.EntityTrait *gog.DGraph }
ExecutionGraph is a graph representing interdependencies between operations.
func NewExecutionGraph ¶
func NewExecutionGraph(log contract.Logger) *ExecutionGraph
NewExecutionGraph creates a new OperationGraph instance.
type ExecutionNode ¶
type ExecutionNode struct { Operation contract.Operation OpRefID string Data contract.OperationData Mutex sync.Mutex Result *contract.OperationResult Use *OperationDataUse Expect *OperationDataUse ExpectBody *params.BodyParameters }
ExecutionNode represents a single operation in the script execution graph. It contains a pointer to an operation and keeps an OperationData instance where operation parameters are stored. Those later get loaded into an Operation's own Data() instance.
func NewExecutionNode ¶
func NewExecutionNode(op contract.Operation, opRefID string, opRef *OperationRef, log contract.Logger) *ExecutionNode
NewExecutionNode creates a new ExecutionNode instance.
func (*ExecutionNode) ID ¶
func (node *ExecutionNode) ID() gcontract.NodeID
ID returns a uniqe operation node ID.
func (*ExecutionNode) Lock ¶
func (node *ExecutionNode) Lock()
Lock locks the node to prevent parallel executions.
type Executor ¶
type Executor struct {
contract.EntityTrait
}
Executor executes an ExecutionGraph that comes from a script.
func NewExecutor ¶
NewExecutor creates a new Executor instance.
func (Executor) Walk ¶
func (ex Executor) Walk( graph gcontract.Graph, n *ExecutionNode, nwg *sync.WaitGroup, nresults *contract.OperationResults, )
Walk walks the execution graph and executes operations.
type NullGraph ¶
type NullGraph struct {
errors.NullObjectPrototype
}
NullGraph is used whenever we can't have a real execution graph from a script. Reports the contained error on every method call.
func (NullGraph) AdjacentNodes ¶
AdjacentNodes reports an error.
type NullScript ¶
type NullScript struct {
errors.NullObjectPrototype
}
NullScript is used whenever we can't have a real one. Reports the contained error on every method call.
func (*NullScript) GetExecutionGraph ¶
func (s *NullScript) GetExecutionGraph() gcontract.Graph
GetExecutionGraph reports an error.
type OperationDataExpect ¶
type OperationDataExpect struct { Body OperationDataMap `yaml:"body"` Headers OperationDataMap `yaml:"headers"` CT string `yaml:"CT"` Status int64 `yaml:"status"` }
OperationDataExpect corresponds to the 'expect' block of the OperationRef in a script file.
type OperationDataMap ¶
OperationDataMap is a map of parameters for an OperationRef.
func (OperationDataMap) Iterate ¶
func (m OperationDataMap) Iterate() contract.ParameterIterator
Iterate creates an iterable channel.
type OperationDataUse ¶
type OperationDataUse struct { Path OperationDataMap `yaml:"path"` Body OperationDataMap `yaml:"body"` Query OperationDataMap `yaml:"query"` Headers OperationDataMap `yaml:"headers"` Security OperationDataMap `yaml:"security"` CT string `yaml:"CT"` Status int64 `yaml:"status"` }
OperationDataUse corresponds to the 'use' block of the OperationRef in a script file.
type OperationRef ¶
type OperationRef struct { OperationID string `yaml:"operationId"` After string `yaml:"after"` Use OperationDataUse `yaml:"use"` Expect OperationDataUse `yaml:"expect"` }
OperationRef is a node of execution graph as desfined in the script file. It references a spec operation and contains the needed data.
type Script ¶
type Script struct { api.OperationCache contract.EntityTrait SpecPath string `yaml:"spec"` Operations map[string]*OperationRef `yaml:"operations"` }
Script is a complex API testing scenario. It defines dependencies between various operations and order of their execution.
func (*Script) GetExecutionGraph ¶
GetExecutionGraph builds and returns an operation execution graph.
func (*Script) GetNode ¶
func (script *Script) GetNode(graph gcontract.Graph, opRefID string, op contract.Operation, opRef *OperationRef) *ExecutionNode
GetNode returns an ExecutionNode instance corresponding to the opRefID. If such a node exists in the graph, it will be returned, otherwise a new node is created.
func (*Script) SetupAfterDependency ¶
func (script *Script) SetupAfterDependency(graph *ExecutionGraph, opRef *OperationRef, opNode *ExecutionNode) error
SetupAfterDependency adds an edge to the execution graph if opRef has an 'after' specified.
func (*Script) SetupDependencies ¶
func (script *Script) SetupDependencies( graph *ExecutionGraph, srcParams *OperationDataMap, dstParams contract.Set, opNode *ExecutionNode, opRefID string, ) error
SetupDependencies iterates over the provided map, looks for reference values, collects a list of references operations along with ParameterAccess functions.