checkmechanism

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

Package checkmechanism provides TestSuites for use with implementations of a mechanism networkservice chain element.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckClientContextAfter

func CheckClientContextAfter(t *testing.T, client networkservice.NetworkServiceClient, mechanismType string, check func(*testing.T, context.Context)) networkservice.NetworkServiceClient

CheckClientContextAfter - returns a NetworkServiceClient that will check the state of the context.Context after it has left

the clientUnderTest.  Note: it should almost always be the case that there are no side effects
related to implementing the Mechanism at this point, as the clientUnderTest can't know what to
do until after the elements after it have returned a fully complete Connection.
t - *testing.T for checks
clientUnderTest - client we are testing - presumed to implement a mechanism
mechanismType - Mechanism.Type implemented by the clientUnderTest
check - function to check that the clientUnderTest has not taken action to implement the Mechanism
        (as it cannot know what to do at this stage)

func CheckClientContextOnReturn

func CheckClientContextOnReturn(t *testing.T, clientUnderTest networkservice.NetworkServiceClient, mechanismType string, check func(*testing.T, context.Context)) networkservice.NetworkServiceClient

CheckClientContextOnReturn - returns a NetworkServiceClient that will check the state of the context.Context

after the clientUnderTest has returned
t - *testing.T for checks
clientUnderTest - client we are testing - presumed to implement a mechanism
mechanismType - Mechanism.Type implemented by the clientUnderTest
check - function to check the state of the context.Context after the clientUnderTest has returned

func CheckClientSetsMechanismPreferences

func CheckClientSetsMechanismPreferences(t *testing.T, clientUnderTest networkservice.NetworkServiceClient, mechanismType string, mechanismCheck func(*testing.T, *networkservice.Mechanism)) networkservice.NetworkServiceClient

CheckClientSetsMechanismPreferences - returns a NetworkServiceClient that will check to make sure that the

clientUnderTest correctly sets the MechanismPreferences to include
a mechanism of type mechanismType
t - *testing.T for checking
clientUnderTest - client we are testing
mechanismType - Mechanism.Type implemented by clientUnderTest
mechanismCheck - function to check for any parameters that should be present in
                 the MechanismPreference

func CheckContextAfterServer

func CheckContextAfterServer(t *testing.T, serverUnderTest networkservice.NetworkServiceServer, mechanismType string, check func(*testing.T, context.Context)) networkservice.NetworkServiceServer

CheckContextAfterServer - returns a NetworkServiceServer that will check the state of the context.Context after it has

left the serverUnderTest.  At this time the context.Context should contain any side effects needed
to implement the Mechanism, as it should have a complete Connection to work with.
t - *testing.T for checks
serverUnderTest - server we are testing - presumed to implement a mechanism
mechanismType - Mechanism.Type implemented by the serverUnderTest
check - function to check that the serverUnderTest has taken action to implement the Mechanism

Types

type ClientSuite

type ClientSuite struct {
	suite.Suite

	Request   *networkservice.NetworkServiceRequest
	ConnClose *networkservice.Connection
	// contains filtered or unexported fields
}

ClientSuite - test suite to check that a NetworkServiceClient implementing a Mechanism meets basic contracts

func NewClientSuite

func NewClientSuite(
	clientUnderTest networkservice.NetworkServiceClient,
	configureContext func(ctx context.Context) context.Context,
	mechanismType string,
	mechanismCheck func(*testing.T, *networkservice.Mechanism),
	contextOnReturnCheck,
	contextCheck func(*testing.T, context.Context),

	request *networkservice.NetworkServiceRequest,
	connClose *networkservice.Connection,
) *ClientSuite

NewClientSuite - returns a ClientTestSuite

clientUnderTest - the client we are testing to make sure it correctly implements a Mechanism
configureContext - a function that is applied to context.Background to make sure anything
                   needed by the clientUnderTest is present in the context.Context
mechanismType - Mechanism.Type implemented by the clientUnderTest
mechanismCheck - function to check that the clientUnderTest has properly added Mechanism.Parameters
                 to the Mechanism it has appended to MechanismPreferences
contextOnReturnCheck - function to check that the context.Context *after* clientUnderTest has returned are correct
contextCheck - function to check that the clientUnderTest introduces no side effects to the context.Context
               before calling the next element in the chain
request - NetworkServiceRequest to be used for testing
connClose - Connection to be used for testing Close(...)

func (*ClientSuite) TestContextAfter

func (m *ClientSuite) TestContextAfter()

TestContextAfter - tests that the clientUnderTest has no side effects on the context.Context before it calls the next element in the chain

func (*ClientSuite) TestContextOnReturn

func (m *ClientSuite) TestContextOnReturn()

TestContextOnReturn - test that the clientUnderTest has the correct side effects on the context.Context when it returns

func (*ClientSuite) TestPropagatesError

func (m *ClientSuite) TestPropagatesError()

TestPropagatesError - tests that the clientUnderTest returns an error when the next element in the chain returned an error to it

func (*ClientSuite) TestPropogatesOpts

func (m *ClientSuite) TestPropogatesOpts()

TestPropogatesOpts - tests that the clientUnderTest passes along the grpc.CallOptions to the next client in the chain

func (*ClientSuite) TestSetsMechanismPreference

func (m *ClientSuite) TestSetsMechanismPreference()

TestSetsMechanismPreference - test that the clientUnderTest correctly sets MechanismPreferences for the Mechanism it implements

before calling the next element in the chain

type ServerSuite

type ServerSuite struct {
	suite.Suite

	Request   *networkservice.NetworkServiceRequest
	ConnClose *networkservice.Connection
	// contains filtered or unexported fields
}

ServerSuite - test suite to check that a NetworkServiceServer implementing a Mechanism meets basic contracts

func NewServerSuite

func NewServerSuite(
	serverUnderTest networkservice.NetworkServiceServer,
	configureContext func(ctx context.Context) context.Context,
	mechanismType string,
	mechanismCheck func(*testing.T, *networkservice.Mechanism),
	contextCheck func(*testing.T, context.Context),
	request *networkservice.NetworkServiceRequest,
	connClose *networkservice.Connection,
) *ServerSuite

NewServerSuite - returns a ServerSuite

serverUnderTest - the server being tested to make sure it correctly implements a Mechanism
configureContext - a function that is applied to context.Background to make sure anything
                   needed by the serverUnderTest is present in the context.Context
mechanismType - Mechanism.Type implemented by the serverUnderTest
contextCheck - function to check that the serverUnderTest introduces all needed side effects to the context.Context
               before calling the next element in the chain
request - NetworkServiceRequest to be used for testing
connClose - Connection to be used for testing Close(...)

func (*ServerSuite) TestContextAfter

func (m *ServerSuite) TestContextAfter()

TestContextAfter - tests that the serverUnderTest has all needed side effects on the context.Context before it calls the next element in the chain

func (*ServerSuite) TestMechanismAfter

func (m *ServerSuite) TestMechanismAfter()

TestMechanismAfter - test to make sure that any changes the server should have made to the Request.Connection.Mechanism

before calling the next chain element have been made

func (*ServerSuite) TestPropagatesError

func (m *ServerSuite) TestPropagatesError()

TestPropagatesError - tests that the serverUnderTest returns an error when the next element in the chain returned an error to it

Jump to

Keyboard shortcuts

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