common

package
v0.0.0-...-05e2fc7 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitRefContextKey = ContextKey("gitRef")
)

Variables

View Source
var (
	CleanableObjects = []functional.Pair[client.Object, client.ObjectList]{
		{First: &v1.Pod{}, Second: &v1.PodList{}},
		{First: &appsv1.Deployment{}, Second: &appsv1.DeploymentList{}},
		{First: &appsv1.DaemonSet{}, Second: &appsv1.DaemonSetList{}},
		{First: &policyv1.PodDisruptionBudget{}, Second: &policyv1.PodDisruptionBudgetList{}},
		{First: &v1.PersistentVolumeClaim{}, Second: &v1.PersistentVolumeClaimList{}},
		{First: &v1.PersistentVolume{}, Second: &v1.PersistentVolumeList{}},
		{First: &storagev1.StorageClass{}, Second: &storagev1.StorageClassList{}},
		{First: &v1alpha5.Provisioner{}, Second: &v1alpha5.ProvisionerList{}},
		{First: &v1.LimitRange{}, Second: &v1.LimitRangeList{}},
		{First: &schedulingv1.PriorityClass{}, Second: &schedulingv1.PriorityClassList{}},
	}
	// Delete objects with Karpenter finalizers separately. Executing delete calls on all of these objects at once
	// may be grouped as DeleteCollection requests, which have a lower timeout than individual delete calls (before k8s 1.27).
	// Separating them out diminishes the chance of running into timeouts when doing cleanup for tests of high scale.
	// https://github.com/kubernetes/kubernetes/pull/115341
	FinalizableObjects = []functional.Pair[client.Object, client.ObjectList]{
		{First: &v1.Node{}, Second: &v1.NodeList{}},
		{First: &v1alpha5.Machine{}, Second: &v1alpha5.MachineList{}},
	}
)

Functions

func NewClient

func NewClient(config *rest.Config) (client.Client, error)

func NewConfig

func NewConfig() *rest.Config

func NodeNames

func NodeNames(nodes []*v1.Node) []string

Types

type ContextKey

type ContextKey string

type Environment

type Environment struct {
	context.Context

	Client     client.Client
	Config     *rest.Config
	KubeClient kubernetes.Interface
	Monitor    *Monitor

	StartingNodeCount int
}

func NewEnvironment

func NewEnvironment(t *testing.T) *Environment

func (*Environment) AfterEach

func (env *Environment) AfterEach()

func (*Environment) BeforeEach

func (env *Environment) BeforeEach()

nolint:gocyclo

func (*Environment) Cleanup

func (env *Environment) Cleanup()

func (*Environment) CleanupObjects

func (env *Environment) CleanupObjects(cleanableObjects ...functional.Pair[client.Object, client.ObjectList])

func (*Environment) EventuallyExpectAvgUtilization

func (env *Environment) EventuallyExpectAvgUtilization(resource v1.ResourceName, comparator string, value float64)

func (*Environment) EventuallyExpectCreatedMachineCount

func (env *Environment) EventuallyExpectCreatedMachineCount(comparator string, count int) []*v1alpha5.Machine

func (*Environment) EventuallyExpectCreatedNodeCount

func (env *Environment) EventuallyExpectCreatedNodeCount(comparator string, count int) []*v1.Node

func (*Environment) EventuallyExpectDeletedNodeCount

func (env *Environment) EventuallyExpectDeletedNodeCount(comparator string, count int) []*v1.Node

func (*Environment) EventuallyExpectDeletedNodeCountWithSelector

func (env *Environment) EventuallyExpectDeletedNodeCountWithSelector(comparator string, count int, selector labels.Selector) []*v1.Node

func (*Environment) EventuallyExpectHealthy

func (env *Environment) EventuallyExpectHealthy(pods ...*v1.Pod)

func (*Environment) EventuallyExpectHealthyPodCount

func (env *Environment) EventuallyExpectHealthyPodCount(selector labels.Selector, numPods int)

func (*Environment) EventuallyExpectHealthyPodCountWithTimeout

func (env *Environment) EventuallyExpectHealthyPodCountWithTimeout(timeout time.Duration, selector labels.Selector, numPods int)

func (*Environment) EventuallyExpectHealthyWithTimeout

func (env *Environment) EventuallyExpectHealthyWithTimeout(timeout time.Duration, pods ...*v1.Pod)

func (*Environment) EventuallyExpectInitializedNodeCount

func (env *Environment) EventuallyExpectInitializedNodeCount(comparator string, count int) []*v1.Node

func (*Environment) EventuallyExpectKarpenterRestarted

func (env *Environment) EventuallyExpectKarpenterRestarted()

func (*Environment) EventuallyExpectMachinesReady

func (env *Environment) EventuallyExpectMachinesReady(machines ...*v1alpha5.Machine)

func (*Environment) EventuallyExpectMinUtilization

func (env *Environment) EventuallyExpectMinUtilization(resource v1.ResourceName, comparator string, value float64)

func (*Environment) EventuallyExpectNodeCount

func (env *Environment) EventuallyExpectNodeCount(comparator string, count int) []*v1.Node

func (*Environment) EventuallyExpectNodeCountWithSelector

func (env *Environment) EventuallyExpectNodeCountWithSelector(comparator string, count int, selector labels.Selector) []*v1.Node

func (*Environment) EventuallyExpectNotFound

func (env *Environment) EventuallyExpectNotFound(objects ...client.Object)

func (*Environment) EventuallyExpectNotFoundAssertion

func (env *Environment) EventuallyExpectNotFoundAssertion(objects ...client.Object) AsyncAssertion

func (*Environment) EventuallyExpectNotFoundAssertionWithOffset

func (env *Environment) EventuallyExpectNotFoundAssertionWithOffset(offset int, objects ...client.Object) AsyncAssertion

func (*Environment) EventuallyExpectNotFoundWithOffset

func (env *Environment) EventuallyExpectNotFoundWithOffset(offset int, objects ...client.Object)

func (*Environment) EventuallyExpectPendingPodCount

func (env *Environment) EventuallyExpectPendingPodCount(selector labels.Selector, numPods int)

func (*Environment) EventuallyExpectRollout

func (env *Environment) EventuallyExpectRollout(name, namespace string)

func (*Environment) ExpectActiveKarpenterPod

func (env *Environment) ExpectActiveKarpenterPod() *v1.Pod

func (*Environment) ExpectActiveKarpenterPodName

func (env *Environment) ExpectActiveKarpenterPodName() string

func (*Environment) ExpectCABundle

func (env *Environment) ExpectCABundle() string

func (*Environment) ExpectCleanCluster

func (env *Environment) ExpectCleanCluster()

func (*Environment) ExpectConfigMapDataOverridden

func (env *Environment) ExpectConfigMapDataOverridden(key types.NamespacedName, data ...map[string]string) (changed bool)

func (*Environment) ExpectConfigMapDataReplaced

func (env *Environment) ExpectConfigMapDataReplaced(key types.NamespacedName, data ...map[string]string) (changed bool)

func (*Environment) ExpectConfigMapExists

func (env *Environment) ExpectConfigMapExists(key types.NamespacedName) *v1.ConfigMap

func (*Environment) ExpectCreated

func (env *Environment) ExpectCreated(objects ...client.Object)

func (*Environment) ExpectCreatedNodeCount

func (env *Environment) ExpectCreatedNodeCount(comparator string, count int) []*v1.Node

func (*Environment) ExpectCreatedOrUpdated

func (env *Environment) ExpectCreatedOrUpdated(objects ...client.Object)

func (*Environment) ExpectCreatedWithOffset

func (env *Environment) ExpectCreatedWithOffset(offset int, objects ...client.Object)

func (*Environment) ExpectDaemonSetEnvironmentVariableUpdated

func (env *Environment) ExpectDaemonSetEnvironmentVariableUpdated(obj client.ObjectKey, name, value string)

func (*Environment) ExpectDaemonSetEnvironmentVariableUpdatedWithOffset

func (env *Environment) ExpectDaemonSetEnvironmentVariableUpdatedWithOffset(offset int, obj client.ObjectKey, name, value string)

func (*Environment) ExpectDeleted

func (env *Environment) ExpectDeleted(objects ...client.Object)

func (*Environment) ExpectDeletedWithOffset

func (env *Environment) ExpectDeletedWithOffset(offset int, objects ...client.Object)

func (*Environment) ExpectExists

func (env *Environment) ExpectExists(obj client.Object)

func (*Environment) ExpectKarpenterPods

func (env *Environment) ExpectKarpenterPods() []*v1.Pod

