Documentation ¶
Overview ¶
Package framework contains provider-independent helper code for building and running E2E tests with Ginkgo. The actual Ginkgo test suites gets assembled by combining this framework, the optional provider support code and specific tests via a separate .go file like Kubernetes' test/e2e.go.
Index ¶
- Constants
- Variables
- func CreateTestingNS(ctx context.Context, baseName string, c clientset.Interface, ...) (*corev1.Namespace, error)
- func LoadConfig() (config *restclient.Config, err error)
- func RandomSuffix() string
- func RegisterClusterFlags(flags *flag.FlagSet)
- func WaitForNamespacesDeleted(ctx context.Context, c clientset.Interface, namespaces []string, ...) error
- type CreateTestingNSFn
- type Framework
- func (f *Framework) AddNamespacesToDelete(namespaces ...*corev1.Namespace)
- func (f *Framework) AfterEach(ctx context.Context)
- func (f *Framework) BeforeEach(ctx context.Context)
- func (f *Framework) ClientConfig() *rest.Config
- func (f *Framework) CreateNamespace(ctx context.Context, baseName string, labels map[string]string) (*corev1.Namespace, error)
- func (f *Framework) DeleteNamespace(ctx context.Context, name string)
- type Options
- type TestContextType
Constants ¶
const ( // DefaultNamespaceDeletionTimeout is timeout duration for waiting for a namespace deletion. DefaultNamespaceDeletionTimeout = 5 * time.Minute )
const ( // PollInterval is how often to Poll pods, nodes and claims. PollInterval = 2 * time.Second )
Variables ¶
var RunID = uuid.NewUUID()
RunID is a unique identifier of the e2e run. Beware that this ID is not the same for all tests in the e2e run, because each Ginkgo node creates it separately.
var TestContext = TestContextType{}
TestContext should be used by all tests to access common context data.
Functions ¶
func CreateTestingNS ¶
func CreateTestingNS(ctx context.Context, baseName string, c clientset.Interface, labels map[string]string) (*corev1.Namespace, error)
CreateTestingNS should be used by every test, note that we append a common prefix to the provided test name. Please see NewFramework instead of using this directly.
func LoadConfig ¶
func LoadConfig() (config *restclient.Config, err error)
LoadConfig returns a config for a rest client with the UserAgent set to include the current test name.
func RandomSuffix ¶
func RandomSuffix() string
RandomSuffix provides a random sequence to append to pods,services,rcs.
func RegisterClusterFlags ¶
RegisterClusterFlags registers flags specific to the cluster e2e test suite.
Types ¶
type CreateTestingNSFn ¶
type CreateTestingNSFn func(ctx context.Context, baseName string, c clientset.Interface, labels map[string]string) (*corev1.Namespace, error)
CreateTestingNSFn is a func that is responsible for creating namespace used for executing e2e tests.
type Framework ¶
type Framework struct { BaseName string // Set together with creating the ClientSet and the namespace. // Guaranteed to be unique in the cluster even when running the same // test multiple times in parallel. UniqueName string ClientSet clientset.Interface ApiExtClient *apiextensionsclientset.Clientset // Helm HelmClient helm.Client HelmLogFile *os.File HelmLogger *log.Logger // configuration for framework's client Options Options SkipNamespaceCreation bool // Whether to skip creating a namespace Namespace *corev1.Namespace // Every test has at least one namespace unless creation is skipped NamespaceDeletionTimeout time.Duration // contains filtered or unexported fields }
Framework supports common operations used by e2e tests; it will keep a client & a namespace for you. Eventual goal is to merge this with integration test framework.
You can configure the pod security level for your test by setting the `NamespacePodSecurityLevel` which will set all three of pod security admission enforce, warn and audit labels on the namespace. The default pod security profile is "restricted". Each of the labels can be overridden by using more specific NamespacePodSecurity* attributes of this struct.
func NewFramework ¶
NewFramework creates a test framework.
func (*Framework) AddNamespacesToDelete ¶
AddNamespacesToDelete adds one or more namespaces to be deleted when the test completes.
func (*Framework) BeforeEach ¶
BeforeEach gets a client and makes a namespace.
func (*Framework) ClientConfig ¶
ClientConfig an externally accessible method for reading the kube client config.
type Options ¶
type Options struct { ClientQPS float32 ClientBurst int GroupVersion *schema.GroupVersion }
Options is a struct for managing test framework options.
type TestContextType ¶
type TestContextType struct { KubeConfig string KubeContext string DeleteNamespace bool DeleteNamespaceOnFailure bool HelmLogFile string // CreateTestingNS is responsible for creating namespace used for executing e2e tests. // It accepts namespace base name, which will be prepended with e2e prefix, kube client // and labels to be applied to a namespace. CreateTestingNS CreateTestingNSFn }
TestContextType contains test settings and global state