Documentation ¶
Overview ¶
Package rpcdut provides a dut.DUT override that adds an additional managed RPC client connection.
Index ¶
- type RPCDUT
- func (rd *RPCDUT) Close(ctx context.Context) error
- func (rd *RPCDUT) Conn() *ssh.Conn
- func (rd *RPCDUT) Connect(ctx context.Context) error
- func (rd *RPCDUT) Connected(ctx context.Context) bool
- func (rd *RPCDUT) DUT() *dut.DUT
- func (rd *RPCDUT) Disconnect(ctx context.Context) error
- func (rd *RPCDUT) HostName() string
- func (rd *RPCDUT) KeyDir() string
- func (rd *RPCDUT) KeyFile() string
- func (rd *RPCDUT) RPC() *rpc.Client
- func (rd *RPCDUT) RPCClose(ctx context.Context) error
- func (rd *RPCDUT) RPCDial(ctx context.Context) error
- func (rd *RPCDUT) RPCHint() *testing.RPCHint
- func (rd *RPCDUT) Reboot(ctx context.Context) error
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) 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 ¶
Disconnect the dut and rpc connection.
func (*RPCDUT) RPC ¶
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) Reboot ¶
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.