controller-runtime: sigs.k8s.io/controller-runtime/pkg/envtest Index | Files | Directories

package envtest

import "sigs.k8s.io/controller-runtime/pkg/envtest"

Package envtest provides libraries for integration testing by starting a local control plane

Control plane binaries (etcd and kube-apiserver) are loaded by default from /usr/local/kubebuilder/bin. This can be overridden by setting the KUBEBUILDER_ASSETS environment variable, or by directly creating a ControlPlane for the Environment to use.

Environment can also be configured to work with an existing cluster, and simply load CRDs and provide client configuration.

Index

Package Files

crd.go doc.go ginkgo.go server.go

Constants

const (
    StartTimeout = 60
    StopTimeout  = 60
)

Default binary path for test framework

Variables

var DefaultKubeAPIServerFlags = []string{
    "--etcd-servers={{ if .EtcdURL }}{{ .EtcdURL.String }}{{ end }}",
    "--cert-dir={{ .CertDir }}",
    "--insecure-port={{ if .URL }}{{ .URL.Port }}{{ end }}",
    "--insecure-bind-address={{ if .URL }}{{ .URL.Hostname }}{{ end }}",
    "--secure-port={{ if .SecurePort }}{{ .SecurePort }}{{ end }}",
    "--admission-control=AlwaysAdmit",
}

DefaultKubeAPIServerFlags are default flags necessary to bring up apiserver.

func CreateCRDs Uses

func CreateCRDs(config *rest.Config, crds []*apiextensionsv1beta1.CustomResourceDefinition) error

CreateCRDs creates the CRDs

func InstallCRDs Uses

func InstallCRDs(config *rest.Config, options CRDInstallOptions) ([]*apiextensionsv1beta1.CustomResourceDefinition, error)

InstallCRDs installs a collection of CRDs into a cluster by reading the crd yaml files from a directory

func WaitForCRDs Uses

func WaitForCRDs(config *rest.Config, crds []*apiextensionsv1beta1.CustomResourceDefinition, options CRDInstallOptions) error

WaitForCRDs waits for the CRDs to appear in discovery

type CRDInstallOptions Uses

type CRDInstallOptions struct {
    // Paths is the path to the directory containing CRDs
    Paths []string

    // CRDs is a list of CRDs to install
    CRDs []*apiextensionsv1beta1.CustomResourceDefinition

    // ErrorIfPathMissing will cause an error if a Path does not exist
    ErrorIfPathMissing bool
    // contains filtered or unexported fields
}

CRDInstallOptions are the options for installing CRDs

type Environment Uses

type Environment struct {
    // ControlPlane is the ControlPlane including the apiserver and etcd
    ControlPlane integration.ControlPlane

    // Config can be used to talk to the apiserver.  It's automatically
    // populated if not set using the standard controller-runtime config
    // loading.
    Config *rest.Config

    // CRDs is a list of CRDs to install
    CRDs []*apiextensionsv1beta1.CustomResourceDefinition

    // CRDDirectoryPaths is a list of paths containing CRD yaml or json configs.
    CRDDirectoryPaths []string

    // UseExisting indicates that this environments should use an
    // existing kubeconfig, instead of trying to stand up a new control plane.
    // This is useful in cases that need aggregated API servers and the like.
    UseExistingCluster *bool

    // ControlPlaneStartTimeout is the maximum duration each controlplane component
    // may take to start. It defaults to the KUBEBUILDER_CONTROLPLANE_START_TIMEOUT
    // environment variable or 20 seconds if unspecified
    ControlPlaneStartTimeout time.Duration

    // ControlPlaneStopTimeout is the maximum duration each controlplane component
    // may take to stop. It defaults to the KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT
    // environment variable or 20 seconds if unspecified
    ControlPlaneStopTimeout time.Duration

    // KubeAPIServerFlags is the set of flags passed while starting the api server.
    KubeAPIServerFlags []string

    // AttachControlPlaneOutput indicates if control plane output will be attached to os.Stdout and os.Stderr.
    // Enable this to get more visibility of the testing control plane.
    // It respect KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT environment variable.
    AttachControlPlaneOutput bool
}

Environment creates a Kubernetes test environment that will start / stop the Kubernetes control plane and install extension APIs

func (*Environment) Start Uses

func (te *Environment) Start() (*rest.Config, error)

Start starts a local Kubernetes server and updates te.ApiserverPort with the port it is listening on

func (*Environment) Stop Uses

func (te *Environment) Stop() error

Stop stops a running server

type NewlineReporter Uses

type NewlineReporter = printer.NewlineReporter

NewlineReporter is Reporter that Prints a newline after the default Reporter output so that the results are correctly parsed by test automation. See issue https://github.com/jstemmer/go-junit-report/issues/31 It's re-exported here to avoid compatibility breakage/mass rewrites.

Directories

PathSynopsis
printerPackage printer contains setup for a friendlier Ginkgo printer that's easier to parse by test automation.

Package envtest imports 21 packages (graph) and is imported by 11 packages. Updated 2019-09-03. Refresh now. Tools for package owners.