...

Package etcd

import "k8s.io/kubernetes/test/integration/etcd"
Overview
Index

Overview ▾

func CrdExistsInDiscovery

func CrdExistsInDiscovery(client apiextensionsclientset.Interface, crd *apiextensionsv1.CustomResourceDefinition) bool

CrdExistsInDiscovery checks to see if the given CRD exists in discovery at all served versions.

func CreateTestCRDs

func CreateTestCRDs(t *testing.T, client apiextensionsclientset.Interface, skipCrdExistsInDiscovery bool, crds ...*apiextensionsv1.CustomResourceDefinition)

CreateTestCRDs creates the given CRDs, any failure causes the test to Fatal. If skipCrdExistsInDiscovery is true, the CRDs are only checked for the Established condition via their Status. If skipCrdExistsInDiscovery is false, the CRDs are checked via discovery, see CrdExistsInDiscovery.

func GetCustomResourceDefinitionData

func GetCustomResourceDefinitionData() []*apiextensionsv1.CustomResourceDefinition

GetCustomResourceDefinitionData returns the resource definitions that back the custom resources included in GetEtcdStorageData. They should be created using CreateTestCRDs before running any tests. We can switch this to v1 CRDs based on transitive call site analysis. Call sites: 1. TestDedupOwnerReferences - beta doesn't matter 2. TestWebhookAdmissionWithWatchCache/TestWebhookAdmissionWithoutWatchCache - beta doesn't matter 3. TestApplyStatus - the version fields don't matter. Pruning isn't checked, just ownership. 4. TestDryRun - versions and pruning don't matter 5. TestStorageVersionBootstrap - versions and pruning don't matter. 6. TestEtcdStoragePath - beta doesn't matter 7. TestCrossGroupStorage - beta doesn't matter 8. TestOverlappingCustomResourceCustomResourceDefinition - beta doesn't matter 9. TestOverlappingCustomResourceAPIService - beta doesn't matter

func GetEtcdStorageData

func GetEtcdStorageData() map[schema.GroupVersionResource]StorageData

GetEtcdStorageData returns etcd data for all persisted objects. It is exported so that it can be reused across multiple tests. It returns a new map on every invocation to prevent different tests from mutating shared state.

func GetEtcdStorageDataForNamespace

func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionResource]StorageData

GetEtcdStorageDataForNamespace returns etcd data for all persisted objects. It is exported so that it can be reused across multiple tests. It returns a new map on every invocation to prevent different tests from mutating shared state. Namespaced objects keys are computed for the specified namespace.

func JSONToUnstructured

func JSONToUnstructured(stub, namespace string, mapping *meta.RESTMapping, dynamicClient dynamic.Interface) (dynamic.ResourceInterface, *unstructured.Unstructured, error)

JSONToUnstructured converts a JSON stub to unstructured.Unstructured and returns a dynamic resource client that can be used to interact with it

type APIServer

APIServer represents a running API server that is ready for use The Cleanup func must be deferred to prevent resource leaks

type APIServer struct {
    Client    clientset.Interface
    Dynamic   dynamic.Interface
    Config    *restclient.Config
    KV        clientv3.KV
    Mapper    meta.RESTMapper
    Resources []Resource
    Cleanup   func()
}

func StartRealAPIServerOrDie

func StartRealAPIServerOrDie(t *testing.T, configFuncs ...func(*options.ServerRunOptions)) *APIServer

StartRealAPIServerOrDie starts an API server that is appropriate for use in tests that require one of every resource

type Prerequisite

Prerequisite contains information required to create a resource (but not verify it)

type Prerequisite struct {
    GvrData schema.GroupVersionResource
    Stub    string
}

type Resource

Resource contains REST mapping information for a specific resource and extra metadata such as delete collection support

type Resource struct {
    Mapping             *meta.RESTMapping
    HasDeleteCollection bool
}

func GetResources

func GetResources(t *testing.T, serverResources []*metav1.APIResourceList) []Resource

GetResources fetches the Resources associated with serverResources that support get and create

type StorageData

StorageData contains information required to create an object and verify its storage in etcd It must be paired with a specific resource

type StorageData struct {
    Stub             string                   // Valid JSON stub to use during create
    Prerequisites    []Prerequisite           // Optional, ordered list of JSON objects to create before stub
    ExpectedEtcdPath string                   // Expected location of object in etcd, do not use any variables, constants, etc to derive this value - always supply the full raw string
    ExpectedGVK      *schema.GroupVersionKind // The GVK that we expect this object to be stored as - leave this nil to use the default
}