util

package
v0.0.0-...-920c39e Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 3 Imported by: 12

Documentation

Index

Constants

View Source
const (
	GCS = "gcs"
)

Allowed source modes for fetching the metrics

Variables

This section is empty.

Functions

This section is empty.

Types

type GCSLogUtils

type GCSLogUtils struct {
	JobLogUtils
	// contains filtered or unexported fields
}

GCSLogUtils defines JobLogUtils interface for the case when source of logs is GCS.

func NewGCSLogUtils

func NewGCSLogUtils() GCSLogUtils

NewGCSLogUtils returns new GCSLogUtils struct with GCS utils initialized.

func (GCSLogUtils) GetBuildNumbersForJob

func (utils GCSLogUtils) GetBuildNumbersForJob(job string) ([]int, error)

GetBuildNumbersForJob return list of build numbers.

func (GCSLogUtils) GetJobRunFileContents

func (utils GCSLogUtils) GetJobRunFileContents(job string, run int, filepath string) ([]byte, error)

GetJobRunFileContents returns the contents of the file given by filepath (relative to run's root dir).

func (GCSLogUtils) GetJobRunFinishedStatus

func (utils GCSLogUtils) GetJobRunFinishedStatus(job string, run int) (bool, error)

GetJobRunFinishedStatus returns the finished status (true/false) for the job run.

func (GCSLogUtils) GetJobRunStartTimestamp

func (utils GCSLogUtils) GetJobRunStartTimestamp(job string, run int) (uint64, error)

GetJobRunStartTimestamp returns start timestamp for the job run.

func (GCSLogUtils) GetLatestBuildNumberForJob

func (utils GCSLogUtils) GetLatestBuildNumberForJob(job string) (int, error)

GetLatestBuildNumberForJob returns latest build number for the job.

func (GCSLogUtils) ListJobRunFilesWithPrefix

func (utils GCSLogUtils) ListJobRunFilesWithPrefix(job string, run int, prefix string) ([]string, error)

ListJobRunFilesWithPrefix returns the list of files with a given path prefix in the job run's root dir.

type JobLogUtils

type JobLogUtils interface {
	GetLatestBuildNumberForJob(string) (int, error)
	GetBuildNumbersForJob(string) ([]int, error)
	GetJobRunStartTimestamp(string, int) (uint64, error)
	GetJobRunFinishedStatus(string, int) (bool, error)
	GetJobRunFileContents(string, int, string) ([]byte, error)
	ListJobRunFilesWithPrefix(string, int, string) ([]string, error)
}

JobLogUtils provides the set of methods used by runselector and scraper for obtaining metrics for a given source mode (GCS/local/...).

func GetJobLogUtilsForMode

func GetJobLogUtilsForMode(mode string) (JobLogUtils, error)

GetJobLogUtilsForMode gives the right utils object based on the source mode.

type MockJobLogUtils

type MockJobLogUtils struct {
	JobLogUtils
	MockBuildNumbers     []int
	MockStartTimestamps  map[int]uint64
	MockFinishedStatuses map[int]bool
	MockFileContents     map[int]map[string][]byte
	MockFilesWithPrefix  map[int]map[string][]string
}

MockJobLogUtils mocks out all moving parts of JobLogUtils, like use of network or reading of files.

func (MockJobLogUtils) GetBuildNumbersForJob

func (utils MockJobLogUtils) GetBuildNumbersForJob(job string) ([]int, error)

GetBuildNumbersForJob return list of build numbers.

func (MockJobLogUtils) GetJobRunFileContents

func (utils MockJobLogUtils) GetJobRunFileContents(job string, run int, filepath string) ([]byte, error)

GetJobRunFileContents returns the contents of the file given by filepath (relative to run's root dir).

func (MockJobLogUtils) GetJobRunFinishedStatus

func (utils MockJobLogUtils) GetJobRunFinishedStatus(job string, run int) (bool, error)

GetJobRunFinishedStatus returns the finished status (true/false) for the job run.

func (MockJobLogUtils) GetJobRunStartTimestamp

func (utils MockJobLogUtils) GetJobRunStartTimestamp(job string, run int) (uint64, error)

GetJobRunStartTimestamp returns start timestamp for the job run.

func (MockJobLogUtils) GetLatestBuildNumberForJob

func (utils MockJobLogUtils) GetLatestBuildNumberForJob(job string) (int, error)

GetLatestBuildNumberForJob returns latest build number for the job.

func (MockJobLogUtils) ListJobRunFilesWithPrefix

func (utils MockJobLogUtils) ListJobRunFilesWithPrefix(job string, run int, prefix string) ([]string, error)

ListJobRunFilesWithPrefix returns the list of files with a given path prefix in the job run's root dir.

Jump to

Keyboard shortcuts

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