func (*Environment) ExpectNoCrashes

func (env *Environment) ExpectNoCrashes()

func (*Environment) ExpectPodENIDisabled

func (env *Environment) ExpectPodENIDisabled()

func (*Environment) ExpectPodENIEnabled

func (env *Environment) ExpectPodENIEnabled()

func (*Environment) ExpectPrefixDelegationDisabled

func (env *Environment) ExpectPrefixDelegationDisabled()

func (*Environment) ExpectPrefixDelegationEnabled

func (env *Environment) ExpectPrefixDelegationEnabled()

func (*Environment) ExpectSettings

func (env *Environment) ExpectSettings() *v1.ConfigMap

ExpectSettings gets the karpenter-global-settings ConfigMap

func (*Environment) ExpectSettingsOverridden

func (env *Environment) ExpectSettingsOverridden(data ...map[string]string)

ExpectSettingsOverridden overrides specific values specified through data. It only overrides or inserts the specific values specified and does not upsert any of the existing data

func (*Environment) ExpectSettingsReplaced

func (env *Environment) ExpectSettingsReplaced(data ...map[string]string)

ExpectSettingsReplaced performs a full replace of the settings, replacing the existing data with the data passed through

func (*Environment) ExpectUniqueNodeNames

func (env *Environment) ExpectUniqueNodeNames(selector labels.Selector, uniqueNames int)

func (*Environment) ExpectUpdated

func (env *Environment) ExpectUpdated(objects ...client.Object)

func (*Environment) ExpectUpdatedWithOffset

func (env *Environment) ExpectUpdatedWithOffset(offset int, objects ...client.Object)

func (*Environment) GetDaemonSetCount

func (env *Environment) GetDaemonSetCount(prov *v1alpha5.Provisioner) int

func (*Environment) GetNode

func (env *Environment) GetNode(nodeName string) v1.Node

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor is used to monitor the cluster state during a running test

func NewMonitor

func NewMonitor(ctx context.Context, kubeClient client.Client) *Monitor

func (*Monitor) AvgUtilization

func (m *Monitor) AvgUtilization(resource v1.ResourceName) float64

func (*Monitor) CreatedNodeCount

func (m *Monitor) CreatedNodeCount() int

CreatedNodeCount returns the number of nodes created since the last reset

func (*Monitor) CreatedNodes

func (m *Monitor) CreatedNodes() []*v1.Node

CreatedNodes returns the nodes that have been created since the last reset (essentially Nodes - NodesAtReset)

func (*Monitor) DeletedNodes

func (m *Monitor) DeletedNodes() []*v1.Node

DeletedNodes returns the nodes that have been deleted since the last reset (essentially NodesAtReset - Nodes)

func (*Monitor) MinUtilization

func (m *Monitor) MinUtilization(resource v1.ResourceName) float64

func (*Monitor) NodeCount

func (m *Monitor) NodeCount() int

NodeCount returns the current number of nodes

func (*Monitor) NodeCountAtReset

func (m *Monitor) NodeCountAtReset() int

NodeCountAtReset returns the number of nodes that were running when the monitor was last reset, typically at the beginning of a test

func (*Monitor) Nodes

func (m *Monitor) Nodes() []*v1.Node

Nodes returns all the nodes on the cluster

func (*Monitor) NodesAtReset

func (m *Monitor) NodesAtReset() []*v1.Node

NodesAtReset returns a slice of nodes that the monitor saw at the last reset

func (*Monitor) PendingPods

func (m *Monitor) PendingPods(selector labels.Selector) []*v1.Pod

PendingPods returns the number of pending pods matching the given selector

func (*Monitor) PendingPodsCount

func (m *Monitor) PendingPodsCount(selector labels.Selector) int

func (*Monitor) Reset

func (m *Monitor) Reset()

Reset resets the cluster monitor prior to running a test.

func (*Monitor) RestartCount

func (m *Monitor) RestartCount() map[string]int

RestartCount returns the containers and number of restarts for that container for all containers in the pods in the given namespace

func (*Monitor) RunningPods

func (m *Monitor) RunningPods(selector labels.Selector) []*v1.Pod

RunningPods returns the number of running pods matching the given selector

func (*Monitor) RunningPodsCount

func (m *Monitor) RunningPodsCount(selector labels.Selector) int

Jump to

Keyboard shortcuts

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