runs

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: EPL-2.0 Imports: 30 Imported by: 0

Documentation

Overview

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

Index

Constants

View Source
const (
	RESULT_PASSED              = "Passed"
	RESULT_PASSED_WITH_DEFECTS = "Passed With Defects"
	RESULT_FAILED              = "Failed"
	RESULT_FAILED_WITH_DEFECTS = "Failed With Defects"
	RESULT_LOST                = "Lost"
	RESULT_ENVFAIL             = "EnvFail"
)
View Source
const (
	// Inside the portfolio file, it must carry a format field with this value inside.
	PORTOLIO_DECLARED_FORMAT_VERSION = "v1alpha"

	// Inside the portfolio file, it should claim to be a resource of this kind.
	PORTFOLIO_DECLARED_RESOURCE_KIND = "galasa.dev/testPortfolio"
)
View Source
const (
	DEFAULT_POLL_INTERVAL_SECONDS            int = 30
	MAX_INT                                  int = int(^uint(0) >> 1)
	DEFAULT_PROGRESS_REPORT_INTERVAL_MINUTES int = 5
	DEFAULT_THROTTLE_TESTS_AT_ONCE           int = 3
)
View Source
const (
	// An active run that should be finished now.
	RUN_U123_FIRST_RUN = `` /* 555-byte string literal not displayed */

	// An active run
	RUN_U123_RE_RUN = `` /* 555-byte string literal not displayed */

	// Another active run
	RUN_U123_RE_RUN_2 = `` /* 555-byte string literal not displayed */

	// A finished run
	RUN_U120 = `` /* 767-byte string literal not displayed */

	// Another finished run
	RUN_U121 = `` /* 767-byte string literal not displayed */

)
View Source
const (
	INT_TYPE_VARIANT_PLAIN_INT = 0
	INT_TYPE_VARIANT_INT8      = 8
	INT_TYPE_VARIANT_INT16     = 16
	INT_TYPE_VARIANT_INT32     = 32
	INT_TYPE_VARIANT_INT64     = 64
)

Variables

View Source
var (
	CANCEL_STATUS = "finished"
	CANCEL_RESULT = "cancelled"
)
View Source
var (
	RESET_STATUS = "queued"
	RESET_RESULT = ""
)
View Source
var (
	TIME_UNIT_WEEKS   = newTimeUnit("weeks", "w", 10080)
	TIME_UNIT_DAYS    = newTimeUnit("days", "d", 1440)
	TIME_UNIT_HOURS   = newTimeUnit("hours", "h", 60)
	TIME_UNIT_MINUTES = newTimeUnit("minutes", "m", 1)
)
View Source
var (
	// Expect the pattern letters + number
	// ^ matches the start of the string
	// $ matches the end of the string
	// If ^ and $ are not specified, then M2M2 would match (two instances of the match)!
	RUN_NAME_PATTERN *regexp.Regexp = regexp.MustCompile("^[a-zA-Z]+[0-9]+$")
)

Functions

func AddClassFlag

func AddClassFlag(command *cobra.Command, flags *utils.TestSelectionFlagValues, isRequired bool, helpText string)

func AddClassesToPortfolio

func AddClassesToPortfolio(testSelection *TestSelection, testOverrides *map[string]string, portfolio *Portfolio)

func AddCommandFlags

func AddCommandFlags(command *cobra.Command, flags *utils.TestSelectionFlagValues)

Adds a ton of flags to a cobra command like 'runs prepare' or 'runs submit'. The flags are consistently added as a result.

func AddGherkinFlag added in v0.32.0

func AddGherkinFlag(command *cobra.Command, flags *utils.TestSelectionFlagValues, isRequired bool, helpText string)

func AreSelectionFlagsProvided

func AreSelectionFlagsProvided(flags *utils.TestSelectionFlagValues) bool

func CancelRun added in v0.32.0

func CancelRun(
	runName string,
	timeService utils.TimeService,
	console utils.Console,
	apiServerUrl string,
	apiClient *galasaapi.APIClient,
) error

