teststruct

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertMessage

type AlertMessage struct {
	TSname     string     `json:"tsname"`
	TSfile     string     `json:"tsfile"`
	TCname     string     `json:"tcname"`
	TCstatus   bool       `json:"tcres"`
	TStepfails []TestStep `json:"tstepfails"`
}

type JSONStep

type JSONStep struct {
	Name       string                 `json:"name"`
	Config     configTestStructJson   `json:"config"`
	Probe      map[string]interface{} `json:"probe"`
	Assertions []string               `json:"assertions"`
	Loop       []string               `json:"loop"`
}

type JSONTestCase

type JSONTestCase struct {
	Name      string               `json:"name"`
	Config    configTestStructJson `json:"config"`
	Loop      []string             `json:"loop"`
	JsonSteps []JSONStep           `json:"steps"`
}

type JSONTestSuite

type JSONTestSuite struct {
	Config        configTestStructJson `json:"config"`
	Name          string               `json:"name"`
	JsonTestCases []JSONTestCase       `json:"testcases"`
	Vars          map[string][]string  `json:"vars"`
}

type ProbeConfigJsonRaw

type ProbeConfigJsonRaw map[string]string

type ProbeWrap

type ProbeWrap struct {
	Probe      probe.Probe   `json:"probe"`
	Frequency  time.Duration `json:"frequency"`  // time interval between two tests
	Retry      int           `json:"retry"`      // nb retry a test case if it is in failure.
	Retrydelay time.Duration `json:"retrydelay"` // delay between two retries
	Timeout    time.Duration `json:"timeout"`    // timeout on executor
}

func (ProbeWrap) Export

func (pw ProbeWrap) Export() ProbeWrapAPI

func (ProbeWrap) Run

func (pw ProbeWrap) Run() []probe.ProbeReturn

type ProbeWrapAPI

type ProbeWrapAPI struct {
	Probe      probe.Probe `json:"probe"`
	Frequency  string      `json:"frequency"`  // time interval between two tests
	Retry      int         `json:"retry"`      // nb retry a test case if it is in failure.
	Retrydelay string      `json:"retrydelay"` // delay between two retries
	Timeout    string      `json:"timeout"`    // timeout on executor
}

type Processing

type Processing struct {
	LastAttempt  time.Time
	Status       StepStatus
	VigieResults []VigieResult
	Issue        string
}

type Step

type Step map[string]interface{}

Step represents a Step

type StepAssertionDescribe

type StepAssertionDescribe struct {
	Assertions []string
}

type StepAssertions

type StepAssertions struct {
	Assertions []string `json:"assertions,omitempty"`
}

StepAssertions contains step assertions

type StepParam

type StepParam struct {
	Frequency  string `json:"frequency"`  // time interval between two test
	Retry      int    `json:"retry"`      // nb retry a test case if it is in failure.
	Retrydelay string `json:"retrydelay"` // delay between two retries
	Timeout    string `json:"timeout"`    // timeout on executor
}

type StepResultDescribe

type StepResultDescribe struct {
	StatusStr                string         `json:"status"`
	LastAttempt              time.Time      `json:"lastattempt"`            // UnixTimeNano si Freq <1sec
	LastPositiveTimeResult   time.Time      `json:"lastpositivetimeresult"` // UnixTimeNano si Freq <1sec
	LastPositiveVigieResults *[]VigieResult `json:"lastpositivevigieresults"`
	VigieResults             []VigieResult  `json:"vigieresults"`
	Details                  []string       `json:"details"`
	LastChange               time.Time      `json:"lastchange"`
}

type StepStatus

type StepStatus int
const (
	Success       StepStatus = 1
	NotDefined    StepStatus = 0
	AssertFailure StepStatus = -1
	Failure       StepStatus = -2
	Timeout       StepStatus = -3
	Error         StepStatus = -4
)

func (StepStatus) Int added in v0.6.0

func (ss StepStatus) Int() int

func (StepStatus) IsSucess

func (ss StepStatus) IsSucess() bool

func (StepStatus) IsTimeMesureable added in v0.5.0

func (ss StepStatus) IsTimeMesureable() bool

func (StepStatus) String

func (ss StepStatus) String() string

type TCAlertShort

type TCAlertShort struct {
	TCHeader
	TestSteps map[uint64]TStepAlertShort `json:"teststeps"`
}

type TCDescribe

type TCDescribe struct {
	ID uint64 `json:"id"`
	// Errors    int             `json:"errors"`
	Status string `json:"status"`
	// Failures  int             `json:"failures"`
	Name      string          `json:"name"`
	TestSteps []TStepDescribe `json:"teststeps"`
}

