util

package
v1.20.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 33 Imported by: 47

Documentation

Index

Constants

View Source
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"
)

Variables

This section is empty.

Functions

func AddTaintToNode added in v1.18.0

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

AddTaintToNode add taints to specific node

func CleanupNodes added in v1.18.0

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

CleanupNodes cleans all nodes which were created during integration test

func CleanupPods added in v1.18.0

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

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

CleanupTest cleans related resources which were created during integration test

func CreateAlgorithmSourceFromPolicy added in v1.18.0

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

CreateAlgorithmSourceFromPolicy creates the schedulerAlgorithmSource from the policy parameter

func GetTolerationSeconds added in v1.18.0

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

GetTolerationSeconds gets the period of time the toleration

func NewMockGCECloud added in v1.11.0

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

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

NodeCopyWithConditions duplicates the ode object with conditions

func NodeReadyStatus added in v1.18.0

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

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

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

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

PodScheduled checks if the pod has been scheduled

func RemoveTaintOffNode added in v1.19.0

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

RemoveTaintOffNode removes a specific taint from a node

func SyncInformerFactory added in v1.19.0

func SyncInformerFactory(testCtx *TestContext)

SyncInformerFactory starts informer and waits for caches to be synced

func UpdateNodeStatus added in v1.18.0

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

UpdateNodeStatus updates the status of node.

func WaitForNodeTaints added in v1.18.0

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

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

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

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

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, podInformer and the shutdown function to stop it.

type TestContext added in v1.18.0

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

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

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

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

func InitTestSchedulerWithOptions added in v1.18.0

func InitTestSchedulerWithOptions(
	t *testing.T,
	testCtx *TestContext,
	policy *schedulerapi.Policy,
	opts ...scheduler.Option,
) *TestContext

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

Jump to

Keyboard shortcuts

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