service

package
v0.0.0-...-e560ebb Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Overview

Package service implements a skylab.Client using calls to BuildBucket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgsCollectingClientWrapper

type ArgsCollectingClientWrapper struct {
	// Name the wrapped client to avoid accidental forwarding of method calls
	// without counting.
	Client Client

	// Calls is a POD that contains the arguments to all Client method calls
	// through a ArgsCollectingClientWrapper.
	Calls struct {
		ValidateArgs []struct {
			Args *request.Args
		}
		LaunchTask []struct {
			Args *request.Args
		}
		FetchResults []struct {
			T TaskReference
		}
		SwarmingTaskID []struct {
			T TaskReference
		}
		URL []struct {
			T TaskReference
		}
	}
}

ArgsCollectingClientWrapper collects arguments provided to the Client method calls before forwarding them to the wrapped Client.

func (*ArgsCollectingClientWrapper) FetchResults

FetchResults implements Client interface.

func (*ArgsCollectingClientWrapper) LaunchTask

LaunchTask implements Client interface.

func (*ArgsCollectingClientWrapper) SwarmingTaskID

func (c *ArgsCollectingClientWrapper) SwarmingTaskID(t TaskReference) string

SwarmingTaskID implements Client interface.

func (*ArgsCollectingClientWrapper) URL

URL implements Client interface.

func (*ArgsCollectingClientWrapper) ValidateArgs

ValidateArgs implements Client interface.

type BotsAwareFakeClient

type BotsAwareFakeClient struct {
	StubClient

	// List of dimensions for each available bot.
	// Dimensions for each bot must be supplied as "key:value" strings.
	Bots []stringset.Set
}

BotsAwareFakeClient implements a fake Client which is aware of the available bots.

BotsAwareFakeClient implements ValidateArgs to be consistent with available bots, buts stubs out the other methods.

func NewBotsAwareFakeClient

func NewBotsAwareFakeClient(bots ...stringset.Set) BotsAwareFakeClient

NewBotsAwareFakeClient creates a new BotsAwareFakeClient with some defaults.

func (BotsAwareFakeClient) ValidateArgs

func (c BotsAwareFakeClient) ValidateArgs(ctx context.Context, args *request.Args) (bool, []types.TaskDimKeyVal, error)

ValidateArgs implements Client interface.

type CallCountingClientWrapper

type CallCountingClientWrapper struct {
	// Name the wrapped client to avoid accidental forwarding of method calls
	// without counting.
	Client Client

	// CallCounts is a POD value that contains the number of each time each method
	// in Client was called.
	CallCounts struct {
		ValidateArgs   int
		LaunchTask     int
		FetchResults   int
		SwarmingTaskID int
		URL            int
	}
}

CallCountingClientWrapper is a Client wrapper that additionally counts the number of times each Client method is called.

func (*CallCountingClientWrapper) FetchResults

FetchResults implements Client interface.

func (*CallCountingClientWrapper) LaunchTask

LaunchTask implements Client interface.

func (*CallCountingClientWrapper) SwarmingTaskID

func (c *CallCountingClientWrapper) SwarmingTaskID(t TaskReference) string

SwarmingTaskID implements Client interface.

func (*CallCountingClientWrapper) URL

URL implements Client interface.

func (*CallCountingClientWrapper) ValidateArgs

ValidateArgs implements Client interface.

type Client

type Client interface {
	// ValidateArgs validates that a test_runner build can be created with
	// the give arguments.
	ValidateArgs(context.Context, *request.Args) (bool, []types.TaskDimKeyVal, error)

	// LaunchTask creates a new test_runner task with the given arguments.
	LaunchTask(context.Context, *request.Args) (TaskReference, error)

	// FetchResults fetches results for a previously launched test_runner task.
	FetchResults(context.Context, TaskReference) (*FetchResultsResponse, error)

	// SwarmingTaskID returns the swarming task ID for a test_runner build.
	SwarmingTaskID(TaskReference) string

	// URL returns a canonical URL for a test_runner build.
	URL(TaskReference) string
}

Client defines an interface used to interact with test_runner as a service.

func NewClient

func NewClient(ctx context.Context, cfg *config.Config) (Client, error)

NewClient creates a concrete instance of a Client.

type FetchResultsResponse

type FetchResultsResponse struct {
	Result    *skylab_test_runner.Result
	LifeCycle test_platform.TaskState_LifeCycle
}

FetchResultsResponse is an implementation-independent container for information about running and finished tasks.

type StubClient

type StubClient struct{}

StubClient implements a noop Client with "reasonable" default behavior for all methods.

func (StubClient) FetchResults

FetchResults implements Client interface.

func (StubClient) LaunchTask

LaunchTask implements Client interface.

func (StubClient) SwarmingTaskID

func (c StubClient) SwarmingTaskID(TaskReference) string

SwarmingTaskID implements Client interface.

func (StubClient) URL

URL implements Client interface.

func (StubClient) ValidateArgs

ValidateArgs implements Client interface.

type StubClientWithCannedResults

type StubClientWithCannedResults struct {
	StubClient
	CannedResponses []FetchResultsResponse
}

StubClientWithCannedResults is a stub Client that always returns canned result for the FetchResults method.

func NewStubClientWithCannedIncompleteTasks

func NewStubClientWithCannedIncompleteTasks(lifeCycle test_platform.TaskState_LifeCycle) *StubClientWithCannedResults

NewStubClientWithCannedIncompleteTasks returns a new StubWithCannedResultsClient where all tasks are deemed incomplete with the given lifeCycle.

In particular, this means that no detailed test_runner response is available in the response for FetchResults.

func NewStubClientWithFailedTasks

func NewStubClientWithFailedTasks() *StubClientWithCannedResults

NewStubClientWithFailedTasks returns a new StubWithCannedResultsClient where all tasks are deemed to have completed, but unsuccessfully.

func NewStubClientWithSuccessfulTasks

func NewStubClientWithSuccessfulTasks() *StubClientWithCannedResults

NewStubClientWithSuccessfulTasks returns a new StubWithCannedResultsClient where all tasks are deemed to have completed successfully.

func (*StubClientWithCannedResults) FetchResults

FetchResults implements Client interface.

type TaskReference

type TaskReference string

TaskReference is an implementation-independent way to identify test_runner tasks.

func NewTaskReference

func NewTaskReference() TaskReference

NewTaskReference creates a unique task reference.

Jump to

Keyboard shortcuts

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