base

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// If defined, calls to cli.RunScenariosParallel will actually be run
	// in serial.  Use this, for example, when the output of the tests is
	// too difficult to read because of the parallelism
	ENV_CLI_NO_PARALLEL = "SKUPPER_TEST_CLI_NO_PARALLEL"

	// If defined, the status commands will try at most this number of
	// attempts (an int).  Otherwise, they'll fail only on the timeout.
	ENV_CLI_MAX_STATUS_ATTEMPTS = "SKUPPER_TEST_CLI_MAX_STATUS_ATTEMPTS"

	// If defined, both stdout and stderr of all issued skupper commands
	// will be shown on the test output, even if they did not fail
	ENV_CLI_VERBOSE_COMMANDS = "SKUPPER_TEST_CLI_VERBOSE_COMMANDS"
)

** CLI **

View Source
const (

	// Skips the creation of namespaces.  Used during testing development,
	// to speed up test runs, by reusing a previously-set environment
	ENV_SKIP_NAMESPACE_SETUP = "SKUPPER_TEST_SKIP_NAMESPACE_SETUP"

	// Skips the teardown of namespaces.  Used during testing development,
	// to leave a test setup behind for semi-automated testing, or for
	// speeding up test runs
	ENV_SKIP_NAMESPACE_TEARDOWN = "SKUPPER_TEST_SKIP_NAMESPACE_TEARDOWN"

	// Individual tests may be marked as issue-related and will be
	// skipped on the normal runs.  Setting this variable will include
	// those on the runs
	ENV_RUN_ISSUE_TESTS = "SKUPPER_TEST_RUN_ISSUE_TESTS"

	// If populated, skupper integration tests will not run in debug mode
	ENV_SKIP_DEBUG = "SKUPPER_TEST_SKIP_DEBUG"
)

General

View Source
const (

	// this is used by policyTestStep at test/integration/acceptance/custom/hello_policy/runner.go
	// It's the number of seconds to wait after any policy changes take effect.  If the PolicyStep
	// defined several policy changes, they'll all run one after the other, then the sleep will
	// kick in.  If no policy changes, no sleep.
	ENV_POST_POLICY_CHANGE_SLEEP = "SKUPPER_TEST_POST_POLICY_CHANGE_SLEEP"

	// By default, after each policy change, the policy runner will wait for all of the
	// configured checks (if any) to return success before moving on.  If this variable is
	// set, the checks will run only once and the test step will fail on unexpected response.
	// The GET checks are used to wait for the policy changes to stabilize before moving to
	// the CLI tasks.  This variable removes that wait, so it can be used to see how the
	// system behaves when tests are run before the changes are finished.
	ENV_POLICY_NO_GET_WAIT = "SKUPPER_TEST_POLICY_NO_GET_WAIT"
)

** POLICY **

Variables

View Source
var (
	TestFlags   testFlags
	FlagsParsed bool = false
)

Functions

func ConnectSimplePublicPrivate

func ConnectSimplePublicPrivate(ctx context.Context, r *ClusterTestRunnerBase) error

func EdgeKubeConfigs

func EdgeKubeConfigs() []string

func GetConsoleData

func GetConsoleData(cc *ClusterContext, consoleUser, consolePass string) (data.ConsoleData, error)

GetConsoleData returns the ConsoleData by emulating query to localhost:8080/DATA via vFlow api on service-controller vflow-collector sidecar

func HandleInterruptSignal

func HandleInterruptSignal(fn func())

HandleInterruptSignal runs the given fn in case test execution was interrupted

func IsMaxStatusAttemptsReached

func IsMaxStatusAttemptsReached(currentAttempt int) bool

This checks whether the current attempt sent as an argument is greather than the environment variable ENV_MAX_STATUS_ATTEMPTS

If the variable is not set or is malformed, this will always return false (meaning that the status commands will only fail once they reach their timeout)

func IsTestInterrupted

func IsTestInterrupted() bool

func IsVerboseCommandOutput

func IsVerboseCommandOutput() bool

func KubeConfigDefault

func KubeConfigDefault() string

KubeConfigDefault returns the "default" KUBECONFIG filename if one exists or an empty string otherwise.

func KubeConfigFiles

func KubeConfigFiles(includeEdge, includePublic bool) []string

KubeConfigFiles return the available kubeconfig files based on provided --kubeconfig, --edgekubeconfig or the default KUBECONFIG environment variable (only if no flag has been provided)

func KubeConfigFilesCount

func KubeConfigFilesCount(includeEdge, includePublic bool) int

KubeConfigFilesCount returns total amount of kubeconfig files provided (using --kubeconfig or --edgekubeconfig) or 1 if no flags provided and the default exists

func KubeConfigs

func KubeConfigs() []string

func MultipleClusters

func MultipleClusters() bool

MultipleClusters returns true if more than one --kubeconfig or --edgekubeconfig files have been provided

func ParseFlags

func ParseFlags()

func PostPolicyChangeSleep

func PostPolicyChangeSleep()

Checks for the environment variable configuration and executes the sleep

func RemoveNamespacesForContexts

func RemoveNamespacesForContexts(r *ClusterTestRunnerBase, public []int, priv []int) error

func RunBasicTopologyTests

func RunBasicTopologyTests(m *testing.M, topology BasicTopologySetup)

func SetupSimplePublicPrivate

func SetupSimplePublicPrivate(ctx context.Context, r *ClusterTestRunnerBase) error

