Skip to content

Commit

Permalink
Initial breakout of scheduling e2es to help assist in both assignment
Browse files Browse the repository at this point in the history
and refactoring.
  • Loading branch information
timothysc committed Mar 14, 2017
1 parent 5e29e1e commit 6cc4067
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 80 deletions.
10 changes: 10 additions & 0 deletions OWNERS_ALIASES
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
aliases:
sig-scheduling-maintainers:
- davidopp
- timothysc
- wojtek-t
sig-scheduling:
- davidopp
- timothysc
- wojtek-t
- k82cn
- jayunit100
sig-cli-maintainers:
- adohe
- brendandburns
Expand Down
2 changes: 2 additions & 0 deletions plugin/pkg/scheduler/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ reviewers:
- davidopp
- timothysc
- wojtek-t
- k82cn
- jayunit100
8 changes: 3 additions & 5 deletions test/e2e/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ go_library(
"networking.go",
"networking_perf.go",
"nodeoutofdisk.go",
"opaque_resource.go",
"pd.go",
"persistent_volumes.go",
"persistent_volumes-disruptive.go",
Expand All @@ -82,11 +81,9 @@ go_library(
"rc.go",
"reboot.go",
"replica_set.go",
"rescheduler.go",
"resize_nodes.go",
"resource_quota.go",
"restart.go",
"scheduler_predicates.go",
"security_context.go",
"service.go",
"service_accounts.go",
Expand Down Expand Up @@ -147,7 +144,6 @@ go_library(
"//pkg/util:go_default_library",
"//pkg/util/exec:go_default_library",
"//pkg/util/logs:go_default_library",
"//pkg/util/system:go_default_library",
"//pkg/util/version:go_default_library",
"//pkg/volume/util/volumehelper:go_default_library",
"//plugin/pkg/admission/serviceaccount:go_default_library",
Expand All @@ -156,6 +152,7 @@ go_library(
"//test/e2e/common:go_default_library",
"//test/e2e/framework:go_default_library",
"//test/e2e/generated:go_default_library",
"//test/e2e/scheduling:go_default_library",
"//test/e2e/upgrades:go_default_library",
"//test/e2e_federation:go_default_library",
"//test/images/net/nat:go_default_library",
Expand All @@ -173,7 +170,6 @@ go_library(
"//vendor:github.com/onsi/ginkgo/config",
"//vendor:github.com/onsi/ginkgo/reporters",
"//vendor:github.com/onsi/gomega",
"//vendor:github.com/stretchr/testify/assert",
"//vendor:github.com/vmware/govmomi/find",
"//vendor:github.com/vmware/govmomi/vim25/types",
"//vendor:golang.org/x/crypto/ssh",
Expand Down Expand Up @@ -230,6 +226,7 @@ go_test(
"//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/metrics:go_default_library",
"//test/e2e/framework:go_default_library",
"//test/e2e/scheduling:go_default_library",
"//test/utils:go_default_library",
"//vendor:github.com/onsi/ginkgo",
"//vendor:github.com/onsi/gomega",
Expand Down Expand Up @@ -267,6 +264,7 @@ filegroup(
"//test/e2e/framework:all-srcs",
"//test/e2e/generated:all-srcs",
"//test/e2e/perftype:all-srcs",
"//test/e2e/scheduling:all-srcs",
"//test/e2e/testing-manifests:all-srcs",
"//test/e2e/upgrades:all-srcs",
],
Expand Down
37 changes: 2 additions & 35 deletions test/e2e/cluster_size_autoscaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/scheduling"
testutils "k8s.io/kubernetes/test/utils"

"github.com/golang/glog"
Expand Down Expand Up @@ -166,7 +167,7 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
})

It("should increase cluster size if pods are pending due to host port conflict [Feature:ClusterSizeAutoscalingScaleUp]", func() {
CreateHostPortPods(f, "host-port", nodeCount+2, false)
scheduling.CreateHostPortPods(f, "host-port", nodeCount+2, false)
defer framework.DeleteRCAndPods(f.ClientSet, f.InternalClientset, f.Namespace.Name, "host-port")

framework.ExpectNoError(WaitForClusterSizeFunc(f.ClientSet,
Expand Down Expand Up @@ -509,40 +510,6 @@ func CreateNodeSelectorPods(f *framework.Framework, id string, replicas int, nod
}
}

func CreateHostPortPods(f *framework.Framework, id string, replicas int, expectRunning bool) {
By(fmt.Sprintf("Running RC which reserves host port"))
config := &testutils.RCConfig{
Client: f.ClientSet,
InternalClient: f.InternalClientset,
Name: id,
Namespace: f.Namespace.Name,
Timeout: defaultTimeout,
Image: framework.GetPauseImageName(f.ClientSet),
Replicas: replicas,
HostPorts: map[string]int{"port1": 4321},
}
err := framework.RunRC(*config)
if expectRunning {
framework.ExpectNoError(err)
}
}

func ReserveCpu(f *framework.Framework, id string, replicas, millicores int) {
By(fmt.Sprintf("Running RC which reserves %v millicores", millicores))
request := int64(millicores / replicas)
config := &testutils.RCConfig{
Client: f.ClientSet,
InternalClient: f.InternalClientset,
Name: id,
Namespace: f.Namespace.Name,
Timeout: defaultTimeout,
Image: framework.GetPauseImageName(f.ClientSet),
Replicas: replicas,
CpuRequest: request,
}
framework.ExpectNoError(framework.RunRC(*config))
}

func ReserveMemory(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool) {
By(fmt.Sprintf("Running RC which reserves %v MB of memory", megabytes))
request := int64(1024 * 1024 * megabytes / replicas)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

"k8s.io/kubernetes/test/e2e/framework"
_ "k8s.io/kubernetes/test/e2e/scheduling"
)

func init() {
Expand Down
21 changes: 21 additions & 0 deletions test/e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5426,3 +5426,24 @@ func DescribeIng(ns string) {
"describe", "ing", fmt.Sprintf("--namespace=%v", ns))
Logf(desc)
}

// NewTestPod returns a pod that has the specified requests and limits
func (f *Framework) NewTestPod(name string, requests v1.ResourceList, limits v1.ResourceList) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "pause",
Image: GetPauseImageName(f.ClientSet),
Resources: v1.ResourceRequirements{
Requests: requests,
Limits: limits,
},
},
},
},
}
}
5 changes: 3 additions & 2 deletions test/e2e/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import (
utilversion "k8s.io/kubernetes/pkg/util/version"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/generated"
"k8s.io/kubernetes/test/e2e/scheduling"
testutils "k8s.io/kubernetes/test/utils"

. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -1416,7 +1417,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
Effect: v1.TaintEffectNoSchedule,
}

nodeName := getNodeThatCanRunPod(f)
nodeName := scheduling.GetNodeThatCanRunPod(f)

By("adding the taint " + testTaint.ToString() + " to a node")
runKubectlRetryOrDie("taint", "nodes", nodeName, testTaint.ToString())
Expand Down Expand Up @@ -1447,7 +1448,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
Effect: v1.TaintEffectNoSchedule,
}

nodeName := getNodeThatCanRunPod(f)
nodeName := scheduling.GetNodeThatCanRunPod(f)

By("adding the taint " + testTaint.ToString() + " to a node")
runKubectlRetryOrDie("taint", "nodes", nodeName, testTaint.ToString())
Expand Down
29 changes: 4 additions & 25 deletions test/e2e/limit_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = framework.KubeDescribe("LimitRange", func() {
Expect(err).NotTo(HaveOccurred())

By("Creating a Pod with no resource requirements")
pod := newTestPod(f, "pod-no-resources", v1.ResourceList{}, v1.ResourceList{})
pod := f.NewTestPod("pod-no-resources", v1.ResourceList{}, v1.ResourceList{})
pod, err = f.ClientSet.Core().Pods(f.Namespace.Name).Create(pod)
Expect(err).NotTo(HaveOccurred())

Expand All @@ -71,7 +71,7 @@ var _ = framework.KubeDescribe("LimitRange", func() {
}

By("Creating a Pod with partial resource requirements")
pod = newTestPod(f, "pod-partial-resources", getResourceList("", "150Mi"), getResourceList("300m", ""))
pod = f.NewTestPod("pod-partial-resources", getResourceList("", "150Mi"), getResourceList("300m", ""))
pod, err = f.ClientSet.Core().Pods(f.Namespace.Name).Create(pod)
Expect(err).NotTo(HaveOccurred())

Expand All @@ -92,12 +92,12 @@ var _ = framework.KubeDescribe("LimitRange", func() {
}

By("Failing to create a Pod with less than min resources")
pod = newTestPod(f, podName, getResourceList("10m", "50Mi"), v1.ResourceList{})
pod = f.NewTestPod(podName, getResourceList("10m", "50Mi"), v1.ResourceList{})
pod, err = f.ClientSet.Core().Pods(f.Namespace.Name).Create(pod)
Expect(err).To(HaveOccurred())

By("Failing to create a Pod with more than max resources")
pod = newTestPod(f, podName, getResourceList("600m", "600Mi"), v1.ResourceList{})
pod = f.NewTestPod(podName, getResourceList("600m", "600Mi"), v1.ResourceList{})
pod, err = f.ClientSet.Core().Pods(f.Namespace.Name).Create(pod)
Expect(err).To(HaveOccurred())
})
Expand Down Expand Up @@ -166,24 +166,3 @@ func newLimitRange(name string, limitType v1.LimitType,
},
}
}

// newTestPod returns a pod that has the specified requests and limits
func newTestPod(f *framework.Framework, name string, requests v1.ResourceList, limits v1.ResourceList) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "pause",
Image: framework.GetPauseImageName(f.ClientSet),
Resources: v1.ResourceRequirements{
Requests: requests,
Limits: limits,
},
},
},
},
}
}
49 changes: 49 additions & 0 deletions test/e2e/scheduling/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)

