core

package
v0.0.3-delta Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Overview

Package core is the backbone of the tunnel client, it defines the tunnel lifecycle and allows attaching hooks for functionality as plugins.

Index

Constants

View Source
const (
	// FileAdded file added in commit
	FileAdded int = iota + 1
	// FileRemoved file removed in commit
	FileRemoved
	// FileModified file modified in commit
	FileModified
)
View Source
const (
	// GitHub as git provider
	GitHub string = "github"
	// GitLab as git provider
	GitLab string = "gitlab"
	// Bitbucket as git provider
	Bitbucket string = "bitbucket"
)

Variables

View Source
var TierOpts = map[Tier]Specs{
	Internal: {CPU: 0.5, RAM: 256},
	XSmall:   {CPU: 1, RAM: 2048},
	Small:    {CPU: 2, RAM: 4096},
	Medium:   {CPU: 4, RAM: 8192},
	Large:    {CPU: 8, RAM: 16384},
	XLarge:   {CPU: 16, RAM: 32768},
}

TierOpts is const map which map each tier to specs

Functions

This section is empty.

Types

type AzureClient

type AzureClient interface {
	FindUsingSASUrl(ctx context.Context, sasURL string) (io.ReadCloser, error)
	Find(ctx context.Context, path string) (io.ReadCloser, error)
	Create(ctx context.Context, path string, reader io.Reader, mimeType string) (string, error)
	CreateUsingSASURL(ctx context.Context, sasURL string, reader io.Reader, mimeType string) (string, error)
	GetSASURL(ctx context.Context, purpose SASURLPurpose, query map[string]interface{}) (string, error)
	Exists(ctx context.Context, path string) (bool, error)
}

AzureClient defines operation for working with azure store

type BlockTestService

type BlockTestService interface {
	GetBlockTests(ctx context.Context, blocklistYAML []string, branch string) error
}

BlockTestService is used for fetching blocklisted tests

type Builder added in v0.6.5

type Builder interface {
	// GetDriver returns driver for use
	GetDriver(version int, ymlFilePath string) (Driver, error)
}

Builder builds the driver for given tas yml version

type Cache

type Cache struct {
	Key   string   `yaml:"key" validate:"required"`
	Paths []string `yaml:"paths" validate:"required"`
}

Cache represents the user's cached directories

type CacheStore

type CacheStore interface {
	// Download downloads cache present at cacheKey
	Download(ctx context.Context, cacheKey string) error
	// Upload creates, compresses and uploads cache at cacheKey
	Upload(ctx context.Context, cacheKey string, itemsToCompress ...string) error
	// CacheWorkspace caches the workspace onto a mounted volume
	CacheWorkspace(ctx context.Context, subModule string) error
	// ExtractWorkspace extracts the workspace cache from mounted volume
	ExtractWorkspace(ctx context.Context, subModule string) error
}

CacheStore defines operation for working with the cache

type CommandType

type CommandType string

CommandType defines type of command

const (
	PreRun          CommandType = "prerun"
	PostRun         CommandType = "postrun"
	InstallRunners  CommandType = "installrunners"
	Execution       CommandType = "execution"
	Discovery       CommandType = "discovery"
	Zstd            CommandType = "zstd"
	CoverageMerge   CommandType = "coveragemerge"
	InstallNodeVer  CommandType = "installnodeversion"
	InitGit         CommandType = "initgit"
	RenameCloneFile CommandType = "renameclonefile"
)

Types of Command string

type CommitChangeList

type CommitChangeList struct {
	Sha      string   `json:"Sha"`
	Link     string   `json:"Link"`
	Added    []string `json:"added"`
	Removed  []string `json:"removed"`
	Modified []string `json:"modified"`
	Message  string   `json:"message"`
}

CommitChangeList defines information related to commits

type ContainerImageConfig

type ContainerImageConfig struct {
	AuthRegistry string
	Image        string
	Mode         config.ModeType
	PullPolicy   config.PullPolicyType
}

ContainerImageConfig contains registry config for docker

type ContainerStatus

type ContainerStatus struct {
	Done  bool
	Error errs.Err
}

ContainerStatus contains status of container

type CoverageManifest

type CoverageManifest struct {
	Removedfiles      []string           `json:"removed_files"`
	AllFilesExecuted  bool               `json:"all_files_executed"`
	CoverageThreshold *CoverageThreshold `json:"coverage_threshold,omitempty"`
}

CoverageManifest for post processing coverage job

type CoverageService

type CoverageService interface {
	MergeAndUpload(ctx context.Context, payload *Payload) error
}

CoverageService services coverage of tests

type CoverageThreshold

type CoverageThreshold struct {
	Branches   float64 `yaml:"branches" json:"branches" validate:"number,min=0,max=100"`
	Lines      float64 `yaml:"lines" json:"lines" validate:"number,min=0,max=100"`
	Functions  float64 `yaml:"functions" json:"functions" validate:"number,min=0,max=100"`
	Statements float64 `yaml:"statements" json:"statements" validate:"number,min=0,max=100"`
	PerFile    bool    `yaml:"perFile" json:"perFile"`
}

CoverageThreshold reprents the code coverage threshold

type DiffManager

type DiffManager interface {
	GetChangedFiles(ctx context.Context, payload *Payload, oauth *Oauth) (map[string]int, error)
}

DiffManager manages the diff findings for the given payload

type DiscoveryResult

type DiscoveryResult struct {
	Tests           []TestPayload      `json:"tests"`
	ImpactedTests   []string           `json:"impactedTests"`
	TestSuites      []TestSuitePayload `json:"testSuites"`
	ExecuteAllTests bool               `json:"executeAllTests"`
	Parallelism     int                `json:"parallelism"`
	SplitMode       SplitMode          `json:"splitMode"`
	RepoID          string             `json:"repoID"`
	BuildID         string             `json:"buildID"`
	CommitID        string             `json:"commitID"`
	TaskID          string             `json:"taskID"`
	OrgID           string             `json:"orgID"`
	Branch          string             `json:"branch"`
	Tier            Tier               `json:"tier"`
	SubModule       string             `json:"subModule"`
	ContainerImage  string             `json:"containerImage"`
}

type DiscoveyArgs added in v0.6.5

type DiscoveyArgs struct {
	TestPattern      []string
	Payload          *Payload
	EnvMap           map[string]string
	SecretData       map[string]string
	TestConfigFile   string
	FrameWork        string
	SmartRun         bool
	Diff             map[string]int
	DiffExists       bool
	FrameWorkVersion int
	CWD              string
}

DiscoveyArgs specify the arguments for discovery

type DockerRunner

type DockerRunner interface {
	// Creates the execution enging
	Create(context.Context, *RunnerOptions) ContainerStatus

	// Run runs the execution engine
	Run(context.Context, *RunnerOptions) ContainerStatus

	// WaitForRunning waits for runner to get completed
	WaitForCompletion(ctx context.Context, r *RunnerOptions) error

	// Destroy the execution engine
	Destroy(ctx context.Context, r *RunnerOptions) error

	// GetInfo will get resources details of the infra
	GetInfo(context.Context) (float32, int64)

	// Initiate runs docker containers
	Initiate(context.Context, *RunnerOptions, chan ContainerStatus)

	// PullImage will pull image from remote
	PullImage(containerImageConfig *ContainerImageConfig, r *RunnerOptions) error

	// KillRunningDocker kills  container spawn by synapse
	KillRunningDocker(ctx context.Context)

	CreateVolume(ctx context.Context, r *RunnerOptions) error

	// RemoveOldVolumes removes volumes that are older than X hours
	RemoveOldVolumes(ctx context.Context)

	// CopyFileToContainer copies content to container in file
	CopyFileToContainer(ctx context.Context, path, fileName, containerID string, content []byte) error

	// FindVolumes checks if docker volume is available
	FindVolumes(volumeName string) (bool, error)

	// RemoveVolume removes volume
	RemoveVolume(ctx context.Context, volumeName string) error
}

DockerRunner defines operations for docker

type Driver added in v0.6.5

type Driver interface {
	// RunDiscovery runs the test discovery
	RunDiscovery(ctx context.Context, payload *Payload,
		taskPayload *TaskPayload, oauth *Oauth, coverageDir string, secretMap map[string]string) error
	// RunExecution runs the test execution
	RunExecution(ctx context.Context, payload *Payload,
		taskPayload *TaskPayload, oauth *Oauth, coverageDir string, secretMap map[string]string) error
}

Driver has the responsibility to run discovery and test execution

type EventType

type EventType string

EventType represents the webhook event

const (
	// EventPush represents the push event.
	EventPush EventType = "push"
	// EventPullRequest represents the pull request event.
	EventPullRequest EventType = "pull-request"
)

type ExecutionID

type ExecutionID string

ExecutionID type

type ExecutionManager

type ExecutionManager interface {
	// ExecuteUserCommands executes the preRun or postRun commands given by user in his yaml.
	ExecuteUserCommands(ctx context.Context,
		commandType CommandType,
		payload *Payload,
		runConfig *Run,
		secretData map[string]string,
		logwriter LogWriterStrategy,
		cwd string) error

	// ExecuteInternalCommands executes the commands like installing runners and test discovery.
	ExecuteInternalCommands(ctx context.Context,
		commandType CommandType,
		commands []string,
		cwd string, envMap,
		secretData map[string]string) error
	// GetEnvVariables get the environment variables from the env map given by user.
	GetEnvVariables(envMap, secretData map[string]string) ([]string, error)
}

ExecutionManager has responsibility for executing the preRun, postRun and internal commands

type ExecutionResult

type ExecutionResult struct {
	TestPayload      []TestPayload      `json:"testResults"`
	TestSuitePayload []TestSuitePayload `json:"testSuiteResults"`
}

ExecutionResult represents the request body for test and test suite execution

type ExecutionResults

type ExecutionResults struct {
	TaskID   string            `json:"taskID"`
	BuildID  string            `json:"buildID"`
	RepoID   string            `json:"repoID"`
	OrgID    string            `json:"orgID"`
	CommitID string            `json:"commitID"`
	TaskType TaskType          `json:"taskType"`
	Results  []ExecutionResult `json:"results"`
}

ExecutionResults represents collection of execution results

type GitManager

type GitManager interface {
	// Clone repository from TAS config
	Clone(ctx context.Context, payload *Payload, oauth *Oauth) error
	// DownloadFileByCommit download file from repo for given commit
	DownloadFileByCommit(ctx context.Context, gitProvider, repoSlug, commitID, filePath string, oauth *Oauth) (string, error)
}

GitManager manages the cloning of git repositories

type JobInfo

type JobInfo struct {
	Status  StatusType `json:"status"`
	JobID   string     `json:"job_id"`
	ID      string     `json:"id"`
	Mode    string     `json:"mode"`
	BuildID string     `json:"build_id"`
	Message string     `json:"message"`
}

JobInfo stuct for job updates info

type ListSubModuleService added in v0.6.5

type ListSubModuleService interface {
	// Send sends count of submodules to TAS server
	Send(ctx context.Context, buildID string, totalSubmodule int) error
}

ListSubModuleService will sends the submodule count to TAS server

type LogWriterStrategy added in v0.6.5

type LogWriterStrategy interface {
	// Write reads data from io.Reader and write it to various data stream
	Write(ctx context.Context, reader io.Reader) <-chan error
}

LogWriterStrategy interface is used to tag all log writing strategy

type LoginDetails

type LoginDetails struct {
	Name           string  `json:"name"`
	SynapseID      string  `json:"synapse_id"`
	SecretKey      string  `json:"secret_key"`
	CPU            float32 `json:"cpu"`
	RAM            int64   `json:"ram"`
	SynapseVersion string  `json:"synapse_version"`
}

LoginDetails struct

type Merge

type Merge struct {
	Patterns []string          `yaml:"pattern" validate:"required,gt=0"`
	EnvMap   map[string]string `yaml:"env" validate:"omitempty,gt=0"`
}

Merge represents pre and post merge

type MergeV2 added in v0.5.0

type MergeV2 struct {
	PreRun     *Run              `yaml:"preRun" validate:"omitempty"`
	SubModules []SubModule       `yaml:"subModules" validate:"required,gt=0"`
	EnvMap     map[string]string `yaml:"env" validate:"omitempty,gt=0"`
}

MergeV2 repersent MergeConfig for version 2 and above

type Message

type Message struct {
	Type    MessageType `json:"type"`
	Content []byte      `json:"content"`
	Success bool        `json:"success"`
}

Message struct

type MessageType

type MessageType string

MessageType defines type of message

