Documentation
¶
Overview ¶
Package verifier is a framework for running verification function in parallel to the actual test with option to re-run verification function in a loop until the primary test is finished.
Usage:
verF := func() (verifier.ResultType, error) {
res := any_test_function_desirable(additional_params)
return verifier.ResultType{Data: res, Timestamp: time.Now()}, nil
}
vf := verifier.NewVerifier(ctx, verF) // This only creates framework. defer vf.Finish() // This destroys framework. (...) vf.StartJob() // This triggers starting verification loop. (...test...) results, err := vf.StopJob() (analyze results slice)
State machine for the verifier:
*
|
V
/-----------------\
| Idle |- - - - - - - - -
\-----------------/ \ verifyFinish
/ ^ \
/ \ v
/ \ /-----------------\
verifyStart ( \ | Finished |
\ ) verifyStop \-----------------/
\ / ^
\ / /
v / /
/-----------------\ / verifyFinish
| Running |- - - - - - - - -
\-----------------/
/ ^
/ \
( )
\ /
\___/
verifyTimeout
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResultType ¶
ResultType defines abstract type of results type to handle.
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
Verifier structure with internal control data.
func NewVerifier ¶
func NewVerifier(ctx context.Context, fptr func(ctx context.Context) (ret ResultType, err error)) *Verifier
NewVerifier launches goroutine for verification and sets it up. The function should not take more than a minute, otherwise it may cause test flakiness. The function will run in a loop anyway.
func (*Verifier) Finish ¶
func (vf *Verifier) Finish()
Finish causes verification goroutine to exit.
func (*Verifier) StartJob ¶
StartJob starts new verification job. Wait for confirmation it has started.
func (*Verifier) StopJob ¶
func (vf *Verifier) StopJob() ([]ResultType, error)
StopJob stops running the job and return its results. It won't interrupt the job, it will simply stop looping the verification function once it returns.