func CountTotalFailedRuns

func CountTotalFailedRuns(finishedRuns map[string]*TestRun, lostRuns map[string]*TestRun) int

func CreateEmptyArtifactFile

func CreateEmptyArtifactFile(fileSystem files.FileSystem, targetFilePath string) (io.WriteCloser, error)

Creates an empty file representing an artifact that is being written. Any parent directories that do not exist will be created. Returns the empty file that was created or an error if any file creation operations failed.

func CreateFormatters

func CreateFormatters() map[string]runsformatter.RunsFormatter

func DeepClone

func DeepClone(original map[string]*TestRun) map[string]*TestRun

func DownloadArtifacts

func DownloadArtifacts(
	runName string,
	forceDownload bool,
	fileSystem files.FileSystem,
	timeService utils.TimeService,
	console utils.Console,
	apiClient *galasaapi.APIClient,
	runDownloadTargetFolder string,
) error

DownloadArtifacts - performs all the logic to implement the `galasactl runs download` command, but in a unit-testable manner.

func FinalHumanReadableReport

func FinalHumanReadableReport(finishedRuns map[string]*TestRun, lostRuns map[string]*TestRun)

FinalHumanReadableReport - Creates a human readable report of how it went.

func FinalHumanReadableReportAsString

func FinalHumanReadableReportAsString(finishedRuns map[string]*TestRun, lostRuns map[string]*TestRun) string

func FormattableTestFromGalasaApi

func FormattableTestFromGalasaApi(runs []galasaapi.Run, apiServerUrl string) []runsformatter.FormattableTest

func FormattableTestFromTestRun

func FormattableTestFromTestRun(finishedMap map[string]*TestRun, lostMap map[string]*TestRun) []runsformatter.FormattableTest

func GetArtifactPathsFromRestApi

func GetArtifactPathsFromRestApi(runId string, apiClient *galasaapi.APIClient) ([]string, error)

Retrieves the paths of all artifacts for a given test run using its runId.

func GetFileFromRestApi

func GetFileFromRestApi(runId string, artifactPath string, apiClient *galasaapi.APIClient) (io.Reader, bool, *http.Response, error)

GetFileFromRestApi Retrieves an artifact for a given test run using its runId from the ecosystem API. Note: The call leaves closing the http request as a responsibility of the caller.

func GetFormatterNamesString

func GetFormatterNamesString(validFormatters map[string]runsformatter.RunsFormatter) string

GetFormatterNamesString builds a string of comma separated, quoted formatter names

func GetRunDetailsFromRasSearchRuns

func GetRunDetailsFromRasSearchRuns(runs []galasaapi.Run, apiClient *galasaapi.APIClient) ([]galasaapi.Run, error)

func GetRuns

func GetRuns(
	runName string,
	age string,
	requestorParameter string,
	resultParameter string,
	shouldGetActive bool,
	outputFormatString string,
	timeService utils.TimeService,
	console utils.Console,
	apiServerUrl string,
	apiClient *galasaapi.APIClient,
) error

GetRuns - performs all the logic to implement the `galasactl runs get` command, but in a unit-testable manner.

func GetRunsFromRestApi

func GetRunsFromRestApi(
	runName string,
	requestorParameter string,
	resultParameter string,
	fromAgeMins int,
	toAgeMins int,
	shouldGetActive bool,
	timeService utils.TimeService,
	apiClient *galasaapi.APIClient,
) ([]galasaapi.Run, error)

Retrieves test runs from the ecosystem API that match a given runName. Multiple test runs can be returned as the runName is not unique.

func GetStreams

func GetStreams(launcher launcher.Launcher) ([]string, error)

func GetTimeUnitsForErrorMessage

func GetTimeUnitsForErrorMessage() string

func GetTimeUnitsMap

func GetTimeUnitsMap() map[string]*TimeUnit

func InterrimProgressReport

func InterrimProgressReport(
	readyRuns []TestRun,
	submittedRuns map[string]*TestRun,
	finishedRuns map[string]*TestRun,
	lostRuns map[string]*TestRun,
	throttle int)

