Documentation ¶
Index ¶
- Constants
- Variables
- func CreateNamespaceOrDie(c clientset.Interface, baseName string, t testing.TB) *v1.Namespace
- func DefaultEtcdOptions() *options.EtcdOptions
- func DefaultOpenAPIConfig() *openapicommon.Config
- func DefaultOpenAPIV3Config() *openapicommon.OpenAPIV3Config
- func DefaultTestServerFlags() []string
- func DeleteNamespaceOrDie(c clientset.Interface, ns *v1.Namespace, t testing.TB)
- func EtcdMain(tests func() int)
- func Filter(nodeList *v1.NodeList, fn func(node v1.Node) bool)
- func GetEtcdURL() string
- func GoleakCheck(tb testing.TB, opts ...goleak.Option)
- func IgnoreBackgroundGoroutines() []goleak.Option
- func IsConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool
- func IsConditionSetAsExpectedSilent(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool
- func IsNodeReady(node *v1.Node) bool
- func IsNodeSchedulable(node *v1.Node) bool
- func NewIntegrationTestNodePreparer(client clientset.Interface, countToStrategy []testutils.CountToStrategy, ...) testutils.TestNodePreparer
- func NewIntegrationTestNodePreparerWithNodeSpec(client clientset.Interface, countToStrategy []testutils.CountToStrategy, ...) testutils.TestNodePreparer
- func NewTBWriter(tb testing.TB) io.Writer
- func RedirectKlog(tb testing.TB, output io.Writer) func()
- func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url string, stopFn func(), err error)
- func SharedEtcd() *storagebackend.Config
- func StartEtcd(tb testing.TB, etcdOutput io.Writer)
- type IntegrationTestNodePreparer
- type TearDownFunc
- type TestServerSetup
Constants ¶
const (
UnprivilegedUserToken = "unprivileged-user"
)
Variables ¶
var MinVerbosity = 4
MinVerbosity determines the minimum klog verbosity when running tests that involve the apiserver. This overrides the -v value from the command line, i.e. -v=0 has no effect when MinVerbosity is 4 (the default). Tests can opt out of this by setting MinVerbosity to zero before starting the control plane or choose some different minimum verbosity.
Functions ¶
func CreateNamespaceOrDie ¶ added in v1.25.0
CreateNamespaceOrDie creates a namespace.
func DefaultEtcdOptions ¶ added in v1.15.0
func DefaultEtcdOptions() *options.EtcdOptions
DefaultEtcdOptions are the default EtcdOptions for use with integration tests.
func DefaultOpenAPIConfig ¶ added in v1.14.0
func DefaultOpenAPIConfig() *openapicommon.Config
DefaultOpenAPIConfig returns an openapicommon.Config initialized to default values.
func DefaultOpenAPIV3Config ¶ added in v1.24.0
func DefaultOpenAPIV3Config() *openapicommon.OpenAPIV3Config
DefaultOpenAPIV3Config returns an openapicommon.Config initialized to default values.
func DefaultTestServerFlags ¶ added in v1.30.6
func DefaultTestServerFlags() []string
DefaultAPIServerFlags returns the default flags used to run kube-apiserver on tests
func DeleteNamespaceOrDie ¶ added in v1.25.0
DeleteNamespaceOrDie deletes a namespace.
func EtcdMain ¶ added in v1.8.0
func EtcdMain(tests func() int)
EtcdMain starts an etcd instance before running tests.
func Filter ¶ added in v1.19.0
Filter filters nodes in NodeList in place, removing nodes that do not satisfy the given condition
func GetEtcdURL ¶ added in v1.8.0
func GetEtcdURL() string
GetEtcdURL returns the URL of the etcd instance started by EtcdMain or StartEtcd.
func GoleakCheck ¶ added in v1.27.0
GoleakCheck sets up leak checking for a test or benchmark. The check runs as cleanup operation and records an error when goroutines were leaked.
func IgnoreBackgroundGoroutines ¶ added in v1.27.0
IgnoreBackgroundGoroutines returns options for goleak.Find which ignore goroutines created by "go test" and init functions, like the one from go.opencensus.io/stats/view/worker.go.
Goroutines that normally get created later when using the apiserver get created already when calling this function, therefore they also get ignored.
func IsConditionSetAsExpected ¶ added in v1.19.0
func IsConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool
IsConditionSetAsExpected returns a wantTrue value if the node has a match to the conditionType, otherwise returns an opposite value of the wantTrue with detailed logging.
func IsConditionSetAsExpectedSilent ¶ added in v1.19.0
func IsConditionSetAsExpectedSilent(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool
IsConditionSetAsExpectedSilent returns a wantTrue value if the node has a match to the conditionType, otherwise returns an opposite value of the wantTrue.
func IsNodeReady ¶ added in v1.19.0
IsNodeReady returns true if: 1) it's Ready condition is set to true 2) doesn't have NetworkUnavailable condition set to true
func IsNodeSchedulable ¶ added in v1.19.0
IsNodeSchedulable returns true if: 1) doesn't have "unschedulable" field set 2) it also returns true from IsNodeReady
func NewIntegrationTestNodePreparer ¶ added in v1.5.0
func NewIntegrationTestNodePreparer(client clientset.Interface, countToStrategy []testutils.CountToStrategy, nodeNamePrefix string) testutils.TestNodePreparer
NewIntegrationTestNodePreparer creates an IntegrationTestNodePreparer configured with defaults.
func NewIntegrationTestNodePreparerWithNodeSpec ¶ added in v1.18.0
func NewIntegrationTestNodePreparerWithNodeSpec(client clientset.Interface, countToStrategy []testutils.CountToStrategy, nodeSpec *v1.Node) testutils.TestNodePreparer
NewIntegrationTestNodePreparerWithNodeSpec creates an IntegrationTestNodePreparer configured with nodespec.
func NewTBWriter ¶ added in v1.27.0
NewTBWriter creates an io.Writer which turns each write into a tb.Log call.
Note that no attempts are made to determine the actual call site because our caller doesn't know about the TB instance and thus cannot mark itself as helper. Therefore the code here doesn't do it either and thus shows up as call site in the testing output. To avoid that, contextual logging and ktesting have to be used.
func RedirectKlog ¶ added in v1.27.0
RedirectKlog modifies the global klog logger so that it writes via the given writer. This only works when different tests run sequentially.
The returned cleanup function restores the previous state. Beware that it is not thread-safe, all goroutines which call klog must have been stopped.
func RunCustomEtcd ¶ added in v1.20.0
func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url string, stopFn func(), err error)
RunCustomEtcd starts a custom etcd instance for test purposes.
func SharedEtcd ¶ added in v1.9.0
func SharedEtcd() *storagebackend.Config
SharedEtcd creates a storage config for a shared etcd instance, with a unique prefix.
func StartEtcd ¶ added in v1.27.0
StartEtcd starts an etcd instance inside a test. It will abort the test if startup fails and clean up after the test automatically. Stdout and stderr of the etcd binary go to the provided writer.
In contrast to EtcdMain, StartEtcd will not do automatic leak checking. Tests can decide if and where they want to do that.
Starting etcd multiple times per test run instead of once with EtcdMain provides better separation between different tests.
Types ¶
type IntegrationTestNodePreparer ¶ added in v1.5.0
type IntegrationTestNodePreparer struct {
// contains filtered or unexported fields
}
IntegrationTestNodePreparer holds configuration information for the test node preparer.
func (*IntegrationTestNodePreparer) CleanupNodes ¶ added in v1.5.0
func (p *IntegrationTestNodePreparer) CleanupNodes(ctx context.Context) error
CleanupNodes deletes existing test nodes.
func (*IntegrationTestNodePreparer) PrepareNodes ¶ added in v1.5.0
func (p *IntegrationTestNodePreparer) PrepareNodes(ctx context.Context, nextNodeIndex int) error
PrepareNodes prepares countToStrategy test nodes.
type TearDownFunc ¶ added in v1.25.0
type TearDownFunc func()
func StartTestServer ¶ added in v1.11.8
func StartTestServer(ctx context.Context, t testing.TB, setup TestServerSetup) (client.Interface, *rest.Config, TearDownFunc)
StartTestServer runs a kube-apiserver, optionally calling out to the setup.ModifyServerRunOptions and setup.ModifyServerConfig functions TODO (pohly): convert to ktesting contexts
type TestServerSetup ¶ added in v1.11.8
type TestServerSetup struct { ModifyServerRunOptions func(*options.ServerRunOptions) ModifyServerConfig func(*controlplane.Config) }
TestServerSetup holds configuration information for a kube-apiserver test server.