go_library(
name = "go_default_library",
srcs = [
"opaque_resource.go",
"predicates.go",
"rescheduler.go",
],
tags = ["automanaged"],
deps = [
"//pkg/api/v1:go_default_library",
"//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/util/system:go_default_library",
"//test/e2e/common:go_default_library",
"//test/e2e/framework:go_default_library",
"//test/utils:go_default_library",
"//vendor:github.com/onsi/ginkgo",
"//vendor:github.com/onsi/gomega",
"//vendor:github.com/stretchr/testify/assert",
"//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/api/resource",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/labels",
"//vendor:k8s.io/apimachinery/pkg/types",
"//vendor:k8s.io/apimachinery/pkg/util/sets",
"//vendor:k8s.io/apimachinery/pkg/util/uuid",
],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
4 changes: 4 additions & 0 deletions test/e2e/scheduling/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
approvers:
- sig-scheduling-maintainers
reviewers:
- sig-scheduling
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package e2e
package scheduling

import (
"fmt"
Expand Down Expand Up @@ -69,7 +69,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
By("Creating a vanilla pod")
requests := v1.ResourceList{v1.ResourceCPU: resource.MustParse("0.1")}
limits := v1.ResourceList{v1.ResourceCPU: resource.MustParse("0.2")}
pod := newTestPod(f, "without-oir", requests, limits)
pod := f.NewTestPod("without-oir", requests, limits)

By("Observing an event that indicates the pod was scheduled")
action := func() error {
Expand All @@ -96,7 +96,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
v1.ResourceCPU: resource.MustParse("0.2"),
opaqueResName: resource.MustParse("2"),
}
pod := newTestPod(f, "min-oir", requests, limits)
pod := f.NewTestPod("min-oir", requests, limits)

By("Observing an event that indicates the pod was scheduled")
action := func() error {
Expand All @@ -118,7 +118,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun

By("Observing an event that indicates the pod was not scheduled")
action := func() error {
_, err := f.ClientSet.Core().Pods(f.Namespace.Name).Create(newTestPod(f, "over-max-oir", requests, limits))
_, err := f.ClientSet.Core().Pods(f.Namespace.Name).Create(f.NewTestPod("over-max-oir", requests, limits))
return err
}
predicate := scheduleFailure("over-max-oir")
Expand Down Expand Up @@ -224,8 +224,8 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
v1.ResourceCPU: resource.MustParse("0.2"),
opaqueResName: resource.MustParse("3"),
}
pod1 := newTestPod(f, "oir-1", requests, limits)
pod2 := newTestPod(f, "oir-2", requests, limits)
pod1 := f.NewTestPod("oir-1", requests, limits)
pod2 := f.NewTestPod("oir-2", requests, limits)

By("Observing an event that indicates one pod was scheduled")
action := func() error {
Expand Down
Loading

0 comments on commit 6cc4067

Please sign in to comment.