dsl

package
v0.8.16 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

* Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	// PluginDefNameKey of the PluginDef map
	PluginDefNameKey = "Name"
	// PluginDefDirKey of the PluginDef map
	PluginDefDirKey = "Dir"
	// PluginDefFilenameKey of the PluginDef map
	PluginDefFilenameKey = "Filename"
	// PluginDefParamsKey of the PluginDef map
	PluginDefParamsKey = "Params"
	// PluginDefSeedKey of the PluginDef map
	PluginDefSeedKey = "Seed"
	// PluginDefVerboseKey of the PluginDef map
	PluginDefVerboseKey = "Verbose"
	// PluginDefPriorityKey of the PluginDef map
	PluginDefPriorityKey = "Priority"
	// PluginDefLabelsKey of the PluginDef map
	PluginDefLabelsKey = "Labels"
	// PluginDefTestsKey of the PluginDef map
	PluginDefTestsKey = "Tests"
	// PluginDefLogLevelKey of the PluginDef map
	PluginDefLogLevelKey = "LogLevels"
	// PluginDefListKey of the PluginDef map
	PluginDefListKey = "List"
	// PluginDefEmitJSONKey of the PluginDef map
	PluginDefEmitJSONKey = "EmitJSON"
	// PluginDefEmitRedactKey = "EmitJSON"
	PluginDefRedactKey = "Redact"
	// PluginDefNonzeroOnAnyErrorKey of the PluginDef map
	PluginDefNonzeroOnAnyErrorKey = "NonzeroOnAnyErrorKey"
	// PluginDefRetryKey of the PluginDef map
	PluginDefRetryKey = "Retry"
	// PluginDefIncludeDirsKey of the PluginDef map
	PluginDefIncludeDirsKey = "IncludeDirs"
)

Variables

View Source
var ThePluginRegistry = make(PluginRegistry)

ThePluginRegistry is the global, well-know registry of supported plax Plugin types

Functions

This section is empty.

Types

type Ctx

type Ctx struct {
	*plaxDsl.Ctx
	ReportPluginDir string
}

Ctx is the context type

func NewCtx

func NewCtx(ctx context.Context) *Ctx

NewCtx builds a new Ctx

type IncludeDirList

type IncludeDirList []string

IncludeDirList are the directories to search when YAML-including.

We make an explicit type to enable flag.Var to parse multiple parameters.

func (*IncludeDirList) Set

func (idl *IncludeDirList) Set(value string) error

Set the include directories

func (*IncludeDirList) String

func (idl *IncludeDirList) String() string

String representation

type Plugin

type Plugin interface {
	// Invoke calls the plugin
	Invoke(ctx context.Context) (*junit.TestSuite, error)
}

Plugin interface of invoking plax

func MakePlugin

func MakePlugin(module PluginModule, def PluginDef) (Plugin, error)

MakePlugin create the plugin

type PluginDef

type PluginDef map[string]interface{}

PluginDef map

func (PluginDef) GetPluginDefDir

func (pd PluginDef) GetPluginDefDir() (string, error)

GetPluginDefDir returns the Dir

func (PluginDef) GetPluginDefFilename

func (pd PluginDef) GetPluginDefFilename() (string, error)

GetPluginDefFilename returns the Filename

func (PluginDef) GetPluginDefIncludeDirsKey added in v0.5.3

func (pd PluginDef) GetPluginDefIncludeDirsKey() ([]string, error)

GetPluginDefIncludeDirsKey returns the Includes list

func (PluginDef) GetPluginDefLabels

func (pd PluginDef) GetPluginDefLabels() (string, error)

GetPluginDefLabels returns the Labels

func (PluginDef) GetPluginDefList

func (pd PluginDef) GetPluginDefList() (bool, error)

GetPluginDefList returns the List flag

func (PluginDef) GetPluginDefLogLevel

func (pd PluginDef) GetPluginDefLogLevel() (string, error)

GetPluginDefLogLevel returns the Filename

func (PluginDef) GetPluginDefName

func (pd PluginDef) GetPluginDefName() (string, error)

GetPluginDefName returns the Name

func (PluginDef) GetPluginDefNonzeroOnAnyErrorKey

func (pd PluginDef) GetPluginDefNonzeroOnAnyErrorKey() (bool, error)

GetPluginDefNonzeroOnAnyErrorKey returns the EmitJSON flag

func (PluginDef) GetPluginDefParams

func (pd PluginDef) GetPluginDefParams() (map[string]interface{}, error)

GetPluginDefParams returns the Params

func (PluginDef) GetPluginDefPriority

func (pd PluginDef) GetPluginDefPriority() (int, error)

GetPluginDefPriority returns the Priority

func (PluginDef) GetPluginDefRedact added in v0.8.1

func (pd PluginDef) GetPluginDefRedact() (bool, error)

GetPluginDefRedact returns the Redact flag.

func (PluginDef) GetPluginDefRetry

func (pd PluginDef) GetPluginDefRetry() (string, error)

GetPluginDefRetry returns the Retry

func (PluginDef) GetPluginDefSeed

func (pd PluginDef) GetPluginDefSeed() (int64, error)

GetPluginDefSeed returns the Seed

func (PluginDef) GetPluginDefTests

func (pd PluginDef) GetPluginDefTests() ([]string, error)

GetPluginDefTests returns the list of test to run

func (PluginDef) GetPluginDefVerbose

func (pd PluginDef) GetPluginDefVerbose() (bool, error)

GetPluginDefVerbose returns the Filename

type PluginMaker

type PluginMaker func(def PluginDef) (Plugin, error)

PluginMaker is the signature for a Plugin constructor

type PluginModule

type PluginModule string

PluginModule identifies the plax plugin by module name

var (
	// DefaultPluginModule to load; "There can be only one!"
	DefaultPluginModule PluginModule = "github.com/Comcast/plax"
)

type PluginOpts

type PluginOpts interface{}

PluginOpts represents generic data that is given to a plugin

type PluginRegistry

type PluginRegistry map[PluginModule]PluginMaker

PluginRegistry maps a PluginModule to a constructor for that type of Plugin

func (PluginRegistry) Register

func (pr PluginRegistry) Register(module PluginModule, maker PluginMaker)

Register registers a plugin

type TestConstraints

type TestConstraints struct {
	Labels   *string      `yaml:"labels,omitempty"`
	Priority *int         `yaml:"priority,omitempty"`
	Retry    int          `yaml:"retry"`
	Seed     int64        `yaml:"seed"`
	Iterate  *TestIterate `yaml:"iterate,omitempty"`
}

TestConstraints used to constrain the tests run

type TestDef

type TestDef struct {
	Path   string                  `yaml:"path"`
	Module PluginModule            `yaml:"version"`
	Params TestParamDependencyList `yaml:"params"`
}

TestDef is a test file or suite (directory)

type TestDefMap

type TestDefMap map[string]TestDef

TestDefMap is a map of TestDefs

type TestDefRef

type TestDefRef struct {
	TestConstraints `yaml:",inline"`
	Name            string       `yaml:"name"`
	Params          TestParamMap `yaml:"params"`
	Guard           *TestGuard   `yaml:"guard,omitempty"`
	// contains filtered or unexported fields
}

TestDefRef references a TestDef with its constraints

type TestDefRefList

type TestDefRefList []TestDefRef

TestDefRefList is a list of TestDefRefs

type TestGroup

type TestGroup struct {
	Iterate *TestIterate     `yaml:"iterate,omitempty"`
	Params  TestParamMap     `yaml:"params"`
	Tests   TestDefRefList   `yaml:"tests"`
	Groups  TestGroupRefList `yaml:"groups"`
}

TestGroup is a set of grouped tests or nested groups

type TestGroupList

type TestGroupList []string

TestGroupList are the test groups to execute

We make an explicit type to enable flag.Var to parse multiple parameters.

func (*TestGroupList) Set

func (tgl *TestGroupList) Set(value string) error

Set the groups

func (*TestGroupList) String

func (tgl *TestGroupList) String() string

String representation

type TestGroupMap

type TestGroupMap map[string]TestGroup

TestGroupMap is a map of TestGroups

type TestGroupRef

type TestGroupRef struct {
	Name   string       `yaml:"name"`
	Params TestParamMap `yaml:"params"`
	Guard  *TestGuard   `yaml:"guard,omitempty"`
}

TestGroupRef references a group by name

type TestGroupRefList

type TestGroupRefList []TestGroupRef

TestGroupRefList is a list of TestGroupRefs

type TestGuard

type TestGuard struct {
	// Libraries is a list of filenames that should contain
	// Javascript.  This source is loaded into each Javascript
	// environment.
	DependsOn TestParamDependencyList `yaml:"dependsOn"`
	Libraries []string                `yaml:"libraries"`
	Source    string                  `yaml:"src"`
}

TestGuard for guarding tests, groups, or iterations

func (*TestGuard) Satisfied

func (tg *TestGuard) Satisfied(ctx *plaxDsl.Ctx, tr TestRun, bs *plaxDsl.Bindings) (bool, error)

Satisfied checks if the guard allows the test to be executed

type TestIterate

type TestIterate struct {
	DependsOn TestParamDependencyList `yaml:"dependsOn"`
	Param     *string                 `yaml:"param"`
	Params    string                  `yaml:"params"`
	Guard     *TestGuard              `yaml:"guard,omitempty"`
}

