grpc

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeRequestAndExpectEventuallyConsistentResponse

func MakeRequestAndExpectEventuallyConsistentResponse(t *testing.T, c Client, timeoutConfig config.TimeoutConfig, gwAddr string, expected ExpectedResponse)

Types

type Client added in v1.2.0

type Client interface {
	SendRPC(t *testing.T, address string, expected ExpectedResponse, timeout time.Duration) (*Response, error)
	Close()
}

Client is an interface used to make requests within conformance tests for grpc scenarios. This can be overridden with custom implementations whenever necessary.

type DefaultClient added in v1.2.0

type DefaultClient struct {
	Conn *grpc.ClientConn
}

DefaultClient is the default implementation of Client. It will be used if a custom implementation is not specified.

func (*DefaultClient) Close added in v1.2.0

func (c *DefaultClient) Close()

func (*DefaultClient) SendRPC added in v1.2.0

func (c *DefaultClient) SendRPC(t *testing.T, address string, expected ExpectedResponse, timeout time.Duration) (*Response, error)

SendRPC sends a gRPC request to the given address with the expected response. An error will be returned if there is an error running the function but not if an HTTP error status code is received.

type ExpectedResponse

type ExpectedResponse struct {
	// Defines the request to make. Only one of EchoRequest and EchoTwoRequest
	// may be set.
	EchoRequest      *pb.EchoRequest
	EchoTwoRequest   *pb.EchoRequest
	EchoThreeRequest *pb.EchoRequest

	// Metadata describing the outgoing request.
	RequestMetadata *RequestMetadata

	// Response defines what response the test case
	// should receive.
	Response Response

	Backend   string
	Namespace string

	// User Given TestCase name
	TestCaseName string
}

ExpectedResponse defines the response expected for a given request.

func (*ExpectedResponse) GetTestCaseName

func (er *ExpectedResponse) GetTestCaseName(i int) string

type RequestMetadata

type RequestMetadata struct {
	// The :authority pseudoheader to set on the outgoing request.
	Authority string

	// Outgoing metadata pairs to add to the request.
	Metadata map[string]string
}

type Response

type Response struct {
	Code     codes.Code
	Headers  *metadata.MD
	Trailers *metadata.MD
	Response *pb.EchoResponse
}

Jump to

Keyboard shortcuts

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