const (
	MsgLogin             MessageType = "login"
	MsgLogout            MessageType = "logout"
	MsgTask              MessageType = "task"
	MsgInfo              MessageType = "info"
	MsgError             MessageType = "error"
	MsgResourceStats     MessageType = "resourcestats"
	MsgJobInfo           MessageType = "jobinfo"
	MsgYMLParsingRequest MessageType = "yml_parsing_request"
	MsgYMLParsingResult  MessageType = "yml_parsing_result"
)

types of messages

type Modifier

type Modifier struct {
	Type   string
	Config string
	Cli    string
}

Modifier defines struct for modifier

type NotifMessage

type NotifMessage struct {
	Type   string
	Value  string
	Status string
	Error  string
}

NotifMessage defines struct for notification message

type Oauth

type Oauth struct {
	AccessToken  string    `json:"access_token"`
	Expiry       time.Time `json:"expiry"`
	RefreshToken string    `json:"refresh_token"`
	Type         TokenType `json:"token_type,omitempty"`
}

Oauth represents the sructure of Oauth

type Payload

type Payload struct {
	RepoSlug                   string             `json:"repo_slug"`
	ForkSlug                   string             `json:"fork_slug"`
	RepoLink                   string             `json:"repo_link"`
	BuildTargetCommit          string             `json:"build_target_commit"`
	BuildBaseCommit            string             `json:"build_base_commit"`
	TaskID                     string             `json:"task_id"`
	BranchName                 string             `json:"branch_name"`
	BuildID                    string             `json:"build_id"`
	RepoID                     string             `json:"repo_id"`
	OrgID                      string             `json:"org_id"`
	GitProvider                string             `json:"git_provider"`
	PrivateRepo                bool               `json:"private_repo"`
	EventType                  EventType          `json:"event_type"`
	Diff                       string             `json:"diff_url"`
	PullRequestNumber          int                `json:"pull_request_number"`
	Commits                    []CommitChangeList `json:"commits"`
	TasFileName                string             `json:"tas_file_name"`
	Locators                   string             `json:"locators"`
	LocatorAddress             string             `json:"locator_address"`
	ParentCommitCoverageExists bool               `json:"parent_commit_coverage_exists"`
	LicenseTier                Tier               `json:"license_tier"`
	CollectCoverage            bool               `json:"collect_coverage"`
	TaskType                   TaskType           `json:"-"`
}

Payload defines structure of payload

type PayloadManager

type PayloadManager interface {
	// ValidatePayload validates the nucleus payload
	ValidatePayload(ctx context.Context, payload *Payload) error
	// FetchPayload used for fetching the payload used for running nucleus
	FetchPayload(ctx context.Context, payloadAddress string) (*Payload, error)
}

PayloadManager defines operations for payload

type Pipeline

type Pipeline struct {
	Cfg                  *config.NucleusConfig
	Payload              *Payload
	Logger               lumber.Logger
	PayloadManager       PayloadManager
	TASConfigManager     TASConfigManager
	GitManager           GitManager
	ExecutionManager     ExecutionManager
	DiffManager          DiffManager
	CacheStore           CacheStore
	TestDiscoveryService TestDiscoveryService
	BlockTestService     BlockTestService
	TestExecutionService TestExecutionService
	CoverageService      CoverageService
	TestStats            TestStats
	Task                 Task
	SecretParser         SecretParser
	Builder              Builder
}

Pipeline defines all attributes of Pipeline

func NewPipeline

func NewPipeline(cfg *config.NucleusConfig, logger lumber.Logger) (*Pipeline, error)

NewPipeline creates and returns a new Pipeline instance

func (*Pipeline) Start

func (pl *Pipeline) Start(ctx context.Context) (err error)

Start starts pipeline lifecycle

type PodType

type PodType string

PodType specifies the type of pod

const (
	NucleusPod  PodType = "nucleus"
	CoveragePod PodType = "coverage"
)

Values that PodType can take

type PostMergeStrategyName

type PostMergeStrategyName string

PostMergeStrategyName type

const (
	AfterNCommitStrategy PostMergeStrategyName = "after_n_commits"
)

All const of type PostMergeStrategyName

type Requests

type Requests interface {
	// MakeAPIRequest makes an HTTP request with auth
	MakeAPIRequest(ctx context.Context, httpMethod, endpoint string, body []byte, params map[string]interface{},
		headers map[string]string) (rawbody []byte, statusCode int, err error)
}