func ShouldPolicyWaitOnGet

func ShouldPolicyWaitOnGet() bool

Reports whether the configuration variable named on the constant ENV_POLICY_NO_GET_WAIT is set or not. If set, the caller should skip any waits related to GET checks

func ShouldRunScenariosInParallel

func ShouldRunScenariosInParallel() bool

func ShouldSkipNamespaceSetup

func ShouldSkipNamespaceSetup() bool

func ShouldSkipNamespaceTeardown

func ShouldSkipNamespaceTeardown() bool

func SkipIssueTests

func SkipIssueTests(t *testing.T)

Tests that are specific for issues can be defined to not run by default on test runs. This function checks the environment variable that configures that behavior and runs t.Skipf on behalf of the test, with a note on how to activate it.

func StopIfInterrupted

func StopIfInterrupted(t *testing.T)

Calls *testing.T.Fatalf if base.UserInterrupted is true In other words, stop that test if someone hit Ctrl+C

func TearDownSimplePublicAndPrivate

func TearDownSimplePublicAndPrivate(r *ClusterTestRunnerBase)

func WaitForSkupperConnectedSites

func WaitForSkupperConnectedSites(ctx context.Context, cc *ClusterContext, sitesTotal int) error

WaitForSkupperConnectedSites waits till total number of sites are connected for the provided ClusterContext. If a timeout occurs or context is closed, an error will be returned

func WaitSkupperComponentRunning

func WaitSkupperComponentRunning(c *ClusterContext, component string) error

func WaitSkupperRunning

func WaitSkupperRunning(c *ClusterContext) error

Types

type BasicTopologySetup

type BasicTopologySetup struct {
	TestRunner       *ClusterTestRunnerBase
	NamespaceId      string
	PreSkupperSetup  func(testRunner *ClusterTestRunnerBase) error
	PostSkupperSetup func(testRunner *ClusterTestRunnerBase) error
}

type ClusterContext

type ClusterContext struct {
	Namespace string

	KubeConfig string
	VanClient  *vanClient.VanClient
	Private    bool
	Id         int
	// contains filtered or unexported fields
}

ClusterContext represents a cluster that is available for testing

func (*ClusterContext) CreateNamespace

func (cc *ClusterContext) CreateNamespace() error

func (*ClusterContext) DeleteNamespace

func (cc *ClusterContext) DeleteNamespace() error

func (*ClusterContext) DumpTestInfo

func (cc *ClusterContext) DumpTestInfo(dirName string)

func (*ClusterContext) KubectlExec

func (cc *ClusterContext) KubectlExec(command string) ([]byte, error)

func (*ClusterContext) LabelNamespace

func (cc *ClusterContext) LabelNamespace(label string, value string) (err error)

As the name says, it will add label to this namespace

type ClusterNeeds

type ClusterNeeds struct {
	// nsId identifier that will be used to compose namespace
	NamespaceId string
	// number of public clusters expected (optional)
	PublicClusters int
	// number of private clusters expected (optional)
	PrivateClusters int
}

ClusterNeeds enable customization of expected number of public or private clusters in order to use multiple clusters. If number of provided clusters do not match test will use only 1, or will be skipped.

type ClusterTestRunner

type ClusterTestRunner interface {
	// Validate validates if given needs are based upon command line arguments
	Validate(needs ClusterNeeds) error
	// Build builds a slice of ClusterContexts to manage each participating cluster
	Build(needs ClusterNeeds, vanClientProvider VanClientProvider) ([]*ClusterContext, error)
	// Return a specific public context
	GetPublicContext(id int) (*ClusterContext, error)
	// Return a specific private context
	GetPrivateContext(id int) (*ClusterContext, error)
	// Return a specific context
	GetContext(private bool, id int) (*ClusterContext, error)
}

ClusterTestRunner defines a common interface to initialize and prepare tests for running against an external cluster

type ClusterTestRunnerBase

type ClusterTestRunnerBase struct {
	Needs           ClusterNeeds
	ClusterContexts []*ClusterContext
	// contains filtered or unexported fields
}

ClusterTestRunnerBase is a base implementation of ClusterTestRunner

func (*ClusterTestRunnerBase) Build

func (c *ClusterTestRunnerBase) Build(needs ClusterNeeds, vanClientProvider VanClientProvider) ([]*ClusterContext, error)

Build creates a ClusterContext slice prepared to communicate with all clusters available to the test suite.

func (*ClusterTestRunnerBase) DumpTestInfo

func (c *ClusterTestRunnerBase) DumpTestInfo(dirname string)

func (*ClusterTestRunnerBase) GetContext

func (c *ClusterTestRunnerBase) GetContext(private bool, id int) (*ClusterContext, error)

func (*ClusterTestRunnerBase) GetPrivateContext

func (c *ClusterTestRunnerBase) GetPrivateContext(id int) (*ClusterContext, error)

func (*ClusterTestRunnerBase) GetPublicContext

func (c *ClusterTestRunnerBase) GetPublicContext(id int) (*ClusterContext, error)

func (*ClusterTestRunnerBase) Validate

func (c *ClusterTestRunnerBase) Validate(needs ClusterNeeds) error

Validate returns an error if cluster needs is not satisfied so that the given test suite needs to be skipped.

type VanClientProvider

type VanClientProvider func(namespace string, context string, kubeConfigPath string) (*vanClient.VanClient, error)

Jump to

Keyboard shortcuts

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