crosserverutil

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: 9 Imported by: 0

Documentation

Overview

Package crosserverutil contains utility functions to manage the cros server lifecycle

Index

Constants

View Source
const DefaultGRPCServerPort = 4445

DefaultGRPCServerPort is the default TCP based GRPC Server port for remote testing

Variables

This section is empty.

Functions

func StartCrosServer

func StartCrosServer(ctx context.Context, sshConn *ssh.Conn, port int) error

StartCrosServer initiates the cros server process and grpc server on DUT through SSH

func StopCrosServer

func StopCrosServer(ctx context.Context, sshConn *ssh.Conn, port int) error

StopCrosServer stops the cros server process and grpc server listening on the given port through SSH

Types

type Client

type Client struct {
	// Conn is the gRPC connection. Use this to create gRPC service stubs.
	Conn *grpc.ClientConn
	// contains filtered or unexported fields
}

Client owns a gRPC connection to the DUT for remote tests to use.

func Dial

func Dial(ctx context.Context, d *dut.DUT, hostname string, port int, useForwarder bool) (*Client, error)

Dial establishes a gRPC connection for a given hostname and port The grpc target will be in the form "[hostname]:[port]" When useForwarder is true, a local to remote port forwarding will be enabled for the desired port

Example without port forwarding:

cl, err := crosserverutil.Dial(ctx, s.DUT(), hostname, port, false)
if err != nil {
 	return err
}
defer cl.Close(ctx)
cs := pb.NewChromeServiceClient(cl.Conn)
res, err := cs.New(ctx, &pb.NewRequest{});

Example with port forwarding:

cl, err := crosserverutil.Dial(ctx, s.DUT(), "localhost", port, true)

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close shuts down cros server and performs other necessary cleanup.

Jump to

Keyboard shortcuts

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