helpers

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 35 Imported by: 1

README

helpers

This package contains helper functions that are used in the actual tests. These functions can be referenced in other repositories (like eventing-contrib) for adding similar tests.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BrokerChannelFlowWithTransformation added in v0.16.0

func BrokerChannelFlowWithTransformation(
	ctx context.Context,
	t *testing.T,
	brokerClass string,
	brokerVersion string,
	triggerVersion string,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

BrokerChannelFlowWithTransformation tests the following topology:

------------- ----------------------
|           | |                    |
v	       | v                    |

EventSource ---> Broker ---> Trigger1 -------> Service(Transformation)

|
|
|-------> Trigger2 -------> Service(Logger1)
|
|
|-------> Trigger3 -------> Channel --------> Subscription --------> Service(Logger2)

Explanation: Trigger1 filters the orignal event and transforms it to a new event, Trigger2 logs all events, Trigger3 filters the transformed event and sends it to Channel.

func BrokerRedelivery added in v0.17.0

func BrokerRedelivery(ctx context.Context, t *testing.T, creator BrokerCreatorWithRetries)

func ChannelChainTestHelper

func ChannelChainTestHelper(
	ctx context.Context,
	t *testing.T,
	subscriptionVersion SubscriptionVersion,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

ChannelChainTestHelper is the helper function for channel_chain_test

func ChannelClusterDefaulterTestHelper

func ChannelClusterDefaulterTestHelper(
	ctx context.Context,
	t *testing.T,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

ChannelClusterDefaulterTestHelper is the helper function for channel_defaulter_test

func ChannelDeadLetterSinkTestHelper added in v0.11.0

func ChannelDeadLetterSinkTestHelper(
	ctx context.Context,
	t *testing.T,
	subscriptionVersion SubscriptionVersion,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

ChannelDeadLetterSinkTestHelper is the helper function for channel_deadlettersink_test

func ChannelNamespaceDefaulterTestHelper

func ChannelNamespaceDefaulterTestHelper(
	ctx context.Context,
	t *testing.T,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

ChannelNamespaceDefaulterTestHelper is the helper function for channel_defaulter_test

func EventTransformationForSubscriptionTestHelper

func EventTransformationForSubscriptionTestHelper(
	ctx context.Context,
	t *testing.T,
	subscriptionVersion SubscriptionVersion,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

EventTransformationForSubscriptionTestHelper is the helper function for channel_event_transformation_test

func EventTransformationForTriggerTestHelper

func EventTransformationForTriggerTestHelper(
	ctx context.Context,
	t *testing.T,
	brokerVersion string,
	triggerVersion string,
	creator BrokerCreator,
	options ...testlib.SetupClientOption)

EventTransformationForTriggerTestHelper tests the following scenario:

            5                 4
      ------------- ----------------------
      |           | |                    |
1     v	 2     | v        3           |

EventSource ---> Broker ---> Trigger1 -------> Service(Transformation)

|
| 6                   7
|-------> Trigger2 -------> Service(Logger)

Note: the number denotes the sequence of the event that flows in this test case.

func ParallelTestHelper added in v0.15.0

func ParallelTestHelper(
	ctx context.Context,
	t *testing.T,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

func ParallelV1TestHelper added in v0.16.0

func ParallelV1TestHelper(
	ctx context.Context,
	t *testing.T,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

func SequenceTestHelper added in v0.15.0

func SequenceTestHelper(
	ctx context.Context,
	t *testing.T,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

func SequenceV1TestHelper added in v0.16.0

func SequenceV1TestHelper(
	ctx context.Context,
	t *testing.T,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

func SingleEventForChannelTestHelper

func SingleEventForChannelTestHelper(
	ctx context.Context,
	t *testing.T, encoding cloudevents.Encoding,
	subscriptionVersion SubscriptionVersion,
	channelVersion string,
	channelTestRunner testlib.ComponentsTestRunner,
	options ...testlib.SetupClientOption)

SingleEventForChannelTestHelper is the helper function for channel_single_event_test channelVersion can be used to override which version you want to create the subscription against. For example, you could create a v1beta1 channel, but create a subscription to its v1alpha1 version by using channelVersion to override it. channelVersion == "" means that the version of the channel subscribed to is not modified.

func TestBrokerWithManyTriggers added in v0.15.0

func TestBrokerWithManyTriggers(ctx context.Context, t *testing.T, brokerCreator BrokerCreator, shouldLabelNamespace bool)

If shouldLabelNamespace is set to true this test annotates the testing namespace so that a default broker is created. It then binds many triggers with different filtering patterns to the broker created by brokerCreator, and sends different events to the broker's address. Finally, it verifies that only the appropriate events are routed to the subscribers.

func TestTriggerNoBroker added in v0.15.0

func TestTriggerNoBroker(ctx context.Context, t *testing.T, channel string, brokerCreator BrokerCreator)

TestTriggerNoBroker will create a Trigger with a non-existent broker, then it will ensure the Status is correctly reflected as failed with BrokerDoesNotExist. Then it will create the broker and ensure that Trigger / Broker will get to Ready state.

Types

type BrokerCreator added in v0.15.0

type BrokerCreator func(client *testlib.Client, version string) string

BrokerCreator creates a broker and returns its broker name. TestBrokerWithManyTriggers will wait for the broker to become ready.

func ChannelBasedBrokerCreator added in v0.15.0

func ChannelBasedBrokerCreator(channel metav1.TypeMeta, brokerClass string) BrokerCreator

ChannelBasedBrokerCreator creates a BrokerCreator that creates a broker based on the channel parameter.

type BrokerCreatorWithRetries added in v0.17.0

type BrokerCreatorWithRetries func(client *testlib.Client, numRetries int32) string

BrokerCreator creates a broker and returns its broker name.

type SubscriptionVersion added in v0.15.0

type SubscriptionVersion string
const (
	SubscriptionV1beta1 SubscriptionVersion = "v1beta1"
	SubscriptionV1      SubscriptionVersion = "v1"
)

Jump to

Keyboard shortcuts

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