type TCHeader

type TCHeader struct {
	ID     uint64 `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status"`
}

type TSAlertShort

type TSAlertShort struct {
	TSHeader
	TestCases map[uint64]TCAlertShort `json:"testcases"`
}

type TSDescribe

type TSDescribe struct {
	//	Errors         int          `json:"errors"`
	Status string `json:"status"`
	//	Failures       int          `json:"failures"`
	Name string `json:"name"`
	ID   uint64 `json:"id"`
	//	TestCaseCount  int          `json:"testcasescount"`
	//	TestStepsCount int          `json:"teststepscount"`
	TestCases []TCDescribe `json:"testcases"`
}

type TSHeader

type TSHeader struct {
	ID     uint64 `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status"`
}

type TStepAlertShort

type TStepAlertShort struct {
	Name    string   `json:"name"`
	ID      uint64   `json:"id"`
	Status  string   `json:"status"`  // Status de la teststep
	Details []string `json:"details"` // Liste des messages result Assertions
}

type TStepDescribe

type TStepDescribe struct {
	Name      string             `json:"name"`
	StepProbe probe.Probe        `json:"probe"`
	StepD     StepParam          `json:"parameters"`
	StepResD  StepResultDescribe `json:"result"`
	StepAss   []string           `json:"assertions"`
}

type Task

type Task struct {
	TestSuite *TestSuite
	TestCase  *TestCase
	TestStep  *TestStep
}

func (*Task) LockAll

func (t *Task) LockAll()

func (*Task) RLockAll

func (t *Task) RLockAll()

func (*Task) RUnlockAll

func (t *Task) RUnlockAll()

func (*Task) UnlockAll

func (t *Task) UnlockAll()

func (*Task) WriteMetadataChanges

func (t *Task) WriteMetadataChanges(lastchg time.Time)

type TestCase

type TestCase struct {
	Name       string
	ID         uint64           `hash:"ignore"`
	Mutex      sync.RWMutex     `hash:"ignore"`
	Config     configTestStruct `hash:"ignore"`
	Status     StepStatus       `hash:"ignore"`
	LastChange time.Time        `hash:"ignore"`
	TestSteps  map[uint64]*TestStep
}

toTestCase is a single test case with its result.

func (*TestCase) FailureCount

func (tc *TestCase) FailureCount() (failCount int)

FailureCount returns the numbers of non success teststep

func (*TestCase) GetStatus added in v0.4.0

func (tc *TestCase) GetStatus() (ss StepStatus)

GetStatus returns this TestCase Status

func (*TestCase) ImportTestSteps added in v0.7.0

func (tc *TestCase) ImportTestSteps(newTSteps map[uint64]*TestStep)

ImportTestSteps will add new TSteps to an empty or already populated TestCase, Import Rules : remove oldTSteps that are absent from the new TSteps, keep common TSteps, add new ones

func (*TestCase) RemoveTestStep added in v0.7.0

func (tc *TestCase) RemoveTestStep(ID uint64)

remobeTestStep simply removes a TestStep from this TestCase, concurency safe

func (*TestCase) SetStatus added in v0.4.0

func (tc *TestCase) SetStatus(newStatus StepStatus)

SetStatus set this TestCase Status

func (*TestCase) ToAlertShortTC

func (tc *TestCase) ToAlertShortTC() TCAlertShort

func (*TestCase) ToHeader

func (tc *TestCase) ToHeader() TCHeader

func (*TestCase) ToJSON

func (tc *TestCase) ToJSON() TCDescribe

func (*TestCase) UpdateStatus

func (tc *TestCase) UpdateStatus() bool

UpdateStatus change and return the TC ResultStatus Loop on each TSteps If one of the TSteps is KO => Set TC status to False

func (*TestCase) WithoutTStep added in v0.4.0

func (tc *TestCase) WithoutTStep() *TestCase

Returns this Testcase without Teststeps

type TestStep

type TestStep struct {
	Mutex                    sync.RWMutex `hash:"ignore"`
	Name                     string
	ID                       uint64 `hash:"ignore"`
	Assertions               []assertion.Assert
	ProbeWrap                ProbeWrap
	Failures                 []string       `hash:"ignore"`
	LastAttempt              time.Time      `hash:"ignore"`
	LastChange               time.Time      `hash:"ignore"`
	LastPositiveTimeResult   time.Time      `hash:"ignore"`
	VigieResults             []VigieResult  `hash:"ignore"`
	LastPositiveVigieResults *[]VigieResult `hash:"ignore"`
	Status                   StepStatus     `hash:"ignore"`
}

