Commit 8091c797 authored by Michelle Au's avatar Michelle Au

Integration and e2e tests

parent 01d83fa1
...@@ -239,6 +239,7 @@ type FakeVolumePlugin struct { ...@@ -239,6 +239,7 @@ type FakeVolumePlugin struct {
VolumeLimits map[string]int64 VolumeLimits map[string]int64
VolumeLimitsError error VolumeLimitsError error
LimitKey string LimitKey string
ProvisionDelaySeconds int
Mounters []*FakeVolume Mounters []*FakeVolume
Unmounters []*FakeVolume Unmounters []*FakeVolume
...@@ -437,7 +438,7 @@ func (plugin *FakeVolumePlugin) NewProvisioner(options VolumeOptions) (Provision ...@@ -437,7 +438,7 @@ func (plugin *FakeVolumePlugin) NewProvisioner(options VolumeOptions) (Provision
plugin.Lock() plugin.Lock()
defer plugin.Unlock() defer plugin.Unlock()
plugin.LastProvisionerOptions = options plugin.LastProvisionerOptions = options
return &FakeProvisioner{options, plugin.Host}, nil return &FakeProvisioner{options, plugin.Host, plugin.ProvisionDelaySeconds}, nil
} }
func (plugin *FakeVolumePlugin) GetAccessModes() []v1.PersistentVolumeAccessMode { func (plugin *FakeVolumePlugin) GetAccessModes() []v1.PersistentVolumeAccessMode {
...@@ -781,6 +782,7 @@ func (fd *FakeDeleter) GetPath() string { ...@@ -781,6 +782,7 @@ func (fd *FakeDeleter) GetPath() string {
type FakeProvisioner struct { type FakeProvisioner struct {
Options VolumeOptions Options VolumeOptions
Host VolumeHost Host VolumeHost
ProvisionDelaySeconds int
} }
func (fc *FakeProvisioner) Provision(selectedNode *v1.Node, allowedTopologies []v1.TopologySelectorTerm) (*v1.PersistentVolume, error) { func (fc *FakeProvisioner) Provision(selectedNode *v1.Node, allowedTopologies []v1.TopologySelectorTerm) (*v1.PersistentVolume, error) {
...@@ -807,6 +809,10 @@ func (fc *FakeProvisioner) Provision(selectedNode *v1.Node, allowedTopologies [] ...@@ -807,6 +809,10 @@ func (fc *FakeProvisioner) Provision(selectedNode *v1.Node, allowedTopologies []
}, },
} }
if fc.ProvisionDelaySeconds > 0 {
time.Sleep(time.Duration(fc.ProvisionDelaySeconds) * time.Second)
}
return pv, nil return pv, nil
} }
......
...@@ -566,13 +566,28 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() { ...@@ -566,13 +566,28 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() {
framework.Skipf("Runs only when number of nodes >= %v", ssReplicas) framework.Skipf("Runs only when number of nodes >= %v", ssReplicas)
} }
By("Creating a StatefulSet with pod anti-affinity on nodes") By("Creating a StatefulSet with pod anti-affinity on nodes")
ss := createStatefulSet(config, ssReplicas, volsPerNode, true) ss := createStatefulSet(config, ssReplicas, volsPerNode, true, false)
validateStatefulSet(config, ss, true) validateStatefulSet(config, ss, true)
}) })
It("should use volumes on one node when pod has affinity", func() { It("should use volumes on one node when pod has affinity", func() {
By("Creating a StatefulSet with pod affinity on nodes") By("Creating a StatefulSet with pod affinity on nodes")
ss := createStatefulSet(config, ssReplicas, volsPerNode/ssReplicas, false) ss := createStatefulSet(config, ssReplicas, volsPerNode/ssReplicas, false, false)
validateStatefulSet(config, ss, false)
})
It("should use volumes spread across nodes when pod management is parallel and pod has anti-affinity", func() {
if len(config.nodes) < ssReplicas {
framework.Skipf("Runs only when number of nodes >= %v", ssReplicas)
}
By("Creating a StatefulSet with pod anti-affinity on nodes")
ss := createStatefulSet(config, ssReplicas, 1, true, true)
validateStatefulSet(config, ss, true)
})
It("should use volumes on one node when pod management is parallel and pod has affinity", func() {
By("Creating a StatefulSet with pod affinity on nodes")
ss := createStatefulSet(config, ssReplicas, 1, false, true)
validateStatefulSet(config, ss, false) validateStatefulSet(config, ss, false)
}) })
}) })
...@@ -1830,7 +1845,7 @@ func findLocalPersistentVolume(c clientset.Interface, volumePath string) (*v1.Pe ...@@ -1830,7 +1845,7 @@ func findLocalPersistentVolume(c clientset.Interface, volumePath string) (*v1.Pe
return nil, nil return nil, nil
} }
func createStatefulSet(config *localTestConfig, ssReplicas int32, volumeCount int, anti bool) *appsv1.StatefulSet { func createStatefulSet(config *localTestConfig, ssReplicas int32, volumeCount int, anti, parallel bool) *appsv1.StatefulSet {
mounts := []v1.VolumeMount{} mounts := []v1.VolumeMount{}
claims := []v1.PersistentVolumeClaim{} claims := []v1.PersistentVolumeClaim{}
for i := 0; i < volumeCount; i++ { for i := 0; i < volumeCount; i++ {
...@@ -1897,6 +1912,10 @@ func createStatefulSet(config *localTestConfig, ssReplicas int32, volumeCount in ...@@ -1897,6 +1912,10 @@ func createStatefulSet(config *localTestConfig, ssReplicas int32, volumeCount in
}, },
} }
if parallel {
spec.Spec.PodManagementPolicy = appsv1.ParallelPodManagement
}
ss, err := config.client.AppsV1().StatefulSets(config.ns).Create(spec) ss, err := config.client.AppsV1().StatefulSets(config.ns).Create(spec)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
......
...@@ -34,6 +34,7 @@ go_test( ...@@ -34,6 +34,7 @@ go_test(
"//pkg/kubeapiserver/admission:go_default_library", "//pkg/kubeapiserver/admission:go_default_library",
"//pkg/scheduler:go_default_library", "//pkg/scheduler:go_default_library",
"//pkg/scheduler/algorithm:go_default_library", "//pkg/scheduler/algorithm:go_default_library",
"//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/algorithmprovider:go_default_library", "//pkg/scheduler/algorithmprovider:go_default_library",
"//pkg/scheduler/api:go_default_library", "//pkg/scheduler/api:go_default_library",
"//pkg/scheduler/apis/config:go_default_library", "//pkg/scheduler/apis/config:go_default_library",
......
...@@ -143,7 +143,7 @@ func initTestScheduler( ...@@ -143,7 +143,7 @@ func initTestScheduler(
) *TestContext { ) *TestContext {
// Pod preemption is enabled by default scheduler configuration, but preemption only happens when PodPriority // Pod preemption is enabled by default scheduler configuration, but preemption only happens when PodPriority
// feature gate is enabled at the same time. // feature gate is enabled at the same time.
return initTestSchedulerWithOptions(t, context, controllerCh, setPodInformer, policy, false, time.Second) return initTestSchedulerWithOptions(t, context, controllerCh, setPodInformer, policy, false, false, time.Second)
} }
// initTestSchedulerWithOptions initializes a test environment and creates a scheduler with default // initTestSchedulerWithOptions initializes a test environment and creates a scheduler with default
...@@ -155,13 +155,15 @@ func initTestSchedulerWithOptions( ...@@ -155,13 +155,15 @@ func initTestSchedulerWithOptions(
setPodInformer bool, setPodInformer bool,
policy *schedulerapi.Policy, policy *schedulerapi.Policy,
disablePreemption bool, disablePreemption bool,
disableEquivalenceCache bool,
resyncPeriod time.Duration, resyncPeriod time.Duration,
) *TestContext { ) *TestContext {
// Enable EnableEquivalenceClassCache for all integration tests. if !disableEquivalenceCache {
defer utilfeaturetesting.SetFeatureGateDuringTest( defer utilfeaturetesting.SetFeatureGateDuringTest(
t, t,
utilfeature.DefaultFeatureGate, utilfeature.DefaultFeatureGate,
features.EnableEquivalenceClassCache, true)() features.EnableEquivalenceClassCache, true)()
}
// 1. Create scheduler // 1. Create scheduler
context.informerFactory = informers.NewSharedInformerFactory(context.clientSet, resyncPeriod) context.informerFactory = informers.NewSharedInformerFactory(context.clientSet, resyncPeriod)
...@@ -256,7 +258,7 @@ func initTest(t *testing.T, nsPrefix string) *TestContext { ...@@ -256,7 +258,7 @@ func initTest(t *testing.T, nsPrefix string) *TestContext {
// configuration but with pod preemption disabled. // configuration but with pod preemption disabled.
func initTestDisablePreemption(t *testing.T, nsPrefix string) *TestContext { func initTestDisablePreemption(t *testing.T, nsPrefix string) *TestContext {
return initTestSchedulerWithOptions( return initTestSchedulerWithOptions(
t, initTestMaster(t, nsPrefix, nil), nil, true, nil, true, time.Second) t, initTestMaster(t, nsPrefix, nil), nil, true, nil, true, false, time.Second)
} }
// cleanupTest deletes the scheduler and the test namespace. It should be called // cleanupTest deletes the scheduler and the test namespace. It should be called
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment