runner

package
v0.0.0-...-ed06964 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitCodeSuccess       = 0
	ExitCodeGeneralError  = 1
	ExitCodeTestNotPassed = 2
)

Variables

View Source
var ErrJUnitNotSupported = errors.New("junit report is not supported for this resource type")
View Source
var ErrNotFound = fmt.Errorf("runner not found")

Functions

func HandleRunError

func HandleRunError(resp *http.Response, reqErr error) error

HandleRunError handles errors returned by the server when running a test. It normalizes the handling of general errors, like 404, but more importantly, it processes the missing environment variables error so the orchestrator can request them from the user.

func Orchestrator

func Orchestrator(
	logger *zap.Logger,
	openapiClient *openapi.APIClient,
	variableSets resourcemanager.Client,
) orchestrator

Types

type Registry

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

func NewRegistry

func NewRegistry(logger *zap.Logger) Registry

func (Registry) Get

func (r Registry) Get(name string) (Runner, error)

func (Registry) List

func (r Registry) List() []string

func (Registry) Register

func (r Registry) Register(runner Runner) Registry

func (Registry) RegisterProxy

func (r Registry) RegisterProxy(proxyName, runnerName string) Registry

type RunOptions

type RunOptions struct {
	// ID of the resource to run
	ID string

	// path to the file with resource definition
	// the file will be applied before running
	DefinitionFile string

	// varsID or path to the file with environment definition
	VarsID string

	// By default the runner will wait for the result of the run
	// if this option is true, the wait will be skipped
	SkipResultWait bool

	// Optional path to the file where the result of the run will be saved
	// in JUnit xml format
	JUnitOuptutFile string

	// Overrides the default required gates for the resource
	RequiredGates []string
}

RunOptions defines options for running a resource ID and DefinitionFile are mutually exclusive and the only required options

type RunResult

type RunResult struct {
	// The resource being run. If has been preprocessed, this needs to be the updated version
	Resource any

	// The result of the run. It can be anything the resource needs for validating and formatting the result
	Run any

	// If true, it means that the current run is ready to be presented to the user
	Finished bool

	// Whether the run has passed or not. Used to determine exit code
	Passed bool
}

RunResult holds the result of the run Resources

type Runner

type Runner interface {
	// Name of the runner. must match the resource name it handles
	Name() string

	// Apply the given file and return a resource. The resource can be of any type.
	// It will then be used by Run method
	Apply(context.Context, fileutil.File) (resource any, _ error)

	// GetByID gets the resource by ID. This method is used to get the resource when running from id
	GetByID(_ context.Context, id string) (resource any, _ error)

	// StartRun starts running the resource and return the result. This method should not wait for the test to finish
	StartRun(_ context.Context, resource any, _ openapi.RunInformation) (RunResult, error)

	// UpdateResult is regularly called by the orchestrator to check the status of the run
	UpdateResult(context.Context, RunResult) (RunResult, error)

	// JUnitResult returns the result of the run in JUnit format
	JUnitResult(context.Context, RunResult) (string, error)

	// Format the result of the run into a string
	FormatResult(_ RunResult, format string) string
}

Runner defines interface for running a resource

func TestRunner

func TestRunner(
	client resourcemanager.Client,
	openapiClient *openapi.APIClient,
	formatter testFormatter,
) Runner

func TestSuiteRunner

func TestSuiteRunner(
	client resourcemanager.Client,
	openapiClient *openapi.APIClient,
	formatter testSuiteFormatter,
) Runner

Jump to

Keyboard shortcuts

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