TestStep est constitué d'une Step ainsi que d'autres objets permettant l'exec et la traçabilité

func (*TestStep) AssertProbeResult

func (tStep *TestStep) AssertProbeResult(probeResult *probe.ProbeAnswer) (assertResults []assertion.AssertResult, success bool)

applyChecks apply checks on result, return true if all assertions are Success, false otherwise

func (*TestStep) GetLastPositiveResult

func (tStep *TestStep) GetLastPositiveResult() (vrs *[]VigieResult)

func (*TestStep) GetReSyncro added in v0.7.0

func (tStep *TestStep) GetReSyncro() (syncroDelay time.Duration)

func (*TestStep) GetStatus

func (tStep *TestStep) GetStatus() (ss StepStatus)

func (*TestStep) ResponseTimeInflux

func (tStep *TestStep) ResponseTimeInflux() float64

responsetime return the duration time between the last call and the received response time is in second

func (*TestStep) ToStepAlertShort

func (tStep *TestStep) ToStepAlertShort() TStepAlertShort

func (*TestStep) ToTestStepDescribe

func (tStep *TestStep) ToTestStepDescribe() TStepDescribe

ToTestStepDescribe return a JSON API response

func (*TestStep) WriteResult

func (tStep *TestStep) WriteResult(pData *Processing) (stateChanged, alertEvent bool)

WriteResult Write all temp processing data during RunTestStep in a teststep

type TestStepComparaison added in v0.7.0

type TestStepComparaison struct {
	Name       string
	Assertions []assertion.Assert
	ProbeWrap  ProbeWrap
}

TestStepComparaison is use to compare a teststep, it only contains fixed values.

type TestSuite

type TestSuite struct {
	Mutex      sync.RWMutex `hash:"ignore"`
	Name       string
	ID         uint64     `hash:"ignore"`
	Status     StepStatus `hash:"ignore"`
	TestCases  map[uint64]*TestCase
	LastChange time.Time `hash:"ignore"`
	SourceFile string    `hash:"ignore"` // Public
}

func (*TestSuite) Failures

func (ts *TestSuite) Failures() (count int)

func (*TestSuite) GetTestcaseByID

func (ts *TestSuite) GetTestcaseByID(TCid uint64) (tc *TestCase)

GetTestcaseByID get a TestCase by is ID in the current TestSuite.

func (*TestSuite) ImportAllTestCases added in v0.7.0

func (ts *TestSuite) ImportAllTestCases(newTCs map[uint64]*TestCase)

ImportAllTestCases will add new TCs, remove oldTC that are absent from the new TCs, keep common TCs

func (*TestSuite) SetStatus

func (ts *TestSuite) SetStatus(status StepStatus)

func (*TestSuite) ToAlertShortTS

func (ts *TestSuite) ToAlertShortTS() TSAlertShort

func (*TestSuite) ToAlertShortTSRec

func (ts *TestSuite) ToAlertShortTSRec() TSAlertShort

func (*TestSuite) ToHeader

func (ts *TestSuite) ToHeader() TSHeader

func (*TestSuite) ToJSON

func (ts *TestSuite) ToJSON() TSDescribe

func (*TestSuite) UnmarshalJSON

func (ts *TestSuite) UnmarshalJSON(data []byte) error

func (*TestSuite) UpdateStatus

func (ts *TestSuite) UpdateStatus()

func (*TestSuite) WithoutTC added in v0.4.0

func (ts *TestSuite) WithoutTC() TestSuite

type TotalAlertMessage

type TotalAlertMessage struct {
	Date       time.Time
	TestSuites map[uint64]TSAlertShort
}

type UIDTest

type UIDTest struct {
	TestSuite TSHeader      `json:"testsuite"`
	TestCase  TCHeader      `json:"testcase"`
	TestStep  TStepDescribe `json:"teststep"`
}

type VigieResult

type VigieResult struct {
	ProbeAnswer       map[string]interface{}   `json:"probe_answer"`
	ProbeInfo         probe.ProbeInfo          `json:"probe_info"`
	AssertionResult   []assertion.AssertResult `json:"assertion_result"`
	Status            StepStatus               `json:"status"`
	StatusDescription string                   `json:"status_description"`
}

func (*VigieResult) GetValues added in v0.6.0

func (vr *VigieResult) GetValues() (vv VigieValue)

type VigieValue added in v0.6.0

type VigieValue struct {
	Status       int
	Responsetime float64
	Msg          string
	Subtest      string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL