resultstore

package
v0.0.2-0...-4bfcaaf Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

README

TestGrid ResultStore

The ResultStore client creates a CRUD interface for users to interact with the Google ResultStore.

ResultStore invocation searching

The ResultStore client allows users to directly search invocations stored in a GCP project given a query. The query format is documented in the SearchInvocationsRequest type. Search will return a list of resultstore.Invocation that satisfies the query condition.

Sample search code snippet

conn, err := resultstore.Connect(ctx, serviceAccountPath)
if err != nil {
  // error handling
}
client := resultstore.NewClient(conn).WithContext(ctx)
invocationClient := client.Invocations()

projectID := "GCP Project ID"
queryTime := time.Unix(1567800000, 0).Format(time.RFC3339)
query := fmt.Sprintf("timing.start_time>%q", queryTime)
invocationsFieldMask := []string{
  "invocations.name",
  "invocations.timing",
  "next_page_token",
}
result, err := invocationClient.Search(ctx, projectID, query, invocationsFieldMask...)

Documentation

Index

Constants

View Source
const (
	// BuildLog appears in the invocation log
	BuildLog = "build.log"

	// Stdout of a build action, which isn't useful right now.
	Stdout = "stdout"
	// Stderr of a build action, which also isn't useful.
	Stderr = "stderr"

	// TestLog appears in the Target Log tab.
	TestLog = "test.log"
	// TestXml causes ResultStore to process this junit.xml to add cases automatically (we aren't using).
	TestXml = "test.xml"

	// TestCov provides line coverage, currently we're not using this.
	TestCov = "test.lcov"
	// BaselineCov provides original line coverage, currently we're not using this.
	BaselineCov = "baseline.lcov"
)

The following logs cause ResultStore to do additional processing

View Source
const (
	// InvocationLog is a more obvious name for the invocation log
	InvocationLog = BuildLog
	// TargetLog is a more obvious name for the target log.
	TargetLog = TestLog
)

ResultStore will display the following logs inline.

View Source
const (
	// Completed cases finished, producing failures if it failed.
	Completed = resultstore.TestCase_COMPLETED
	// Cancelled cases did not complete (should have an error).
	Cancelled = resultstore.TestCase_CANCELLED
	// Skipped cases did not run.
	Skipped = resultstore.TestCase_SKIPPED
)

Common constants.

View Source
const (
	// Running means incomplete.
	Running = resultstore.Status_TESTING
	// Passed means successful.
	Passed = resultstore.Status_PASSED
	// Failed means unsuccessful.
	Failed = resultstore.Status_FAILED
)

Common statuses

View Source
const (
	// Default is the expected single-configuration id.
	Default = "default"
)

Variables

View Source
var TestFields = [...]string{
	"actions.name",
	"actions.test_action",
	"actions.description",
	"actions.timing",
}

TestFields represent all fields this client cares about.

Functions

func Connect

func Connect(ctx context.Context, serviceAccountPath string) (*grpc.ClientConn, error)

Connect returns a secure gRPC connection.

Authenticates as the service account if specified otherwise the default user.

func Files

func Files(fs []File) []*resultstore.File

Files converts a list of files.

func URL

func URL(resourceName string) string

func UUID

func UUID() string

UUID represents a universally "unique" identifier.

Types

type Action

type Action struct {
	// StatusAttributes
	// Description of the status.
	Description string
	// Status indicates whether the action completed successfully.
	Status Status

	// Timing
	// Start of the action.
	Start time.Time
	// Duration of the action.
	Duration time.Duration

	// Node or machine on which the test ran.
	Node string
	// ExitCode of the command
	ExitCode int
}

Action rerepresents a step in the target, such as a container or command.

type Actions

type Actions struct {
	Client
	// contains filtered or unexported fields
}

Actions client.

func (Actions) Create

func (a Actions) Create(id string, test Test) (string, error)

Create a test action under the specified ID, returning the fully-qualified path.

Technically there are also build actions, but these do not show up in the ResultStore UI.

func (Actions) List

func (a Actions) List(fields ...string) ([]Test, error)

List tests in this configured target.

type Case

type Case struct {
	// Name identifies the test within its class.
	Name string

	// Class is the container holding one or more names.
	Class string
	// Result indicates whether it ran and to completion.
	Result Result

	// Duration of the case.
	Duration time.Duration
	// Errors preventing the case from completing.
	Errors []Error
	// Failures encountered upon completion.
	Failures []Failure
	// Files specific to this case
	Files []File
	// Properties of the case
	Properties []Property
	// Start time of the case.
	Start time.Time
}

Case represents the completion of a test case/method.

func (Case) To

func (c Case) To() *resultstore.TestCase

To converts the case to the corresponding ResultStore TestCase proto.

type Client

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

Client provides ResultStore CRUD methods.

func NewClient

func NewClient(conn *grpc.ClientConn) *Client

NewClient uses the specified gRPC connection to connect to ResultStore.

func (Client) Actions

func (c Client) Actions(configuredTargetName string) Actions

Actions provides CRUD methods for a configured target.

func (Client) Configurations

func (c Client) Configurations(invocationName string) Configurations

Configurations provides CRUD methods for an invocation's configurations.

func (Client) ConfiguredTargets

func (c Client) ConfiguredTargets(targetName, configID string) ConfiguredTargets

ConfiguredTargets provides CRUD methods for a target's configured targets.

func (Client) Invocations

func (c Client) Invocations() Invocations

Invocations provides Invocation CRUD methods.

func (Client) Targets

func (c Client) Targets(invocationName string) Targets

Targets provides CRUD methods for an invocations's targets.

func (*Client) WithContext

func (c *Client) WithContext(ctx context.Context) *Client

WithContext uses the specified context for all RPCs.

func (*Client) WithSecret

