etcd

package
v1.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 33 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CrdExistsInDiscovery

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 added in v1.15.0

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

Types

type APIServer added in v1.22.0

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

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

func StartRealAPIServerOrDie added in v1.22.0

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

type Prerequisite struct {
	GvrData schema.GroupVersionResource
	Stub    string
}

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

type Resource

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

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

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

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
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL