testsuite

package
v0.0.0-...-aedf96a Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: Apache-2.0 Imports: 3 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Test

type Test interface {
	/*
		Defines the configuration object that controls how the test will be executed. If you want to enable advanced
			features like network partitioning, you can do so here.
	*/
	GetTestConfiguration() TestConfiguration

	// Initializes the network to the desired state before test execution
	Setup(networkCtx *networks.NetworkContext) (networks.Network, error)

	// NOTE: if Go had generics, 'network' would be a parameterized type representing the network that this test consumes
	// as produced by the NetworkLoader
	/*
		Runs test logic against the given network, with failures reported using the given context.

		Args:
			network: A user-defined representation of the network. NOTE: Because Go doesn't have generics, this will need to
				be casted to the appropriate type.
			context: The test context, which is the user's tool for making test assertions.
	*/
	Run(network networks.Network, testCtx TestContext)

	/*
		The amount of time the test's `Run` method will be allowed to execute for before it's killed and the test
			is marked as failed. This does NOT include the time needed to do pre-test setup or post-test teardown,
			which is handled by `GetSetupTeardownBuffer`. The total amount of time a test (with setup & teardown) is allowed
			to run for = GetExecutionTimeout + GetSetupBuffer.
	*/
	GetExecutionTimeout() time.Duration

	/*
		How long the test will be given to do the pre-execution setup and post-setup teardown before the test will be
			hard-killed. The total amount of time a test (with setup & teardown) is allowed to run
			for = GetExecutionTimeout + GetSetupTeardownBuffer.
	*/
	GetSetupTeardownBuffer() time.Duration
}

An interface encapsulating a test to run against a test network.

type TestConfiguration

type TestConfiguration struct {
	// If true, enables the test to set up network partitions between services
	// This should NOT be done thoughtlessly, however - when partitioning is enabled,
	//  adding services will be slower because all the other nodes in the network will
	//  need to update their iptables for the new node. The slowdown will scale with the
	//  number of services in your network.
	IsPartitioningEnabled bool

	// A mapping of ID -> URL where the artifact containing files should be downloaded from
	// The ID is the ID that service initializers will use when requesting to use the artifact
	FilesArtifactUrls map[services.FilesArtifactID]string
}

Holds configuration values that, if set, give the test the ability to do special things

type TestContext

type TestContext struct{}

An object that will be passed in to every test, which the user can use to manipulate the results of the test

func (TestContext) AssertTrue

func (context TestContext) AssertTrue(condition bool, err error)

Asserts that the given condition is true, and if not then fails the test and returns the given error

func (TestContext) Fatal

func (context TestContext) Fatal(err error)

Fails the test with the given error

type TestSuite

type TestSuite interface {
	// Get all the tests in the test suite; this is where users will "register" their tests
	GetTests() map[string]Test

	// Determines how many IP addresses will be available in the Docker network created for each test, which determines
	//  the maximum number of services that can be created in the test. The maximum number of services that each
	//  test can have = 2 ^ network_width_bits
	GetNetworkWidthBits() uint32
}

An interface which the user implements to register their tests.

Jump to

Keyboard shortcuts

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