Requests is a util interface for making API Requests

type ResourceStats

type ResourceStats struct {
	Status StatType `json:"status"`
	CPU    float32  `json:"cpu"`
	RAM    int64    `json:"ram"`
}

ResourceStats struct for CPU, RAM details

type Run

type Run struct {
	Commands []string          `yaml:"command" validate:"omitempty,gt=0"`
	EnvMap   map[string]string `yaml:"env" validate:"omitempty,gt=0"`
}

Run represents pre and post runs

type RunnerOptions

type RunnerOptions struct {
	ContainerID       string            `json:"container_id"`
	DockerImage       string            `json:"docker_image"`
	ContainerPort     int               `json:"container_port"`
	HostPort          int               `json:"host_port"`
	Label             map[string]string `json:"label"`
	NameSpace         string            `json:"name_space"`
	ServiceAccount    string            `json:"service_account"`
	PodName           string            `json:"pod_name"`
	ContainerName     string            `json:"container_name"`
	ContainerArgs     []string          `json:"container_args"`
	ContainerCommands []string          `json:"container_commands"`
	HostVolumePath    string            `json:"host_volume_path"`
	Env               []string          `json:"env"`
	OrgID             string            `json:"org_id"`
	Vault             *VaultOpts        `json:"vault"`
	LogfilePath       string            `json:"logfile_path"`
	PodType           PodType           `json:"pod_type"`
	Tier              Tier              `json:"tier"`
}

RunnerOptions provides the the required instructions for execution engine.

type SASURLPurpose added in v0.6.20

type SASURLPurpose string

SASURLPurpose defines reasons for which SAS Url is required

const (
	PurposeCache          SASURLPurpose = "cache"
	PurposeWorkspaceCache SASURLPurpose = "workspace_cache"
	PurposePreRunLogs     SASURLPurpose = "pre_run_logs"
	PurposePostRunLogs    SASURLPurpose = "post_run_logs"
	PurposeExecutionLogs  SASURLPurpose = "execution_logs"
)

SASURLPurpose values

type Secret

type Secret map[string]string

Secret struct for holding secret data

type SecretParser

type SecretParser interface {
	// GetOauthSecret parses the oauth secret for given path
	GetOauthSecret(filepath string) (*Oauth, error)
	// GetRepoSecret parses the repo secret for given path
	GetRepoSecret(string) (map[string]string, error)
	// SubstituteSecret replace secret placeholders with their respective values
	SubstituteSecret(command string, secretData map[string]string) (string, error)
	// Expired reports whether the token is expired.
	Expired(token *Oauth) bool
}

SecretParser defines operation for parsing the vault secrets in given path

type SecretsManager

type SecretsManager interface {
	// GetLambdatestSecrets returns lambdatest config
	GetLambdatestSecrets() *config.LambdatestConfig

	// GetDockerSecrets returns Mode , RegistryAuth, and URL for pulling remote docker image
	GetDockerSecrets(r *RunnerOptions) (ContainerImageConfig, error)

	// GetSynapseName returns synapse name mentioned in config
	GetSynapseName() string
	// GetOauthToken returns oauth token
	GetOauthToken() *Oauth

	// GetGitSecretBytes get git secrets in bytes
	GetGitSecretBytes() ([]byte, error)

	// GetRepoSecretBytes get repo secrets in bytes
	GetRepoSecretBytes(repo string) ([]byte, error)
}

SecretsManager defines operation for secrets

type Specs

type Specs struct {
	CPU float32
	RAM int64
}

Specs denotes system specification

type SplitMode added in v0.2.0

type SplitMode string

SplitMode is the mode for splitting tests

const (
	FileSplit SplitMode = "file"
	TestSplit SplitMode = "test"
)

list of support test splitting modes

type Stability

type Stability struct {
	ConsecutiveRuns int `yaml:"consecutive_runs"`
}

Stability defines struct for stability

type StatType

type StatType string

StatType defines type of resource status

const (
	ResourceRelease StatType = "release"
	ResourceCapture StatType = "capture"
)

ResourceStats types

type Status

type Status string

Status represents the task status

const (
	Initiating Status = "initiating"
	Running    Status = "running"
	Failed     Status = "failed"
	Aborted    Status = "aborted"
	Passed     Status = "passed"
	Error      Status = "error"
)

