Documentation ¶
Overview ¶
Package devserver provides a client for devservers. For more information about devservers, see go/devserver-doc.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseGSURL ¶
ParseGSURL parses a Google Cloud Storage URL. It is parsed as:
gs://<bucket>/<path>
Note that path is not prefixed with a slash, which is suitable for use with GCS APIs.
Types ¶
type Client ¶
type Client interface { // Open opens a file on Google Cloud Storage at gsURL. gsURL must have a "gs://" scheme. // Callers are responsible to close the/ returned io.ReadCloser after use. // If the file does not exist, os.ErrNotExist is returned. Open(ctx context.Context, gsURL string) (io.ReadCloser, error) // Stage opens a file on Google Cloud Storage at gsURL. sURL must have a "gs://" scheme. // Returns a http or file url to the data. Stage(ctx context.Context, gsURL string) (*url.URL, error) // TearDown should be called once when the Client is destructed, // regardless of whether Open was called or not. TearDown() error }
Client is a client interface to communicate with devservers.
func NewClient ¶
func NewClient(ctx context.Context, devservers []string, tlwServer, dutName, dutServer, swarmingTaskID, buildBucketID string) (Client, error)
NewClient creates a Client from a list of devservers, DUT server or a TLW server. If dutServer is non-empty, DUTServiceClient is returned. If tlwServer is non-empty, TLWClient is returned. If devserver contains 1 or more element, RealClient is returned. If the oth are empty, PseudoClient is returned.
type DUTServiceClient ¶
type DUTServiceClient struct {
// contains filtered or unexported fields
}
DUTServiceClient is an implementation of Client to communicate with DUT Service API.
func NewDUTServiceClient ¶
func NewDUTServiceClient(ctx context.Context, dutServer string) (*DUTServiceClient, error)
NewDUTServiceClient creates a DUTServiceClient.
func (*DUTServiceClient) Open ¶
func (c *DUTServiceClient) Open(ctx context.Context, gsURL string) (io.ReadCloser, error)
Open downloads a file on GCS from storage.googleapis.com to specified destination and return io.ReadCloser for the file.
func (*DUTServiceClient) Stage ¶
Stage downloads a file on GCS from storage.googleapis.com to specified destination and return file: url for the file.
func (*DUTServiceClient) TearDown ¶
func (c *DUTServiceClient) TearDown() error
TearDown closes the gRPC connection to the DUTService service.
type FakeClient ¶
type FakeClient struct {
// contains filtered or unexported fields
}
FakeClient is a fake implementation of devserver.Client suitable for unit tests.
func NewFakeClient ¶
func NewFakeClient(files map[string][]byte) *FakeClient
NewFakeClient constructs a FakeClient. files is a map from GS URL to content.
func (*FakeClient) Open ¶
func (c *FakeClient) Open(ctx context.Context, gsURL string) (io.ReadCloser, error)
Open simulates a download from Google Cloud Storage.
type PseudoClient ¶
type PseudoClient struct {
// contains filtered or unexported fields
}
PseudoClient is an implementation of Client to simulate devservers without credentials.
func NewPseudoClient ¶
func NewPseudoClient(opts ...PseudoClientOption) *PseudoClient
NewPseudoClient creates a PseudoClient.
func (*PseudoClient) Open ¶
func (c *PseudoClient) Open(ctx context.Context, gsURL string) (io.ReadCloser, error)
Open downloads a file on GCS directly from storage.googleapis.com.
type PseudoClientOption ¶
type PseudoClientOption func(o *pseudoClientOptions)
PseudoClientOption is an option accepted by NewPseudoClient to configure PseudoClient initialization.
func WithBaseURL ¶
func WithBaseURL(baseURL string) PseudoClientOption
WithBaseURL returns an option that specifies the base URL of Google Cloud Storage HTTP API.
func WithHTTPClient ¶
func WithHTTPClient(cl *http.Client) PseudoClientOption
WithHTTPClient returns an option that specifies http.Client used by PseudoClient.
type RealClient ¶
type RealClient struct {
// contains filtered or unexported fields
}
RealClient is an implementation of Client to communicate with real devservers.
func NewRealClient ¶
func NewRealClient(ctx context.Context, dsURLs []string, o *RealClientOptions) *RealClient
NewRealClient creates a RealClient. This function checks if devservers at dsURLs are up, and selects a subset of devservers to use. A devserver URL is usually in the form of "http://<hostname>:<port>", without trailing slashes. If we can not verify a devserver is up within ctx's timeout, it is considered down. Be sure to set ctx's timeout carefully since this function can block until it expires if any devserver is down. If o is nil, default options are used. If o is partially nil, defaults are used for them.
func (*RealClient) Open ¶
func (c *RealClient) Open(ctx context.Context, gsURL string) (io.ReadCloser, error)
Open downloads a file on GCS via devservers. It returns an error if no devserver is up.
func (*RealClient) Stage ¶
Stage stages a file on GCS via devservers. It returns an error if no devserver is up.
func (*RealClient) Status ¶
func (c *RealClient) Status() string
Status returns a message describing the status of devservers.
func (*RealClient) UpServerURLs ¶
func (c *RealClient) UpServerURLs() []string
UpServerURLs returns URLs of operational devservers.
type RealClientOptions ¶
type RealClientOptions struct { // HTTPClient is HTTP client to use. If nil, defaultHTTPClient is used. HTTPClient *http.Client // StageRetryWaits instructs retry strategy for stage. // Its length is the number of retries and the i-th value is the interval before i-th retry. // If nil, default strategy is used. If zero-length slice, no retry is attempted. StageRetryWaits []time.Duration // SwarmingTaskID specifies the task ID of the scheduled job that run Tast tests. SwarmingTaskID string // BuildBucketID specifies the build bucket ID for the schedule job that run Tast tests BuildBucketID string }
RealClientOptions contains options used when connecting to devserver.
type TLWClient ¶
type TLWClient struct {
// contains filtered or unexported fields
}
TLWClient is an implementation of Client to communicate with Test Lab Services wiring API.
func NewTLWClient ¶
NewTLWClient creates a TLWClient.
func (*TLWClient) Open ¶
Open downloads a file on GCS from storage.googleapis.com using the TLW API.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package devservertest provides a fake implementation of devservers.
|
Package devservertest provides a fake implementation of devservers. |