testutils

package
v1.14.0-beta15 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TearDown is used to TearDown assets after a test completes. This is used in kube2e tests to uninstall
	// Gloo after a test suite completes
	TearDown = "TEAR_DOWN"

	// SkipInstall can be used when running Kube suites consecutively, and you didnt tear down the Gloo
	// installation from a previous run
	SkipInstall = "SKIP_INSTALL"

	// KubeTestType is used to indicate which kube2e suite should be run while executing regression tests
	KubeTestType = "KUBE2E_TESTS"

	// InvalidTestReqsEnvVar is used to define the behavior for running tests locally when the provided requirements
	// are not met. See ValidateRequirementsAndNotifyGinkgo for a detail of available behaviors
	InvalidTestReqsEnvVar = "INVALID_TEST_REQS"

	// RunKubeTests is used to enable any tests which depend on Kubernetes. NOTE: Kubernetes back tests should
	// be written into the kube2e suites, and those don't require this guard.
	RunKubeTests = "RUN_KUBE_TESTS"

	// RunVaultTests is used to enable any tests which depend on Vault.
	RunVaultTests = "RUN_VAULT_TESTS"

	// RunConsulTests is used to enable any tests which depend on Consul.
	RunConsulTests = "RUN_CONSUL_TESTS"

	// WaitOnFail is used to halt execution of a failed test to give the developer a chance to inspect
	// any assets before they are cleaned up when the test completes
	// This functionality is defined: https://github.com/solo-io/solo-kit/blob/main/test/helpers/fail_handler.go
	// and for it to be available, a test must have registered the custom fail handler using `RegisterCommonFailHandlers`
	WaitOnFail = "WAIT_ON_FAIL"

	// SkipTempDisabledTests is used to temporarily disable tests in CI
	// This should be used sparingly, and if you disable a test, you should create a Github issue
	// to track re-enabling the test
	SkipTempDisabledTests = "SKIP_TEMP_DISABLED"
)

Variables

This section is empty.

Functions

func IsEnvTruthy

func IsEnvTruthy(envVarName string) bool

IsEnvTruthy returns true if a given environment variable has a truthy value Examples of truthy values are: "1", "t", "T", "true", "TRUE", "True". Anything else is considered false.

func ShouldRunKubeTests

func ShouldRunKubeTests() bool

ShouldRunKubeTests returns true if any tests which require a Kubernetes cluster should be executed This may guard tests which are run using our old CloudBuilder infrastructure. In the future, all kube tests should be written in our Kube2e suites, which are run with a kubernetes cluster

func ShouldSkipInstall

func ShouldSkipInstall() bool

ShouldSkipInstall returns true if any assets that need to be created before a test (for example Gloo being installed) should be skipped. This is typically used in tandem with ShouldTearDown when running consecutive tests and skipping both the tear down and install of Gloo Edge.

func ShouldSkipTempDisabledTests

func ShouldSkipTempDisabledTests() bool

ShouldSkipTempDisabledTests returns true if temporarily disabled tests should be skipped

func ShouldTearDown

func ShouldTearDown() bool

ShouldTearDown returns true if any assets that were created before a test (for example Gloo being installed) should be torn down after the test.

func ValidateRequirements

func ValidateRequirements(requirements []Requirement) error

ValidateRequirements returns an error if any of the Requirements are not met

func ValidateRequirementsAndNotifyGinkgo

func ValidateRequirementsAndNotifyGinkgo(requirements ...Requirement)

ValidateRequirementsAndNotifyGinkgo validates that the provided Requirements are met, and if they are not, uses the InvalidTestReqsEnvVar to determine how to proceed: Options are:

  • `run`: Ignore any invalid requirements and execute the tests
  • `skip`: Notify Ginkgo that the current spec was skipped
  • `fail`: Notify Ginkgo that the current spec has failed [DEFAULT]

Types

type RequiredConfiguration

type RequiredConfiguration struct {
	// contains filtered or unexported fields
}

func (RequiredConfiguration) Validate

func (r RequiredConfiguration) Validate() error

Validate returns an error is the RequiredConfiguration is not met

type Requirement

type Requirement func(configuration *RequiredConfiguration)

Requirement represents a required property for tests.

func AwsCredentials

func AwsCredentials() Requirement

AwsCredentials returns a Requirement that expects tests to require Aws credentials

func Consul

func Consul() Requirement

Consul returns a Requirement that expects tests to require a Consul instance

func DefinedEnv

func DefinedEnv(env string) Requirement

DefinedEnv returns a Requirement that expects tests to have the injected environment variable defined

func Kubernetes

func Kubernetes(reason string) Requirement

Kubernetes returns a Requirement that expects tests to require Kubernetes configuration

func LinuxOnly

func LinuxOnly(reason string) Requirement

LinuxOnly returns a Requirement that expects tests to only run on Linux

func TruthyEnv

func TruthyEnv(env string) Requirement

TruthyEnv returns a Requirement that expects tests to have the injected environment variable set to a truthy value

func Vault

func Vault() Requirement

Vault returns a Requirement that expects tests to require a Vault instance

Jump to

Keyboard shortcuts

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