func (c *Client) WithSecret(authorizationToken Secret) *Client

WithSecret applies the specified secret to all requests.

type Configurations

type Configurations struct {
	Client
	// contains filtered or unexported fields
}

Configurations client.

func (Configurations) Create

func (c Configurations) Create(id string) (string, error)

Create a new configuration using the specified basename, returning the fully qualified path.

type ConfiguredTargets

type ConfiguredTargets struct {
	Client
	// contains filtered or unexported fields
}

ConfiguredTargets client.

func (ConfiguredTargets) Create

func (ct ConfiguredTargets) Create(act Action) (string, error)

Create a new configured target, returning the fully qualified path.

type Error

type Error struct {
	// Message of the error
	Message string
	// Type of error, currently useless.
	Type string
	// Stack trace, separated by new lines.
	Stack string
}

Error describes what prevented completion.

func (Error) To

func (e Error) To() *resultstore.TestError

Error returns the corresponding ResultStore TestError message

type Failure

type Failure struct {
	// Message is the failure message.
	Message string
	// Type is the type/type/class of error, currently appears useless.
	Type string
	// Stack represents the call stack, separated by new lines.
	Stack string
	// Expected represents what we expected, often just one value.
	Expected []string
	// Actual represents what we actually got.
	Actual []string
}

Failure describes the encountered problem.

func (Failure) To

To converts the failure into a ResultStore TestFailure proto

type File

type File struct {
	// Unique name within the set
	ID string

	// ContentType tells the browser how to render
	ContentType string
	// Length if complete and known
	Length int64
	// URL to file in Google Cloud Storage, such as gs://bucket/path/foo
	URL string
}

File represents a file stored in GCS

func (File) To

func (f File) To() *resultstore.File

To converts the file to the corresponding ResultStore File proto.

type Invocation

type Invocation struct {
	// Name of the invocation, immutable after creation.
	Name string
	// Project in GCP that owns this invocation.
	Project string

	// Details describing the invocation.
	Details string
	// Duration of the invocation
	Duration time.Duration
	// Start time of the invocation
	Start time.Time

	// Files for this invocation (InvocationLog in particular)
	Files []File
	// Properties of the invocation, currently appears to be useless.
	Properties []Property

	// Status indicating whether the invocation completed successfully.
	Status Status
	// Description of the status.
	Description string
}

Invocation represents a flatted ResultStore invocation

func (Invocation) To

To converts the invocation into a ResultStore Invoation proto.

type Invocations

type Invocations struct {
	Client
}

Invocations client.

func (Invocations) Create

func (i Invocations) Create(inv Invocation) (string, error)

Create a new invocation (project must be specified).

func (Invocations) Finish

func (i Invocations) Finish(name string) error

Finish an invocation, preventing further updates. TODO(fejta): consider renaming this to Finalize()

func (Invocations) Get

func (i Invocations) Get(name string, fields ...string) (*Invocation, error)

Get an existing invocation at name.

func (Invocations) Search

func (i Invocations) Search(ctx context.Context, projectID string, query string, fields ...string) ([]*Invocation, error)

Search finds all the invocations that satisfies the query condition within a project.

func (Invocations) Update

func (i Invocations) Update(inv Invocation, fields ...string) error

Update a pre-existing invocation at name.

type Property

type Property = resultstore.Property

Property represents a key-value pairing.

func Properties

func Properties(pairs ...string) []Property

Properties converts key, value pairs into a property list.

type Result

Result specifies whether the test passed.

type Secret

type Secret string

Secret represents a secret authorization uuid to protect invocations.

func NewSecret

func NewSecret() Secret

NewSecret returns a new, unique identifier.

type Status

type Status = resultstore.Status

Status represents the status of the action/target/invocation.

type Suite

type Suite struct {
	// Name of the suite, such as the tested class.
	Name string

	// Cases holds details about each case in the suite.
	Cases []Case
	// Duration of the entire suite.
	Duration time.Duration
	// Errors that prevented the suite from completing.
	Errors []Error
	// Failures detected during the suite.
	Failures []Failure
	// Files outputted by the suite.
	Files []File
	// Properties of the suite.
	Properties []Property
	// Result determines whether the suite ran and finished.
	Result Result
	// Time the suite started
	Start time.Time
	// Suites hold details about child suites.
	Suites []Suite
}

Suite represents testing details.

func (Suite) To

func (s Suite) To() *resultstore.TestSuite

To converts a suite into the corresponding ResultStore TestSuite proto.

type Target

type Target struct {
	// Name of the target, immutable.
	Name string

	// Start time of the target.
	Start time.Time
	// Duration the target ran.
	Duration time.Duration

	// Status specifying whether the target completed successfully.
	Status Status
	// Description of the status
	Description string

	// Tags are metadata for the target (like github labels).
	Tags []string
	// Properties of the target
	Properties []Property
}

Target represents a set of commands run inside the same pod.

func (Target) To

func (t Target) To() *resultstore.Target

To converts a target into the corresponding ResultStore Target proto.

type Targets

type Targets struct {
	Client
	// contains filtered or unexported fields
}

Targets client.

func (Targets) Create

func (t Targets) Create(id string, target Target) (string, error)

Create a new target with the specified id (target basename), returing the fully qualified path.

func (Targets) List

func (t Targets) List(fields ...string) ([]Target, error)

List requested fields in targets, does not currently handle paging.

type Test

type Test struct {
	// Action holds generic metadata about the test
	Action
	// Suite holds a variety of case and sub-suite data.
	Suite
	// Warnings, appear to be useless.
	Warnings []string
}

Test represents a test action, containing action, suite and warnings.

func (Test) To

func (t Test) To() *resultstore.Action

To converts the test into the corresponding ResultStore Action proto

Jump to

Keyboard shortcuts

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