func InterrimProgressReportAsString

func InterrimProgressReportAsString(
	readyRuns []TestRun,
	submittedRuns map[string]*TestRun,
	finishedRuns map[string]*TestRun,
	lostRuns map[string]*TestRun,
	throttle int) string

func NewTestSelectionFlagValues

func NewTestSelectionFlagValues() *utils.TestSelectionFlagValues

func ReportJSON

func ReportJSON(
	fileSystem files.FileSystem,
	reportJsonFilename string,
	finishedRuns map[string]*TestRun,
	lostRuns map[string]*TestRun) error

func ReportJunit

func ReportJunit(
	fileSystem files.FileSystem,
	reportJunitFilename string,
	groupName string,
	finishedRuns map[string]*TestRun,
	lostRuns map[string]*TestRun) error

func ReportYaml

func ReportYaml(
	fileSystem files.FileSystem,
	reportYamlFilename string,
	finishedRuns map[string]*TestRun,
	lostRuns map[string]*TestRun) error

func ResetRun added in v0.32.0

func ResetRun(
	runName string,
	timeService utils.TimeService,
	console utils.Console,
	apiServerUrl string,
	apiClient *galasaapi.APIClient,
) error

func TransferContent

func TransferContent(sourceFile io.Reader, targetFile io.WriteCloser, targetFilePath string) error

Writes the contents of a given source file into a given target file using a buffer to read and write the contents in chunks.

func ValidateResultParameter

func ValidateResultParameter(resultInputString string, apiClient *galasaapi.APIClient) (string, error)

func ValidateRunName

func ValidateRunName(runName string) error

ValidateRunName - Checks that a run name is valid, as much as we can. Returns an error if it's invalid, nil if it looks valid. This function does not consult with an ecosystem, just checks the format of the runName.

func ValidateStream

func ValidateStream(validStreamNames []string, streamNameToCheck string) error

func WriteArtifactToFileSystem

func WriteArtifactToFileSystem(
	fileSystem files.FileSystem,
	targetFilePath string,
	artifactPath string,
	fileDownloaded io.Reader,
	shouldOverwrite bool,
	console utils.Console) error

Writes an artifact to the host's file system, creating a new directory for the run's artifacts to be written to. Existing files are only overwritten if the --force option is used as part of the "runs download" command.

func WritePortfolio

func WritePortfolio(fileSystem files.FileSystem, filename string, portfolio *Portfolio) error

Types

type JunitFailure

type JunitFailure struct {
	Message string `xml:"message,attr"`
	Type    string `xml:"type,attr"`
}

type JunitTestCase

type JunitTestCase struct {
	ID      string        `xml:"id,attr"`
	Name    string        `xml:"name,attr"`
	Time    int           `xml:"time,attr"`
	Failure *JunitFailure `xml:"failure"`
}

type JunitTestSuite

type JunitTestSuite struct {
	ID       string          `xml:"id,attr"`
	Name     string          `xml:"name,attr"`
	Tests    int             `xml:"tests,attr"`
	Failures int             `xml:"failures,attr"`
	Time     int             `xml:"time,attr"`
	TestCase []JunitTestCase `xml:"testcase"`
}

type JunitTestSuites

type JunitTestSuites struct {
	XMLName   xml.Name         `xml:"testsuites"`
	ID        string           `xml:"id,attr"`
	Name      string           `xml:"name,attr"`
	Tests     int              `xml:"tests,attr"`
	Failures  int              `xml:"failures,attr"`
	Time      int              `xml:"time,attr"`
	Testsuite []JunitTestSuite `xml:"testsuite"`
}

type ObrBasedValidator

type ObrBasedValidator struct {
}

func (*ObrBasedValidator) Validate

type Portfolio

type Portfolio struct {
	APIVersion string            `yaml:"apiVersion"`
	Kind       string            `yaml:"kind"`
	Metadata   PortfolioMetadata `yaml:"metadata"`

	Classes []PortfolioClass `yaml:"classes"`
}

