package utils
import "k8s.io/kubernetes/test/utils"
Index ¶
- Variables
- func AddLabelsToNode(c clientset.Interface, nodeName string, labels map[string]string) error
- func AdmissionWebhookHandler(t *testing.T, admit func(*v1beta1.AdmissionReview) error) http.HandlerFunc
- func CheckDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName, revision, image string) error
- func CreateDeploymentWithRetries(c clientset.Interface, namespace string, obj *apps.Deployment) error
- func CreatePersistentVolumeClaimWithRetries(c clientset.Interface, namespace string, obj *v1.PersistentVolumeClaim) error
- func CreatePersistentVolumeWithRetries(c clientset.Interface, obj *v1.PersistentVolume) error
- func CreatePod(ctx context.Context, client clientset.Interface, namespace string, podCount int, podTemplate PodTemplate) error
- func CreatePodWithPersistentVolume(ctx context.Context, client clientset.Interface, namespace string, claimTemplate *v1.PersistentVolumeClaim, factory volumeFactory, podTemplate PodTemplate, count int, bindVolume bool) error
- func CreatePodWithRetries(c clientset.Interface, namespace string, obj *v1.Pod) error
- func CreateRCWithRetries(c clientset.Interface, namespace string, obj *v1.ReplicationController) error
- func CreateReplicaSetWithRetries(c clientset.Interface, namespace string, obj *apps.ReplicaSet) error
- func CreateServiceWithRetries(c clientset.Interface, namespace string, obj *v1.Service) error
- func DeleteResource(c clientset.Interface, kind schema.GroupKind, namespace, name string, options metav1.DeleteOptions) error
- func DoPrepareNode(ctx context.Context, client clientset.Interface, node *v1.Node, strategy PrepareNodeStrategy) error
- func EncodeCertPEM(cert *x509.Certificate) []byte
- func FailedContainers(pod *v1.Pod) map[string]ContainerFailures
- func GetAllReplicaSets(deployment *apps.Deployment, c clientset.Interface) ([]*apps.ReplicaSet, []*apps.ReplicaSet, *apps.ReplicaSet, error)
- func GetCAdvisorRootDir() (string, error)
- func GetK8sBuildOutputDir(isDockerizedBuild bool, targetArch string) (string, error)
- func GetK8sRootDir() (string, error)
- func GetNewReplicaSet(deployment *apps.Deployment, c clientset.Interface) (*apps.ReplicaSet, error)
- func GetNodeCondition(status *v1.NodeStatus, conditionType v1.NodeConditionType) (int, *v1.NodeCondition)
- func GetOldReplicaSets(deployment *apps.Deployment, c clientset.Interface) ([]*apps.ReplicaSet, []*apps.ReplicaSet, error)
- func LogPodsOfDeployment(c clientset.Interface, deployment *apps.Deployment, rsList []*apps.ReplicaSet, logf LogfFn)
- func LogReplicaSetsOfDeployment(deployment *apps.Deployment, allOldRSs []*apps.ReplicaSet, newRS *apps.ReplicaSet, logf LogfFn)
- func MakePodSpec() v1.PodSpec
- func MakeTempDirOrDie(prefix string, baseDir string) string
- func NewAdmissionWebhookServer(handler http.Handler) (string, func(), error)
- func NewPrivateKey() (*rsa.PrivateKey, error)
- func NewSignedCert(cfg *certutil.Config, key crypto.Signer, caCert *x509.Certificate, caKey crypto.Signer) (*x509.Certificate, error)
- func PodRunningReady(p *v1.Pod) (bool, error)
- func PodRunningReadyOrSucceeded(p *v1.Pod) (bool, error)
- func PodSucceeded(p *v1.Pod) (bool, error)
- func RemoveLabelOffNode(c clientset.Interface, nodeName string, labelKeys []string) error
- func RetryErrorCondition(condition wait.ConditionWithContextFunc) wait.ConditionWithContextFunc
- func RetryWithExponentialBackOff(fn wait.ConditionFunc) error
- func RootDir() (string, error)
- func RunDeployment(ctx context.Context, config DeploymentConfig) error
- func RunPodAndGetNodeName(ctx context.Context, c clientset.Interface, pod *v1.Pod, timeout time.Duration) (string, error)
- func RunRC(ctx context.Context, config RCConfig) error
- func RunReplicaSet(ctx context.Context, config ReplicaSetConfig) error
- func ScaleResourceWithRetries(scalesGetter scaleclient.ScalesGetter, namespace, name string, size uint, gvr schema.GroupVersionResource) error
- func StartPods(c clientset.Interface, replicas int, namespace string, podNamePrefix string, pod v1.Pod, waitForRunning bool, logFunc func(fmt string, args ...interface{})) error
- func TerminatedContainers(pod *v1.Pod) map[string]string
- func UpdateDeploymentWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateDeploymentFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*apps.Deployment, error)
- func UpdateReplicaSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateReplicaSetFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*apps.ReplicaSet, error)
- func VerifyLabelsRemoved(c clientset.Interface, nodeName string, labelKeys []string) error
- func WaitForDeploymentComplete(c clientset.Interface, d *apps.Deployment, logf LogfFn, pollInterval, pollTimeout time.Duration) error
- func WaitForDeploymentCompleteAndCheckRolling(c clientset.Interface, d *apps.Deployment, logf LogfFn, pollInterval, pollTimeout time.Duration) error
- func WaitForDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName string, revision, image string, logf LogfFn, pollInterval, pollTimeout time.Duration) error
- func WaitForDeploymentUpdatedReplicasGTE(c clientset.Interface, ns, deploymentName string, minUpdatedReplicas int32, desiredGeneration int64, pollInterval, pollTimeout time.Duration) error
- func WaitForDeploymentWithCondition(c clientset.Interface, ns, deploymentName, reason string, condType apps.DeploymentConditionType, logf LogfFn, pollInterval, pollTimeout time.Duration) error
- func WaitForEnoughPodsWithLabelRunning(c clientset.Interface, ns string, label labels.Selector, replicas int) error
- func WaitForObservedDeployment(c clientset.Interface, ns, deploymentName string, desiredGeneration int64) error
- func WaitForPodsWithLabelRunning(c clientset.Interface, ns string, label labels.Selector) error
- func WaitRSStable(t *testing.T, clientSet clientset.Interface, rs *apps.ReplicaSet, pollInterval, pollTimeout time.Duration) error
- type AuditAnnotationsFilter
- type AuditEvent
- type ContainerFailures
- type CountToPodStrategy
- type CountToStrategy
- type DeploymentConfig
- type JobConfig
- type LabelNodePrepareStrategy
- func NewLabelNodePrepareStrategy(labelKey string, labelValues ...string) *LabelNodePrepareStrategy
- func (*LabelNodePrepareStrategy) CleanupDependentObjects(ctx context.Context, nodeName string, client clientset.Interface) error
- func (s *LabelNodePrepareStrategy) CleanupNode(ctx context.Context, node *v1.Node) *v1.Node
- func (*LabelNodePrepareStrategy) PrepareDependentObjects(ctx context.Context, node *v1.Node, client clientset.Interface) error
- func (s *LabelNodePrepareStrategy) PreparePatch(*v1.Node) []byte
- type LogfFn
- type MissingEventsReport
- func CheckAuditLines(stream io.Reader, expected []AuditEvent, version schema.GroupVersion) (missingReport *MissingEventsReport, err error)
- func CheckAuditLinesFiltered(stream io.Reader, expected []AuditEvent, version schema.GroupVersion, customAnnotationsFilter AuditAnnotationsFilter) (missingReport *MissingEventsReport, err error)
- func (m *MissingEventsReport) String() string
- type NodeAllocatableStrategy
- func NewNodeAllocatableStrategy(nodeAllocatable map[v1.ResourceName]string, csiNodeAllocatable map[string]*storagev1.VolumeNodeResources, migratedPlugins []string) *NodeAllocatableStrategy
- func (s *NodeAllocatableStrategy) CleanupDependentObjects(ctx context.Context, nodeName string, client clientset.Interface) error
- func (s *NodeAllocatableStrategy) CleanupNode(ctx context.Context, node *v1.Node) *v1.Node
- func (s *NodeAllocatableStrategy) PrepareDependentObjects(ctx context.Context, node *v1.Node, client clientset.Interface) error
- func (s *NodeAllocatableStrategy) PreparePatch(node *v1.Node) []byte
- type PodStore
- func NewPodStore(c clientset.Interface, namespace string, label labels.Selector, field fields.Selector) (*PodStore, error)
- func (s *PodStore) List() []*v1.Pod
- func (s *PodStore) Stop()
- type PodTemplate
- type PrepareNodeStrategy
- type RCConfig
- type RCStartupStatus
- type ReplicaSetConfig
- type RunObjectConfig
- type TestNodePreparer
- type TestPodCreateStrategy
- func NewCreatePodWithPersistentVolumeStrategy(claimTemplate *v1.PersistentVolumeClaim, factory volumeFactory, podTemplate PodTemplate) TestPodCreateStrategy
- func NewCustomCreatePodStrategy(podTemplate PodTemplate) TestPodCreateStrategy
- type TestPodCreator
- func NewTestPodCreator(client clientset.Interface, config *TestPodCreatorConfig) *TestPodCreator
- func (c *TestPodCreator) CreatePods(ctx context.Context) error
- type TestPodCreatorConfig
- func NewTestPodCreatorConfig() *TestPodCreatorConfig
- func (c *TestPodCreatorConfig) AddStrategy( namespace string, podCount int, strategy TestPodCreateStrategy)
- type TrivialNodePrepareStrategy
- func (*TrivialNodePrepareStrategy) CleanupDependentObjects(ctx context.Context, nodeName string, client clientset.Interface) error
- func (*TrivialNodePrepareStrategy) CleanupNode(ctx context.Context, node *v1.Node) *v1.Node
- func (*TrivialNodePrepareStrategy) PrepareDependentObjects(ctx context.Context, node *v1.Node, client clientset.Interface) error
- func (*TrivialNodePrepareStrategy) PreparePatch(*v1.Node) []byte
- type UniqueNodeLabelStrategy
- func NewUniqueNodeLabelStrategy(labelKey string) *UniqueNodeLabelStrategy
- func (*UniqueNodeLabelStrategy) CleanupDependentObjects(ctx context.Context, nodeName string, client clientset.Interface) error
- func (s *UniqueNodeLabelStrategy) CleanupNode(ctx context.Context, node *v1.Node) *v1.Node
- func (*UniqueNodeLabelStrategy) PrepareDependentObjects(ctx context.Context, node *v1.Node, client clientset.Interface) error
- func (s *UniqueNodeLabelStrategy) PreparePatch(*v1.Node) []byte
- type UpdateDeploymentFunc
- type UpdateReplicaSetFunc
Variables ¶
var LocalhostCert = []byte("" /* 1136 byte string literal not displayed */)
LocalhostCert was generated from crypto/tls/generate_cert.go with the following command:
go run generate_cert.go --rsa-bits 2048 --host 127.0.0.1,::1,example.com --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h
var LocalhostKey = []byte("" /* 1676 byte string literal not displayed */)
LocalhostKey is the private key for LocalhostCert.
Functions ¶
func AddLabelsToNode ¶
func AdmissionWebhookHandler ¶
func AdmissionWebhookHandler(t *testing.T, admit func(*v1beta1.AdmissionReview) error) http.HandlerFunc
AdmissionWebhookHandler creates a HandlerFunc that decodes/encodes AdmissionReview and performs given admit function
func CheckDeploymentRevisionAndImage ¶
func CheckDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName, revision, image string) error
CheckDeploymentRevisionAndImage checks if the input deployment's and its new replica set's revision and image are as expected.
func CreateDeploymentWithRetries ¶
func CreateDeploymentWithRetries(c clientset.Interface, namespace string, obj *apps.Deployment) error
func CreatePersistentVolumeClaimWithRetries ¶
func CreatePersistentVolumeClaimWithRetries(c clientset.Interface, namespace string, obj *v1.PersistentVolumeClaim) error
func CreatePersistentVolumeWithRetries ¶
func CreatePersistentVolumeWithRetries(c clientset.Interface, obj *v1.PersistentVolume) error
func CreatePod ¶
func CreatePod(ctx context.Context, client clientset.Interface, namespace string, podCount int, podTemplate PodTemplate) error
func CreatePodWithPersistentVolume ¶
func CreatePodWithPersistentVolume(ctx context.Context, client clientset.Interface, namespace string, claimTemplate *v1.PersistentVolumeClaim, factory volumeFactory, podTemplate PodTemplate, count int, bindVolume bool) error
func CreatePodWithRetries ¶
func CreateRCWithRetries ¶
func CreateRCWithRetries(c clientset.Interface, namespace string, obj *v1.ReplicationController) error
func CreateReplicaSetWithRetries ¶
func CreateReplicaSetWithRetries(c clientset.Interface, namespace string, obj *apps.ReplicaSet) error
func CreateServiceWithRetries ¶
func DeleteResource ¶
func DeleteResource(c clientset.Interface, kind schema.GroupKind, namespace, name string, options metav1.DeleteOptions) error
func DoPrepareNode ¶
func DoPrepareNode(ctx context.Context, client clientset.Interface, node *v1.Node, strategy PrepareNodeStrategy) error
func EncodeCertPEM ¶
func EncodeCertPEM(cert *x509.Certificate) []byte
EncodeCertPEM returns PEM-endcoded certificate data
func FailedContainers ¶
func FailedContainers(pod *v1.Pod) map[string]ContainerFailures
FailedContainers inspects all containers in a pod and returns failure information for containers that have failed or been restarted. A map is returned where the key is the containerID and the value is a struct containing the restart and failure information
func GetAllReplicaSets ¶
func GetAllReplicaSets(deployment *apps.Deployment, c clientset.Interface) ([]*apps.ReplicaSet, []*apps.ReplicaSet, *apps.ReplicaSet, error)
GetAllReplicaSets returns the old and new replica sets targeted by the given Deployment. It gets PodList and ReplicaSetList from client interface. Note that the first set of old replica sets doesn't include the ones with no pods, and the second set of old replica sets include all old replica sets. The third returned value is the new replica set, and it may be nil if it doesn't exist yet.
func GetCAdvisorRootDir ¶
GetCAdvisorRootDir returns the root directory for cAdvisor, if present in the gopath.
func GetK8sBuildOutputDir ¶
GetK8sBuildOutputDir returns the build output directory for k8s For dockerized build, targetArch (eg: 'linux/arm64', 'linux/amd64') must be explicitly specified For non dockerized build, targetArch is ignored
func GetK8sRootDir ¶
GetK8sRootDir returns the root directory for kubernetes, if present in the gopath.
func GetNewReplicaSet ¶
func GetNewReplicaSet(deployment *apps.Deployment, c clientset.Interface) (*apps.ReplicaSet, error)
GetNewReplicaSet returns a replica set that matches the intent of the given deployment; get ReplicaSetList from client interface. Returns nil if the new replica set doesn't exist yet.
func GetNodeCondition ¶
func GetNodeCondition(status *v1.NodeStatus, conditionType v1.NodeConditionType) (int, *v1.NodeCondition)
GetNodeCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.
func GetOldReplicaSets ¶
func GetOldReplicaSets(deployment *apps.Deployment, c clientset.Interface) ([]*apps.ReplicaSet, []*apps.ReplicaSet, error)
GetOldReplicaSets returns the old replica sets targeted by the given Deployment; get PodList and ReplicaSetList from client interface. Note that the first set of old replica sets doesn't include the ones with no pods, and the second set of old replica sets include all old replica sets.
func LogPodsOfDeployment ¶
func LogPodsOfDeployment(c clientset.Interface, deployment *apps.Deployment, rsList []*apps.ReplicaSet, logf LogfFn)
func LogReplicaSetsOfDeployment ¶
func LogReplicaSetsOfDeployment(deployment *apps.Deployment, allOldRSs []*apps.ReplicaSet, newRS *apps.ReplicaSet, logf LogfFn)
func MakePodSpec ¶
func MakeTempDirOrDie ¶
func NewAdmissionWebhookServer ¶
NewAdmissionWebhookServer sets up a webhook server with TLS enabled, returns URL and Close function for the server
func NewPrivateKey ¶
func NewPrivateKey() (*rsa.PrivateKey, error)
NewPrivateKey creates an RSA private key
func NewSignedCert ¶
func NewSignedCert(cfg *certutil.Config, key crypto.Signer, caCert *x509.Certificate, caKey crypto.Signer) (*x509.Certificate, error)
NewSignedCert creates a signed certificate using the given CA certificate and key
func PodRunningReady ¶
PodRunningReady checks whether pod p's phase is running and it has a ready condition of status true.
func PodRunningReadyOrSucceeded ¶
func PodSucceeded ¶
func RemoveLabelOffNode ¶
RemoveLabelOffNode is for cleaning up labels temporarily added to node, won't fail if target label doesn't exist or has been removed.
func RetryErrorCondition ¶
func RetryErrorCondition(condition wait.ConditionWithContextFunc) wait.ConditionWithContextFunc
func RetryWithExponentialBackOff ¶
func RetryWithExponentialBackOff(fn wait.ConditionFunc) error
Utility for retrying the given function with exponential backoff.
func RootDir ¶
RootDir gets the on-disk kubernetes source directory, returning an error is none is found
func RunDeployment ¶
func RunDeployment(ctx context.Context, config DeploymentConfig) error
RunDeployment Launches (and verifies correctness) of a Deployment and will wait for all pods it spawns to become "Running". It's the caller's responsibility to clean up externally (i.e. use the namespace lifecycle for handling Cleanup).
func RunPodAndGetNodeName ¶
func RunPodAndGetNodeName(ctx context.Context, c clientset.Interface, pod *v1.Pod, timeout time.Duration) (string, error)
func RunRC ¶
RunRC Launches (and verifies correctness) of a Replication Controller and will wait for all pods it spawns to become "Running". It's the caller's responsibility to clean up externally (i.e. use the namespace lifecycle for handling Cleanup).
func RunReplicaSet ¶
func RunReplicaSet(ctx context.Context, config ReplicaSetConfig) error
RunReplicaSet launches (and verifies correctness) of a ReplicaSet and waits until all the pods it launches to reach the "Running" state. It's the caller's responsibility to clean up externally (i.e. use the namespace lifecycle for handling Cleanup).
func ScaleResourceWithRetries ¶
func ScaleResourceWithRetries(scalesGetter scaleclient.ScalesGetter, namespace, name string, size uint, gvr schema.GroupVersionResource) error
func StartPods ¶
func StartPods(c clientset.Interface, replicas int, namespace string, podNamePrefix string, pod v1.Pod, waitForRunning bool, logFunc func(fmt string, args ...interface{})) error
Simplified version of RunRC, that does not create RC, but creates plain Pods. Optionally waits for pods to start running (if waitForRunning == true). The number of replicas must be non-zero.
func TerminatedContainers ¶
TerminatedContainers inspects all containers in a pod and returns a map of "container name: termination reason", for all currently terminated containers.
func UpdateDeploymentWithRetries ¶
func UpdateDeploymentWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateDeploymentFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*apps.Deployment, error)
func UpdateReplicaSetWithRetries ¶
func UpdateReplicaSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateReplicaSetFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*apps.ReplicaSet, error)
func VerifyLabelsRemoved ¶
VerifyLabelsRemoved checks if Node for given nodeName does not have any of labels from labelKeys. Return non-nil error if it does.
func WaitForDeploymentComplete ¶
func WaitForDeploymentComplete(c clientset.Interface, d *apps.Deployment, logf LogfFn, pollInterval, pollTimeout time.Duration) error
Waits for the deployment to complete, and don't check if rolling update strategy is broken. Rolling update strategy is used only during a rolling update, and can be violated in other situations, such as shortly after a scaling event or the deployment is just created.
func WaitForDeploymentCompleteAndCheckRolling ¶
func WaitForDeploymentCompleteAndCheckRolling(c clientset.Interface, d *apps.Deployment, logf LogfFn, pollInterval, pollTimeout time.Duration) error
Waits for the deployment to complete, and check rolling update strategy isn't broken at any times. Rolling update strategy should not be broken during a rolling update.
func WaitForDeploymentRevisionAndImage ¶
func WaitForDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName string, revision, image string, logf LogfFn, pollInterval, pollTimeout time.Duration) error
WaitForDeploymentRevisionAndImage waits for the deployment's and its new RS's revision and container image to match the given revision and image. Note that deployment revision and its new RS revision should be updated shortly, so we only wait for 1 minute here to fail early.
func WaitForDeploymentUpdatedReplicasGTE ¶
func WaitForDeploymentUpdatedReplicasGTE(c clientset.Interface, ns, deploymentName string, minUpdatedReplicas int32, desiredGeneration int64, pollInterval, pollTimeout time.Duration) error
WaitForDeploymentUpdatedReplicasGTE waits for given deployment to be observed by the controller and has at least a number of updatedReplicas
func WaitForDeploymentWithCondition ¶
func WaitForDeploymentWithCondition(c clientset.Interface, ns, deploymentName, reason string, condType apps.DeploymentConditionType, logf LogfFn, pollInterval, pollTimeout time.Duration) error
func WaitForEnoughPodsWithLabelRunning ¶
func WaitForEnoughPodsWithLabelRunning(c clientset.Interface, ns string, label labels.Selector, replicas int) error
Wait up to 10 minutes for at least 'replicas' many pods to be Running and at least one matching pod exists. If 'replicas' is < 0, wait for all matching pods running.
func WaitForObservedDeployment ¶
func WaitForObservedDeployment(c clientset.Interface, ns, deploymentName string, desiredGeneration int64) error
func WaitForPodsWithLabelRunning ¶
Wait up to 10 minutes for all matching pods to become Running and at least one matching pod exists.
func WaitRSStable ¶
func WaitRSStable(t *testing.T, clientSet clientset.Interface, rs *apps.ReplicaSet, pollInterval, pollTimeout time.Duration) error
Verify .Status.Replicas is equal to .Spec.Replicas
Types ¶
type AuditAnnotationsFilter ¶
type AuditEvent ¶
type AuditEvent struct { ID types.UID Level auditinternal.Level Stage auditinternal.Stage RequestURI string Verb string Code int32 User string ImpersonatedUser string ImpersonatedGroups string Resource string Namespace string RequestObject bool ResponseObject bool AuthorizeDecision string // The Check functions in this package takes ownerships of these maps. You should // not reference these maps after calling the Check functions. AdmissionWebhookMutationAnnotations map[string]string AdmissionWebhookPatchAnnotations map[string]string // Only populated when a filter is provided to testEventFromInternalFiltered CustomAuditAnnotations map[string]string }
AuditEvent is a simplified representation of an audit event for testing purposes
type ContainerFailures ¶
type ContainerFailures struct { Restarts int // contains filtered or unexported fields }
type CountToPodStrategy ¶
type CountToPodStrategy struct { Count int Strategy TestPodCreateStrategy }
type CountToStrategy ¶
type CountToStrategy struct { Count int Strategy PrepareNodeStrategy }
type DeploymentConfig ¶
type DeploymentConfig struct { RCConfig }
type JobConfig ¶
type JobConfig struct { RCConfig }
type LabelNodePrepareStrategy ¶
type LabelNodePrepareStrategy struct { LabelKey string LabelValues []string // contains filtered or unexported fields }
func NewLabelNodePrepareStrategy ¶
func NewLabelNodePrepareStrategy(labelKey string, labelValues ...string) *LabelNodePrepareStrategy
func (*LabelNodePrepareStrategy) CleanupDependentObjects ¶
func (*LabelNodePrepareStrategy) CleanupDependentObjects(ctx context.Context, nodeName string, client clientset.Interface) error
func (*LabelNodePrepareStrategy) CleanupNode ¶
func (*LabelNodePrepareStrategy) PrepareDependentObjects ¶
func (*LabelNodePrepareStrategy) PrepareDependentObjects(ctx context.Context, node *v1.Node, client clientset.Interface) error
func (*LabelNodePrepareStrategy) PreparePatch ¶
func (s *LabelNodePrepareStrategy) PreparePatch(*v1.Node) []byte
type LogfFn ¶
type LogfFn func(format string, args ...interface{})
type MissingEventsReport ¶
type MissingEventsReport struct { FirstEventChecked *auditinternal.Event LastEventChecked *auditinternal.Event NumEventsChecked int MissingEvents []AuditEvent AllEvents []AuditEvent }
MissingEventsReport provides an analysis if any events are missing
func CheckAuditLines ¶
func CheckAuditLines(stream io.Reader, expected []AuditEvent, version schema.GroupVersion) (missingReport *MissingEventsReport, err error)
CheckAuditLines searches the audit log for the expected audit lines.
func CheckAuditLinesFiltered ¶
func CheckAuditLinesFiltered(stream io.Reader, expected []AuditEvent, version schema.GroupVersion, customAnnotationsFilter AuditAnnotationsFilter) (missingReport *MissingEventsReport, err error)
CheckAuditLinesFiltered searches the audit log for the expected audit lines, customAnnotationsFilter controls which audit annotations are added to AuditEvent.CustomAuditAnnotations. If the customAnnotationsFilter is nil, AuditEvent.CustomAuditAnnotations will be empty.
func (*MissingEventsReport) String ¶
func (m *MissingEventsReport) String() string
String returns a human readable string representation of the report
type NodeAllocatableStrategy ¶
type NodeAllocatableStrategy struct { // Node.status.allocatable to fill to all nodes. NodeAllocatable map[v1.ResourceName]string // Map <driver_name> -> VolumeNodeResources to fill into csiNode.spec.drivers[<driver_name>]. CsiNodeAllocatable map[string]*storagev1.VolumeNodeResources // List of in-tree volume plugins migrated to CSI. MigratedPlugins []string }
NodeAllocatableStrategy fills node.status.allocatable and csiNode.spec.drivers[*].allocatable. csiNode is created if it does not exist. On cleanup, any csiNode.spec.drivers[*].allocatable is set to nil.
func NewNodeAllocatableStrategy ¶
func NewNodeAllocatableStrategy(nodeAllocatable map[v1.ResourceName]string, csiNodeAllocatable map[string]*storagev1.VolumeNodeResources, migratedPlugins []string) *NodeAllocatableStrategy
func (*NodeAllocatableStrategy) CleanupDependentObjects ¶
func (s *NodeAllocatableStrategy) CleanupDependentObjects(ctx context.Context, nodeName string, client clientset.Interface) error
func (*NodeAllocatableStrategy) CleanupNode ¶
func (*NodeAllocatableStrategy) PrepareDependentObjects ¶
func (s *NodeAllocatableStrategy) PrepareDependentObjects(ctx context.Context, node *v1.Node, client clientset.Interface) error
func (*NodeAllocatableStrategy) PreparePatch ¶
func (s *NodeAllocatableStrategy) PreparePatch(node *v1.Node) []byte
type PodStore ¶
type PodStore struct { cache.Store Reflector *cache.Reflector // contains filtered or unexported fields }
Convenient wrapper around cache.Store that returns list of v1.Pod instead of interface{}.
func NewPodStore ¶
func NewPodStore(c clientset.Interface, namespace string, label labels.Selector, field fields.Selector) (*PodStore, error)
func (*PodStore) List ¶
func (*PodStore) Stop ¶
func (s *PodStore) Stop()
type PodTemplate ¶
type PodTemplate interface { // GetPodTemplate returns a pod template for one out of many different pods. // Pods with numbers in the range [index, index+count-1] will be created // based on what GetPodTemplate returns. It gets called multiple times // with a fixed index and increasing count parameters. This number can, // but doesn't have to be, used to modify parts of the pod spec like // for example a named reference to some other object. GetPodTemplate(index, count int) (*v1.Pod, error) }
PodTemplate is responsible for creating a v1.Pod instance that is ready to be sent to the API server.
func StaticPodTemplate ¶
func StaticPodTemplate(pod *v1.Pod) PodTemplate
StaticPodTemplate returns an implementation of PodTemplate for a fixed pod that is the same regardless of the index.
type PrepareNodeStrategy ¶
type PrepareNodeStrategy interface { // Modify pre-created Node objects before the test starts. PreparePatch(node *v1.Node) []byte // Create or modify any objects that depend on the node before the test starts. // Caller will re-try when http.StatusConflict error is returned. PrepareDependentObjects(ctx context.Context, node *v1.Node, client clientset.Interface) error // Clean up any node modifications after the test finishes. CleanupNode(ctx context.Context, node *v1.Node) *v1.Node // Clean up any objects that depend on the node after the test finishes. // Caller will re-try when http.StatusConflict error is returned. CleanupDependentObjects(ctx context.Context, nodeName string, client clientset.Interface) error }
type RCConfig ¶
type RCConfig struct { Affinity *v1.Affinity Client clientset.Interface ScalesGetter scaleclient.ScalesGetter Image string Command []string Name string Namespace string PollInterval time.Duration Timeout time.Duration PodStatusFile *os.File Replicas int CpuRequest int64 // millicores CpuLimit int64 // millicores MemRequest int64 // bytes MemLimit int64 // bytes GpuLimit int64 // count ReadinessProbe *v1.Probe DNSPolicy *v1.DNSPolicy PriorityClassName string TerminationGracePeriodSeconds *int64 Lifecycle *v1.Lifecycle SchedulerName string // Env vars, set the same for every pod. Env map[string]string // Extra labels and annotations added to every pod. Labels map[string]string Annotations map[string]string // Node selector for pods in the RC. NodeSelector map[string]string // Tolerations for pods in the RC. Tolerations []v1.Toleration // Ports to declare in the container (map of name to containerPort). Ports map[string]int // Ports to declare in the container as host and container ports. HostPorts map[string]int Volumes []v1.Volume VolumeMounts []v1.VolumeMount // Pointer to a list of pods; if non-nil, will be set to a list of pods // created by this RC by RunRC. CreatedPods *[]*v1.Pod // Maximum allowable container failures. If exceeded, RunRC returns an error. // Defaults to replicas*0.1 if unspecified. MaxContainerFailures *int // Maximum allowed pod deletions count. If exceeded, RunRC returns an error. // Defaults to 0. MaxAllowedPodDeletions int // If set to false starting RC will print progress, otherwise only errors will be printed. Silent bool // If set this function will be used to print log lines instead of klog. LogFunc func(fmt string, args ...interface{}) // If set those functions will be used to gather data from Nodes - in integration tests where no // kubelets are running those variables should be nil. NodeDumpFunc func(ctx context.Context, c clientset.Interface, nodeNames []string, logFunc func(fmt string, args ...interface{})) ContainerDumpFunc func(ctx context.Context, c clientset.Interface, ns string, logFunc func(ftm string, args ...interface{})) // Names of the secrets and configmaps to mount. SecretNames []string ConfigMapNames []string ServiceAccountTokenProjections int // Additional containers to run in the pod AdditionalContainers []v1.Container // Security context for created pods SecurityContext *v1.SecurityContext }
func (*RCConfig) RCConfigLog ¶
type RCStartupStatus ¶
type RCStartupStatus struct { Expected int Terminating int Running int RunningButNotReady int Waiting int Pending int Scheduled int Unknown int Inactive int FailedContainers int Created []*v1.Pod ContainerRestartNodes sets.String }
func (*RCStartupStatus) String ¶
func (s *RCStartupStatus) String(name string) string
type ReplicaSetConfig ¶
type ReplicaSetConfig struct { RCConfig }
type RunObjectConfig ¶
type RunObjectConfig interface { Run() error GetName() string GetNamespace() string GetKind() schema.GroupKind GetClient() clientset.Interface GetScalesGetter() scaleclient.ScalesGetter SetClient(clientset.Interface) SetScalesClient(scaleclient.ScalesGetter) GetReplicas() int GetLabelValue(string) (string, bool) GetGroupResource() schema.GroupResource GetGroupVersionResource() schema.GroupVersionResource }
type TestNodePreparer ¶
type TestNodePreparer interface { PrepareNodes(ctx context.Context, nextNodeIndex int) error CleanupNodes(ctx context.Context) error }
type TestPodCreateStrategy ¶
type TestPodCreateStrategy func(ctx context.Context, client clientset.Interface, namespace string, podCount int) error
func NewCreatePodWithPersistentVolumeStrategy ¶
func NewCreatePodWithPersistentVolumeStrategy(claimTemplate *v1.PersistentVolumeClaim, factory volumeFactory, podTemplate PodTemplate) TestPodCreateStrategy
func NewCustomCreatePodStrategy ¶
func NewCustomCreatePodStrategy(podTemplate PodTemplate) TestPodCreateStrategy
type TestPodCreator ¶
type TestPodCreator struct { Client clientset.Interface // namespace -> count -> strategy Config *TestPodCreatorConfig }
func NewTestPodCreator ¶
func NewTestPodCreator(client clientset.Interface, config *TestPodCreatorConfig) *TestPodCreator
func (*TestPodCreator) CreatePods ¶
func (c *TestPodCreator) CreatePods(ctx context.Context) error
type TestPodCreatorConfig ¶
type TestPodCreatorConfig map[string][]CountToPodStrategy
func NewTestPodCreatorConfig ¶
func NewTestPodCreatorConfig() *TestPodCreatorConfig
func (*TestPodCreatorConfig) AddStrategy ¶
func (c *TestPodCreatorConfig) AddStrategy( namespace string, podCount int, strategy TestPodCreateStrategy)
type TrivialNodePrepareStrategy ¶
type TrivialNodePrepareStrategy struct{}
func (*TrivialNodePrepareStrategy) CleanupDependentObjects ¶
func (*TrivialNodePrepareStrategy) CleanupDependentObjects(ctx context.Context, nodeName string, client clientset.Interface) error
func (*TrivialNodePrepareStrategy) CleanupNode ¶
func (*TrivialNodePrepareStrategy) PrepareDependentObjects ¶
func (*TrivialNodePrepareStrategy) PrepareDependentObjects(ctx context.Context, node *v1.Node, client clientset.Interface) error
func (*TrivialNodePrepareStrategy) PreparePatch ¶
func (*TrivialNodePrepareStrategy) PreparePatch(*v1.Node) []byte
type UniqueNodeLabelStrategy ¶
type UniqueNodeLabelStrategy struct { LabelKey string }
UniqueNodeLabelStrategy sets a unique label for each node.
func NewUniqueNodeLabelStrategy ¶
func NewUniqueNodeLabelStrategy(labelKey string) *UniqueNodeLabelStrategy
func (*UniqueNodeLabelStrategy) CleanupDependentObjects ¶
func (*UniqueNodeLabelStrategy) CleanupDependentObjects(ctx context.Context, nodeName string, client clientset.Interface) error
func (*UniqueNodeLabelStrategy) CleanupNode ¶
func (*UniqueNodeLabelStrategy) PrepareDependentObjects ¶
func (*UniqueNodeLabelStrategy) PrepareDependentObjects(ctx context.Context, node *v1.Node, client clientset.Interface) error
func (*UniqueNodeLabelStrategy) PreparePatch ¶
func (s *UniqueNodeLabelStrategy) PreparePatch(*v1.Node) []byte
type UpdateDeploymentFunc ¶
type UpdateDeploymentFunc func(d *apps.Deployment)
type UpdateReplicaSetFunc ¶
type UpdateReplicaSetFunc func(d *apps.ReplicaSet)
Source Files ¶
admission_webhook.go audit.go conditions.go create_resources.go delete_resources.go density_utils.go deployment.go node.go paths.go pki_helpers.go pod_store.go replicaset.go runners.go tmpdir.go update_resources.go
Directories ¶
Path | Synopsis |
---|---|
test/utils/apiserver | |
test/utils/crd | |
test/utils/format | Package format is an extension of Gomega's format package which improves printing of objects that can be serialized well as YAML, like the structs in the Kubernetes API. |
test/utils/harness | |
test/utils/image | |
test/utils/junit | Package junit provides data structures to allow easy XML encoding and decoding of JUnit test results. |
test/utils/ktesting | Package ktesting is a wrapper around k8s.io/klog/v2/ktesting. |
test/utils/ktesting/examples | |
test/utils/ktesting/examples/gomega | The tests will fail and therefore are excluded from normal "make test" via the "example" build tag. |
test/utils/ktesting/examples/logging | The tests will fail and therefore are excluded from normal "make test" via the "example" build tag. |
test/utils/ktesting/examples/with_ktesting | The tests will fail and therefore are excluded from normal "make test" via the "example" build tag. |
test/utils/ktesting/examples/without_ktesting | The tests will fail and therefore are excluded from normal "make test" via the "example" build tag. |
test/utils/ktesting/initoption | |
test/utils/ktesting/internal | |
test/utils/kubeconfig | |
test/utils/oidc | |
test/utils/oidc/handlers |
- Version
- v1.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 65 packages
- Last checked
- 3 hours ago –
Tools for package owners.