Documentation ¶
Overview ¶
Package e2e contains supporting infrastructure for end-to-end integration testing driven by the tests in cmd/e2e-test.
Test should be written with a Sandbox:
func TestExample(t *testing.T) { for _, tc := range []struct{ ... }{ ... }{ tc := tc // avoid variable capture Framework.RunWithSandbox(t, func(t *testing.T, s *e2e.Sandbox) { t.Parallel() // Test code... }) } }
The Sandbox will handle resource isolation and reclaimation.
Index ¶
- func CreateEchoService(s *Sandbox, name string, annotations map[string]string) (*v1.Pod, *v1.Service, error)
- func CreateSecret(s *Sandbox, name string, data map[string][]byte) (*v1.Secret, error)
- func NewCloud(project string) (cloud.Cloud, error)
- func WaitForGCLBDeletion(ctx context.Context, c cloud.Cloud, g *fuzz.GCLB, ...) error
- func WaitForIngress(s *Sandbox, ing *v1beta1.Ingress, options *WaitForIngressOptions) (*v1beta1.Ingress, error)
- func WaitForIngressDeletion(ctx context.Context, g *fuzz.GCLB, s *Sandbox, ing *v1beta1.Ingress, ...) error
- type Framework
- type IngressStability
- type Options
- type Sandbox
- type StatusManager
- type WaitForIngressOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateEchoService ¶
func CreateEchoService(s *Sandbox, name string, annotations map[string]string) (*v1.Pod, *v1.Service, error)
CreateEchoService creates the pod and service serving echoheaders.
func CreateSecret ¶
CreateSecret creates a secret from the given data.
func WaitForGCLBDeletion ¶
func WaitForGCLBDeletion(ctx context.Context, c cloud.Cloud, g *fuzz.GCLB, options *fuzz.GCLBDeleteOptions) error
WaitForGCLBDeletion waits for the resources associated with the GLBC to be deleted.
func WaitForIngress ¶
func WaitForIngress(s *Sandbox, ing *v1beta1.Ingress, options *WaitForIngressOptions) (*v1beta1.Ingress, error)
WaitForIngress to stabilize.
Types ¶
type Framework ¶
type Framework struct { RestConfig *rest.Config Clientset *kubernetes.Clientset BackendConfigClient *backendconfigclient.Clientset Project string Cloud cloud.Cloud Rand *rand.Rand // contains filtered or unexported fields }
Framework is the end-to-end test framework.
func NewFramework ¶
NewFramework returns a new test framework to run.
func (*Framework) CatchSIGINT ¶
func (f *Framework) CatchSIGINT()
CatchSIGINT and cleanup sandboxes when the test is interrupted.
func (*Framework) RunWithSandbox ¶
RunWithSandbox runs the testFunc with the Sandbox, taking care of resource cleanup and isolation. This indirectly calls testing.T.Run().
func (*Framework) SanityCheck ¶
SanityCheck the test environment before proceeding.
type IngressStability ¶ added in v1.5.0
type IngressStability string
IngressStability denotes the stabilization status of all Ingresses in a sandbox.
var ( // Stable indicates an Ingress is stable (i.e consistently serving 200's) Stable IngressStability = "Stable" // Unstable indicates an Ingress is unstable (i.e serving 404/502's). Unstable IngressStability = "Unstable" )
type Sandbox ¶
type Sandbox struct { // Namespace to create resources in. Resources created in this namespace // will be deleted with Destroy(). Namespace string // ValidatorEnv for use with the test. ValidatorEnv fuzz.ValidatorEnv // contains filtered or unexported fields }
Sandbox represents a sandbox for running tests in a Kubernetes cluster.
func (*Sandbox) Destroy ¶
func (s *Sandbox) Destroy()
Destroy the sandbox and all resources associated with the sandbox.
func (*Sandbox) MasterUpgraded ¶ added in v1.5.0
MasterUpgraded checks the config map for whether or not the k8s master has successfully finished upgrading or not
func (*Sandbox) MasterUpgrading ¶ added in v1.5.0
MasterUpgrading checks the config map for whether or not the k8s master has successfully finished upgrading or not
func (*Sandbox) PutStatus ¶ added in v1.5.0
func (s *Sandbox) PutStatus(status IngressStability)
type StatusManager ¶ added in v1.5.0
type StatusManager struct {
// contains filtered or unexported fields
}
StatusManager manages the status of sandboxed Ingresses via a ConfigMap. It interacts with the an external framework test portion as follows: 1. StatusManager initializes and creates the ConfigMap status-cm. It listens on updates via informers. 2. e2e test calls StatusManager.putStatus with the Ingress name as key, and Unstable as the status 3. e2e test watches for when Ingress stabilizes, then uses StatusManager to update the Ingress's status to Stable 4. The external framework test reads from ConfigMap status-cm. When it detects that all Ingresses are stable (i.e., no value in the map is Unstable), it starts the MasterUpgrade. 5. When the k8s master finishes upgrading, the framework test writes the timestamp to the master-upgraded key in the ConfigMap 6. The external framework test writes the exit key in the ConfigMap to indicate that the e2e test can exit. 7. The StatusManager loop reads the exit key, then starts shutdown().
func NewStatusManager ¶ added in v1.5.0
func NewStatusManager(f *Framework) *StatusManager
type WaitForIngressOptions ¶ added in v1.5.0
type WaitForIngressOptions struct { // ExpectUnreachable is true when we expect the LB to still be // programming itself (i.e 404's / 502's) ExpectUnreachable bool }
WaitForIngressOptions holds options dictating how we wait for an ingress to stabilize.