func NewPortfolio

func NewPortfolio() *Portfolio

func ReadPortfolio

func ReadPortfolio(fileSystem files.FileSystem, filename string) (*Portfolio, error)

type PortfolioClass

type PortfolioClass struct {
	Bundle     string            `yaml:"bundle"`
	Class      string            `yaml:"class"`
	Stream     string            `yaml:"stream"`
	Obr        string            `yaml:"obr"`
	Overrides  map[string]string `yaml:"overrides"`
	GherkinUrl string            `yaml:"gherkin"`
}

type PortfolioMetadata

type PortfolioMetadata struct {
	Name string `yaml:"name"`
}

type StreamBasedValidator

type StreamBasedValidator struct {
}

func (*StreamBasedValidator) Validate

type Submitter

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

func NewSubmitter

func NewSubmitter(
	galasaHome utils.GalasaHome,
	fileSystem files.FileSystem,
	launcher launcher.Launcher,
	timeService utils.TimeService,
	env utils.Environment,
	console utils.Console,
	expander images.ImageExpander,
) *Submitter

func (*Submitter) ExecuteSubmitRuns

func (submitter *Submitter) ExecuteSubmitRuns(
	params *utils.RunsSubmitCmdValues,
	TestSelectionFlagValues *utils.TestSelectionFlagValues,

) error

func (*Submitter) GetCurrentUserName

func (submitter *Submitter) GetCurrentUserName() string

type TestClass

type TestClass struct {
	Bundle string
	Class  string

	// The stream will be set for ecosystem runs.
	Stream string

	// The obr will be set for local runs.
	Obr string

	//Gherkin URL for local runs
	GherkinUrl string
}

type TestMethod

type TestMethod struct {
	Method string `yaml:"name" json:"name"`
	Result string `yaml:"result" json:"result"`
}

type TestReport

type TestReport struct {
	Tests []TestRun `yaml:"tests" json:"tests"`
}

type TestRun

type TestRun struct {
	Name           string            `yaml:"name" json:"name"`
	Bundle         string            `yaml:"bundle" json:"bundle"`
	Class          string            `yaml:"class" json:"class"`
	Stream         string            `yaml:"stream" json:"stream"`
	Obr            string            `yaml:"obr" json:"obr"`
	Status         string            `yaml:"status" json:"status"`
	QueuedTimeUTC  string            `yaml:"queued" json:"queued"`
	Requestor      string            `yaml:"requestor" json:"requestor"`
	Result         string            `yaml:"result" json:"result"`
	Overrides      map[string]string `yaml:"overrides" json:"overrides"`
	Tests          []TestMethod      `yaml:"tests" json:"tests"`
	GherkinUrl     string            `yaml:"gherkin"`
	GherkinFeature string            `yaml:"feature"`
}

type TestSelection

type TestSelection struct {
	Classes []TestClass
}

func SelectTests

func SelectTests(launcherInstance launcher.Launcher, flags *utils.TestSelectionFlagValues) (TestSelection, error)

type TestSelectionFlagValidator

type TestSelectionFlagValidator interface {
	Validate(flags *utils.TestSelectionFlagValues) error
}

func NewObrBasedValidator

func NewObrBasedValidator() TestSelectionFlagValidator

func NewStreamBasedValidator

func NewStreamBasedValidator() TestSelectionFlagValidator

type TimeUnit

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

func GetTimeUnitFromShortName

func GetTimeUnitFromShortName(shortName string) (*TimeUnit, bool)

func GetTimeUnitsOrderedList

func GetTimeUnitsOrderedList() []*TimeUnit

func (*TimeUnit) GetLongName

func (unit *TimeUnit) GetLongName() string

func (*TimeUnit) GetMinuteMultiplier

func (unit *TimeUnit) GetMinuteMultiplier() int

func (*TimeUnit) GetShortName

func (unit *TimeUnit) GetShortName() string

Jump to

Keyboard shortcuts

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