Const related to task status

type StatusType

type StatusType string

StatusType defines type job status

const (
	JobCompleted StatusType = "complete"
	JobStarted   StatusType = "started"
	JobFailed    StatusType = "failed"
)

JobInfo types

type SubModule added in v0.5.0

type SubModule struct {
	Name               string   `yaml:"name" validate:"required"`
	Path               string   `yaml:"path" validate:"required"`
	Patterns           []string `yaml:"pattern" validate:"required,gt=0"`
	Framework          string   `yaml:"framework" validate:"required,oneof=jest mocha jasmine"`
	Blocklist          []string `yaml:"blocklist"`
	Prerun             *Run     `yaml:"preRun" validate:"omitempty"`
	Postrun            *Run     `yaml:"postRun" validate:"omitempty"`
	RunPrerunEveryTime bool     `yaml:"runPreRunEveryTime"`
	Parallelism        int      `yaml:"parallelism"` // TODO: will be supported later
	ConfigFile         string   `yaml:"configFile" validate:"omitempty"`
}

SubModule represent the structure of subModule yaml v2

type SubModuleList added in v0.5.0

type SubModuleList struct {
	BuildID        string `json:"buildID"`
	TotalSubModule int    `json:"totalSubModule"`
}

SubModuleList repersent submodule list API payload

type SynapseManager

type SynapseManager interface {
	// InitiateConnection initiates the connection with LT cloud
	InitiateConnection(ctx context.Context, wg *sync.WaitGroup, connectionFailed chan struct{})
}

SynapseManager denfines operations for synapse client

type TASConfig

type TASConfig struct {
	SmartRun          bool               `yaml:"smartRun"`
	Framework         string             `yaml:"framework" validate:"required,oneof=jest mocha jasmine golang junit"`
	Blocklist         []string           `yaml:"blocklist"`
	Postmerge         *Merge             `yaml:"postMerge" validate:"omitempty"`
	Premerge          *Merge             `yaml:"preMerge" validate:"omitempty"`
	Cache             *Cache             `yaml:"cache" validate:"omitempty"`
	Prerun            *Run               `yaml:"preRun" validate:"omitempty"`
	Postrun           *Run               `yaml:"postRun" validate:"omitempty"`
	Parallelism       int                `yaml:"parallelism"`
	SplitMode         SplitMode          `yaml:"splitMode" validate:"oneof=test file"`
	SkipCache         bool               `yaml:"skipCache"`
	ConfigFile        string             `yaml:"configFile" validate:"omitempty"`
	CoverageThreshold *CoverageThreshold `yaml:"coverageThreshold" validate:"omitempty"`
	Tier              Tier               `yaml:"tier" validate:"oneof=xsmall small medium large xlarge"`
	NodeVersion       string             `yaml:"nodeVersion" validate:"omitempty,semver"`
	ContainerImage    string             `yaml:"containerImage"`
	FrameworkVersion  int                `yaml:"frameworkVersion" validate:"omitempty"`
	Version           string             `yaml:"version" validate:"required"`
}

TASConfig represents the .tas.yml file

type TASConfigDownloaderOutput added in v0.10.2

type TASConfigDownloaderOutput struct {
	Version   int         `json:"version"`
	TasConfig interface{} `json:"tasConfig"`
}

type TASConfigManager

type TASConfigManager interface {
	// LoadAndValidate loads and returns the tas config
	LoadAndValidate(ctx context.Context, version int, path string, eventType EventType, licenseTier Tier) (interface{}, error)

	// GetVersion returns TAS yml version
	GetVersion(path string) (int, error)

	// GetTasConfigFilePath returns file path of tas config
	GetTasConfigFilePath(payload *Payload) (string, error)
}

TASConfigManager defines operations for tas config

type TASConfigV2 added in v0.5.0

