kubernetesk8s.io/kubernetes/test/integration/util Index | Files

package util

import "k8s.io/kubernetes/test/integration/util"

Index

Constants

const (
	// TestProjectID is the project id used for creating NewMockGCECloud
	TestProjectID = "test-project"
	// TestNetworkProjectID is the network project id for creating NewMockGCECloud
	TestNetworkProjectID = "net-test-project"
	// TestRegion is the region for creating NewMockGCECloud
	TestRegion = "test-region"
	// TestZone is the zone for creating NewMockGCECloud
	TestZone = "test-zone"
	// TestNetworkName is the network name for creating NewMockGCECloud
	TestNetworkName = "test-network"
	// TestSubnetworkName is the sub network name for creating NewMockGCECloud
	TestSubnetworkName = "test-sub-network"
	// TestSecondaryRangeName is the secondary range name for creating NewMockGCECloud
	TestSecondaryRangeName = "test-secondary-range"
)

Functions

func AddTaintToNode

func AddTaintToNode(cs clientset.Interface, nodeName string, taint v1.Taint) error

AddTaintToNode add taints to specific node

func CleanupNodes

func CleanupNodes(cs clientset.Interface, t *testing.T)

CleanupNodes cleans all nodes which were created during integration test

func CleanupPods

func CleanupPods(cs clientset.Interface, t *testing.T, pods []*v1.Pod)

CleanupPods deletes the given pods and waits for them to be actually deleted.

func CleanupTest

func CleanupTest(t *testing.T, testCtx *TestContext)

CleanupTest cleans related resources which were created during integration test

func CreateAlgorithmSourceFromPolicy

func CreateAlgorithmSourceFromPolicy(policy *schedulerapi.Policy, clientSet clientset.Interface) schedulerapi.SchedulerAlgorithmSource

CreateAlgorithmSourceFromPolicy creates the schedulerAlgorithmSource from the policy parameter

func GetTolerationSeconds

func GetTolerationSeconds(tolerations []v1.Toleration) (int64, error)

GetTolerationSeconds gets the period of time the toleration

func NewMockGCECloud

func NewMockGCECloud(cloud cloud.Cloud) (*gce.Cloud, error)

NewMockGCECloud returns a handle to a Cloud instance that is served by a mock http server

func NodeCopyWithConditions

func NodeCopyWithConditions(node *v1.Node, conditions []v1.NodeCondition) *v1.Node

NodeCopyWithConditions duplicates the ode object with conditions

func NodeReadyStatus

func NodeReadyStatus(conditions []v1.NodeCondition) (v1.ConditionStatus, error)

NodeReadyStatus returns the status of first condition with type NodeReady. If none of the condition is of type NodeReady, returns an error.

func NodeTainted

func NodeTainted(cs clientset.Interface, nodeName string, taints []v1.Taint) wait.ConditionFunc

NodeTainted return a condition function that returns true if the given node contains the taints.

func PodDeleted

func PodDeleted(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc

PodDeleted returns true if a pod is not found in the given namespace.

func PodScheduled

func PodScheduled(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc

PodScheduled checks if the pod has been scheduled

func SyncInformerFactory

func SyncInformerFactory(testCtx *TestContext)

SyncInformerFactory starts informer and waits for caches to be synced

func UpdateNodeStatus

func UpdateNodeStatus(cs clientset.Interface, node *v1.Node) error

UpdateNodeStatus updates the status of node.

func WaitForNodeTaints

func WaitForNodeTaints(cs clientset.Interface, node *v1.Node, taints []v1.Taint) error

WaitForNodeTaints waits for a node to have the target taints and returns an error if it does not have taints within the given timeout.

func WaitForPodToSchedule

func WaitForPodToSchedule(cs clientset.Interface, pod *v1.Pod) error

WaitForPodToSchedule waits for a pod to get scheduled and returns an error if it does not get scheduled within the timeout duration (30 seconds).

func WaitForPodToScheduleWithTimeout

func WaitForPodToScheduleWithTimeout(cs clientset.Interface, pod *v1.Pod, timeout time.Duration) error

WaitForPodToScheduleWithTimeout waits for a pod to get scheduled and returns an error if it does not scheduled within the given timeout.

func WaitForSchedulerCacheCleanup

func WaitForSchedulerCacheCleanup(sched *scheduler.Scheduler, t *testing.T)

WaitForSchedulerCacheCleanup waits for cleanup of scheduler's cache to complete

Types

type ShutdownFunc

type ShutdownFunc func()

ShutdownFunc represents the function handle to be called, typically in a defer handler, to shutdown a running module

func StartApiserver

func StartApiserver() (string, ShutdownFunc)

StartApiserver starts a local API server for testing and returns the handle to the URL and the shutdown function to stop it.

func StartFakePVController

func StartFakePVController(clientSet clientset.Interface) ShutdownFunc

StartFakePVController is a simplified pv controller logic that sets PVC VolumeName and annotation for each PV binding. TODO(mborsz): Use a real PV controller here.

func StartScheduler

StartScheduler configures and starts a scheduler given a handle to the clientSet interface and event broadcaster. It returns the running scheduler and the shutdown function to stop it.

type TestContext

type TestContext struct {
	CloseFn         framework.CloseFunc
	HTTPServer      *httptest.Server
	NS              *v1.Namespace
	ClientSet       *clientset.Clientset
	InformerFactory informers.SharedInformerFactory
	Scheduler       *scheduler.Scheduler
	Ctx             context.Context
	CancelFn        context.CancelFunc
}

TestContext store necessary context info

func InitTestMaster

func InitTestMaster(t *testing.T, nsPrefix string, admission admission.Interface) *TestContext

InitTestMaster initializes a test environment and creates a master with default configuration.

func InitTestScheduler

func InitTestScheduler(
	t *testing.T,
	testCtx *TestContext,
	setPodInformer bool,
	policy *schedulerapi.Policy,
) *TestContext

InitTestScheduler initializes a test environment and creates a scheduler with default configuration.

func InitTestSchedulerWithOptions

func InitTestSchedulerWithOptions(
	t *testing.T,
	testCtx *TestContext,
	setPodInformer bool,
	policy *schedulerapi.Policy,
	resyncPeriod time.Duration,
	opts ...scheduler.Option,
) *TestContext

InitTestSchedulerWithOptions initializes a test environment and creates a scheduler with default configuration and other options.

Source Files

cloud.go util.go

Version
v1.19.0-beta.0
Published
May 19, 2020
Platform
js/wasm
Imports
33 packages
Last checked
26 seconds ago

Tools for package owners.