TestIterate is used to iterate over a collection and invoke the test suite or test file multiple times

type TestIterateBindings

type TestIterateBindings struct {
	// contains filtered or unexported fields
}

TestIterateBindings is the bindings for an iteration

type TestIterateBindingsList

type TestIterateBindingsList []TestIterateBindings

TestIterateBindingsList is a list of test iteration bindings

type TestList

type TestList []string

TestList are the individual tests to execute

We make an explicit type to enable flag.Var to parse multiple parameters.

func (*TestList) Set

func (tl *TestList) Set(value string) error

Set the test in the testList

func (*TestList) String

func (tl *TestList) String() string

String representation

type TestParamBinding

type TestParamBinding struct {
	// DependsOn is a list of dependent parameters
	DependsOn TestParamDependencyList `json:"dependsOn" yaml:"dependsOn"`

	// Cmd is the command name of the program.
	//
	// Subject to expansion.
	Cmd string `json:"cmd" yaml:"cmd"`

	// Args is the list of command-line arguments for the program.
	//
	// Subject to expansion.
	Args []string `json:"args" yaml:"args"`

	// tpem is the map of environment variables to pass into the Run script
	Envs TestParamEnvMap `json:"envs" yaml:"envs"`

	// Redact the parameter binding flag
	Redact bool `json:"redact" yaml:"redact"`
	// contains filtered or unexported fields
}

TestParamBinding binds a value to a parameter via a command

type TestParamBindingMap

type TestParamBindingMap map[string]TestParamBinding

TestParamBindingMap is a map of TestParamBinding

type TestParamDependency

type TestParamDependency string

TestParamDependency name

type TestParamDependencyList

type TestParamDependencyList []TestParamDependency

TestParamDependencyList parameter dependency list

type TestParamEnvMap

type TestParamEnvMap map[string]interface{}

TestParamEnvMap type

type TestParamMap

type TestParamMap map[string]string

TestParamMap of parameter keys to non substituted parameter values

type TestReportPlugin added in v0.8.10

type TestReportPlugin struct {

	// DependsOn the parameters in the map for configuration
	DependsOn TestParamDependencyList `yaml:"dependsOn"`

	// Config is the configuration (if any) for the report plugin.
	Config interface{} `yaml:"config,omitempty" json:"config,omitempty"`
	// contains filtered or unexported fields
}

TestReportPlugin to execute the report

func (*TestReportPlugin) Generate added in v0.8.10

func (trp *TestReportPlugin) Generate(ctx *dsl.Ctx, tpbm TestParamBindingMap, bs plaxDsl.Bindings, tr *report.TestReport) error

Generate the test report using the TestReportPlugin for the TestRun

type TestReportPluginMap added in v0.8.10

type TestReportPluginMap map[string]TestReportPlugin

TestReportPluginMap dsl for mpa of TestReportPlugins

func (TestReportPluginMap) Generate added in v0.8.10

func (trpm TestReportPluginMap) Generate(ctx *dsl.Ctx, tpbm TestParamBindingMap, bs plaxDsl.Bindings, tr *report.TestReport, emitJSON bool) error

Generate the test reports from the TestReportPluginMap for the TestRun

type TestRun

type TestRun struct {
	Name    string              `yaml:"name" json:"name"`
	Version string              `yaml:"version" json:"version"`
	Tests   TestDefMap          `yaml:"tests" json:"-"`
	Groups  TestGroupMap        `yaml:"groups" json:"-"`
	Params  TestParamBindingMap `yaml:"params" json:"-"`
	Reports TestReportPluginMap `yaml:"reports" json:"-"`
	// contains filtered or unexported fields
}

TestRun is the top-level type for a test run.

func NewTestRun

func NewTestRun(ctx *Ctx, trps *TestRunParams) (*TestRun, error)

NewTestRun makes a new TestRun with the given TestRunParams

func (*TestRun) Exec

func (tr *TestRun) Exec(ctx *Ctx) error

Exec the TestRun

type TestRunParams

type TestRunParams struct {
	Bindings        plaxDsl.Bindings
	Groups          TestGroupList
	Tests           TestList
	SuiteName       *string
	IncludeDirs     IncludeDirList
	Filename        *string
	Dir             *string
	ReportPluginDir *string
	EmitJSON        *bool
	Verbose         *bool
	LogLevel        *string
	Labels          *string
	Priority        *int
	Redact          *bool
}

TestRunParams used to exec a TestRun

type TestSuiteRef

type TestSuiteRef struct {
	// contains filtered or unexported fields
}

TestSuiteRef reference

Jump to

Keyboard shortcuts

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