package testing
import "k8s.io/apiserver/pkg/storage/testing"
Index ¶
- func CreateList(prefix string, helper storage.Interface, list runtime.Object) error
- func CreateObjList(prefix string, helper storage.Interface, items []runtime.Object) error
- func CreatePodPredicate(field fields.Selector, namespaceScoped bool, indexField []string) storage.SelectionPredicate
- func DeepEqualSafePodSpec() example.PodSpec
- func ExpectContains(t *testing.T, msg string, expectedList []interface{}, got interface{})
- func ExpectContinueMatches(t *testing.T, expect, got string)
- func RunBenchmarkStoreList(ctx context.Context, b *testing.B, store storage.Interface, data BenchmarkData, useIndex bool)
- func RunBenchmarkStoreListCreate(ctx context.Context, b *testing.B, store storage.Interface, match metav1.ResourceVersionMatch)
- func RunOptionalTestProgressNotify(ctx context.Context, t *testing.T, store storage.Interface)
- func RunSendInitialEventsBackwardCompatibility(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestClusterScopedWatch(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestConditionalDelete(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestConsistentList(ctx context.Context, t *testing.T, store storage.Interface, increaseRV IncreaseRVFunc, cacheEnabled, consistentReadsSupported, listFromCacheSnapshot bool)
- func RunTestCount(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestCreate(ctx context.Context, t *testing.T, store storage.Interface, validation KeyValidation)
- func RunTestCreateWithKeyExist(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestCreateWithTTL(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestDelayedWatchDelivery(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestDeleteTriggerWatch(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestDeleteWithConflict(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestDeleteWithSuggestion(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestDeleteWithSuggestionAndConflict(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestDeleteWithSuggestionOfDeletedObject(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestGet(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestGetListNonRecursive(ctx context.Context, t *testing.T, increaseRV IncreaseRVFunc, store storage.Interface)
- func RunTestGetListRecursivePrefix(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestGuaranteedUpdate(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer, validation KeyValidation)
- func RunTestGuaranteedUpdateChecksStoredData(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer)
- func RunTestGuaranteedUpdateWithConflict(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestGuaranteedUpdateWithSuggestionAndConflict(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestGuaranteedUpdateWithTTL(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestList(ctx context.Context, t *testing.T, store storage.Interface, increaseRV IncreaseRVFunc, ignoreWatchCacheTests bool)
- func RunTestListContinuation(ctx context.Context, t *testing.T, store storage.Interface, validation CallsValidation)
- func RunTestListContinuationWithFilter(ctx context.Context, t *testing.T, store storage.Interface, validation CallsValidation)
- func RunTestListInconsistentContinuation(ctx context.Context, t *testing.T, store storage.Interface, compaction Compaction)
- func RunTestListPaginationRareObject(ctx context.Context, t *testing.T, store storage.Interface, validation CallsValidation)
- func RunTestListPaging(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestListResourceVersionMatch(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer)
- func RunTestNamespaceScopedList(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestNamespaceScopedWatch(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestOptionalWatchBookmarksWithCorrectResourceVersion(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestPreconditionalDeleteWithOnlySuggestionPass(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestPreconditionalDeleteWithSuggestion(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestTransformationFailure(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer)
- func RunTestUnconditionalDelete(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestValidateDeletionWithOnlySuggestionValid(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestValidateDeletionWithSuggestion(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestWatch(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestWatchContextCancel(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestWatchDeleteEventObjectHaveLatestRV(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestWatchDispatchBookmarkEvents(ctx context.Context, t *testing.T, store storage.Interface, expectedWatchBookmarks bool)
- func RunTestWatchError(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer)
- func RunTestWatchFromNonZero(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestWatchFromZero(ctx context.Context, t *testing.T, store storage.Interface, compaction Compaction)
- func RunTestWatchInitializationSignal(ctx context.Context, t *testing.T, store storage.Interface)
- func RunTestWatchWithUnsafeDelete(ctx context.Context, t *testing.T, store InterfaceWithCorruptTransformer)
- func RunTestWatcherTimeout(ctx context.Context, t *testing.T, store storage.Interface)
- func RunWatchErrorIsBlockingFurtherEvents(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer)
- func RunWatchListMatchSingle(ctx context.Context, t *testing.T, store storage.Interface)
- func RunWatchSemanticInitialEventsExtended(ctx context.Context, t *testing.T, store storage.Interface)
- func RunWatchSemantics(ctx context.Context, t *testing.T, store storage.Interface)
- func TestCheckNoMoreResultsWithIgnoreFunc(t *testing.T, w watch.Interface, ignore func(watch.Event) bool)
- func TestCheckResultsInStrictOrder(t *testing.T, w watch.Interface, expectedEvents []watch.Event)
- type BenchmarkData
- type CallsValidation
- type Compaction
- type IncreaseRVFunc
- type InterfaceWithCorruptTransformer
- type InterfaceWithPrefixTransformer
- type KeyValidation
- type PrefixTransformer
- func NewPrefixTransformer(prefix []byte, stale bool) *PrefixTransformer
- func (p *PrefixTransformer) GetReadsAndReset() uint64
- func (p *PrefixTransformer) TransformFromStorage(ctx context.Context, data []byte, dataCtx value.Context) ([]byte, bool, error)
- func (p *PrefixTransformer) TransformToStorage(ctx context.Context, data []byte, dataCtx value.Context) ([]byte, error)
- type PrefixTransformerModifier
- type StorageInjectingListErrors
Functions ¶
func CreateList ¶
CreateList will properly create a list using the storage interface.
func CreateObjList ¶
CreateObjList will create a list from the array of objects.
func CreatePodPredicate ¶
func CreatePodPredicate(field fields.Selector, namespaceScoped bool, indexField []string) storage.SelectionPredicate
func DeepEqualSafePodSpec ¶
DeepEqualSafePodSpec returns an example.PodSpec safe for deep-equal operations.
func ExpectContains ¶
func ExpectContinueMatches ¶
func RunBenchmarkStoreList ¶
func RunBenchmarkStoreList(ctx context.Context, b *testing.B, store storage.Interface, data BenchmarkData, useIndex bool)
func RunBenchmarkStoreListCreate ¶
func RunBenchmarkStoreListCreate(ctx context.Context, b *testing.B, store storage.Interface, match metav1.ResourceVersionMatch)
func RunOptionalTestProgressNotify ¶
RunOptionalTestProgressNotify tests ProgressNotify feature of ListOptions. Given this feature is currently not explicitly used by higher layers of Kubernetes (it rather is used by wrappers of storage.Interface to implement its functionalities) this test is currently considered optional.
func RunSendInitialEventsBackwardCompatibility ¶
func RunSendInitialEventsBackwardCompatibility(ctx context.Context, t *testing.T, store storage.Interface)
RunSendInitialEventsBackwardCompatibility test backward compatibility when SendInitialEvents option is set against various implementations. Backward compatibility is defined as RV = "" || RV = "O" and AllowWatchBookmark is set to false. In that case we expect a watch request to be established.
func RunTestClusterScopedWatch ¶
It tests watches of cluster-scoped resources.
func RunTestConditionalDelete ¶
func RunTestConsistentList ¶
func RunTestConsistentList(ctx context.Context, t *testing.T, store storage.Interface, increaseRV IncreaseRVFunc, cacheEnabled, consistentReadsSupported, listFromCacheSnapshot bool)
func RunTestCount ¶
func RunTestCreate ¶
func RunTestCreate(ctx context.Context, t *testing.T, store storage.Interface, validation KeyValidation)
func RunTestCreateWithKeyExist ¶
func RunTestCreateWithTTL ¶
func RunTestDelayedWatchDelivery ¶
func RunTestDeleteTriggerWatch ¶
func RunTestDeleteWithConflict ¶
RunTestDeleteWithConflict tests the case when another conflicting update happened before the delete completed.
func RunTestDeleteWithSuggestion ¶
func RunTestDeleteWithSuggestionAndConflict ¶
func RunTestDeleteWithSuggestionAndConflict(ctx context.Context, t *testing.T, store storage.Interface)
func RunTestDeleteWithSuggestionOfDeletedObject ¶
func RunTestDeleteWithSuggestionOfDeletedObject(ctx context.Context, t *testing.T, store storage.Interface)
func RunTestGet ¶
func RunTestGetListNonRecursive ¶
func RunTestGetListNonRecursive(ctx context.Context, t *testing.T, increaseRV IncreaseRVFunc, store storage.Interface)
func RunTestGetListRecursivePrefix ¶
RunTestGetListRecursivePrefix tests how recursive parameter works for object keys that are prefixes of each other.
func RunTestGuaranteedUpdate ¶
func RunTestGuaranteedUpdate(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer, validation KeyValidation)
func RunTestGuaranteedUpdateChecksStoredData ¶
func RunTestGuaranteedUpdateChecksStoredData(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer)
func RunTestGuaranteedUpdateWithConflict ¶
func RunTestGuaranteedUpdateWithConflict(ctx context.Context, t *testing.T, store storage.Interface)
func RunTestGuaranteedUpdateWithSuggestionAndConflict ¶
func RunTestGuaranteedUpdateWithSuggestionAndConflict(ctx context.Context, t *testing.T, store storage.Interface)
func RunTestGuaranteedUpdateWithTTL ¶
func RunTestList ¶
func RunTestList(ctx context.Context, t *testing.T, store storage.Interface, increaseRV IncreaseRVFunc, ignoreWatchCacheTests bool)
func RunTestListContinuation ¶
func RunTestListContinuation(ctx context.Context, t *testing.T, store storage.Interface, validation CallsValidation)
func RunTestListContinuationWithFilter ¶
func RunTestListContinuationWithFilter(ctx context.Context, t *testing.T, store storage.Interface, validation CallsValidation)
func RunTestListInconsistentContinuation ¶
func RunTestListInconsistentContinuation(ctx context.Context, t *testing.T, store storage.Interface, compaction Compaction)
func RunTestListPaginationRareObject ¶
func RunTestListPaginationRareObject(ctx context.Context, t *testing.T, store storage.Interface, validation CallsValidation)
func RunTestListPaging ¶
func RunTestListResourceVersionMatch ¶
func RunTestListResourceVersionMatch(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer)
func RunTestNamespaceScopedList ¶
func RunTestNamespaceScopedWatch ¶
It tests watch of namespace-scoped resources.
func RunTestOptionalWatchBookmarksWithCorrectResourceVersion ¶
func RunTestOptionalWatchBookmarksWithCorrectResourceVersion(ctx context.Context, t *testing.T, store storage.Interface)
RunOptionalTestWatchBookmarksWithCorrectResourceVersion tests whether bookmark events are sent with correct resource versions. This feature is currently implemented in watch cache layer, so this is optional.
TODO(#109831): ProgressNotify feature is effectively implementing the same
functionality, so we should refactor this functionality to share the same input.
func RunTestPreconditionalDeleteWithOnlySuggestionPass ¶
func RunTestPreconditionalDeleteWithOnlySuggestionPass(ctx context.Context, t *testing.T, store storage.Interface)
RunTestPreconditionalDeleteWithOnlySuggestionPass tests the case of delete with preconditions, when the suggested cachedExistingObject passes the preconditions while the current version does not pass the preconditions.
func RunTestPreconditionalDeleteWithSuggestion ¶
func RunTestPreconditionalDeleteWithSuggestion(ctx context.Context, t *testing.T, store storage.Interface)
func RunTestTransformationFailure ¶
func RunTestTransformationFailure(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer)
func RunTestUnconditionalDelete ¶
func RunTestValidateDeletionWithOnlySuggestionValid ¶
func RunTestValidateDeletionWithOnlySuggestionValid(ctx context.Context, t *testing.T, store storage.Interface)
RunTestValidateDeletionWithOnlySuggestionValid tests the case of delete with validateDeletion function, when the suggested cachedExistingObject passes the validate function while the current version does not pass the validate function.
func RunTestValidateDeletionWithSuggestion ¶
func RunTestValidateDeletionWithSuggestion(ctx context.Context, t *testing.T, store storage.Interface)
func RunTestWatch ¶
func RunTestWatchContextCancel ¶
func RunTestWatchDeleteEventObjectHaveLatestRV ¶
func RunTestWatchDeleteEventObjectHaveLatestRV(ctx context.Context, t *testing.T, store storage.Interface)
func RunTestWatchDispatchBookmarkEvents ¶
func RunTestWatchDispatchBookmarkEvents(ctx context.Context, t *testing.T, store storage.Interface, expectedWatchBookmarks bool)
RunOptionalTestWatchDispatchBookmarkEvents tests whether bookmark events are sent. This feature is currently implemented in watch cache layer, so this is optional.
TODO(#109831): ProgressNotify feature is effectively implementing the same
functionality, so we should refactor this functionality to share the same input.
func RunTestWatchError ¶
func RunTestWatchError(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer)
func RunTestWatchFromNonZero ¶
func RunTestWatchFromZero ¶
func RunTestWatchFromZero(ctx context.Context, t *testing.T, store storage.Interface, compaction Compaction)
RunTestWatchFromZero tests that
- watch from 0 should sync up and grab the object added before
- For testing with etcd, watch from 0 is able to return events for objects whose previous version has been compacted. If testing with cacher, we expect compaction to be nil.
func RunTestWatchInitializationSignal ¶
func RunTestWatchWithUnsafeDelete ¶
func RunTestWatchWithUnsafeDelete(ctx context.Context, t *testing.T, store InterfaceWithCorruptTransformer)
func RunTestWatcherTimeout ¶
func RunWatchErrorIsBlockingFurtherEvents ¶
func RunWatchErrorIsBlockingFurtherEvents(ctx context.Context, t *testing.T, store InterfaceWithPrefixTransformer)
func RunWatchListMatchSingle ¶
func RunWatchSemanticInitialEventsExtended ¶
func RunWatchSemanticInitialEventsExtended(ctx context.Context, t *testing.T, store storage.Interface)
RunWatchSemanticInitialEventsExtended checks if the bookmark event marking the end of the list stream contains the global RV.
note that this scenario differs from the one in RunWatchSemantics by adding the pod to a different ns to advance the global RV
func RunWatchSemantics ¶
RunWatchSemantics test the following cases:
+-----------------+---------------------+-------------------+ | ResourceVersion | AllowWatchBookmarks | SendInitialEvents | +=================+=====================+===================+ | Unset | true/false | true/false | | 0 | true/false | true/false | | 1 | true/false | true/false | | Current | true/false | true/false | +-----------------+---------------------+-------------------+ where: - false indicates the value of the param was set to "false" by a test case - true indicates the value of the param was set to "true" by a test case
func TestCheckNoMoreResultsWithIgnoreFunc ¶
func TestCheckNoMoreResultsWithIgnoreFunc(t *testing.T, w watch.Interface, ignore func(watch.Event) bool)
func TestCheckResultsInStrictOrder ¶
Types ¶
type BenchmarkData ¶
func PrepareBenchchmarkData ¶
func PrepareBenchchmarkData(namespaceCount, podPerNamespaceCount, nodeCount int) (data BenchmarkData)
type CallsValidation ¶
type Compaction ¶
type IncreaseRVFunc ¶
type InterfaceWithCorruptTransformer ¶
type InterfaceWithPrefixTransformer ¶
type InterfaceWithPrefixTransformer interface { storage.Interface UpdatePrefixTransformer(PrefixTransformerModifier) func() }
type KeyValidation ¶
type PrefixTransformer ¶
type PrefixTransformer struct {
// contains filtered or unexported fields
}
PrefixTransformer adds and verifies that all data has the correct prefix on its way in and out.
func NewPrefixTransformer ¶
func NewPrefixTransformer(prefix []byte, stale bool) *PrefixTransformer
func (*PrefixTransformer) GetReadsAndReset ¶
func (p *PrefixTransformer) GetReadsAndReset() uint64
func (*PrefixTransformer) TransformFromStorage ¶
func (p *PrefixTransformer) TransformFromStorage(ctx context.Context, data []byte, dataCtx value.Context) ([]byte, bool, error)
func (*PrefixTransformer) TransformToStorage ¶
func (p *PrefixTransformer) TransformToStorage(ctx context.Context, data []byte, dataCtx value.Context) ([]byte, error)
type PrefixTransformerModifier ¶
type PrefixTransformerModifier func(*PrefixTransformer) value.Transformer
type StorageInjectingListErrors ¶
type StorageInjectingListErrors struct { storage.Interface Errors int // contains filtered or unexported fields }
StorageInjectingListErrors injects a dummy error for first N GetList calls.
func (*StorageInjectingListErrors) ErrorsConsumed ¶
func (s *StorageInjectingListErrors) ErrorsConsumed() (bool, error)
func (*StorageInjectingListErrors) GetList ¶
func (s *StorageInjectingListErrors) GetList(ctx context.Context, key string, opts storage.ListOptions, listObj runtime.Object) error
Source Files ¶
store_benchmarks.go store_tests.go utils.go watcher_tests.go
- Version
- v0.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 38 packages
- Last checked
- 7 hours ago –
Tools for package owners.