type TASConfigV2 struct {
	SmartRun          bool               `yaml:"smartRun"`
	Cache             *Cache             `yaml:"cache" validate:"omitempty"`
	Tier              Tier               `yaml:"tier" validate:"oneof=xsmall small medium large xlarge"`
	PostMerge         *MergeV2           `yaml:"postMerge" validate:"omitempty"`
	PreMerge          *MergeV2           `yaml:"preMerge" validate:"omitempty"`
	SkipCache         bool               `yaml:"skipCache"`
	CoverageThreshold *CoverageThreshold `yaml:"coverageThreshold" validate:"omitempty"`
	Parallelism       int                `yaml:"parallelism"` // TODO: will be supported later
	Version           string             `yaml:"version" validate:"required"`
	SplitMode         SplitMode          `yaml:"splitMode" validate:"oneof=test file"`
	ContainerImage    string             `yaml:"containerImage"`
	NodeVersion       string             `yaml:"nodeVersion" validate:"omitempty,semver"`
}

TASConfigV2 repersent TASConfig for version 2 and above

type TasVersion added in v0.5.0

type TasVersion struct {
	Version string `yaml:"version" validate:"required"`
}

TasVersion used to identify yaml version

type Task

type Task interface {
	// UpdateStatus updates status of the task
	UpdateStatus(ctx context.Context, payload *TaskPayload) error
}

Task is a service to update task status at neuron

type TaskPayload

type TaskPayload struct {
	TaskID      string    `json:"task_id"`
	Status      Status    `json:"status"`
	RepoSlug    string    `json:"repo_slug"`
	RepoLink    string    `json:"repo_link"`
	RepoID      string    `json:"repo_id"`
	OrgID       string    `json:"org_id"`
	GitProvider string    `json:"git_provider"`
	CommitID    string    `json:"commit_id,omitempty"`
	BuildID     string    `json:"build_id"`
	StartTime   time.Time `json:"start_time"`
	EndTime     time.Time `json:"end_time,omitempty"`
	Remark      string    `json:"remark,omitempty"`
	Type        TaskType  `json:"type"`
}

TaskPayload repersent task response given by nucleus to neuron

type TaskType

type TaskType string

TaskType specifies the type of a Task

const (
	DiscoveryTask TaskType = "discover"
	ExecutionTask TaskType = "execute"
	FlakyTask     TaskType = "flaky"
)

Task Type values.

type TestDiscoveryService

type TestDiscoveryService interface {
	// Discover executes the test discovery scripts.
	Discover(ctx context.Context, args *DiscoveyArgs) (*DiscoveryResult, error)

	// SendResult sends discovery result to TAS server
	SendResult(ctx context.Context, testDiscoveryResult *DiscoveryResult) error
}

TestDiscoveryService services discovery of tests

type TestExecutionArgs added in v0.6.5

type TestExecutionArgs struct {
	Payload           *Payload
	CoverageDir       string
	LogWriterStrategy LogWriterStrategy
	TestPattern       []string
	EnvMap            map[string]string
	TestConfigFile    string
	FrameWork         string
	SecretData        map[string]string
	FrameWorkVersion  int
	CWD               string
}

TestExecutionArgs specify the argument for test discovery

type TestExecutionService

type TestExecutionService interface {
	// Run executes the test execution scripts
	Run(ctx context.Context, testExecutionArgs *TestExecutionArgs) (results *ExecutionResults, err error)
	// SendResults sends the test execution results to the TAS server.
	SendResults(ctx context.Context, payload *ExecutionResults) (resp *TestReportResponsePayload, err error)
}

TestExecutionService services execution of tests

type TestPayload

type TestPayload struct {
	TestID          string             `json:"testID"`
	Detail          string             `json:"_detail"`
	SuiteID         string             `json:"suiteID"`
	Suites          []string           `json:"_suites"`
	Title           string             `json:"title"`
	FullTitle       string             `json:"fullTitle"`
	Name            string             `json:"name"`
	Duration        int                `json:"duration"`
	FilePath        string             `json:"file"`
	Line            string             `json:"line"`
	Col             string             `json:"col"`
	CurrentRetry    int                `json:"currentRetry"`
	Status          string             `json:"status"`
	DAG             []string           `json:"dependsOn"`
	Filelocator     string             `json:"locator"`
	BlocklistSource string             `json:"blocklistSource"`
	Blocklisted     bool               `json:"blocklist"`
	StartTime       time.Time          `json:"start_time"`
	EndTime         time.Time          `json:"end_time"`
	Stats           []TestProcessStats `json:"stats"`
	FailureMessage  string             `json:"failureMessage"`
}

TestPayload represents the request body for test execution

type TestProcessStats

type TestProcessStats struct {
	Memory     uint64    `json:"memory_consumed,omitempty"`
	CPU        float64   `json:"cpu_percentage,omitempty"`
	Storage    uint64    `json:"storage,omitempty"`
	RecordTime time.Time `json:"record_time"`
}

TestProcessStats process stats associated with each test

type TestReportResponsePayload added in v0.3.1

type TestReportResponsePayload struct {
	TaskID     string `json:"taskID"`
	TaskStatus Status `json:"taskStatus"`
	Remark     string `json:"remark,omitempty"`
}

TestReportResponsePayload represents the response body for test and test suite report api.

type TestStats

type TestStats interface {
	CaptureTestStats(pid int32, collectStats bool) error
}

TestStats is used for servicing stat collection

type TestStatus

type TestStatus string

TestStatus stores tests status

const (
	Blocklisted TestStatus = "blocklisted"
	Quarantined TestStatus = "quarantined"
)

type TestSuitePayload

type TestSuitePayload struct {
	SuiteID         string             `json:"suiteID"`
	SuiteName       string             `json:"suiteName"`
	ParentSuiteID   string             `json:"parentSuiteID"`
	BlocklistSource string             `json:"blocklistSource"`
	Blocklisted     bool               `json:"blocklist"`
	StartTime       time.Time          `json:"start_time"`
	EndTime         time.Time          `json:"end_time"`
	Duration        int                `json:"duration"`
	Status          string             `json:"status"`
	Stats           []TestProcessStats `json:"stats"`
	TotalTests      int                `json:"totalTests"`
}

TestSuitePayload represents the request body for test suite execution

type Tier

type Tier string

Tier type of synapse

const (
	Internal Tier = "internal"
	XSmall   Tier = "xsmall"
	Small    Tier = "small"
	Medium   Tier = "medium"
	Large    Tier = "large"
	XLarge   Tier = "xlarge"
)

TaskTier values.

type TokenType

type TokenType string
const (
	// Bearer as token type
	Bearer TokenType = "Bearer"
	// Basic as token type
	Basic TokenType = "Basic"
)

type VaultOpts

type VaultOpts struct {
	// SecretPath path of the repo secrets.
	SecretPath string
	// TokenPath path of the user token.
	TokenPath string
	// RoleName vault role name
	RoleName string
	// Namespace is the default vault namespace
	Namespace string
}

VaultOpts provides the vault path options

type VaultSecret

type VaultSecret struct {
	Secrets Secret `json:"data"`
}

VaultSecret holds secrets in vault format

type VolumeDetails added in v0.7.0

type VolumeDetails struct {
	CreatedAt  time.Time              `json:"CreatedAt,omitempty"`
	Driver     string                 `json:"Driver"`
	Labels     map[string]string      `json:"Labels"`
	Mountpoint string                 `json:"Mountpoint"`
	Name       string                 `json:"Name"`
	Options    map[string]string      `json:"Options"`
	Scope      string                 `json:"Scope"`
	Status     map[string]interface{} `json:"Status,omitempty"`
}

VolumeDetails docker volume options

type YMLParsingRequestMessage added in v0.10.2

type YMLParsingRequestMessage struct {
	GitProvider string    `json:"gitProvider"`
	CommitID    string    `json:"commitID"`
	Event       EventType `json:"eventType"`
	RepoSlug    string    `json:"repoSlug"`
	TasFileName string    `json:"tasFilePath"`
	LicenseTier Tier      `json:"license_tier"`
	OrgID       string    `json:"orgID"`
	BuildID     string    `json:"buildID"`
}

type YMLParsingResultMessage added in v0.10.2

type YMLParsingResultMessage struct {
	ErrorMsg  string                    `json:"ErrorMsg"`
	OrgID     string                    `json:"orgID"`
	BuildID   string                    `json:"buildID"`
	YMLOutput TASConfigDownloaderOutput `json:"ymlOutput"`
}

type ZstdCompressor

type ZstdCompressor interface {
	Compress(ctx context.Context, compressedFileName string, preservePath bool, workingDirectory string, filesToCompress ...string) error
	Decompress(ctx context.Context, filePath string, preservePath bool, workingDirectory string) error
}

ZstdCompressor performs zstd compression and decompression

Jump to

Keyboard shortcuts

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