rpcdut

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package rpcdut provides a dut.DUT override that adds an additional managed RPC client connection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RPCDUT

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

RPCDUT extends dut.DUT to maintain an additional RPC connection.

In order for this to work correctly, test code must use this DUT's methods and always reconstruct rpc clients using RPC() before use. This is because RPCDUT sets up hooks that intercept dut.DUT's methods to enable us to reconnect the RPC connection, when the underlying dut connection is changed using Connect, Disconnect, Reboot, WaitUnreachable, or WaitConnect. Upon reconnect, any saved rpc clients from RPC() will be invalidated.

RPCDUT is designed to encapsulate dut.DUT. Please add any missing dut.DUT methods as proxies in RPCDUT.

Note that this implementation is not thread safe.

func NewRPCDUT

func NewRPCDUT(ctx context.Context, d *dut.DUT, h *testing.RPCHint, bundleName string) (*RPCDUT, error)

NewRPCDUT creates a new RPCDUT with a dialed rpc connection.

func (*RPCDUT) Close

func (rd *RPCDUT) Close(ctx context.Context) error

Close closes the rpc connection without disconnecting the ssh connection.

func (*RPCDUT) Conn

func (rd *RPCDUT) Conn() *ssh.Conn

Conn returns the underlying DUT Conn().

func (*RPCDUT) Connect

func (rd *RPCDUT) Connect(ctx context.Context) error

Connect the dut and rpc connection.

func (*RPCDUT) Connected

func (rd *RPCDUT) Connected(ctx context.Context) bool

Connected returns the connected status of the underlying DUT.

func (*RPCDUT) DUT

func (rd *RPCDUT) DUT() *dut.DUT

DUT returns the underlying DUT that does not manage the rpc connection.

This is strictly for being able to call functions that do not accept RPCDUT. If the target method will reboot the dut, you must call RPCDUT.RPCClose before the call and RPCDUT.RPCDial after the call.

func (*RPCDUT) Disconnect

func (rd *RPCDUT) Disconnect(ctx context.Context) error

Disconnect the dut and rpc connection.

func (*RPCDUT) HostName

func (rd *RPCDUT) HostName() string

HostName returns the hostname of the underlying DUT.

func (*RPCDUT) KeyDir

func (rd *RPCDUT) KeyDir() string

KeyDir returns the keydir of the underlying DUT.

func (*RPCDUT) KeyFile

func (rd *RPCDUT) KeyFile() string

KeyFile returns the keyfile of the underlying DUT.

func (*RPCDUT) RPC

func (rd *RPCDUT) RPC() *rpc.Client

RPC returns the current rpc client or nil if a reconnection (Reboot) previously failed.

The client returned will be nullified if a reconnection was necessary. This can happen if a Reboot was issued.

func (*RPCDUT) RPCClose

func (rd *RPCDUT) RPCClose(ctx context.Context) error

RPCClose closes the rpc connection if one existed.

func (*RPCDUT) RPCDial

func (rd *RPCDUT) RPCDial(ctx context.Context) error

RPCDial dials the rpc connection.

func (*RPCDUT) RPCHint

func (rd *RPCDUT) RPCHint() *testing.RPCHint

RPCHint return the saved RPC hint.

func (*RPCDUT) Reboot

func (rd *RPCDUT) Reboot(ctx context.Context) error

Reboot the dut and then reestablish the rpc connection.

The tast gRPC connection relies on the dut.DUT's existing ssh connection. When a Dial is initiated, it starts the remote bundle on the dut with the "-rpc" argument and sets up pipes for stdin/stdout. The returned gRPC client proxies gRPC requests to and from the remote bundle over the stdin/stdout provided by the long running ssh command/connection. So, if the dut is going to reboot, the remote bundle will be exiting and the ssh connection will be closing. When the ssh connection is reconnected, we can restart the remote bundle rpc server.

Jump to

Keyboard shortcuts

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