execution

package
v1.6.10 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 30 Imported by: 12

Documentation

Overview

Package execution handles gauge's execution of spec/scenario/steps

   Execution can be of two types
	- Simple execution
	- Paralell execution

   Execution Flow :
   	- Checks for updates
    	- Validation
    	- Init Registry
    	- Saving Execution result

   Strategy
    	- Lazy : Lazy is a parallelization strategy for execution. In this case tests assignment will be dynamic during execution, i.e. assign the next spec in line to the stream that has completed it’s previous execution and is waiting for more work.
    	- Eager : Eager is a parallelization strategy for execution. In this case tests are distributed before execution, thus making them an equal number based distribution.

Index

Constants

View Source
const (
	// Success indicated successful operation
	Success = 0
	// ExecutionFailed indicates gauge's execution failed
	ExecutionFailed = 1
	// ParseFailed indicates one or more parse errors
	ParseFailed = 2
	// ValidationFailed indicates one or more validation errors
	ValidationFailed = 3
)
View Source
const Eager string = "eager"

Eager is a parallelization strategy for execution. In this case tests are distributed before execution, thus making them an equal number based distribution.

View Source
const Lazy string = "lazy"

Lazy is a parallelization strategy for execution. In this case tests assignment will be dynamic during execution, i.e. assign the next spec in line to the stream that has completed it’s previous execution and is waiting for more work.

Variables

View Source
var ExecuteSpecs = func(specDirs []string) int {
	err := validateFlags()
	if err != nil {
		logger.Fatal(true, err.Error())
	}
	if config.CheckUpdates() {
		i := &install.UpdateFacade{}
		i.BufferUpdateDetails()
		defer i.PrintUpdateBuffer()
	}
	skel.SetupPlugins(MachineReadable)
	err = os.Setenv(gaugeParallelStreamCountEnv, strconv.Itoa(NumberOfExecutionStreams))
	if err != nil {
		logger.Fatalf(true, "failed to set env %s. %s", gaugeParallelStreamCountEnv, err.Error())
	}

	res := validation.ValidateSpecs(specDirs, false)
	if len(res.Errs) > 0 {
		if res.ParseOk {
			return ParseFailed
		}
		return ValidationFailed
	}
	if res.SpecCollection.Size() < 1 {
		logger.Infof(true, "No specifications found in %s.", strings.Join(specDirs, ", "))
		err := res.Runner.Kill()
		if err != nil {
			logger.Errorf(false, "unable to kill runner: %s", err.Error())
		}
		if res.ParseOk {
			return Success
		}
		return ExecutionFailed
	}
	event.InitRegistry()
	wg := &sync.WaitGroup{}
	reporter.ListenExecutionEvents(wg)
	rerun.ListenFailedScenarios(wg, specDirs)
	if env.SaveExecutionResult() {
		ListenSuiteEndAndSaveResult(wg)
	}
	defer wg.Wait()
	ei := newExecutionInfo(res.SpecCollection, res.Runner, nil, res.ErrMap, InParallel, 0)

	e := ei.getExecutor()
	logger.Debug(true, "Run started")
	return printExecutionResult(e.run(), res.ParseOk)
}

ExecuteSpecs : Check for updates, validates the specs (by invoking the respective language runners), initiates the registry which is needed for console reporting, execution API and Rerunning of specs and finally saves the execution result as binary in .gauge folder.

View Source
var ExecuteTags = ""

ExecuteTags holds the tags to filter the execution by

View Source
var ExecutionArgs []*gauge.ExecutionArg
View Source
var InParallel bool

InParallel if true executes the specs in parallel else in serial.

View Source
var MachineReadable bool

MachineReadable indicates that the output is in json format

View Source
var MaxRetriesCount int

Count of iterations

View Source
var NumberOfExecutionStreams int

NumberOfExecutionStreams shows the number of execution streams, in parallel execution.

View Source
var RetryOnlyTags string

Tags to filter specs/scenarios to retry

View Source
var Strategy string

Strategy for execution, can be either 'Eager' or 'Lazy'

View Source
var TagsToFilterForParallelRun string
View Source
var Verbose bool

Verbose if true prints additional details about the execution

Functions

func ListenSuiteEndAndSaveResult added in v0.8.5

func ListenSuiteEndAndSaveResult(wg *sync.WaitGroup)

ListenSuiteEndAndSaveResult listens to execution events and writes the failed scenarios to JSON file

func ReadLastExecutionResult added in v1.0.3

func ReadLastExecutionResult() (interface{}, error)

ReadLastExecutionResult returns the result of previous execution in JSON format This is stored in $GAUGE_PROJECT_ROOT/.gauge/executionStatus.json file after every execution

func SetTableRows added in v0.8.4

func SetTableRows(tableRows string)

SetTableRows is used to limit data driven execution to specific rows

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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