target

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package target is responsible for maintaining resources related to targets.

Index

Constants

View Source
const (
	// SSHPingTimeout is the timeout for checking if SSH connection to DUT is open.
	SSHPingTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

func ServoHost

func ServoHost(ctx context.Context, role string, testVars map[string]string) string

ServoHost finds servo related information for a particular role from a variable to value map.

Types

type Config

type Config struct {
	SSHConfig     *protocol.SSHConfig
	Retries       int
	TastVars      map[string]string
	ServiceConfig *ServiceConfig
}

Config contains configs for creating connection.

type Conn

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

Conn holds an SSH connection to a target device, as well as several other objects whose lifetime is tied to the connection such as SSH port forwards.

func (*Conn) Healthy

func (c *Conn) Healthy(ctx context.Context) error

Healthy checks health of the connection by sending an SSH ping packet.

func (*Conn) SSHConn

func (c *Conn) SSHConn() *ssh.Conn

SSHConn returns an SSH connection. A returned connection is owned by Conn and should not be closed by users.

func (*Conn) Services

func (c *Conn) Services() *Services

Services returns an object owning services tied to an SSH connection.

func (*Conn) Target

func (c *Conn) Target() string

Target returns a connection spec as [<user>@]host[:<port>].

type ConnCache

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

ConnCache manages a cached connection to the target.

ConnCache is not goroutine-safe.

func NewConnCache

func NewConnCache(ctx context.Context, cfg *Config, target, proxyCommand, role string) (cc *ConnCache, retErr error)

NewConnCache establishes a new connection to target and return a ConnCache. Call Close when it is no longer needed.

func (*ConnCache) Close

func (cc *ConnCache) Close(ctx context.Context) error

Close closes a cached connection.

func (*ConnCache) Conn

func (cc *ConnCache) Conn() *Conn

Conn returns a cached connection to the target.

A connection returned from this function is owned by ConnCache. Do not call its Close.

func (*ConnCache) ConnectionSpec

func (cc *ConnCache) ConnectionSpec() string

ConnectionSpec returns a connection spec as [<user>@]host[:<port>].

func (*ConnCache) DefaultTimeout

func (cc *ConnCache) DefaultTimeout() time.Duration

DefaultTimeout returns the default timeout for connection operations.

func (*ConnCache) EnsureConn

func (cc *ConnCache) EnsureConn(ctx context.Context, rebootBeforeReconnect bool) error

EnsureConn ensures a cached connection to the target is available and healthy, possibly creating a new connection.

EnsureConn has slight performance hit because it checks the connection health by sending SSH ping. Unless you expect connection drops (e.g. after running test bundles), use Conn without calling this method.

Be aware that calling EnsureConn may invalidate a connection previously returned from Conn.

func (*ConnCache) InitBootID

func (cc *ConnCache) InitBootID() string

InitBootID returns a boot ID string obtained on the first successful connection to the target. An empty string is returned if it is unavailable.

func (*ConnCache) ProxyCommand

func (cc *ConnCache) ProxyCommand() string

ProxyCommand returns the proxy command.

type ServiceConfig

type ServiceConfig struct {
	TLWServer              string
	UseEphemeralDevserver  bool
	Devservers             []string
	TastDir                string
	ExtraAllowedBuckets    []string
	DebuggerPorts          []int
	DebuggerPortForwarding bool
}

ServiceConfig contains configs for creating a service.

type Services

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

Services owns services exposed to a target by SSH port forwarding. Services is owned by Conn because its lifetime is tied to a corresponding SSH connection.

func (*Services) DUTServerAddr

func (s *Services) DUTServerAddr() (addr net.Addr, ok bool)

DUTServerAddr returns the address of port-forwarded TLW service accessible from the target, if available.

func (*Services) EphemeralDevserverURL

func (s *Services) EphemeralDevserverURL() (url string, ok bool)

EphemeralDevserverURL returns the URL of port-forwarded ephemeral devserver accessible from the target, if available.

func (*Services) TLWAddr

func (s *Services) TLWAddr() (addr net.Addr, ok bool)

TLWAddr returns the address of port-forwarded TLW service accessible from the target, if available.

Jump to

Keyboard shortcuts

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