Commit b0d3f32e authored by Tim St. Clair's avatar Tim St. Clair

Update test/e2e for test/e2e/framework refactoring

parent a55b4f2e
...@@ -65,7 +65,7 @@ import ( ...@@ -65,7 +65,7 @@ import (
"k8s.io/kubernetes/plugin/pkg/scheduler" "k8s.io/kubernetes/plugin/pkg/scheduler"
_ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider" _ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider"
"k8s.io/kubernetes/plugin/pkg/scheduler/factory" "k8s.io/kubernetes/plugin/pkg/scheduler/factory"
"k8s.io/kubernetes/test/e2e" e2e "k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/integration" "k8s.io/kubernetes/test/integration"
"k8s.io/kubernetes/test/integration/framework" "k8s.io/kubernetes/test/integration/framework"
......
...@@ -180,7 +180,7 @@ right thing. ...@@ -180,7 +180,7 @@ right thing.
Here are a few pointers: Here are a few pointers:
+ [E2e Framework](../../test/e2e/framework.go): + [E2e Framework](../../test/e2e/framework/framework.go):
Familiarise yourself with this test framework and how to use it. Familiarise yourself with this test framework and how to use it.
Amongst others, it automatically creates uniquely named namespaces Amongst others, it automatically creates uniquely named namespaces
within which your tests can run to avoid name clashes, and reliably within which your tests can run to avoid name clashes, and reliably
...@@ -194,7 +194,7 @@ Here are a few pointers: ...@@ -194,7 +194,7 @@ Here are a few pointers:
should always use this framework. Trying other home-grown should always use this framework. Trying other home-grown
approaches to avoiding name clashes and resource leaks has proven approaches to avoiding name clashes and resource leaks has proven
to be a very bad idea. to be a very bad idea.
+ [E2e utils library](../../test/e2e/util.go): + [E2e utils library](../../test/e2e/framework/util.go):
This handy library provides tons of reusable code for a host of This handy library provides tons of reusable code for a host of
commonly needed test functionality, including waiting for resources commonly needed test functionality, including waiting for resources
to enter specified states, safely and consistently retrying failed to enter specified states, safely and consistently retrying failed
......
...@@ -79,7 +79,7 @@ pkg/util/oom/oom_linux.go:// Writes 'value' to /proc/<pid>/oom_score_adj for all ...@@ -79,7 +79,7 @@ pkg/util/oom/oom_linux.go:// Writes 'value' to /proc/<pid>/oom_score_adj for all
pkg/util/oom/oom_linux.go:// Writes 'value' to /proc/<pid>/oom_score_adj. PID = 0 means self pkg/util/oom/oom_linux.go:// Writes 'value' to /proc/<pid>/oom_score_adj. PID = 0 means self
test/e2e/configmap.go: Command: []string{"/mt", "--break_on_expected_content=false", "--retry_time=120", "--file_content_in_loop=/etc/configmap-volume/data-1"}, test/e2e/configmap.go: Command: []string{"/mt", "--break_on_expected_content=false", "--retry_time=120", "--file_content_in_loop=/etc/configmap-volume/data-1"},
test/e2e/downwardapi_volume.go: Command: []string{"/mt", "--break_on_expected_content=false", "--retry_time=120", "--file_content_in_loop=" + filePath}, test/e2e/downwardapi_volume.go: Command: []string{"/mt", "--break_on_expected_content=false", "--retry_time=120", "--file_content_in_loop=" + filePath},
test/e2e/es_cluster_logging.go: Failf("No cluster_name field in Elasticsearch response: %v", esResponse) test/e2e/es_cluster_logging.go: framework.Failf("No cluster_name field in Elasticsearch response: %v", esResponse)
test/e2e/es_cluster_logging.go: // Check to see if have a cluster_name field. test/e2e/es_cluster_logging.go: // Check to see if have a cluster_name field.
test/e2e/es_cluster_logging.go: clusterName, ok := esResponse["cluster_name"] test/e2e/es_cluster_logging.go: clusterName, ok := esResponse["cluster_name"]
test/e2e/host_path.go: fmt.Sprintf("--file_content_in_loop=%v", filePath), test/e2e/host_path.go: fmt.Sprintf("--file_content_in_loop=%v", filePath),
......
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -188,18 +189,18 @@ type stringPair struct { ...@@ -188,18 +189,18 @@ type stringPair struct {
data, fileName string data, fileName string
} }
var _ = KubeDescribe("Addon update", func() { var _ = framework.KubeDescribe("Addon update", func() {
var dir string var dir string
var sshClient *ssh.Client var sshClient *ssh.Client
f := NewDefaultFramework("addon-update-test") f := framework.NewDefaultFramework("addon-update-test")
BeforeEach(func() { BeforeEach(func() {
// This test requires: // This test requires:
// - SSH master access // - SSH master access
// ... so the provider check should be identical to the intersection of // ... so the provider check should be identical to the intersection of
// providers that provide those capabilities. // providers that provide those capabilities.
if !providerIs("gce") { if !framework.ProviderIs("gce") {
return return
} }
...@@ -210,26 +211,26 @@ var _ = KubeDescribe("Addon update", func() { ...@@ -210,26 +211,26 @@ var _ = KubeDescribe("Addon update", func() {
// Reduce the addon update intervals so that we have faster response // Reduce the addon update intervals so that we have faster response
// to changes in the addon directory. // to changes in the addon directory.
// do not use "service" command because it clears the environment variables // do not use "service" command because it clears the environment variables
switch testContext.OSDistro { switch framework.TestContext.OSDistro {
case "debian": case "debian":
sshExecAndVerify(sshClient, "sudo TEST_ADDON_CHECK_INTERVAL_SEC=1 /etc/init.d/kube-addons restart") sshExecAndVerify(sshClient, "sudo TEST_ADDON_CHECK_INTERVAL_SEC=1 /etc/init.d/kube-addons restart")
case "trusty": case "trusty":
sshExecAndVerify(sshClient, "sudo initctl restart kube-addons TEST_ADDON_CHECK_INTERVAL_SEC=1") sshExecAndVerify(sshClient, "sudo initctl restart kube-addons TEST_ADDON_CHECK_INTERVAL_SEC=1")
default: default:
Failf("Unsupported OS distro type %s", testContext.OSDistro) framework.Failf("Unsupported OS distro type %s", framework.TestContext.OSDistro)
} }
}) })
AfterEach(func() { AfterEach(func() {
if sshClient != nil { if sshClient != nil {
// restart addon_update with the default options // restart addon_update with the default options
switch testContext.OSDistro { switch framework.TestContext.OSDistro {
case "debian": case "debian":
sshExec(sshClient, "sudo /etc/init.d/kube-addons restart") sshExec(sshClient, "sudo /etc/init.d/kube-addons restart")
case "trusty": case "trusty":
sshExec(sshClient, "sudo initctl restart kube-addons") sshExec(sshClient, "sudo initctl restart kube-addons")
default: default:
Failf("Unsupported OS distro type %s", testContext.OSDistro) framework.Failf("Unsupported OS distro type %s", framework.TestContext.OSDistro)
} }
sshClient.Close() sshClient.Close()
} }
...@@ -242,7 +243,7 @@ var _ = KubeDescribe("Addon update", func() { ...@@ -242,7 +243,7 @@ var _ = KubeDescribe("Addon update", func() {
// - master access // - master access
// ... so the provider check should be identical to the intersection of // ... so the provider check should be identical to the intersection of
// providers that provide those capabilities. // providers that provide those capabilities.
SkipUnlessProviderIs("gce") framework.SkipUnlessProviderIs("gce")
//these tests are long, so I squeezed several cases in one scenario //these tests are long, so I squeezed several cases in one scenario
Expect(sshClient).NotTo(BeNil()) Expect(sshClient).NotTo(BeNil())
...@@ -337,20 +338,20 @@ var _ = KubeDescribe("Addon update", func() { ...@@ -337,20 +338,20 @@ var _ = KubeDescribe("Addon update", func() {
}) })
func waitForServiceInAddonTest(c *client.Client, addonNamespace, name string, exist bool) { func waitForServiceInAddonTest(c *client.Client, addonNamespace, name string, exist bool) {
expectNoError(waitForService(c, addonNamespace, name, exist, addonTestPollInterval, addonTestPollTimeout)) framework.ExpectNoError(framework.WaitForService(c, addonNamespace, name, exist, addonTestPollInterval, addonTestPollTimeout))
} }
func waitForReplicationControllerInAddonTest(c *client.Client, addonNamespace, name string, exist bool) { func waitForReplicationControllerInAddonTest(c *client.Client, addonNamespace, name string, exist bool) {
expectNoError(waitForReplicationController(c, addonNamespace, name, exist, addonTestPollInterval, addonTestPollTimeout)) framework.ExpectNoError(framework.WaitForReplicationController(c, addonNamespace, name, exist, addonTestPollInterval, addonTestPollTimeout))
} }
// TODO marekbiskup 2015-06-11: merge the ssh code into pkg/util/ssh.go after // TODO marekbiskup 2015-06-11: merge the ssh code into pkg/util/ssh.go after
// kubernetes v1.0 is released. In particular the code of sshExec. // kubernetes v1.0 is released. In particular the code of sshExec.
func getMasterSSHClient() (*ssh.Client, error) { func getMasterSSHClient() (*ssh.Client, error) {
// Get a signer for the provider. // Get a signer for the provider.
signer, err := getSigner(testContext.Provider) signer, err := framework.GetSigner(framework.TestContext.Provider)
if err != nil { if err != nil {
return nil, fmt.Errorf("error getting signer for provider %s: '%v'", testContext.Provider, err) return nil, fmt.Errorf("error getting signer for provider %s: '%v'", framework.TestContext.Provider, err)
} }
config := &ssh.ClientConfig{ config := &ssh.ClientConfig{
...@@ -358,7 +359,7 @@ func getMasterSSHClient() (*ssh.Client, error) { ...@@ -358,7 +359,7 @@ func getMasterSSHClient() (*ssh.Client, error) {
Auth: []ssh.AuthMethod{ssh.PublicKeys(signer)}, Auth: []ssh.AuthMethod{ssh.PublicKeys(signer)},
} }
host := getMasterHost() + ":22" host := framework.GetMasterHost() + ":22"
client, err := ssh.Dial("tcp", host, config) client, err := ssh.Dial("tcp", host, config)
if err != nil { if err != nil {
return nil, fmt.Errorf("error getting SSH client to host %s: '%v'", host, err) return nil, fmt.Errorf("error getting SSH client to host %s: '%v'", host, err)
...@@ -373,7 +374,7 @@ func sshExecAndVerify(client *ssh.Client, cmd string) { ...@@ -373,7 +374,7 @@ func sshExecAndVerify(client *ssh.Client, cmd string) {
} }
func sshExec(client *ssh.Client, cmd string) (string, string, int, error) { func sshExec(client *ssh.Client, cmd string) (string, string, int, error) {
Logf("Executing '%s' on %v", cmd, client.RemoteAddr()) framework.Logf("Executing '%s' on %v", cmd, client.RemoteAddr())
session, err := client.NewSession() session, err := client.NewSession()
if err != nil { if err != nil {
return "", "", 0, fmt.Errorf("error creating session to host %s: '%v'", client.RemoteAddr(), err) return "", "", 0, fmt.Errorf("error creating session to host %s: '%v'", client.RemoteAddr(), err)
...@@ -405,7 +406,7 @@ func sshExec(client *ssh.Client, cmd string) (string, string, int, error) { ...@@ -405,7 +406,7 @@ func sshExec(client *ssh.Client, cmd string) (string, string, int, error) {
} }
func writeRemoteFile(sshClient *ssh.Client, data, dir, fileName string, mode os.FileMode) error { func writeRemoteFile(sshClient *ssh.Client, data, dir, fileName string, mode os.FileMode) error {
Logf(fmt.Sprintf("Writing remote file '%s/%s' on %v", dir, fileName, sshClient.RemoteAddr())) framework.Logf(fmt.Sprintf("Writing remote file '%s/%s' on %v", dir, fileName, sshClient.RemoteAddr()))
session, err := sshClient.NewSession() session, err := sshClient.NewSession()
if err != nil { if err != nil {
return fmt.Errorf("error creating session to host %s: '%v'", sshClient.RemoteAddr(), err) return fmt.Errorf("error creating session to host %s: '%v'", sshClient.RemoteAddr(), err)
......
...@@ -30,6 +30,7 @@ import ( ...@@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -43,8 +44,8 @@ const ( ...@@ -43,8 +44,8 @@ const (
v1JobSelectorKey = "job-name" v1JobSelectorKey = "job-name"
) )
var _ = KubeDescribe("V1Job", func() { var _ = framework.KubeDescribe("V1Job", func() {
f := NewDefaultFramework("v1job") f := framework.NewDefaultFramework("v1job")
parallelism := 2 parallelism := 2
completions := 4 completions := 4
lotsOfFailures := 5 // more than completions lotsOfFailures := 5 // more than completions
...@@ -105,7 +106,7 @@ var _ = KubeDescribe("V1Job", func() { ...@@ -105,7 +106,7 @@ var _ = KubeDescribe("V1Job", func() {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Ensuring job shows many failures") By("Ensuring job shows many failures")
err = wait.Poll(poll, v1JobTimeout, func() (bool, error) { err = wait.Poll(framework.Poll, v1JobTimeout, func() (bool, error) {
curr, err := f.Client.Batch().Jobs(f.Namespace.Name).Get(job.Name) curr, err := f.Client.Batch().Jobs(f.Namespace.Name).Get(job.Name)
if err != nil { if err != nil {
return false, err return false, err
...@@ -274,7 +275,7 @@ func deleteV1Job(c *client.Client, ns, name string) error { ...@@ -274,7 +275,7 @@ func deleteV1Job(c *client.Client, ns, name string) error {
// Wait for all pods to become Running. Only use when pods will run for a long time, or it will be racy. // Wait for all pods to become Running. Only use when pods will run for a long time, or it will be racy.
func waitForAllPodsRunningV1(c *client.Client, ns, jobName string, parallelism int) error { func waitForAllPodsRunningV1(c *client.Client, ns, jobName string, parallelism int) error {
label := labels.SelectorFromSet(labels.Set(map[string]string{v1JobSelectorKey: jobName})) label := labels.SelectorFromSet(labels.Set(map[string]string{v1JobSelectorKey: jobName}))
return wait.Poll(poll, v1JobTimeout, func() (bool, error) { return wait.Poll(framework.Poll, v1JobTimeout, func() (bool, error) {
options := api.ListOptions{LabelSelector: label} options := api.ListOptions{LabelSelector: label}
pods, err := c.Pods(ns).List(options) pods, err := c.Pods(ns).List(options)
if err != nil { if err != nil {
...@@ -292,7 +293,7 @@ func waitForAllPodsRunningV1(c *client.Client, ns, jobName string, parallelism i ...@@ -292,7 +293,7 @@ func waitForAllPodsRunningV1(c *client.Client, ns, jobName string, parallelism i
// Wait for job to reach completions. // Wait for job to reach completions.
func waitForV1JobFinish(c *client.Client, ns, jobName string, completions int) error { func waitForV1JobFinish(c *client.Client, ns, jobName string, completions int) error {
return wait.Poll(poll, v1JobTimeout, func() (bool, error) { return wait.Poll(framework.Poll, v1JobTimeout, func() (bool, error) {
curr, err := c.Batch().Jobs(ns).Get(jobName) curr, err := c.Batch().Jobs(ns).Get(jobName)
if err != nil { if err != nil {
return false, err return false, err
...@@ -303,7 +304,7 @@ func waitForV1JobFinish(c *client.Client, ns, jobName string, completions int) e ...@@ -303,7 +304,7 @@ func waitForV1JobFinish(c *client.Client, ns, jobName string, completions int) e
// Wait for job fail. // Wait for job fail.
func waitForV1JobFail(c *client.Client, ns, jobName string) error { func waitForV1JobFail(c *client.Client, ns, jobName string) error {
return wait.Poll(poll, v1JobTimeout, func() (bool, error) { return wait.Poll(framework.Poll, v1JobTimeout, func() (bool, error) {
curr, err := c.Batch().Jobs(ns).Get(jobName) curr, err := c.Batch().Jobs(ns).Get(jobName)
if err != nil { if err != nil {
return false, err return false, err
......
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
) )
...@@ -31,9 +32,9 @@ const ( ...@@ -31,9 +32,9 @@ const (
sleepDuration = 10 * time.Second sleepDuration = 10 * time.Second
) )
var _ = KubeDescribe("Cadvisor", func() { var _ = framework.KubeDescribe("Cadvisor", func() {
f := NewDefaultFramework("cadvisor") f := framework.NewDefaultFramework("cadvisor")
It("should be healthy on every node.", func() { It("should be healthy on every node.", func() {
CheckCadvisorHealthOnAllNodes(f.Client, 5*time.Minute) CheckCadvisorHealthOnAllNodes(f.Client, 5*time.Minute)
...@@ -44,7 +45,7 @@ func CheckCadvisorHealthOnAllNodes(c *client.Client, timeout time.Duration) { ...@@ -44,7 +45,7 @@ func CheckCadvisorHealthOnAllNodes(c *client.Client, timeout time.Duration) {
// It should be OK to list unschedulable Nodes here. // It should be OK to list unschedulable Nodes here.
By("getting list of nodes") By("getting list of nodes")
nodeList, err := c.Nodes().List(api.ListOptions{}) nodeList, err := c.Nodes().List(api.ListOptions{})
expectNoError(err) framework.ExpectNoError(err)
var errors []error var errors []error
retries := maxRetries retries := maxRetries
for { for {
...@@ -65,8 +66,8 @@ func CheckCadvisorHealthOnAllNodes(c *client.Client, timeout time.Duration) { ...@@ -65,8 +66,8 @@ func CheckCadvisorHealthOnAllNodes(c *client.Client, timeout time.Duration) {
if retries--; retries <= 0 { if retries--; retries <= 0 {
break break
} }
Logf("failed to retrieve kubelet stats -\n %v", errors) framework.Logf("failed to retrieve kubelet stats -\n %v", errors)
time.Sleep(sleepDuration) time.Sleep(sleepDuration)
} }
Failf("Failed after retrying %d times for cadvisor to be healthy on all nodes. Errors:\n%v", maxRetries, errors) framework.Failf("Failed after retrying %d times for cadvisor to be healthy on all nodes. Errors:\n%v", maxRetries, errors)
} }
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
"time" "time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -37,16 +38,16 @@ const ( ...@@ -37,16 +38,16 @@ const (
// run by default. // run by default.
// //
// These tests take ~20 minutes to run each. // These tests take ~20 minutes to run each.
var _ = KubeDescribe("Cluster size autoscaling [Feature:ClusterSizeAutoscaling] [Slow]", func() { var _ = framework.KubeDescribe("Cluster size autoscaling [Feature:ClusterSizeAutoscaling] [Slow]", func() {
f := NewDefaultFramework("autoscaling") f := framework.NewDefaultFramework("autoscaling")
var nodeCount int var nodeCount int
var coresPerNode int var coresPerNode int
var memCapacityMb int var memCapacityMb int
BeforeEach(func() { BeforeEach(func() {
SkipUnlessProviderIs("gce") framework.SkipUnlessProviderIs("gce")
nodes := ListSchedulableNodesOrDie(f.Client) nodes := framework.ListSchedulableNodesOrDie(f.Client)
nodeCount = len(nodes.Items) nodeCount = len(nodes.Items)
Expect(nodeCount).NotTo(BeZero()) Expect(nodeCount).NotTo(BeZero())
cpu := nodes.Items[0].Status.Capacity[api.ResourceCPU] cpu := nodes.Items[0].Status.Capacity[api.ResourceCPU]
...@@ -64,23 +65,23 @@ var _ = KubeDescribe("Cluster size autoscaling [Feature:ClusterSizeAutoscaling] ...@@ -64,23 +65,23 @@ var _ = KubeDescribe("Cluster size autoscaling [Feature:ClusterSizeAutoscaling]
// Consume 50% CPU // Consume 50% CPU
rcs := createConsumingRCs(f, "cpu-utilization", nodeCount*coresPerNode, 500, 0) rcs := createConsumingRCs(f, "cpu-utilization", nodeCount*coresPerNode, 500, 0)
err := waitForClusterSize(f.Client, nodeCount+1, scaleUpTimeout) err := framework.WaitForClusterSize(f.Client, nodeCount+1, scaleUpTimeout)
for _, rc := range rcs { for _, rc := range rcs {
rc.CleanUp() rc.CleanUp()
} }
expectNoError(err) framework.ExpectNoError(err)
expectNoError(waitForClusterSize(f.Client, nodeCount, scaleDownTimeout)) framework.ExpectNoError(framework.WaitForClusterSize(f.Client, nodeCount, scaleDownTimeout))
}) })
It("Should scale cluster size based on cpu reservation", func() { It("Should scale cluster size based on cpu reservation", func() {
setUpAutoscaler("cpu/node_reservation", 0.5, nodeCount, nodeCount+1) setUpAutoscaler("cpu/node_reservation", 0.5, nodeCount, nodeCount+1)
ReserveCpu(f, "cpu-reservation", 600*nodeCount*coresPerNode) ReserveCpu(f, "cpu-reservation", 600*nodeCount*coresPerNode)
expectNoError(waitForClusterSize(f.Client, nodeCount+1, scaleUpTimeout)) framework.ExpectNoError(framework.WaitForClusterSize(f.Client, nodeCount+1, scaleUpTimeout))
expectNoError(DeleteRC(f.Client, f.Namespace.Name, "cpu-reservation")) framework.ExpectNoError(framework.DeleteRC(f.Client, f.Namespace.Name, "cpu-reservation"))
expectNoError(waitForClusterSize(f.Client, nodeCount, scaleDownTimeout)) framework.ExpectNoError(framework.WaitForClusterSize(f.Client, nodeCount, scaleDownTimeout))
}) })
It("Should scale cluster size based on memory utilization", func() { It("Should scale cluster size based on memory utilization", func() {
...@@ -89,23 +90,23 @@ var _ = KubeDescribe("Cluster size autoscaling [Feature:ClusterSizeAutoscaling] ...@@ -89,23 +90,23 @@ var _ = KubeDescribe("Cluster size autoscaling [Feature:ClusterSizeAutoscaling]
// Consume 60% of total memory capacity // Consume 60% of total memory capacity
megabytesPerReplica := int(memCapacityMb * 6 / 10 / coresPerNode) megabytesPerReplica := int(memCapacityMb * 6 / 10 / coresPerNode)
rcs := createConsumingRCs(f, "mem-utilization", nodeCount*coresPerNode, 0, megabytesPerReplica) rcs := createConsumingRCs(f, "mem-utilization", nodeCount*coresPerNode, 0, megabytesPerReplica)
err := waitForClusterSize(f.Client, nodeCount+1, scaleUpTimeout) err := framework.WaitForClusterSize(f.Client, nodeCount+1, scaleUpTimeout)
for _, rc := range rcs { for _, rc := range rcs {
rc.CleanUp() rc.CleanUp()
} }
expectNoError(err) framework.ExpectNoError(err)
expectNoError(waitForClusterSize(f.Client, nodeCount, scaleDownTimeout)) framework.ExpectNoError(framework.WaitForClusterSize(f.Client, nodeCount, scaleDownTimeout))
}) })
It("Should scale cluster size based on memory reservation", func() { It("Should scale cluster size based on memory reservation", func() {
setUpAutoscaler("memory/node_reservation", 0.5, nodeCount, nodeCount+1) setUpAutoscaler("memory/node_reservation", 0.5, nodeCount, nodeCount+1)
ReserveMemory(f, "memory-reservation", nodeCount*memCapacityMb*6/10) ReserveMemory(f, "memory-reservation", nodeCount*memCapacityMb*6/10)
expectNoError(waitForClusterSize(f.Client, nodeCount+1, scaleUpTimeout)) framework.ExpectNoError(framework.WaitForClusterSize(f.Client, nodeCount+1, scaleUpTimeout))
expectNoError(DeleteRC(f.Client, f.Namespace.Name, "memory-reservation")) framework.ExpectNoError(framework.DeleteRC(f.Client, f.Namespace.Name, "memory-reservation"))
expectNoError(waitForClusterSize(f.Client, nodeCount, scaleDownTimeout)) framework.ExpectNoError(framework.WaitForClusterSize(f.Client, nodeCount, scaleDownTimeout))
}) })
}) })
...@@ -113,17 +114,17 @@ func setUpAutoscaler(metric string, target float64, min, max int) { ...@@ -113,17 +114,17 @@ func setUpAutoscaler(metric string, target float64, min, max int) {
// TODO integrate with kube-up.sh script once it will support autoscaler setup. // TODO integrate with kube-up.sh script once it will support autoscaler setup.
By("Setting up autoscaler to scale based on " + metric) By("Setting up autoscaler to scale based on " + metric)
out, err := exec.Command("gcloud", "compute", "instance-groups", "managed", "set-autoscaling", out, err := exec.Command("gcloud", "compute", "instance-groups", "managed", "set-autoscaling",
testContext.CloudConfig.NodeInstanceGroup, framework.TestContext.CloudConfig.NodeInstanceGroup,
"--project="+testContext.CloudConfig.ProjectID, "--project="+framework.TestContext.CloudConfig.ProjectID,
"--zone="+testContext.CloudConfig.Zone, "--zone="+framework.TestContext.CloudConfig.Zone,
"--custom-metric-utilization=metric=custom.cloudmonitoring.googleapis.com/kubernetes.io/"+metric+fmt.Sprintf(",utilization-target=%v", target)+",utilization-target-type=GAUGE", "--custom-metric-utilization=metric=custom.cloudmonitoring.googleapis.com/kubernetes.io/"+metric+fmt.Sprintf(",utilization-target=%v", target)+",utilization-target-type=GAUGE",
fmt.Sprintf("--min-num-replicas=%v", min), fmt.Sprintf("--min-num-replicas=%v", min),
fmt.Sprintf("--max-num-replicas=%v", max), fmt.Sprintf("--max-num-replicas=%v", max),
).CombinedOutput() ).CombinedOutput()
expectNoError(err, "Output: "+string(out)) framework.ExpectNoError(err, "Output: "+string(out))
} }
func createConsumingRCs(f *Framework, name string, count, cpuPerReplica, memPerReplica int) []*ResourceConsumer { func createConsumingRCs(f *framework.Framework, name string, count, cpuPerReplica, memPerReplica int) []*ResourceConsumer {
var res []*ResourceConsumer var res []*ResourceConsumer
for i := 1; i <= count; i++ { for i := 1; i <= count; i++ {
name := fmt.Sprintf("%s-%d", name, i) name := fmt.Sprintf("%s-%d", name, i)
...@@ -135,16 +136,16 @@ func createConsumingRCs(f *Framework, name string, count, cpuPerReplica, memPerR ...@@ -135,16 +136,16 @@ func createConsumingRCs(f *Framework, name string, count, cpuPerReplica, memPerR
func cleanUpAutoscaler() { func cleanUpAutoscaler() {
By("Removing autoscaler") By("Removing autoscaler")
out, err := exec.Command("gcloud", "compute", "instance-groups", "managed", "stop-autoscaling", out, err := exec.Command("gcloud", "compute", "instance-groups", "managed", "stop-autoscaling",
testContext.CloudConfig.NodeInstanceGroup, framework.TestContext.CloudConfig.NodeInstanceGroup,
"--project="+testContext.CloudConfig.ProjectID, "--project="+framework.TestContext.CloudConfig.ProjectID,
"--zone="+testContext.CloudConfig.Zone, "--zone="+framework.TestContext.CloudConfig.Zone,
).CombinedOutput() ).CombinedOutput()
expectNoError(err, "Output: "+string(out)) framework.ExpectNoError(err, "Output: "+string(out))
} }
func ReserveCpu(f *Framework, id string, millicores int) { func ReserveCpu(f *framework.Framework, id string, millicores int) {
By(fmt.Sprintf("Running RC which reserves %v millicores", millicores)) By(fmt.Sprintf("Running RC which reserves %v millicores", millicores))
config := &RCConfig{ config := &framework.RCConfig{
Client: f.Client, Client: f.Client,
Name: id, Name: id,
Namespace: f.Namespace.Name, Namespace: f.Namespace.Name,
...@@ -153,12 +154,12 @@ func ReserveCpu(f *Framework, id string, millicores int) { ...@@ -153,12 +154,12 @@ func ReserveCpu(f *Framework, id string, millicores int) {
Replicas: millicores / 100, Replicas: millicores / 100,
CpuRequest: 100, CpuRequest: 100,
} }
expectNoError(RunRC(*config)) framework.ExpectNoError(framework.RunRC(*config))
} }
func ReserveMemory(f *Framework, id string, megabytes int) { func ReserveMemory(f *framework.Framework, id string, megabytes int) {
By(fmt.Sprintf("Running RC which reserves %v MB of memory", megabytes)) By(fmt.Sprintf("Running RC which reserves %v MB of memory", megabytes))
config := &RCConfig{ config := &framework.RCConfig{
Client: f.Client, Client: f.Client,
Name: id, Name: id,
Namespace: f.Namespace.Name, Namespace: f.Namespace.Name,
...@@ -167,5 +168,5 @@ func ReserveMemory(f *Framework, id string, megabytes int) { ...@@ -167,5 +168,5 @@ func ReserveMemory(f *Framework, id string, megabytes int) {
Replicas: megabytes / 500, Replicas: megabytes / 500,
MemRequest: 500 * 1024 * 1024, MemRequest: 500 * 1024 * 1024,
} }
expectNoError(RunRC(*config)) framework.ExpectNoError(framework.RunRC(*config))
} }
...@@ -22,14 +22,15 @@ import ( ...@@ -22,14 +22,15 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = KubeDescribe("ConfigMap", func() { var _ = framework.KubeDescribe("ConfigMap", func() {
f := NewDefaultFramework("configmap") f := framework.NewDefaultFramework("configmap")
It("should be consumable from pods in volume [Conformance]", func() { It("should be consumable from pods in volume [Conformance]", func() {
doConfigMapE2EWithoutMappings(f, 0, 0) doConfigMapE2EWithoutMappings(f, 0, 0)
...@@ -82,12 +83,12 @@ var _ = KubeDescribe("ConfigMap", func() { ...@@ -82,12 +83,12 @@ var _ = KubeDescribe("ConfigMap", func() {
defer func() { defer func() {
By("Cleaning up the configMap") By("Cleaning up the configMap")
if err := f.Client.ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil { if err := f.Client.ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil {
Failf("unable to delete configMap %v: %v", configMap.Name, err) framework.Failf("unable to delete configMap %v: %v", configMap.Name, err)
} }
}() }()
var err error var err error
if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil { if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
Failf("unable to create test configMap %s: %v", configMap.Name, err) framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
} }
pod := &api.Pod{ pod := &api.Pod{
...@@ -133,13 +134,13 @@ var _ = KubeDescribe("ConfigMap", func() { ...@@ -133,13 +134,13 @@ var _ = KubeDescribe("ConfigMap", func() {
_, err = f.Client.Pods(f.Namespace.Name).Create(pod) _, err = f.Client.Pods(f.Namespace.Name).Create(pod)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
expectNoError(waitForPodRunningInNamespace(f.Client, pod.Name, f.Namespace.Name)) framework.ExpectNoError(framework.WaitForPodRunningInNamespace(f.Client, pod.Name, f.Namespace.Name))
pollLogs := func() (string, error) { pollLogs := func() (string, error) {
return getPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName) return framework.GetPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName)
} }
Eventually(pollLogs, podLogTimeout, poll).Should(ContainSubstring("value-1")) Eventually(pollLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("value-1"))
By(fmt.Sprintf("Updating configmap %v", configMap.Name)) By(fmt.Sprintf("Updating configmap %v", configMap.Name))
configMap.ResourceVersion = "" // to force update configMap.ResourceVersion = "" // to force update
...@@ -148,7 +149,7 @@ var _ = KubeDescribe("ConfigMap", func() { ...@@ -148,7 +149,7 @@ var _ = KubeDescribe("ConfigMap", func() {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("waiting to observe update in volume") By("waiting to observe update in volume")
Eventually(pollLogs, podLogTimeout, poll).Should(ContainSubstring("value-2")) Eventually(pollLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("value-2"))
}) })
It("should be consumable via environment variable [Conformance]", func() { It("should be consumable via environment variable [Conformance]", func() {
...@@ -158,12 +159,12 @@ var _ = KubeDescribe("ConfigMap", func() { ...@@ -158,12 +159,12 @@ var _ = KubeDescribe("ConfigMap", func() {
defer func() { defer func() {
By("Cleaning up the configMap") By("Cleaning up the configMap")
if err := f.Client.ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil { if err := f.Client.ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil {
Failf("unable to delete configMap %v: %v", configMap.Name, err) framework.Failf("unable to delete configMap %v: %v", configMap.Name, err)
} }
}() }()
var err error var err error
if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil { if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
Failf("unable to create test configMap %s: %v", configMap.Name, err) framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
} }
pod := &api.Pod{ pod := &api.Pod{
...@@ -195,13 +196,13 @@ var _ = KubeDescribe("ConfigMap", func() { ...@@ -195,13 +196,13 @@ var _ = KubeDescribe("ConfigMap", func() {
}, },
} }
testContainerOutput("consume configMaps", f.Client, pod, 0, []string{ framework.TestContainerOutput("consume configMaps", f.Client, pod, 0, []string{
"CONFIG_DATA_1=value-1", "CONFIG_DATA_1=value-1",
}, f.Namespace.Name) }, f.Namespace.Name)
}) })
}) })
func newConfigMap(f *Framework, name string) *api.ConfigMap { func newConfigMap(f *framework.Framework, name string) *api.ConfigMap {
return &api.ConfigMap{ return &api.ConfigMap{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Namespace: f.Namespace.Name, Namespace: f.Namespace.Name,
...@@ -215,7 +216,7 @@ func newConfigMap(f *Framework, name string) *api.ConfigMap { ...@@ -215,7 +216,7 @@ func newConfigMap(f *Framework, name string) *api.ConfigMap {
} }
} }
func doConfigMapE2EWithoutMappings(f *Framework, uid, fsGroup int64) { func doConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup int64) {
var ( var (
name = "configmap-test-volume-" + string(util.NewUUID()) name = "configmap-test-volume-" + string(util.NewUUID())
volumeName = "configmap-volume" volumeName = "configmap-volume"
...@@ -227,12 +228,12 @@ func doConfigMapE2EWithoutMappings(f *Framework, uid, fsGroup int64) { ...@@ -227,12 +228,12 @@ func doConfigMapE2EWithoutMappings(f *Framework, uid, fsGroup int64) {
defer func() { defer func() {
By("Cleaning up the configMap") By("Cleaning up the configMap")
if err := f.Client.ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil { if err := f.Client.ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil {
Failf("unable to delete configMap %v: %v", configMap.Name, err) framework.Failf("unable to delete configMap %v: %v", configMap.Name, err)
} }
}() }()
var err error var err error
if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil { if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
Failf("unable to create test configMap %s: %v", configMap.Name, err) framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
} }
pod := &api.Pod{ pod := &api.Pod{
...@@ -279,13 +280,13 @@ func doConfigMapE2EWithoutMappings(f *Framework, uid, fsGroup int64) { ...@@ -279,13 +280,13 @@ func doConfigMapE2EWithoutMappings(f *Framework, uid, fsGroup int64) {
pod.Spec.SecurityContext.FSGroup = &fsGroup pod.Spec.SecurityContext.FSGroup = &fsGroup
} }
testContainerOutput("consume configMaps", f.Client, pod, 0, []string{ framework.TestContainerOutput("consume configMaps", f.Client, pod, 0, []string{
"content of file \"/etc/configmap-volume/data-1\": value-1", "content of file \"/etc/configmap-volume/data-1\": value-1",
}, f.Namespace.Name) }, f.Namespace.Name)
} }
func doConfigMapE2EWithMappings(f *Framework, uid, fsGroup int64) { func doConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup int64) {
var ( var (
name = "configmap-test-volume-map-" + string(util.NewUUID()) name = "configmap-test-volume-map-" + string(util.NewUUID())
volumeName = "configmap-volume" volumeName = "configmap-volume"
...@@ -297,12 +298,12 @@ func doConfigMapE2EWithMappings(f *Framework, uid, fsGroup int64) { ...@@ -297,12 +298,12 @@ func doConfigMapE2EWithMappings(f *Framework, uid, fsGroup int64) {
defer func() { defer func() {
By("Cleaning up the configMap") By("Cleaning up the configMap")
if err := f.Client.ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil { if err := f.Client.ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil {
Failf("unable to delete configMap %v: %v", configMap.Name, err) framework.Failf("unable to delete configMap %v: %v", configMap.Name, err)
} }
}() }()
var err error var err error
if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil { if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
Failf("unable to create test configMap %s: %v", configMap.Name, err) framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
} }
pod := &api.Pod{ pod := &api.Pod{
...@@ -355,7 +356,7 @@ func doConfigMapE2EWithMappings(f *Framework, uid, fsGroup int64) { ...@@ -355,7 +356,7 @@ func doConfigMapE2EWithMappings(f *Framework, uid, fsGroup int64) {
pod.Spec.SecurityContext.FSGroup = &fsGroup pod.Spec.SecurityContext.FSGroup = &fsGroup
} }
testContainerOutput("consume configMaps", f.Client, pod, 0, []string{ framework.TestContainerOutput("consume configMaps", f.Client, pod, 0, []string{
"content of file \"/etc/configmap-volume/path/to/data-2\": value-2", "content of file \"/etc/configmap-volume/path/to/data-2\": value-2",
}, f.Namespace.Name) }, f.Namespace.Name)
} }
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -35,49 +36,49 @@ const ( ...@@ -35,49 +36,49 @@ const (
probTestInitialDelaySeconds = 30 probTestInitialDelaySeconds = 30
) )
var _ = KubeDescribe("Probing container", func() { var _ = framework.KubeDescribe("Probing container", func() {
framework := NewDefaultFramework("container-probe") f := framework.NewDefaultFramework("container-probe")
var podClient client.PodInterface var podClient client.PodInterface
probe := webserverProbeBuilder{} probe := webserverProbeBuilder{}
BeforeEach(func() { BeforeEach(func() {
podClient = framework.Client.Pods(framework.Namespace.Name) podClient = f.Client.Pods(f.Namespace.Name)
}) })
It("with readiness probe should not be ready before initial delay and never restart [Conformance]", func() { It("with readiness probe should not be ready before initial delay and never restart [Conformance]", func() {
p, err := podClient.Create(makePodSpec(probe.withInitialDelay().build(), nil)) p, err := podClient.Create(makePodSpec(probe.withInitialDelay().build(), nil))
expectNoError(err) framework.ExpectNoError(err)
Expect(wait.Poll(poll, 240*time.Second, func() (bool, error) { Expect(wait.Poll(framework.Poll, 240*time.Second, func() (bool, error) {
p, err := podClient.Get(p.Name) p, err := podClient.Get(p.Name)
if err != nil { if err != nil {
return false, err return false, err
} }
ready := api.IsPodReady(p) ready := api.IsPodReady(p)
if !ready { if !ready {
Logf("pod is not yet ready; pod has phase %q.", p.Status.Phase) framework.Logf("pod is not yet ready; pod has phase %q.", p.Status.Phase)
return false, nil return false, nil
} }
return true, nil return true, nil
})).NotTo(HaveOccurred(), "pod never became ready") })).NotTo(HaveOccurred(), "pod never became ready")
p, err = podClient.Get(p.Name) p, err = podClient.Get(p.Name)
expectNoError(err) framework.ExpectNoError(err)
isReady, err := podRunningReady(p) isReady, err := framework.PodRunningReady(p)
expectNoError(err) framework.ExpectNoError(err)
Expect(isReady).To(BeTrue(), "pod should be ready") Expect(isReady).To(BeTrue(), "pod should be ready")
// We assume the pod became ready when the container became ready. This // We assume the pod became ready when the container became ready. This
// is true for a single container pod. // is true for a single container pod.
readyTime, err := getTransitionTimeForReadyCondition(p) readyTime, err := getTransitionTimeForReadyCondition(p)
expectNoError(err) framework.ExpectNoError(err)
startedTime, err := getContainerStartedTime(p, probTestContainerName) startedTime, err := getContainerStartedTime(p, probTestContainerName)
expectNoError(err) framework.ExpectNoError(err)
Logf("Container started at %v, pod became ready at %v", startedTime, readyTime) framework.Logf("Container started at %v, pod became ready at %v", startedTime, readyTime)
initialDelay := probTestInitialDelaySeconds * time.Second initialDelay := probTestInitialDelaySeconds * time.Second
if readyTime.Sub(startedTime) < initialDelay { if readyTime.Sub(startedTime) < initialDelay {
Failf("Pod became ready before it's %v initial delay", initialDelay) framework.Failf("Pod became ready before it's %v initial delay", initialDelay)
} }
restartCount := getRestartCount(p) restartCount := getRestartCount(p)
...@@ -86,9 +87,9 @@ var _ = KubeDescribe("Probing container", func() { ...@@ -86,9 +87,9 @@ var _ = KubeDescribe("Probing container", func() {
It("with readiness probe that fails should never be ready and never restart [Conformance]", func() { It("with readiness probe that fails should never be ready and never restart [Conformance]", func() {
p, err := podClient.Create(makePodSpec(probe.withFailing().build(), nil)) p, err := podClient.Create(makePodSpec(probe.withFailing().build(), nil))
expectNoError(err) framework.ExpectNoError(err)
err = wait.Poll(poll, 180*time.Second, func() (bool, error) { err = wait.Poll(framework.Poll, 180*time.Second, func() (bool, error) {
p, err := podClient.Get(p.Name) p, err := podClient.Get(p.Name)
if err != nil { if err != nil {
return false, err return false, err
...@@ -96,13 +97,13 @@ var _ = KubeDescribe("Probing container", func() { ...@@ -96,13 +97,13 @@ var _ = KubeDescribe("Probing container", func() {
return api.IsPodReady(p), nil return api.IsPodReady(p), nil
}) })
if err != wait.ErrWaitTimeout { if err != wait.ErrWaitTimeout {
Failf("expecting wait timeout error but got: %v", err) framework.Failf("expecting wait timeout error but got: %v", err)
} }
p, err = podClient.Get(p.Name) p, err = podClient.Get(p.Name)
expectNoError(err) framework.ExpectNoError(err)
isReady, err := podRunningReady(p) isReady, err := framework.PodRunningReady(p)
Expect(isReady).NotTo(BeTrue(), "pod should be not ready") Expect(isReady).NotTo(BeTrue(), "pod should be not ready")
restartCount := getRestartCount(p) restartCount := getRestartCount(p)
......
...@@ -32,6 +32,7 @@ import ( ...@@ -32,6 +32,7 @@ import (
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -53,25 +54,25 @@ const ( ...@@ -53,25 +54,25 @@ const (
// happen. In the future, running in parallel may work if we have an eviction // happen. In the future, running in parallel may work if we have an eviction
// model which lets the DS controller kick out other pods to make room. // model which lets the DS controller kick out other pods to make room.
// See http://issues.k8s.io/21767 for more details // See http://issues.k8s.io/21767 for more details
var _ = KubeDescribe("Daemon set [Serial]", func() { var _ = framework.KubeDescribe("Daemon set [Serial]", func() {
var f *Framework var f *framework.Framework
AfterEach(func() { AfterEach(func() {
if daemonsets, err := f.Client.DaemonSets(f.Namespace.Name).List(api.ListOptions{}); err == nil { if daemonsets, err := f.Client.DaemonSets(f.Namespace.Name).List(api.ListOptions{}); err == nil {
Logf("daemonset: %s", runtime.EncodeOrDie(api.Codecs.LegacyCodec(registered.EnabledVersions()...), daemonsets)) framework.Logf("daemonset: %s", runtime.EncodeOrDie(api.Codecs.LegacyCodec(registered.EnabledVersions()...), daemonsets))
} else { } else {
Logf("unable to dump daemonsets: %v", err) framework.Logf("unable to dump daemonsets: %v", err)
} }
if pods, err := f.Client.Pods(f.Namespace.Name).List(api.ListOptions{}); err == nil { if pods, err := f.Client.Pods(f.Namespace.Name).List(api.ListOptions{}); err == nil {
Logf("pods: %s", runtime.EncodeOrDie(api.Codecs.LegacyCodec(registered.EnabledVersions()...), pods)) framework.Logf("pods: %s", runtime.EncodeOrDie(api.Codecs.LegacyCodec(registered.EnabledVersions()...), pods))
} else { } else {
Logf("unable to dump pods: %v", err) framework.Logf("unable to dump pods: %v", err)
} }
err := clearDaemonSetNodeLabels(f.Client) err := clearDaemonSetNodeLabels(f.Client)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
}) })
f = NewDefaultFramework("daemonsets") f = framework.NewDefaultFramework("daemonsets")
image := "gcr.io/google_containers/serve_hostname:v1.4" image := "gcr.io/google_containers/serve_hostname:v1.4"
dsName := "daemon-set" dsName := "daemon-set"
...@@ -89,7 +90,7 @@ var _ = KubeDescribe("Daemon set [Serial]", func() { ...@@ -89,7 +90,7 @@ var _ = KubeDescribe("Daemon set [Serial]", func() {
It("should run and stop simple daemon", func() { It("should run and stop simple daemon", func() {
label := map[string]string{daemonsetNameLabel: dsName} label := map[string]string{daemonsetNameLabel: dsName}
Logf("Creating simple daemon set %s", dsName) framework.Logf("Creating simple daemon set %s", dsName)
_, err := c.DaemonSets(ns).Create(&extensions.DaemonSet{ _, err := c.DaemonSets(ns).Create(&extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: dsName, Name: dsName,
...@@ -113,7 +114,7 @@ var _ = KubeDescribe("Daemon set [Serial]", func() { ...@@ -113,7 +114,7 @@ var _ = KubeDescribe("Daemon set [Serial]", func() {
}) })
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
defer func() { defer func() {
Logf("Check that reaper kills all daemon pods for %s", dsName) framework.Logf("Check that reaper kills all daemon pods for %s", dsName)
dsReaper, err := kubectl.ReaperFor(extensions.Kind("DaemonSet"), c) dsReaper, err := kubectl.ReaperFor(extensions.Kind("DaemonSet"), c)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
err = dsReaper.Stop(ns, dsName, 0, nil) err = dsReaper.Stop(ns, dsName, 0, nil)
...@@ -146,7 +147,7 @@ var _ = KubeDescribe("Daemon set [Serial]", func() { ...@@ -146,7 +147,7 @@ var _ = KubeDescribe("Daemon set [Serial]", func() {
It("should run and stop complex daemon", func() { It("should run and stop complex daemon", func() {
complexLabel := map[string]string{daemonsetNameLabel: dsName} complexLabel := map[string]string{daemonsetNameLabel: dsName}
nodeSelector := map[string]string{daemonsetColorLabel: "blue"} nodeSelector := map[string]string{daemonsetColorLabel: "blue"}
Logf("Creating daemon with a node selector %s", dsName) framework.Logf("Creating daemon with a node selector %s", dsName)
_, err := c.DaemonSets(ns).Create(&extensions.DaemonSet{ _, err := c.DaemonSets(ns).Create(&extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: dsName, Name: dsName,
...@@ -177,7 +178,7 @@ var _ = KubeDescribe("Daemon set [Serial]", func() { ...@@ -177,7 +178,7 @@ var _ = KubeDescribe("Daemon set [Serial]", func() {
Expect(err).NotTo(HaveOccurred(), "error waiting for daemon pods to be running on no nodes") Expect(err).NotTo(HaveOccurred(), "error waiting for daemon pods to be running on no nodes")
By("Change label of node, check that daemon pod is launched.") By("Change label of node, check that daemon pod is launched.")
nodeList := ListSchedulableNodesOrDie(f.Client) nodeList := framework.ListSchedulableNodesOrDie(f.Client)
Expect(len(nodeList.Items)).To(BeNumerically(">", 0)) Expect(len(nodeList.Items)).To(BeNumerically(">", 0))
newNode, err := setDaemonSetNodeLabels(c, nodeList.Items[0].Name, nodeSelector) newNode, err := setDaemonSetNodeLabels(c, nodeList.Items[0].Name, nodeSelector)
Expect(err).NotTo(HaveOccurred(), "error setting labels on node") Expect(err).NotTo(HaveOccurred(), "error setting labels on node")
...@@ -212,7 +213,7 @@ func separateDaemonSetNodeLabels(labels map[string]string) (map[string]string, m ...@@ -212,7 +213,7 @@ func separateDaemonSetNodeLabels(labels map[string]string) (map[string]string, m
} }
func clearDaemonSetNodeLabels(c *client.Client) error { func clearDaemonSetNodeLabels(c *client.Client) error {
nodeList := ListSchedulableNodesOrDie(c) nodeList := framework.ListSchedulableNodesOrDie(c)
for _, node := range nodeList.Items { for _, node := range nodeList.Items {
_, err := setDaemonSetNodeLabels(c, node.Name, map[string]string{}) _, err := setDaemonSetNodeLabels(c, node.Name, map[string]string{})
if err != nil { if err != nil {
...@@ -248,7 +249,7 @@ func setDaemonSetNodeLabels(c *client.Client, nodeName string, labels map[string ...@@ -248,7 +249,7 @@ func setDaemonSetNodeLabels(c *client.Client, nodeName string, labels map[string
return true, err return true, err
} }
if se, ok := err.(*apierrs.StatusError); ok && se.ErrStatus.Reason == unversioned.StatusReasonConflict { if se, ok := err.(*apierrs.StatusError); ok && se.ErrStatus.Reason == unversioned.StatusReasonConflict {
Logf("failed to update node due to resource version conflict") framework.Logf("failed to update node due to resource version conflict")
return false, nil return false, nil
} }
return false, err return false, err
...@@ -262,7 +263,7 @@ func setDaemonSetNodeLabels(c *client.Client, nodeName string, labels map[string ...@@ -262,7 +263,7 @@ func setDaemonSetNodeLabels(c *client.Client, nodeName string, labels map[string
return newNode, nil return newNode, nil
} }
func checkDaemonPodOnNodes(f *Framework, selector map[string]string, nodeNames []string) func() (bool, error) { func checkDaemonPodOnNodes(f *framework.Framework, selector map[string]string, nodeNames []string) func() (bool, error) {
return func() (bool, error) { return func() (bool, error) {
selector := labels.Set(selector).AsSelector() selector := labels.Set(selector).AsSelector()
options := api.ListOptions{LabelSelector: selector} options := api.ListOptions{LabelSelector: selector}
...@@ -276,7 +277,7 @@ func checkDaemonPodOnNodes(f *Framework, selector map[string]string, nodeNames [ ...@@ -276,7 +277,7 @@ func checkDaemonPodOnNodes(f *Framework, selector map[string]string, nodeNames [
for _, pod := range pods { for _, pod := range pods {
nodesToPodCount[pod.Spec.NodeName] += 1 nodesToPodCount[pod.Spec.NodeName] += 1
} }
Logf("nodesToPodCount: %#v", nodesToPodCount) framework.Logf("nodesToPodCount: %#v", nodesToPodCount)
// Ensure that exactly 1 pod is running on all nodes in nodeNames. // Ensure that exactly 1 pod is running on all nodes in nodeNames.
for _, nodeName := range nodeNames { for _, nodeName := range nodeNames {
...@@ -292,10 +293,10 @@ func checkDaemonPodOnNodes(f *Framework, selector map[string]string, nodeNames [ ...@@ -292,10 +293,10 @@ func checkDaemonPodOnNodes(f *Framework, selector map[string]string, nodeNames [
} }
} }
func checkRunningOnAllNodes(f *Framework, selector map[string]string) func() (bool, error) { func checkRunningOnAllNodes(f *framework.Framework, selector map[string]string) func() (bool, error) {
return func() (bool, error) { return func() (bool, error) {
nodeList, err := f.Client.Nodes().List(api.ListOptions{}) nodeList, err := f.Client.Nodes().List(api.ListOptions{})
expectNoError(err) framework.ExpectNoError(err)
nodeNames := make([]string, 0) nodeNames := make([]string, 0)
for _, node := range nodeList.Items { for _, node := range nodeList.Items {
nodeNames = append(nodeNames, node.Name) nodeNames = append(nodeNames, node.Name)
...@@ -304,6 +305,6 @@ func checkRunningOnAllNodes(f *Framework, selector map[string]string) func() (bo ...@@ -304,6 +305,6 @@ func checkRunningOnAllNodes(f *Framework, selector map[string]string) func() (bo
} }
} }
func checkRunningOnNoNodes(f *Framework, selector map[string]string) func() (bool, error) { func checkRunningOnNoNodes(f *framework.Framework, selector map[string]string) func() (bool, error) {
return checkDaemonPodOnNodes(f, selector, make([]string, 0)) return checkDaemonPodOnNodes(f, selector, make([]string, 0))
} }
...@@ -23,12 +23,13 @@ import ( ...@@ -23,12 +23,13 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = KubeDescribe("Kubernetes Dashboard", func() { var _ = framework.KubeDescribe("Kubernetes Dashboard", func() {
const ( const (
uiServiceName = "kubernetes-dashboard" uiServiceName = "kubernetes-dashboard"
uiAppName = uiServiceName uiAppName = uiServiceName
...@@ -37,36 +38,36 @@ var _ = KubeDescribe("Kubernetes Dashboard", func() { ...@@ -37,36 +38,36 @@ var _ = KubeDescribe("Kubernetes Dashboard", func() {
serverStartTimeout = 1 * time.Minute serverStartTimeout = 1 * time.Minute
) )
f := NewDefaultFramework(uiServiceName) f := framework.NewDefaultFramework(uiServiceName)
It("should check that the kubernetes-dashboard instance is alive", func() { It("should check that the kubernetes-dashboard instance is alive", func() {
By("Checking whether the kubernetes-dashboard service exists.") By("Checking whether the kubernetes-dashboard service exists.")
err := waitForService(f.Client, uiNamespace, uiServiceName, true, poll, serviceStartTimeout) err := framework.WaitForService(f.Client, uiNamespace, uiServiceName, true, framework.Poll, framework.ServiceStartTimeout)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Checking to make sure the kubernetes-dashboard pods are running") By("Checking to make sure the kubernetes-dashboard pods are running")
selector := labels.SelectorFromSet(labels.Set(map[string]string{"k8s-app": uiAppName})) selector := labels.SelectorFromSet(labels.Set(map[string]string{"k8s-app": uiAppName}))
err = waitForPodsWithLabelRunning(f.Client, uiNamespace, selector) err = framework.WaitForPodsWithLabelRunning(f.Client, uiNamespace, selector)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Checking to make sure we get a response from the kubernetes-dashboard.") By("Checking to make sure we get a response from the kubernetes-dashboard.")
err = wait.Poll(poll, serverStartTimeout, func() (bool, error) { err = wait.Poll(framework.Poll, serverStartTimeout, func() (bool, error) {
var status int var status int
proxyRequest, errProxy := getServicesProxyRequest(f.Client, f.Client.Get()) proxyRequest, errProxy := framework.GetServicesProxyRequest(f.Client, f.Client.Get())
if errProxy != nil { if errProxy != nil {
Logf("Get services proxy request failed: %v", errProxy) framework.Logf("Get services proxy request failed: %v", errProxy)
} }
// Query against the proxy URL for the kube-ui service. // Query against the proxy URL for the kube-ui service.
err := proxyRequest.Namespace(uiNamespace). err := proxyRequest.Namespace(uiNamespace).
Name(uiServiceName). Name(uiServiceName).
Timeout(singleCallTimeout). Timeout(framework.SingleCallTimeout).
Do(). Do().
StatusCode(&status). StatusCode(&status).
Error() Error()
if status != http.StatusOK { if status != http.StatusOK {
Logf("Unexpected status from kubernetes-dashboard: %v", status) framework.Logf("Unexpected status from kubernetes-dashboard: %v", status)
} else if err != nil { } else if err != nil {
Logf("Request to kube-ui failed: %v", err) framework.Logf("Request to kube-ui failed: %v", err)
} }
// Don't return err here as it aborts polling. // Don't return err here as it aborts polling.
return status == http.StatusOK, nil return status == http.StatusOK, nil
...@@ -77,7 +78,7 @@ var _ = KubeDescribe("Kubernetes Dashboard", func() { ...@@ -77,7 +78,7 @@ var _ = KubeDescribe("Kubernetes Dashboard", func() {
var status int var status int
err = f.Client.Get(). err = f.Client.Get().
AbsPath("/ui"). AbsPath("/ui").
Timeout(singleCallTimeout). Timeout(framework.SingleCallTimeout).
Do(). Do().
StatusCode(&status). StatusCode(&status).
Error() Error()
......
...@@ -31,6 +31,7 @@ import ( ...@@ -31,6 +31,7 @@ import (
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
) )
const dnsTestPodHostName = "dns-querier-1" const dnsTestPodHostName = "dns-querier-1"
...@@ -150,9 +151,9 @@ func createProbeCommand(namesToResolve []string, hostEntries []string, fileNameP ...@@ -150,9 +151,9 @@ func createProbeCommand(namesToResolve []string, hostEntries []string, fileNameP
func assertFilesExist(fileNames []string, fileDir string, pod *api.Pod, client *client.Client) { func assertFilesExist(fileNames []string, fileDir string, pod *api.Pod, client *client.Client) {
var failed []string var failed []string
expectNoError(wait.Poll(time.Second*2, time.Second*60, func() (bool, error) { framework.ExpectNoError(wait.Poll(time.Second*2, time.Second*60, func() (bool, error) {
failed = []string{} failed = []string{}
subResourceProxyAvailable, err := serverVersionGTE(subResourcePodProxyVersion, client) subResourceProxyAvailable, err := framework.ServerVersionGTE(framework.SubResourcePodProxyVersion, client)
if err != nil { if err != nil {
return false, err return false, err
} }
...@@ -175,20 +176,20 @@ func assertFilesExist(fileNames []string, fileDir string, pod *api.Pod, client * ...@@ -175,20 +176,20 @@ func assertFilesExist(fileNames []string, fileDir string, pod *api.Pod, client *
Do().Raw() Do().Raw()
} }
if err != nil { if err != nil {
Logf("Unable to read %s from pod %s: %v", fileName, pod.Name, err) framework.Logf("Unable to read %s from pod %s: %v", fileName, pod.Name, err)
failed = append(failed, fileName) failed = append(failed, fileName)
} }
} }
if len(failed) == 0 { if len(failed) == 0 {
return true, nil return true, nil
} }
Logf("Lookups using %s failed for: %v\n", pod.Name, failed) framework.Logf("Lookups using %s failed for: %v\n", pod.Name, failed)
return false, nil return false, nil
})) }))
Expect(len(failed)).To(Equal(0)) Expect(len(failed)).To(Equal(0))
} }
func validateDNSResults(f *Framework, pod *api.Pod, fileNames []string) { func validateDNSResults(f *framework.Framework, pod *api.Pod, fileNames []string) {
By("submitting the pod to kubernetes") By("submitting the pod to kubernetes")
podClient := f.Client.Pods(f.Namespace.Name) podClient := f.Client.Pods(f.Namespace.Name)
...@@ -198,15 +199,15 @@ func validateDNSResults(f *Framework, pod *api.Pod, fileNames []string) { ...@@ -198,15 +199,15 @@ func validateDNSResults(f *Framework, pod *api.Pod, fileNames []string) {
podClient.Delete(pod.Name, api.NewDeleteOptions(0)) podClient.Delete(pod.Name, api.NewDeleteOptions(0))
}() }()
if _, err := podClient.Create(pod); err != nil { if _, err := podClient.Create(pod); err != nil {
Failf("Failed to create %s pod: %v", pod.Name, err) framework.Failf("Failed to create %s pod: %v", pod.Name, err)
} }
expectNoError(f.WaitForPodRunning(pod.Name)) framework.ExpectNoError(f.WaitForPodRunning(pod.Name))
By("retrieving the pod") By("retrieving the pod")
pod, err := podClient.Get(pod.Name) pod, err := podClient.Get(pod.Name)
if err != nil { if err != nil {
Failf("Failed to get pod %s: %v", pod.Name, err) framework.Failf("Failed to get pod %s: %v", pod.Name, err)
} }
// Try to find results for each expected name. // Try to find results for each expected name.
By("looking for the results for each expected name from probiers") By("looking for the results for each expected name from probiers")
...@@ -214,21 +215,21 @@ func validateDNSResults(f *Framework, pod *api.Pod, fileNames []string) { ...@@ -214,21 +215,21 @@ func validateDNSResults(f *Framework, pod *api.Pod, fileNames []string) {
// TODO: probe from the host, too. // TODO: probe from the host, too.
Logf("DNS probes using %s succeeded\n", pod.Name) framework.Logf("DNS probes using %s succeeded\n", pod.Name)
} }
func verifyDNSPodIsRunning(f *Framework) { func verifyDNSPodIsRunning(f *framework.Framework) {
systemClient := f.Client.Pods(api.NamespaceSystem) systemClient := f.Client.Pods(api.NamespaceSystem)
By("Waiting for DNS Service to be Running") By("Waiting for DNS Service to be Running")
options := api.ListOptions{LabelSelector: dnsServiceLabelSelector} options := api.ListOptions{LabelSelector: dnsServiceLabelSelector}
dnsPods, err := systemClient.List(options) dnsPods, err := systemClient.List(options)
if err != nil { if err != nil {
Failf("Failed to list all dns service pods") framework.Failf("Failed to list all dns service pods")
} }
if len(dnsPods.Items) != 1 { if len(dnsPods.Items) != 1 {
Failf("Unexpected number of pods (%d) matches the label selector %v", len(dnsPods.Items), dnsServiceLabelSelector.String()) framework.Failf("Unexpected number of pods (%d) matches the label selector %v", len(dnsPods.Items), dnsServiceLabelSelector.String())
} }
expectNoError(waitForPodRunningInNamespace(f.Client, dnsPods.Items[0].Name, api.NamespaceSystem)) framework.ExpectNoError(framework.WaitForPodRunningInNamespace(f.Client, dnsPods.Items[0].Name, api.NamespaceSystem))
} }
func createServiceSpec(serviceName string, isHeadless bool, selector map[string]string) *api.Service { func createServiceSpec(serviceName string, isHeadless bool, selector map[string]string) *api.Service {
...@@ -249,8 +250,8 @@ func createServiceSpec(serviceName string, isHeadless bool, selector map[string] ...@@ -249,8 +250,8 @@ func createServiceSpec(serviceName string, isHeadless bool, selector map[string]
return headlessService return headlessService
} }
var _ = KubeDescribe("DNS", func() { var _ = framework.KubeDescribe("DNS", func() {
f := NewDefaultFramework("dns") f := framework.NewDefaultFramework("dns")
It("should provide DNS for the cluster [Conformance]", func() { It("should provide DNS for the cluster [Conformance]", func() {
verifyDNSPodIsRunning(f) verifyDNSPodIsRunning(f)
...@@ -264,7 +265,7 @@ var _ = KubeDescribe("DNS", func() { ...@@ -264,7 +265,7 @@ var _ = KubeDescribe("DNS", func() {
"google.com", "google.com",
} }
// Added due to #8512. This is critical for GCE and GKE deployments. // Added due to #8512. This is critical for GCE and GKE deployments.
if providerIs("gce", "gke") { if framework.ProviderIs("gce", "gke") {
namesToResolve = append(namesToResolve, "metadata") namesToResolve = append(namesToResolve, "metadata")
} }
......
...@@ -20,22 +20,23 @@ import ( ...@@ -20,22 +20,23 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
) )
var _ = KubeDescribe("Docker Containers", func() { var _ = framework.KubeDescribe("Docker Containers", func() {
framework := NewDefaultFramework("containers") f := framework.NewDefaultFramework("containers")
var c *client.Client var c *client.Client
var ns string var ns string
BeforeEach(func() { BeforeEach(func() {
c = framework.Client c = f.Client
ns = framework.Namespace.Name ns = f.Namespace.Name
}) })
It("should use the image defaults if command and args are blank [Conformance]", func() { It("should use the image defaults if command and args are blank [Conformance]", func() {
testContainerOutput("use defaults", c, entrypointTestPod(), 0, []string{ framework.TestContainerOutput("use defaults", c, entrypointTestPod(), 0, []string{
"[/ep default arguments]", "[/ep default arguments]",
}, ns) }, ns)
}) })
...@@ -44,7 +45,7 @@ var _ = KubeDescribe("Docker Containers", func() { ...@@ -44,7 +45,7 @@ var _ = KubeDescribe("Docker Containers", func() {
pod := entrypointTestPod() pod := entrypointTestPod()
pod.Spec.Containers[0].Args = []string{"override", "arguments"} pod.Spec.Containers[0].Args = []string{"override", "arguments"}
testContainerOutput("override arguments", c, pod, 0, []string{ framework.TestContainerOutput("override arguments", c, pod, 0, []string{
"[/ep override arguments]", "[/ep override arguments]",
}, ns) }, ns)
}) })
...@@ -55,7 +56,7 @@ var _ = KubeDescribe("Docker Containers", func() { ...@@ -55,7 +56,7 @@ var _ = KubeDescribe("Docker Containers", func() {
pod := entrypointTestPod() pod := entrypointTestPod()
pod.Spec.Containers[0].Command = []string{"/ep-2"} pod.Spec.Containers[0].Command = []string{"/ep-2"}
testContainerOutput("override command", c, pod, 0, []string{ framework.TestContainerOutput("override command", c, pod, 0, []string{
"[/ep-2]", "[/ep-2]",
}, ns) }, ns)
}) })
...@@ -65,7 +66,7 @@ var _ = KubeDescribe("Docker Containers", func() { ...@@ -65,7 +66,7 @@ var _ = KubeDescribe("Docker Containers", func() {
pod.Spec.Containers[0].Command = []string{"/ep-2"} pod.Spec.Containers[0].Command = []string{"/ep-2"}
pod.Spec.Containers[0].Args = []string{"override", "arguments"} pod.Spec.Containers[0].Args = []string{"override", "arguments"}
testContainerOutput("override all", c, pod, 0, []string{ framework.TestContainerOutput("override all", c, pod, 0, []string{
"[/ep-2 override arguments]", "[/ep-2 override arguments]",
}, ns) }, ns)
}) })
......
...@@ -21,12 +21,13 @@ import ( ...@@ -21,12 +21,13 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
) )
var _ = KubeDescribe("Downward API", func() { var _ = framework.KubeDescribe("Downward API", func() {
framework := NewDefaultFramework("downward-api") f := framework.NewDefaultFramework("downward-api")
It("should provide pod name and namespace as env vars [Conformance]", func() { It("should provide pod name and namespace as env vars [Conformance]", func() {
podName := "downward-api-" + string(util.NewUUID()) podName := "downward-api-" + string(util.NewUUID())
...@@ -53,10 +54,10 @@ var _ = KubeDescribe("Downward API", func() { ...@@ -53,10 +54,10 @@ var _ = KubeDescribe("Downward API", func() {
expectations := []string{ expectations := []string{
fmt.Sprintf("POD_NAME=%v", podName), fmt.Sprintf("POD_NAME=%v", podName),
fmt.Sprintf("POD_NAMESPACE=%v", framework.Namespace.Name), fmt.Sprintf("POD_NAMESPACE=%v", f.Namespace.Name),
} }
testDownwardAPI(framework, podName, env, expectations) testDownwardAPI(f, podName, env, expectations)
}) })
It("should provide pod IP as an env var", func() { It("should provide pod IP as an env var", func() {
...@@ -77,11 +78,11 @@ var _ = KubeDescribe("Downward API", func() { ...@@ -77,11 +78,11 @@ var _ = KubeDescribe("Downward API", func() {
"POD_IP=(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)", "POD_IP=(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)",
} }
testDownwardAPI(framework, podName, env, expectations) testDownwardAPI(f, podName, env, expectations)
}) })
}) })
func testDownwardAPI(framework *Framework, podName string, env []api.EnvVar, expectations []string) { func testDownwardAPI(f *framework.Framework, podName string, env []api.EnvVar, expectations []string) {
pod := &api.Pod{ pod := &api.Pod{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: podName, Name: podName,
...@@ -100,5 +101,5 @@ func testDownwardAPI(framework *Framework, podName string, env []api.EnvVar, exp ...@@ -100,5 +101,5 @@ func testDownwardAPI(framework *Framework, podName string, env []api.EnvVar, exp
}, },
} }
framework.TestContainerOutputRegexp("downward api env vars", pod, 0, expectations) f.TestContainerOutputRegexp("downward api env vars", pod, 0, expectations)
} }
...@@ -22,21 +22,22 @@ import ( ...@@ -22,21 +22,22 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = KubeDescribe("Downward API volume", func() { var _ = framework.KubeDescribe("Downward API volume", func() {
// How long to wait for a log pod to be displayed // How long to wait for a log pod to be displayed
const podLogTimeout = 45 * time.Second const podLogTimeout = 45 * time.Second
f := NewDefaultFramework("downward-api") f := framework.NewDefaultFramework("downward-api")
It("should provide podname only [Conformance]", func() { It("should provide podname only [Conformance]", func() {
podName := "downwardapi-volume-" + string(util.NewUUID()) podName := "downwardapi-volume-" + string(util.NewUUID())
pod := downwardAPIVolumePodForSimpleTest(podName, "/etc/podname") pod := downwardAPIVolumePodForSimpleTest(podName, "/etc/podname")
testContainerOutput("downward API volume plugin", f.Client, pod, 0, []string{ framework.TestContainerOutput("downward API volume plugin", f.Client, pod, 0, []string{
fmt.Sprintf("%s\n", podName), fmt.Sprintf("%s\n", podName),
}, f.Namespace.Name) }, f.Namespace.Name)
}) })
...@@ -50,7 +51,7 @@ var _ = KubeDescribe("Downward API volume", func() { ...@@ -50,7 +51,7 @@ var _ = KubeDescribe("Downward API volume", func() {
RunAsUser: &uid, RunAsUser: &uid,
FSGroup: &gid, FSGroup: &gid,
} }
testContainerOutput("downward API volume plugin", f.Client, pod, 0, []string{ framework.TestContainerOutput("downward API volume plugin", f.Client, pod, 0, []string{
fmt.Sprintf("%s\n", podName), fmt.Sprintf("%s\n", podName),
}, f.Namespace.Name) }, f.Namespace.Name)
}) })
...@@ -71,15 +72,15 @@ var _ = KubeDescribe("Downward API volume", func() { ...@@ -71,15 +72,15 @@ var _ = KubeDescribe("Downward API volume", func() {
_, err := f.Client.Pods(f.Namespace.Name).Create(pod) _, err := f.Client.Pods(f.Namespace.Name).Create(pod)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
expectNoError(waitForPodRunningInNamespace(f.Client, pod.Name, f.Namespace.Name)) framework.ExpectNoError(framework.WaitForPodRunningInNamespace(f.Client, pod.Name, f.Namespace.Name))
pod, err = f.Client.Pods(f.Namespace.Name).Get(pod.Name) pod, err = f.Client.Pods(f.Namespace.Name).Get(pod.Name)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Eventually(func() (string, error) { Eventually(func() (string, error) {
return getPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName) return framework.GetPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName)
}, },
podLogTimeout, poll).Should(ContainSubstring("key1=\"value1\"\n")) podLogTimeout, framework.Poll).Should(ContainSubstring("key1=\"value1\"\n"))
//modify labels //modify labels
pod.Labels["key3"] = "value3" pod.Labels["key3"] = "value3"
...@@ -88,9 +89,9 @@ var _ = KubeDescribe("Downward API volume", func() { ...@@ -88,9 +89,9 @@ var _ = KubeDescribe("Downward API volume", func() {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Eventually(func() (string, error) { Eventually(func() (string, error) {
return getPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName) return framework.GetPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName)
}, },
podLogTimeout, poll).Should(ContainSubstring("key3=\"value3\"\n")) podLogTimeout, framework.Poll).Should(ContainSubstring("key3=\"value3\"\n"))
}) })
...@@ -108,15 +109,15 @@ var _ = KubeDescribe("Downward API volume", func() { ...@@ -108,15 +109,15 @@ var _ = KubeDescribe("Downward API volume", func() {
By("Creating the pod") By("Creating the pod")
_, err := f.Client.Pods(f.Namespace.Name).Create(pod) _, err := f.Client.Pods(f.Namespace.Name).Create(pod)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
expectNoError(waitForPodRunningInNamespace(f.Client, pod.Name, f.Namespace.Name)) framework.ExpectNoError(framework.WaitForPodRunningInNamespace(f.Client, pod.Name, f.Namespace.Name))
pod, err = f.Client.Pods(f.Namespace.Name).Get(pod.Name) pod, err = f.Client.Pods(f.Namespace.Name).Get(pod.Name)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Eventually(func() (string, error) { Eventually(func() (string, error) {
return getPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName) return framework.GetPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName)
}, },
podLogTimeout, poll).Should(ContainSubstring("builder=\"bar\"\n")) podLogTimeout, framework.Poll).Should(ContainSubstring("builder=\"bar\"\n"))
//modify annotations //modify annotations
pod.Annotations["builder"] = "foo" pod.Annotations["builder"] = "foo"
...@@ -125,9 +126,9 @@ var _ = KubeDescribe("Downward API volume", func() { ...@@ -125,9 +126,9 @@ var _ = KubeDescribe("Downward API volume", func() {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Eventually(func() (string, error) { Eventually(func() (string, error) {
return getPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName) return framework.GetPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName)
}, },
podLogTimeout, poll).Should(ContainSubstring("builder=\"foo\"\n")) podLogTimeout, framework.Poll).Should(ContainSubstring("builder=\"foo\"\n"))
}) })
}) })
......
...@@ -36,6 +36,7 @@ import ( ...@@ -36,6 +36,7 @@ import (
gcecloud "k8s.io/kubernetes/pkg/cloudprovider/providers/gce" gcecloud "k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/runtime" "k8s.io/kubernetes/pkg/util/runtime"
"k8s.io/kubernetes/test/e2e/framework"
) )
const ( const (
...@@ -99,19 +100,19 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { ...@@ -99,19 +100,19 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
// Delete any namespaces except default and kube-system. This ensures no // Delete any namespaces except default and kube-system. This ensures no
// lingering resources are left over from a previous test run. // lingering resources are left over from a previous test run.
if testContext.CleanStart { if framework.TestContext.CleanStart {
c, err := loadClient() c, err := framework.LoadClient()
if err != nil { if err != nil {
glog.Fatal("Error loading client: ", err) glog.Fatal("Error loading client: ", err)
} }
deleted, err := deleteNamespaces(c, nil /* deleteFilter */, []string{api.NamespaceSystem, api.NamespaceDefault}) deleted, err := framework.DeleteNamespaces(c, nil /* deleteFilter */, []string{api.NamespaceSystem, api.NamespaceDefault})
if err != nil { if err != nil {
Failf("Error deleting orphaned namespaces: %v", err) framework.Failf("Error deleting orphaned namespaces: %v", err)
} }
glog.Infof("Waiting for deletion of the following namespaces: %v", deleted) glog.Infof("Waiting for deletion of the following namespaces: %v", deleted)
if err := waitForNamespacesDeleted(c, deleted, namespaceCleanupTimeout); err != nil { if err := framework.WaitForNamespacesDeleted(c, deleted, framework.NamespaceCleanupTimeout); err != nil {
Failf("Failed to delete orphaned namespaces %v: %v", deleted, err) framework.Failf("Failed to delete orphaned namespaces %v: %v", deleted, err)
} }
} }
...@@ -119,15 +120,15 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { ...@@ -119,15 +120,15 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
// cluster infrastructure pods that are being pulled or started can block // cluster infrastructure pods that are being pulled or started can block
// test pods from running, and tests that ensure all pods are running and // test pods from running, and tests that ensure all pods are running and
// ready will fail). // ready will fail).
if err := waitForPodsRunningReady(api.NamespaceSystem, testContext.MinStartupPods, podStartupTimeout); err != nil { if err := framework.WaitForPodsRunningReady(api.NamespaceSystem, framework.TestContext.MinStartupPods, podStartupTimeout); err != nil {
if c, errClient := loadClient(); errClient != nil { if c, errClient := framework.LoadClient(); errClient != nil {
Logf("Unable to dump cluster information because: %v", errClient) framework.Logf("Unable to dump cluster information because: %v", errClient)
} else { } else {
dumpAllNamespaceInfo(c, api.NamespaceSystem) framework.DumpAllNamespaceInfo(c, api.NamespaceSystem)
} }
logFailedContainers(api.NamespaceSystem) framework.LogFailedContainers(api.NamespaceSystem)
runKubernetesServiceTestContainer(testContext.RepoRoot, api.NamespaceDefault) framework.RunKubernetesServiceTestContainer(framework.TestContext.RepoRoot, api.NamespaceDefault)
Failf("Error waiting for all pods to be running and ready: %v", err) framework.Failf("Error waiting for all pods to be running and ready: %v", err)
} }
return nil return nil
...@@ -188,7 +189,7 @@ var _ = ginkgo.SynchronizedAfterSuite(func() { ...@@ -188,7 +189,7 @@ var _ = ginkgo.SynchronizedAfterSuite(func() {
}, func() { }, func() {
// Run only Ginkgo on node 1 // Run only Ginkgo on node 1
if framework.TestContext.ReportDir != "" { if framework.TestContext.ReportDir != "" {
CoreDump(framework.TestContext.ReportDir) framework.CoreDump(framework.TestContext.ReportDir)
} }
}) })
...@@ -225,6 +226,6 @@ func RunE2ETests(t *testing.T) { ...@@ -225,6 +226,6 @@ func RunE2ETests(t *testing.T) {
r = append(r, reporters.NewJUnitReporter(path.Join(framework.TestContext.ReportDir, fmt.Sprintf("junit_%v%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode)))) r = append(r, reporters.NewJUnitReporter(path.Join(framework.TestContext.ReportDir, fmt.Sprintf("junit_%v%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode))))
} }
} }
glog.Infof("Starting e2e run %q on Ginkgo node %d", runId, config.GinkgoConfig.ParallelNode) glog.Infof("Starting e2e run %q on Ginkgo node %d", framework.RunId, config.GinkgoConfig.ParallelNode)
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Kubernetes e2e suite", r) ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Kubernetes e2e suite", r)
} }
...@@ -18,10 +18,12 @@ package e2e ...@@ -18,10 +18,12 @@ package e2e
import ( import (
"testing" "testing"
"k8s.io/kubernetes/test/e2e/framework"
) )
func init() { func init() {
RegisterFlags() framework.RegisterFlags()
} }
func TestE2E(t *testing.T) { func TestE2E(t *testing.T) {
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apimachinery/registered" "k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
) )
...@@ -33,9 +34,9 @@ const ( ...@@ -33,9 +34,9 @@ const (
testImageNonRootUid = "gcr.io/google_containers/mounttest-user:0.3" testImageNonRootUid = "gcr.io/google_containers/mounttest-user:0.3"
) )
var _ = KubeDescribe("EmptyDir volumes", func() { var _ = framework.KubeDescribe("EmptyDir volumes", func() {
f := NewDefaultFramework("emptydir") f := framework.NewDefaultFramework("emptydir")
Context("when FSGroup is specified [Feature:FSGroup]", func() { Context("when FSGroup is specified [Feature:FSGroup]", func() {
It("new files should be created with FSGroup ownership when container is root", func() { It("new files should be created with FSGroup ownership when container is root", func() {
...@@ -117,7 +118,7 @@ const ( ...@@ -117,7 +118,7 @@ const (
volumeName = "test-volume" volumeName = "test-volume"
) )
func doTestSetgidFSGroup(f *Framework, image string, medium api.StorageMedium) { func doTestSetgidFSGroup(f *framework.Framework, image string, medium api.StorageMedium) {
var ( var (
volumePath = "/test-volume" volumePath = "/test-volume"
filePath = path.Join(volumePath, "test-file") filePath = path.Join(volumePath, "test-file")
...@@ -147,7 +148,7 @@ func doTestSetgidFSGroup(f *Framework, image string, medium api.StorageMedium) { ...@@ -147,7 +148,7 @@ func doTestSetgidFSGroup(f *Framework, image string, medium api.StorageMedium) {
f.TestContainerOutput(msg, pod, 0, out) f.TestContainerOutput(msg, pod, 0, out)
} }
func doTestVolumeModeFSGroup(f *Framework, image string, medium api.StorageMedium) { func doTestVolumeModeFSGroup(f *framework.Framework, image string, medium api.StorageMedium) {
var ( var (
volumePath = "/test-volume" volumePath = "/test-volume"
source = &api.EmptyDirVolumeSource{Medium: medium} source = &api.EmptyDirVolumeSource{Medium: medium}
...@@ -172,7 +173,7 @@ func doTestVolumeModeFSGroup(f *Framework, image string, medium api.StorageMediu ...@@ -172,7 +173,7 @@ func doTestVolumeModeFSGroup(f *Framework, image string, medium api.StorageMediu
f.TestContainerOutput(msg, pod, 0, out) f.TestContainerOutput(msg, pod, 0, out)
} }
func doTest0644FSGroup(f *Framework, image string, medium api.StorageMedium) { func doTest0644FSGroup(f *framework.Framework, image string, medium api.StorageMedium) {
var ( var (
volumePath = "/test-volume" volumePath = "/test-volume"
filePath = path.Join(volumePath, "test-file") filePath = path.Join(volumePath, "test-file")
...@@ -200,7 +201,7 @@ func doTest0644FSGroup(f *Framework, image string, medium api.StorageMedium) { ...@@ -200,7 +201,7 @@ func doTest0644FSGroup(f *Framework, image string, medium api.StorageMedium) {
f.TestContainerOutput(msg, pod, 0, out) f.TestContainerOutput(msg, pod, 0, out)
} }
func doTestVolumeMode(f *Framework, image string, medium api.StorageMedium) { func doTestVolumeMode(f *framework.Framework, image string, medium api.StorageMedium) {
var ( var (
volumePath = "/test-volume" volumePath = "/test-volume"
source = &api.EmptyDirVolumeSource{Medium: medium} source = &api.EmptyDirVolumeSource{Medium: medium}
...@@ -222,7 +223,7 @@ func doTestVolumeMode(f *Framework, image string, medium api.StorageMedium) { ...@@ -222,7 +223,7 @@ func doTestVolumeMode(f *Framework, image string, medium api.StorageMedium) {
f.TestContainerOutput(msg, pod, 0, out) f.TestContainerOutput(msg, pod, 0, out)
} }
func doTest0644(f *Framework, image string, medium api.StorageMedium) { func doTest0644(f *framework.Framework, image string, medium api.StorageMedium) {
var ( var (
volumePath = "/test-volume" volumePath = "/test-volume"
filePath = path.Join(volumePath, "test-file") filePath = path.Join(volumePath, "test-file")
...@@ -247,7 +248,7 @@ func doTest0644(f *Framework, image string, medium api.StorageMedium) { ...@@ -247,7 +248,7 @@ func doTest0644(f *Framework, image string, medium api.StorageMedium) {
f.TestContainerOutput(msg, pod, 0, out) f.TestContainerOutput(msg, pod, 0, out)
} }
func doTest0666(f *Framework, image string, medium api.StorageMedium) { func doTest0666(f *framework.Framework, image string, medium api.StorageMedium) {
var ( var (
volumePath = "/test-volume" volumePath = "/test-volume"
filePath = path.Join(volumePath, "test-file") filePath = path.Join(volumePath, "test-file")
...@@ -272,7 +273,7 @@ func doTest0666(f *Framework, image string, medium api.StorageMedium) { ...@@ -272,7 +273,7 @@ func doTest0666(f *Framework, image string, medium api.StorageMedium) {
f.TestContainerOutput(msg, pod, 0, out) f.TestContainerOutput(msg, pod, 0, out)
} }
func doTest0777(f *Framework, image string, medium api.StorageMedium) { func doTest0777(f *framework.Framework, image string, medium api.StorageMedium) {
var ( var (
volumePath = "/test-volume" volumePath = "/test-volume"
filePath = path.Join(volumePath, "test-file") filePath = path.Join(volumePath, "test-file")
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/test/e2e/framework"
"strconv" "strconv"
...@@ -28,8 +29,8 @@ import ( ...@@ -28,8 +29,8 @@ import (
// This test will create a pod with a secret volume and gitRepo volume // This test will create a pod with a secret volume and gitRepo volume
// Thus requests a secret, a git server pod, and a git server service // Thus requests a secret, a git server pod, and a git server service
var _ = KubeDescribe("EmptyDir wrapper volumes", func() { var _ = framework.KubeDescribe("EmptyDir wrapper volumes", func() {
f := NewDefaultFramework("emptydir-wrapper") f := framework.NewDefaultFramework("emptydir-wrapper")
It("should becomes running", func() { It("should becomes running", func() {
name := "emptydir-wrapper-test-" + string(util.NewUUID()) name := "emptydir-wrapper-test-" + string(util.NewUUID())
...@@ -48,7 +49,7 @@ var _ = KubeDescribe("EmptyDir wrapper volumes", func() { ...@@ -48,7 +49,7 @@ var _ = KubeDescribe("EmptyDir wrapper volumes", func() {
var err error var err error
if secret, err = f.Client.Secrets(f.Namespace.Name).Create(secret); err != nil { if secret, err = f.Client.Secrets(f.Namespace.Name).Create(secret); err != nil {
Failf("unable to create test secret %s: %v", secret.Name, err) framework.Failf("unable to create test secret %s: %v", secret.Name, err)
} }
gitServerPodName := "git-server-" + string(util.NewUUID()) gitServerPodName := "git-server-" + string(util.NewUUID())
...@@ -76,7 +77,7 @@ var _ = KubeDescribe("EmptyDir wrapper volumes", func() { ...@@ -76,7 +77,7 @@ var _ = KubeDescribe("EmptyDir wrapper volumes", func() {
} }
if gitServerPod, err = f.Client.Pods(f.Namespace.Name).Create(gitServerPod); err != nil { if gitServerPod, err = f.Client.Pods(f.Namespace.Name).Create(gitServerPod); err != nil {
Failf("unable to create test git server pod %s: %v", gitServerPod.Name, err) framework.Failf("unable to create test git server pod %s: %v", gitServerPod.Name, err)
} }
// Portal IP and port // Portal IP and port
...@@ -99,7 +100,7 @@ var _ = KubeDescribe("EmptyDir wrapper volumes", func() { ...@@ -99,7 +100,7 @@ var _ = KubeDescribe("EmptyDir wrapper volumes", func() {
} }
if gitServerSvc, err = f.Client.Services(f.Namespace.Name).Create(gitServerSvc); err != nil { if gitServerSvc, err = f.Client.Services(f.Namespace.Name).Create(gitServerSvc); err != nil {
Failf("unable to create test git server service %s: %v", gitServerSvc.Name, err) framework.Failf("unable to create test git server service %s: %v", gitServerSvc.Name, err)
} }
gitVolumeName := "git-volume" gitVolumeName := "git-volume"
...@@ -152,28 +153,28 @@ var _ = KubeDescribe("EmptyDir wrapper volumes", func() { ...@@ -152,28 +153,28 @@ var _ = KubeDescribe("EmptyDir wrapper volumes", func() {
} }
if pod, err = f.Client.Pods(f.Namespace.Name).Create(pod); err != nil { if pod, err = f.Client.Pods(f.Namespace.Name).Create(pod); err != nil {
Failf("unable to create pod %v: %v", pod.Name, err) framework.Failf("unable to create pod %v: %v", pod.Name, err)
} }
defer func() { defer func() {
By("Cleaning up the secret") By("Cleaning up the secret")
if err := f.Client.Secrets(f.Namespace.Name).Delete(secret.Name); err != nil { if err := f.Client.Secrets(f.Namespace.Name).Delete(secret.Name); err != nil {
Failf("unable to delete secret %v: %v", secret.Name, err) framework.Failf("unable to delete secret %v: %v", secret.Name, err)
} }
By("Cleaning up the git server pod") By("Cleaning up the git server pod")
if err = f.Client.Pods(f.Namespace.Name).Delete(gitServerPod.Name, api.NewDeleteOptions(0)); err != nil { if err = f.Client.Pods(f.Namespace.Name).Delete(gitServerPod.Name, api.NewDeleteOptions(0)); err != nil {
Failf("unable to delete git server pod %v: %v", gitServerPod.Name, err) framework.Failf("unable to delete git server pod %v: %v", gitServerPod.Name, err)
} }
By("Cleaning up the git server svc") By("Cleaning up the git server svc")
if err = f.Client.Services(f.Namespace.Name).Delete(gitServerSvc.Name); err != nil { if err = f.Client.Services(f.Namespace.Name).Delete(gitServerSvc.Name); err != nil {
Failf("unable to delete git server svc %v: %v", gitServerSvc.Name, err) framework.Failf("unable to delete git server svc %v: %v", gitServerSvc.Name, err)
} }
By("Cleaning up the git vol pod") By("Cleaning up the git vol pod")
if err = f.Client.Pods(f.Namespace.Name).Delete(pod.Name, api.NewDeleteOptions(0)); err != nil { if err = f.Client.Pods(f.Namespace.Name).Delete(pod.Name, api.NewDeleteOptions(0)); err != nil {
Failf("unable to delete git vol pod %v: %v", pod.Name, err) framework.Failf("unable to delete git vol pod %v: %v", pod.Name, err)
} }
}() }()
expectNoError(waitForPodRunningInNamespace(f.Client, pod.Name, f.Namespace.Name)) framework.ExpectNoError(framework.WaitForPodRunningInNamespace(f.Client, pod.Name, f.Namespace.Name))
}) })
}) })
...@@ -22,14 +22,15 @@ import ( ...@@ -22,14 +22,15 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = KubeDescribe("Etcd failure [Disruptive]", func() { var _ = framework.KubeDescribe("Etcd failure [Disruptive]", func() {
framework := NewDefaultFramework("etcd-failure") f := framework.NewDefaultFramework("etcd-failure")
BeforeEach(func() { BeforeEach(func() {
// This test requires: // This test requires:
...@@ -37,12 +38,12 @@ var _ = KubeDescribe("Etcd failure [Disruptive]", func() { ...@@ -37,12 +38,12 @@ var _ = KubeDescribe("Etcd failure [Disruptive]", func() {
// - master access // - master access
// ... so the provider check should be identical to the intersection of // ... so the provider check should be identical to the intersection of
// providers that provide those capabilities. // providers that provide those capabilities.
SkipUnlessProviderIs("gce") framework.SkipUnlessProviderIs("gce")
Expect(RunRC(RCConfig{ Expect(framework.RunRC(framework.RCConfig{
Client: framework.Client, Client: f.Client,
Name: "baz", Name: "baz",
Namespace: framework.Namespace.Name, Namespace: f.Namespace.Name,
Image: "gcr.io/google_containers/pause:2.0", Image: "gcr.io/google_containers/pause:2.0",
Replicas: 1, Replicas: 1,
})).NotTo(HaveOccurred()) })).NotTo(HaveOccurred())
...@@ -50,7 +51,7 @@ var _ = KubeDescribe("Etcd failure [Disruptive]", func() { ...@@ -50,7 +51,7 @@ var _ = KubeDescribe("Etcd failure [Disruptive]", func() {
It("should recover from network partition with master", func() { It("should recover from network partition with master", func() {
etcdFailTest( etcdFailTest(
framework, f,
"sudo iptables -A INPUT -p tcp --destination-port 4001 -j DROP", "sudo iptables -A INPUT -p tcp --destination-port 4001 -j DROP",
"sudo iptables -D INPUT -p tcp --destination-port 4001 -j DROP", "sudo iptables -D INPUT -p tcp --destination-port 4001 -j DROP",
) )
...@@ -58,19 +59,19 @@ var _ = KubeDescribe("Etcd failure [Disruptive]", func() { ...@@ -58,19 +59,19 @@ var _ = KubeDescribe("Etcd failure [Disruptive]", func() {
It("should recover from SIGKILL", func() { It("should recover from SIGKILL", func() {
etcdFailTest( etcdFailTest(
framework, f,
"pgrep etcd | xargs -I {} sudo kill -9 {}", "pgrep etcd | xargs -I {} sudo kill -9 {}",
"echo 'do nothing. monit should restart etcd.'", "echo 'do nothing. monit should restart etcd.'",
) )
}) })
}) })
func etcdFailTest(framework *Framework, failCommand, fixCommand string) { func etcdFailTest(f *framework.Framework, failCommand, fixCommand string) {
doEtcdFailure(failCommand, fixCommand) doEtcdFailure(failCommand, fixCommand)
checkExistingRCRecovers(framework) checkExistingRCRecovers(f)
ServeImageOrFail(framework, "basic", "gcr.io/google_containers/serve_hostname:v1.4") ServeImageOrFail(f, "basic", "gcr.io/google_containers/serve_hostname:v1.4")
} }
// For this duration, etcd will be failed by executing a failCommand on the master. // For this duration, etcd will be failed by executing a failCommand on the master.
...@@ -89,25 +90,25 @@ func doEtcdFailure(failCommand, fixCommand string) { ...@@ -89,25 +90,25 @@ func doEtcdFailure(failCommand, fixCommand string) {
} }
func masterExec(cmd string) { func masterExec(cmd string) {
result, err := SSH(cmd, getMasterHost()+":22", testContext.Provider) result, err := framework.SSH(cmd, framework.GetMasterHost()+":22", framework.TestContext.Provider)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
if result.Code != 0 { if result.Code != 0 {
LogSSHResult(result) framework.LogSSHResult(result)
Failf("master exec command returned non-zero") framework.Failf("master exec command returned non-zero")
} }
} }
func checkExistingRCRecovers(f *Framework) { func checkExistingRCRecovers(f *framework.Framework) {
By("assert that the pre-existing replication controller recovers") By("assert that the pre-existing replication controller recovers")
podClient := f.Client.Pods(f.Namespace.Name) podClient := f.Client.Pods(f.Namespace.Name)
rcSelector := labels.Set{"name": "baz"}.AsSelector() rcSelector := labels.Set{"name": "baz"}.AsSelector()
By("deleting pods from existing replication controller") By("deleting pods from existing replication controller")
expectNoError(wait.Poll(time.Millisecond*500, time.Second*60, func() (bool, error) { framework.ExpectNoError(wait.Poll(time.Millisecond*500, time.Second*60, func() (bool, error) {
options := api.ListOptions{LabelSelector: rcSelector} options := api.ListOptions{LabelSelector: rcSelector}
pods, err := podClient.List(options) pods, err := podClient.List(options)
if err != nil { if err != nil {
Logf("apiserver returned error, as expected before recovery: %v", err) framework.Logf("apiserver returned error, as expected before recovery: %v", err)
return false, nil return false, nil
} }
if len(pods.Items) == 0 { if len(pods.Items) == 0 {
...@@ -117,12 +118,12 @@ func checkExistingRCRecovers(f *Framework) { ...@@ -117,12 +118,12 @@ func checkExistingRCRecovers(f *Framework) {
err = podClient.Delete(pod.Name, api.NewDeleteOptions(0)) err = podClient.Delete(pod.Name, api.NewDeleteOptions(0))
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
} }
Logf("apiserver has recovered") framework.Logf("apiserver has recovered")
return true, nil return true, nil
})) }))
By("waiting for replication controller to recover") By("waiting for replication controller to recover")
expectNoError(wait.Poll(time.Millisecond*500, time.Second*60, func() (bool, error) { framework.ExpectNoError(wait.Poll(time.Millisecond*500, time.Second*60, func() (bool, error) {
options := api.ListOptions{LabelSelector: rcSelector} options := api.ListOptions{LabelSelector: rcSelector}
pods, err := podClient.List(options) pods, err := podClient.List(options)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
......
...@@ -26,17 +26,18 @@ import ( ...@@ -26,17 +26,18 @@ import (
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = KubeDescribe("Events", func() { var _ = framework.KubeDescribe("Events", func() {
framework := NewDefaultFramework("events") f := framework.NewDefaultFramework("events")
It("should be sent by kubelets and the scheduler about pods scheduling and running [Conformance]", func() { It("should be sent by kubelets and the scheduler about pods scheduling and running [Conformance]", func() {
podClient := framework.Client.Pods(framework.Namespace.Name) podClient := f.Client.Pods(f.Namespace.Name)
By("creating the pod") By("creating the pod")
name := "send-events-" + string(util.NewUUID()) name := "send-events-" + string(util.NewUUID())
...@@ -66,10 +67,10 @@ var _ = KubeDescribe("Events", func() { ...@@ -66,10 +67,10 @@ var _ = KubeDescribe("Events", func() {
podClient.Delete(pod.Name, nil) podClient.Delete(pod.Name, nil)
}() }()
if _, err := podClient.Create(pod); err != nil { if _, err := podClient.Create(pod); err != nil {
Failf("Failed to create pod: %v", err) framework.Failf("Failed to create pod: %v", err)
} }
expectNoError(framework.WaitForPodRunning(pod.Name)) framework.ExpectNoError(f.WaitForPodRunning(pod.Name))
By("verifying the pod is in kubernetes") By("verifying the pod is in kubernetes")
selector := labels.SelectorFromSet(labels.Set(map[string]string{"time": value})) selector := labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))
...@@ -80,21 +81,21 @@ var _ = KubeDescribe("Events", func() { ...@@ -80,21 +81,21 @@ var _ = KubeDescribe("Events", func() {
By("retrieving the pod") By("retrieving the pod")
podWithUid, err := podClient.Get(pod.Name) podWithUid, err := podClient.Get(pod.Name)
if err != nil { if err != nil {
Failf("Failed to get pod: %v", err) framework.Failf("Failed to get pod: %v", err)
} }
fmt.Printf("%+v\n", podWithUid) fmt.Printf("%+v\n", podWithUid)
var events *api.EventList var events *api.EventList
// Check for scheduler event about the pod. // Check for scheduler event about the pod.
By("checking for scheduler event about the pod") By("checking for scheduler event about the pod")
expectNoError(wait.Poll(time.Second*2, time.Second*60, func() (bool, error) { framework.ExpectNoError(wait.Poll(time.Second*2, time.Second*60, func() (bool, error) {
selector := fields.Set{ selector := fields.Set{
"involvedObject.kind": "Pod", "involvedObject.kind": "Pod",
"involvedObject.uid": string(podWithUid.UID), "involvedObject.uid": string(podWithUid.UID),
"involvedObject.namespace": framework.Namespace.Name, "involvedObject.namespace": f.Namespace.Name,
"source": api.DefaultSchedulerName, "source": api.DefaultSchedulerName,
}.AsSelector() }.AsSelector()
options := api.ListOptions{FieldSelector: selector} options := api.ListOptions{FieldSelector: selector}
events, err := framework.Client.Events(framework.Namespace.Name).List(options) events, err := f.Client.Events(f.Namespace.Name).List(options)
if err != nil { if err != nil {
return false, err return false, err
} }
...@@ -106,15 +107,15 @@ var _ = KubeDescribe("Events", func() { ...@@ -106,15 +107,15 @@ var _ = KubeDescribe("Events", func() {
})) }))
// Check for kubelet event about the pod. // Check for kubelet event about the pod.
By("checking for kubelet event about the pod") By("checking for kubelet event about the pod")
expectNoError(wait.Poll(time.Second*2, time.Second*60, func() (bool, error) { framework.ExpectNoError(wait.Poll(time.Second*2, time.Second*60, func() (bool, error) {
selector := fields.Set{ selector := fields.Set{
"involvedObject.uid": string(podWithUid.UID), "involvedObject.uid": string(podWithUid.UID),
"involvedObject.kind": "Pod", "involvedObject.kind": "Pod",
"involvedObject.namespace": framework.Namespace.Name, "involvedObject.namespace": f.Namespace.Name,
"source": "kubelet", "source": "kubelet",
}.AsSelector() }.AsSelector()
options := api.ListOptions{FieldSelector: selector} options := api.ListOptions{FieldSelector: selector}
events, err = framework.Client.Events(framework.Namespace.Name).List(options) events, err = f.Client.Events(f.Namespace.Name).List(options)
if err != nil { if err != nil {
return false, err return false, err
} }
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -41,17 +42,17 @@ try: ...@@ -41,17 +42,17 @@ try:
except: except:
print 'err'` print 'err'`
var _ = KubeDescribe("ClusterDns [Feature:Example]", func() { var _ = framework.KubeDescribe("ClusterDns [Feature:Example]", func() {
framework := NewDefaultFramework("cluster-dns") f := framework.NewDefaultFramework("cluster-dns")
var c *client.Client var c *client.Client
BeforeEach(func() { BeforeEach(func() {
c = framework.Client c = f.Client
}) })
It("should create pod that uses dns [Conformance]", func() { It("should create pod that uses dns [Conformance]", func() {
mkpath := func(file string) string { mkpath := func(file string) string {
return filepath.Join(testContext.RepoRoot, "examples/cluster-dns", file) return filepath.Join(framework.TestContext.RepoRoot, "examples/cluster-dns", file)
} }
// contrary to the example, this test does not use contexts, for simplicity // contrary to the example, this test does not use contexts, for simplicity
...@@ -75,22 +76,22 @@ var _ = KubeDescribe("ClusterDns [Feature:Example]", func() { ...@@ -75,22 +76,22 @@ var _ = KubeDescribe("ClusterDns [Feature:Example]", func() {
namespaces := []*api.Namespace{nil, nil} namespaces := []*api.Namespace{nil, nil}
for i := range namespaces { for i := range namespaces {
var err error var err error
namespaces[i], err = framework.CreateNamespace(fmt.Sprintf("dnsexample%d", i), nil) namespaces[i], err = f.CreateNamespace(fmt.Sprintf("dnsexample%d", i), nil)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
} }
for _, ns := range namespaces { for _, ns := range namespaces {
runKubectlOrDie("create", "-f", backendRcYaml, getNsCmdFlag(ns)) framework.RunKubectlOrDie("create", "-f", backendRcYaml, getNsCmdFlag(ns))
} }
for _, ns := range namespaces { for _, ns := range namespaces {
runKubectlOrDie("create", "-f", backendSvcYaml, getNsCmdFlag(ns)) framework.RunKubectlOrDie("create", "-f", backendSvcYaml, getNsCmdFlag(ns))
} }
// wait for objects // wait for objects
for _, ns := range namespaces { for _, ns := range namespaces {
waitForRCPodsRunning(c, ns.Name, backendRcName) framework.WaitForRCPodsRunning(c, ns.Name, backendRcName)
waitForService(c, ns.Name, backendSvcName, true, poll, serviceStartTimeout) framework.WaitForService(c, ns.Name, backendSvcName, true, framework.Poll, framework.ServiceStartTimeout)
} }
// it is not enough that pods are running because they may be set to running, but // it is not enough that pods are running because they may be set to running, but
// the application itself may have not been initialized. Just query the application. // the application itself may have not been initialized. Just query the application.
...@@ -99,11 +100,11 @@ var _ = KubeDescribe("ClusterDns [Feature:Example]", func() { ...@@ -99,11 +100,11 @@ var _ = KubeDescribe("ClusterDns [Feature:Example]", func() {
options := api.ListOptions{LabelSelector: label} options := api.ListOptions{LabelSelector: label}
pods, err := c.Pods(ns.Name).List(options) pods, err := c.Pods(ns.Name).List(options)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
err = podsResponding(c, ns.Name, backendPodName, false, pods) err = framework.PodsResponding(c, ns.Name, backendPodName, false, pods)
Expect(err).NotTo(HaveOccurred(), "waiting for all pods to respond") Expect(err).NotTo(HaveOccurred(), "waiting for all pods to respond")
Logf("found %d backend pods responding in namespace %s", len(pods.Items), ns.Name) framework.Logf("found %d backend pods responding in namespace %s", len(pods.Items), ns.Name)
err = serviceResponding(c, ns.Name, backendSvcName) err = framework.ServiceResponding(c, ns.Name, backendSvcName)
Expect(err).NotTo(HaveOccurred(), "waiting for the service to respond") Expect(err).NotTo(HaveOccurred(), "waiting for the service to respond")
} }
...@@ -120,31 +121,31 @@ var _ = KubeDescribe("ClusterDns [Feature:Example]", func() { ...@@ -120,31 +121,31 @@ var _ = KubeDescribe("ClusterDns [Feature:Example]", func() {
pods, err := c.Pods(namespaces[0].Name).List(options) pods, err := c.Pods(namespaces[0].Name).List(options)
if err != nil || pods == nil || len(pods.Items) == 0 { if err != nil || pods == nil || len(pods.Items) == 0 {
Failf("no running pods found") framework.Failf("no running pods found")
} }
podName := pods.Items[0].Name podName := pods.Items[0].Name
queryDns := fmt.Sprintf(queryDnsPythonTemplate, backendSvcName+"."+namespaces[0].Name) queryDns := fmt.Sprintf(queryDnsPythonTemplate, backendSvcName+"."+namespaces[0].Name)
_, err = lookForStringInPodExec(namespaces[0].Name, podName, []string{"python", "-c", queryDns}, "ok", dnsReadyTimeout) _, err = framework.LookForStringInPodExec(namespaces[0].Name, podName, []string{"python", "-c", queryDns}, "ok", dnsReadyTimeout)
Expect(err).NotTo(HaveOccurred(), "waiting for output from pod exec") Expect(err).NotTo(HaveOccurred(), "waiting for output from pod exec")
updatedPodYaml := prepareResourceWithReplacedString(frontendPodYaml, "dns-backend.development.cluster.local", fmt.Sprintf("dns-backend.%s.svc.cluster.local", namespaces[0].Name)) updatedPodYaml := prepareResourceWithReplacedString(frontendPodYaml, "dns-backend.development.cluster.local", fmt.Sprintf("dns-backend.%s.svc.cluster.local", namespaces[0].Name))
// create a pod in each namespace // create a pod in each namespace
for _, ns := range namespaces { for _, ns := range namespaces {
newKubectlCommand("create", "-f", "-", getNsCmdFlag(ns)).withStdinData(updatedPodYaml).execOrDie() framework.NewKubectlCommand("create", "-f", "-", getNsCmdFlag(ns)).WithStdinData(updatedPodYaml).ExecOrDie()
} }
// wait until the pods have been scheduler, i.e. are not Pending anymore. Remember // wait until the pods have been scheduler, i.e. are not Pending anymore. Remember
// that we cannot wait for the pods to be running because our pods terminate by themselves. // that we cannot wait for the pods to be running because our pods terminate by themselves.
for _, ns := range namespaces { for _, ns := range namespaces {
err := waitForPodNotPending(c, ns.Name, frontendPodName) err := framework.WaitForPodNotPending(c, ns.Name, frontendPodName)
expectNoError(err) framework.ExpectNoError(err)
} }
// wait for pods to print their result // wait for pods to print their result
for _, ns := range namespaces { for _, ns := range namespaces {
_, err := lookForStringInLog(ns.Name, frontendPodName, frontendPodContainerName, podOutput, podStartTimeout) _, err := framework.LookForStringInLog(ns.Name, frontendPodName, frontendPodContainerName, podOutput, framework.PodStartTimeout)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
} }
}) })
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"time" "time"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -33,7 +34,7 @@ import ( ...@@ -33,7 +34,7 @@ import (
const ( const (
k8bpsContainerVersion = "r.2.8.19" // Container version, see the examples/k8petstore dockerfiles for details. k8bpsContainerVersion = "r.2.8.19" // Container version, see the examples/k8petstore dockerfiles for details.
k8bpsThroughputDummy = "0" // Polling time = 0, since we poll in ginkgo rather than using the shell script tests. k8bpsThroughputDummy = "0" // Polling time = 0, since we framework.Poll in ginkgo rather than using the shell script tests.
k8bpsRedisSlaves = "1" // Number of redis slaves. k8bpsRedisSlaves = "1" // Number of redis slaves.
k8bpsDontRunTest = "0" // Don't bother embedded test. k8bpsDontRunTest = "0" // Don't bother embedded test.
k8bpsStartupTimeout = 30 * time.Second // Amount of elapsed time before petstore transactions are being stored. k8bpsStartupTimeout = 30 * time.Second // Amount of elapsed time before petstore transactions are being stored.
...@@ -47,7 +48,7 @@ const ( ...@@ -47,7 +48,7 @@ const (
// readTransactions reads # of transactions from the k8petstore web server endpoint. // readTransactions reads # of transactions from the k8petstore web server endpoint.
// for more details see the source of the k8petstore web server. // for more details see the source of the k8petstore web server.
func readTransactions(c *client.Client, ns string) (error, int) { func readTransactions(c *client.Client, ns string) (error, int) {
proxyRequest, errProxy := getServicesProxyRequest(c, c.Get()) proxyRequest, errProxy := framework.GetServicesProxyRequest(c, c.Get())
if errProxy != nil { if errProxy != nil {
return errProxy, -1 return errProxy, -1
} }
...@@ -68,11 +69,11 @@ func readTransactions(c *client.Client, ns string) (error, int) { ...@@ -68,11 +69,11 @@ func readTransactions(c *client.Client, ns string) (error, int) {
func runK8petstore(restServers int, loadGenerators int, c *client.Client, ns string, finalTransactionsExpected int, maxTime time.Duration) { func runK8petstore(restServers int, loadGenerators int, c *client.Client, ns string, finalTransactionsExpected int, maxTime time.Duration) {
var err error = nil var err error = nil
k8bpsScriptLocation := filepath.Join(testContext.RepoRoot, "examples/k8petstore/k8petstore-nodeport.sh") k8bpsScriptLocation := filepath.Join(framework.TestContext.RepoRoot, "examples/k8petstore/k8petstore-nodeport.sh")
cmd := exec.Command( cmd := exec.Command(
k8bpsScriptLocation, k8bpsScriptLocation,
testContext.KubectlPath, framework.TestContext.KubectlPath,
k8bpsContainerVersion, k8bpsContainerVersion,
k8bpsThroughputDummy, k8bpsThroughputDummy,
strconv.Itoa(restServers), strconv.Itoa(restServers),
...@@ -85,25 +86,25 @@ func runK8petstore(restServers int, loadGenerators int, c *client.Client, ns str ...@@ -85,25 +86,25 @@ func runK8petstore(restServers int, loadGenerators int, c *client.Client, ns str
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
Logf("Starting k8petstore application....") framework.Logf("Starting k8petstore application....")
// Run the k8petstore app, and log / fail if it returns any errors. // Run the k8petstore app, and log / fail if it returns any errors.
// This should return quickly, assuming containers are downloaded. // This should return quickly, assuming containers are downloaded.
if err = cmd.Start(); err != nil { if err = cmd.Start(); err != nil {
Failf("%v", err) framework.Failf("%v", err)
} }
// Make sure there are no command errors. // Make sure there are no command errors.
if err = cmd.Wait(); err != nil { if err = cmd.Wait(); err != nil {
if exiterr, ok := err.(*exec.ExitError); ok { if exiterr, ok := err.(*exec.ExitError); ok {
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
Logf("Exit Status: %d", status.ExitStatus()) framework.Logf("Exit Status: %d", status.ExitStatus())
} }
} }
} }
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Logf("... Done starting k8petstore ") framework.Logf("... Done starting k8petstore ")
totalTransactions := 0 totalTransactions := 0
Logf("Start polling, timeout is %v seconds", maxTime) framework.Logf("Start polling, timeout is %v seconds", maxTime)
// How long until the FIRST transactions are created. // How long until the FIRST transactions are created.
startupTimeout := time.After(time.Duration(k8bpsStartupTimeout)) startupTimeout := time.After(time.Duration(k8bpsStartupTimeout))
...@@ -113,18 +114,18 @@ func runK8petstore(restServers int, loadGenerators int, c *client.Client, ns str ...@@ -113,18 +114,18 @@ func runK8petstore(restServers int, loadGenerators int, c *client.Client, ns str
tick := time.Tick(2 * time.Second) tick := time.Tick(2 * time.Second)
var ready = false var ready = false
Logf("Now waiting %v seconds to see progress (transactions > 3)", k8bpsStartupTimeout) framework.Logf("Now waiting %v seconds to see progress (transactions > 3)", k8bpsStartupTimeout)
T: T:
for { for {
select { select {
case <-transactionsCompleteTimeout: case <-transactionsCompleteTimeout:
Logf("Completion timeout %v reached, %v transactions not complete. Breaking!", time.Duration(maxTime), finalTransactionsExpected) framework.Logf("Completion timeout %v reached, %v transactions not complete. Breaking!", time.Duration(maxTime), finalTransactionsExpected)
break T break T
case <-tick: case <-tick:
// Don't fail if there's an error. We expect a few failures might happen in the cloud. // Don't fail if there's an error. We expect a few failures might happen in the cloud.
err, totalTransactions = readTransactions(c, ns) err, totalTransactions = readTransactions(c, ns)
if err == nil { if err == nil {
Logf("PetStore : Time: %v, %v = total petstore transactions stored into redis.", time.Now(), totalTransactions) framework.Logf("PetStore : Time: %v, %v = total petstore transactions stored into redis.", time.Now(), totalTransactions)
if totalTransactions >= k8bpsMinTransactionsOnStartup { if totalTransactions >= k8bpsMinTransactionsOnStartup {
ready = true ready = true
} }
...@@ -133,14 +134,14 @@ T: ...@@ -133,14 +134,14 @@ T:
} }
} else { } else {
if ready { if ready {
Logf("Blip: during polling: %v", err) framework.Logf("Blip: during polling: %v", err)
} else { } else {
Logf("Not ready yet: %v", err) framework.Logf("Not ready yet: %v", err)
} }
} }
case <-startupTimeout: case <-startupTimeout:
if !ready { if !ready {
Logf("Startup Timeout %v reached: Its been too long and we still haven't started accumulating %v transactions!", startupTimeout, k8bpsMinTransactionsOnStartup) framework.Logf("Startup Timeout %v reached: Its been too long and we still haven't started accumulating %v transactions!", startupTimeout, k8bpsMinTransactionsOnStartup)
break T break T
} }
} }
...@@ -152,19 +153,19 @@ T: ...@@ -152,19 +153,19 @@ T:
Ω(totalTransactions).Should(BeNumerically(">", finalTransactionsExpected)) Ω(totalTransactions).Should(BeNumerically(">", finalTransactionsExpected))
} }
var _ = KubeDescribe("Pet Store [Feature:Example]", func() { var _ = framework.KubeDescribe("Pet Store [Feature:Example]", func() {
BeforeEach(func() { BeforeEach(func() {
// The shell scripts in k8petstore break on jenkins... Pure golang rewrite is in progress. // The shell scripts in k8petstore break on jenkins... Pure golang rewrite is in progress.
SkipUnlessProviderIs("local") framework.SkipUnlessProviderIs("local")
}) })
// The number of nodes dictates total number of generators/transaction expectations. // The number of nodes dictates total number of generators/transaction expectations.
var nodeCount int var nodeCount int
f := NewDefaultFramework("petstore") f := framework.NewDefaultFramework("petstore")
It(fmt.Sprintf("should scale to persist a nominal number ( %v ) of transactions in %v seconds", k8bpsSmokeTestFinalTransactions, k8bpsSmokeTestTimeout), func() { It(fmt.Sprintf("should scale to persist a nominal number ( %v ) of transactions in %v seconds", k8bpsSmokeTestFinalTransactions, k8bpsSmokeTestTimeout), func() {
nodes := ListSchedulableNodesOrDie(f.Client) nodes := framework.ListSchedulableNodesOrDie(f.Client)
nodeCount = len(nodes.Items) nodeCount = len(nodes.Items)
loadGenerators := nodeCount loadGenerators := nodeCount
......
...@@ -19,14 +19,15 @@ package e2e ...@@ -19,14 +19,15 @@ package e2e
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
) )
// These tests exercise the Kubernetes expansion syntax $(VAR). // These tests exercise the Kubernetes expansion syntax $(VAR).
// For more information, see: docs/design/expansion.md // For more information, see: docs/design/expansion.md
var _ = KubeDescribe("Variable Expansion", func() { var _ = framework.KubeDescribe("Variable Expansion", func() {
framework := NewDefaultFramework("var-expansion") f := framework.NewDefaultFramework("var-expansion")
It("should allow composing env vars into new env vars [Conformance]", func() { It("should allow composing env vars into new env vars [Conformance]", func() {
podName := "var-expansion-" + string(util.NewUUID()) podName := "var-expansion-" + string(util.NewUUID())
...@@ -61,7 +62,7 @@ var _ = KubeDescribe("Variable Expansion", func() { ...@@ -61,7 +62,7 @@ var _ = KubeDescribe("Variable Expansion", func() {
}, },
} }
framework.TestContainerOutput("env composition", pod, 0, []string{ f.TestContainerOutput("env composition", pod, 0, []string{
"FOO=foo-value", "FOO=foo-value",
"BAR=bar-value", "BAR=bar-value",
"FOOBAR=foo-value;;bar-value", "FOOBAR=foo-value;;bar-value",
...@@ -93,7 +94,7 @@ var _ = KubeDescribe("Variable Expansion", func() { ...@@ -93,7 +94,7 @@ var _ = KubeDescribe("Variable Expansion", func() {
}, },
} }
framework.TestContainerOutput("substitution in container's command", pod, 0, []string{ f.TestContainerOutput("substitution in container's command", pod, 0, []string{
"test-value", "test-value",
}) })
}) })
...@@ -124,7 +125,7 @@ var _ = KubeDescribe("Variable Expansion", func() { ...@@ -124,7 +125,7 @@ var _ = KubeDescribe("Variable Expansion", func() {
}, },
} }
framework.TestContainerOutput("substitution in container's args", pod, 0, []string{ f.TestContainerOutput("substitution in container's args", pod, 0, []string{
"test-value", "test-value",
}) })
}) })
......
/* /*
Copyright 2015 The Kubernetes Authors All rights reserved. Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
......
...@@ -56,15 +56,15 @@ type Framework struct { ...@@ -56,15 +56,15 @@ type Framework struct {
// Constraints that passed to a check which is executed after data is gathered to // Constraints that passed to a check which is executed after data is gathered to
// see if 99% of results are within acceptable bounds. It as to be injected in the test, // see if 99% of results are within acceptable bounds. It as to be injected in the test,
// as expectations vary greatly. Constraints are groupped by the container names. // as expectations vary greatly. Constraints are groupped by the container names.
addonResourceConstraints map[string]resourceConstraint AddonResourceConstraints map[string]ResourceConstraint
logsSizeWaitGroup sync.WaitGroup logsSizeWaitGroup sync.WaitGroup
logsSizeCloseChannel chan bool logsSizeCloseChannel chan bool
logsSizeVerifier *LogsSizeVerifier logsSizeVerifier *LogsSizeVerifier
// To make sure that this framework cleans up after itself, no matter what, // To make sure that this framework cleans up after itself, no matter what,
// we install a cleanup action before each test and clear it after. If we // we install a Cleanup action before each test and clear it after. If we
// should abort, the AfterSuite hook should run all cleanup actions. // should abort, the AfterSuite hook should run all Cleanup actions.
cleanupHandle CleanupActionHandle cleanupHandle CleanupActionHandle
// configuration for framework's client // configuration for framework's client
...@@ -77,16 +77,16 @@ type TestDataSummary interface { ...@@ -77,16 +77,16 @@ type TestDataSummary interface {
} }
type FrameworkOptions struct { type FrameworkOptions struct {
clientQPS float32 ClientQPS float32
clientBurst int ClientBurst int
} }
// NewFramework makes a new framework and sets up a BeforeEach/AfterEach for // NewFramework makes a new framework and sets up a BeforeEach/AfterEach for
// you (you can write additional before/after each functions). // you (you can write additional before/after each functions).
func NewDefaultFramework(baseName string) *Framework { func NewDefaultFramework(baseName string) *Framework {
options := FrameworkOptions{ options := FrameworkOptions{
clientQPS: 20, ClientQPS: 20,
clientBurst: 50, ClientBurst: 50,
} }
return NewFramework(baseName, options) return NewFramework(baseName, options)
} }
...@@ -94,27 +94,27 @@ func NewDefaultFramework(baseName string) *Framework { ...@@ -94,27 +94,27 @@ func NewDefaultFramework(baseName string) *Framework {
func NewFramework(baseName string, options FrameworkOptions) *Framework { func NewFramework(baseName string, options FrameworkOptions) *Framework {
f := &Framework{ f := &Framework{
BaseName: baseName, BaseName: baseName,
addonResourceConstraints: make(map[string]resourceConstraint), AddonResourceConstraints: make(map[string]ResourceConstraint),
options: options, options: options,
} }
BeforeEach(f.beforeEach) BeforeEach(f.BeforeEach)
AfterEach(f.afterEach) AfterEach(f.AfterEach)
return f return f
} }
// beforeEach gets a client and makes a namespace. // BeforeEach gets a client and makes a namespace.
func (f *Framework) beforeEach() { func (f *Framework) BeforeEach() {
// The fact that we need this feels like a bug in ginkgo. // The fact that we need this feels like a bug in ginkgo.
// https://github.com/onsi/ginkgo/issues/222 // https://github.com/onsi/ginkgo/issues/222
f.cleanupHandle = AddCleanupAction(f.afterEach) f.cleanupHandle = AddCleanupAction(f.AfterEach)
By("Creating a kubernetes client") By("Creating a kubernetes client")
config, err := loadConfig() config, err := LoadConfig()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
config.QPS = f.options.clientQPS config.QPS = f.options.ClientQPS
config.Burst = f.options.clientBurst config.Burst = f.options.ClientBurst
c, err := loadClientFromConfig(config) c, err := loadClientFromConfig(config)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
...@@ -129,15 +129,15 @@ func (f *Framework) beforeEach() { ...@@ -129,15 +129,15 @@ func (f *Framework) beforeEach() {
f.Namespace = namespace f.Namespace = namespace
if testContext.VerifyServiceAccount { if TestContext.VerifyServiceAccount {
By("Waiting for a default service account to be provisioned in namespace") By("Waiting for a default service account to be provisioned in namespace")
err = waitForDefaultServiceAccountInNamespace(c, namespace.Name) err = WaitForDefaultServiceAccountInNamespace(c, namespace.Name)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
} else { } else {
Logf("Skipping waiting for service account") Logf("Skipping waiting for service account")
} }
if testContext.GatherKubeSystemResourceUsageData { if TestContext.GatherKubeSystemResourceUsageData {
f.gatherer, err = NewResourceUsageGatherer(c) f.gatherer, err = NewResourceUsageGatherer(c)
if err != nil { if err != nil {
Logf("Error while creating NewResourceUsageGatherer: %v", err) Logf("Error while creating NewResourceUsageGatherer: %v", err)
...@@ -146,7 +146,7 @@ func (f *Framework) beforeEach() { ...@@ -146,7 +146,7 @@ func (f *Framework) beforeEach() {
} }
} }
if testContext.GatherLogsSizes { if TestContext.GatherLogsSizes {
f.logsSizeWaitGroup = sync.WaitGroup{} f.logsSizeWaitGroup = sync.WaitGroup{}
f.logsSizeWaitGroup.Add(1) f.logsSizeWaitGroup.Add(1)
f.logsSizeCloseChannel = make(chan bool) f.logsSizeCloseChannel = make(chan bool)
...@@ -158,14 +158,14 @@ func (f *Framework) beforeEach() { ...@@ -158,14 +158,14 @@ func (f *Framework) beforeEach() {
} }
} }
// afterEach deletes the namespace, after reading its events. // AfterEach deletes the namespace, after reading its events.
func (f *Framework) afterEach() { func (f *Framework) AfterEach() {
RemoveCleanupAction(f.cleanupHandle) RemoveCleanupAction(f.cleanupHandle)
// DeleteNamespace at the very end in defer, to avoid any // DeleteNamespace at the very end in defer, to avoid any
// expectation failures preventing deleting the namespace. // expectation failures preventing deleting the namespace.
defer func() { defer func() {
if testContext.DeleteNamespace { if TestContext.DeleteNamespace {
for _, ns := range f.namespacesToDelete { for _, ns := range f.namespacesToDelete {
By(fmt.Sprintf("Destroying namespace %q for this suite.", ns.Name)) By(fmt.Sprintf("Destroying namespace %q for this suite.", ns.Name))
...@@ -193,23 +193,23 @@ func (f *Framework) afterEach() { ...@@ -193,23 +193,23 @@ func (f *Framework) afterEach() {
// Print events if the test failed. // Print events if the test failed.
if CurrentGinkgoTestDescription().Failed { if CurrentGinkgoTestDescription().Failed {
dumpAllNamespaceInfo(f.Client, f.Namespace.Name) DumpAllNamespaceInfo(f.Client, f.Namespace.Name)
} }
summaries := make([]TestDataSummary, 0) summaries := make([]TestDataSummary, 0)
if testContext.GatherKubeSystemResourceUsageData && f.gatherer != nil { if TestContext.GatherKubeSystemResourceUsageData && f.gatherer != nil {
By("Collecting resource usage data") By("Collecting resource usage data")
summaries = append(summaries, f.gatherer.stopAndSummarize([]int{90, 99, 100}, f.addonResourceConstraints)) summaries = append(summaries, f.gatherer.stopAndSummarize([]int{90, 99, 100}, f.AddonResourceConstraints))
} }
if testContext.GatherLogsSizes { if TestContext.GatherLogsSizes {
By("Gathering log sizes data") By("Gathering log sizes data")
close(f.logsSizeCloseChannel) close(f.logsSizeCloseChannel)
f.logsSizeWaitGroup.Wait() f.logsSizeWaitGroup.Wait()
summaries = append(summaries, f.logsSizeVerifier.GetSummary()) summaries = append(summaries, f.logsSizeVerifier.GetSummary())
} }
if testContext.GatherMetricsAfterTest { if TestContext.GatherMetricsAfterTest {
By("Gathering metrics") By("Gathering metrics")
// TODO: enable Scheduler and ControllerManager metrics grabbing when Master's Kubelet will be registered. // TODO: enable Scheduler and ControllerManager metrics grabbing when Master's Kubelet will be registered.
grabber, err := metrics.NewMetricsGrabber(f.Client, true, false, false, true) grabber, err := metrics.NewMetricsGrabber(f.Client, true, false, false, true)
...@@ -225,7 +225,7 @@ func (f *Framework) afterEach() { ...@@ -225,7 +225,7 @@ func (f *Framework) afterEach() {
} }
} }
outputTypes := strings.Split(testContext.OutputPrintType, ",") outputTypes := strings.Split(TestContext.OutputPrintType, ",")
for _, printType := range outputTypes { for _, printType := range outputTypes {
switch printType { switch printType {
case "hr": case "hr":
...@@ -246,13 +246,13 @@ func (f *Framework) afterEach() { ...@@ -246,13 +246,13 @@ func (f *Framework) afterEach() {
// Check whether all nodes are ready after the test. // Check whether all nodes are ready after the test.
// This is explicitly done at the very end of the test, to avoid // This is explicitly done at the very end of the test, to avoid
// e.g. not removing namespace in case of this failure. // e.g. not removing namespace in case of this failure.
if err := allNodesReady(f.Client, time.Minute); err != nil { if err := AllNodesReady(f.Client, time.Minute); err != nil {
Failf("All nodes should be ready after test, %v", err) Failf("All nodes should be ready after test, %v", err)
} }
} }
func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (*api.Namespace, error) { func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (*api.Namespace, error) {
createTestingNS := testContext.CreateTestingNS createTestingNS := TestContext.CreateTestingNS
if createTestingNS == nil { if createTestingNS == nil {
createTestingNS = CreateTestingNS createTestingNS = CreateTestingNS
} }
...@@ -270,12 +270,12 @@ func (f *Framework) WaitForPodTerminated(podName, reason string) error { ...@@ -270,12 +270,12 @@ func (f *Framework) WaitForPodTerminated(podName, reason string) error {
// WaitForPodRunning waits for the pod to run in the namespace. // WaitForPodRunning waits for the pod to run in the namespace.
func (f *Framework) WaitForPodRunning(podName string) error { func (f *Framework) WaitForPodRunning(podName string) error {
return waitForPodRunningInNamespace(f.Client, podName, f.Namespace.Name) return WaitForPodRunningInNamespace(f.Client, podName, f.Namespace.Name)
} }
// WaitForPodReady waits for the pod to flip to ready in the namespace. // WaitForPodReady waits for the pod to flip to ready in the namespace.
func (f *Framework) WaitForPodReady(podName string) error { func (f *Framework) WaitForPodReady(podName string) error {
return waitTimeoutForPodReadyInNamespace(f.Client, podName, f.Namespace.Name, podStartTimeout) return waitTimeoutForPodReadyInNamespace(f.Client, podName, f.Namespace.Name, PodStartTimeout)
} }
// WaitForPodRunningSlow waits for the pod to run in the namespace. // WaitForPodRunningSlow waits for the pod to run in the namespace.
...@@ -287,12 +287,12 @@ func (f *Framework) WaitForPodRunningSlow(podName string) error { ...@@ -287,12 +287,12 @@ func (f *Framework) WaitForPodRunningSlow(podName string) error {
// WaitForPodNoLongerRunning waits for the pod to no longer be running in the namespace, for either // WaitForPodNoLongerRunning waits for the pod to no longer be running in the namespace, for either
// success or failure. // success or failure.
func (f *Framework) WaitForPodNoLongerRunning(podName string) error { func (f *Framework) WaitForPodNoLongerRunning(podName string) error {
return waitForPodNoLongerRunningInNamespace(f.Client, podName, f.Namespace.Name) return WaitForPodNoLongerRunningInNamespace(f.Client, podName, f.Namespace.Name)
} }
// Runs the given pod and verifies that the output of exact container matches the desired output. // Runs the given pod and verifies that the output of exact container matches the desired output.
func (f *Framework) TestContainerOutput(scenarioName string, pod *api.Pod, containerIndex int, expectedOutput []string) { func (f *Framework) TestContainerOutput(scenarioName string, pod *api.Pod, containerIndex int, expectedOutput []string) {
testContainerOutput(scenarioName, f.Client, pod, containerIndex, expectedOutput, f.Namespace.Name) TestContainerOutput(scenarioName, f.Client, pod, containerIndex, expectedOutput, f.Namespace.Name)
} }
// Runs the given pod and verifies that the output of exact container matches the desired regexps. // Runs the given pod and verifies that the output of exact container matches the desired regexps.
...@@ -406,7 +406,7 @@ func kubectlExec(namespace string, podName, containerName string, args ...string ...@@ -406,7 +406,7 @@ func kubectlExec(namespace string, podName, containerName string, args ...string
} }
cmdArgs = append(cmdArgs, args...) cmdArgs = append(cmdArgs, args...)
cmd := kubectlCmd(cmdArgs...) cmd := KubectlCmd(cmdArgs...)
cmd.Stdout, cmd.Stderr = &stdout, &stderr cmd.Stdout, cmd.Stderr = &stdout, &stderr
Logf("Running '%s %s'", cmd.Path, strings.Join(cmd.Args, " ")) Logf("Running '%s %s'", cmd.Path, strings.Join(cmd.Args, " "))
......
...@@ -101,7 +101,7 @@ func (s *LogsSizeDataSummary) PrintHumanReadable() string { ...@@ -101,7 +101,7 @@ func (s *LogsSizeDataSummary) PrintHumanReadable() string {
} }
func (s *LogsSizeDataSummary) PrintJSON() string { func (s *LogsSizeDataSummary) PrintJSON() string {
return prettyPrintJSON(*s) return PrettyPrintJSON(*s)
} }
type LogsSizeData struct { type LogsSizeData struct {
...@@ -144,8 +144,8 @@ func (d *LogsSizeData) AddNewData(ip, path string, timestamp time.Time, size int ...@@ -144,8 +144,8 @@ func (d *LogsSizeData) AddNewData(ip, path string, timestamp time.Time, size int
// NewLogsVerifier creates a new LogsSizeVerifier which will stop when stopChannel is closed // NewLogsVerifier creates a new LogsSizeVerifier which will stop when stopChannel is closed
func NewLogsVerifier(c *client.Client, stopChannel chan bool) *LogsSizeVerifier { func NewLogsVerifier(c *client.Client, stopChannel chan bool) *LogsSizeVerifier {
nodeAddresses, err := NodeSSHHosts(c) nodeAddresses, err := NodeSSHHosts(c)
expectNoError(err) ExpectNoError(err)
masterAddress := getMasterHost() + ":22" masterAddress := GetMasterHost() + ":22"
workChannel := make(chan WorkItem, len(nodeAddresses)+1) workChannel := make(chan WorkItem, len(nodeAddresses)+1)
workers := make([]*LogSizeGatherer, workersNo) workers := make([]*LogSizeGatherer, workersNo)
...@@ -241,7 +241,7 @@ func (g *LogSizeGatherer) Work() bool { ...@@ -241,7 +241,7 @@ func (g *LogSizeGatherer) Work() bool {
sshResult, err := SSH( sshResult, err := SSH(
fmt.Sprintf("ls -l %v | awk '{print $9, $5}' | tr '\n' ' '", strings.Join(workItem.paths, " ")), fmt.Sprintf("ls -l %v | awk '{print $9, $5}' | tr '\n' ' '", strings.Join(workItem.paths, " ")),
workItem.ip, workItem.ip,
testContext.Provider, TestContext.Provider,
) )
if err != nil { if err != nil {
Logf("Error while trying to SSH to %v, skipping probe. Error: %v", workItem.ip, err) Logf("Error while trying to SSH to %v, skipping probe. Error: %v", workItem.ip, err)
......
...@@ -91,7 +91,7 @@ func (m *MetricsForE2E) PrintHumanReadable() string { ...@@ -91,7 +91,7 @@ func (m *MetricsForE2E) PrintHumanReadable() string {
func (m *MetricsForE2E) PrintJSON() string { func (m *MetricsForE2E) PrintJSON() string {
m.filterMetrics() m.filterMetrics()
return prettyPrintJSON(*m) return PrettyPrintJSON(*m)
} }
var InterestingApiServerMetrics = []string{ var InterestingApiServerMetrics = []string{
...@@ -287,7 +287,7 @@ func HighLatencyRequests(c *client.Client) (int, error) { ...@@ -287,7 +287,7 @@ func HighLatencyRequests(c *client.Client) (int, error) {
} }
} }
Logf("API calls latencies: %s", prettyPrintJSON(metrics)) Logf("API calls latencies: %s", PrettyPrintJSON(metrics))
return badMetrics, nil return badMetrics, nil
} }
...@@ -295,7 +295,7 @@ func HighLatencyRequests(c *client.Client) (int, error) { ...@@ -295,7 +295,7 @@ func HighLatencyRequests(c *client.Client) (int, error) {
// Verifies whether 50, 90 and 99th percentiles of PodStartupLatency are // Verifies whether 50, 90 and 99th percentiles of PodStartupLatency are
// within the threshold. // within the threshold.
func VerifyPodStartupLatency(latency PodStartupLatency) error { func VerifyPodStartupLatency(latency PodStartupLatency) error {
Logf("Pod startup latency: %s", prettyPrintJSON(latency)) Logf("Pod startup latency: %s", PrettyPrintJSON(latency))
if latency.Latency.Perc50 > podStartupThreshold { if latency.Latency.Perc50 > podStartupThreshold {
return fmt.Errorf("too high pod startup latency 50th percentile: %v", latency.Latency.Perc50) return fmt.Errorf("too high pod startup latency 50th percentile: %v", latency.Latency.Perc50)
...@@ -310,9 +310,9 @@ func VerifyPodStartupLatency(latency PodStartupLatency) error { ...@@ -310,9 +310,9 @@ func VerifyPodStartupLatency(latency PodStartupLatency) error {
} }
// Resets latency metrics in apiserver. // Resets latency metrics in apiserver.
func resetMetrics(c *client.Client) error { func ResetMetrics(c *client.Client) error {
Logf("Resetting latency metrics in apiserver...") Logf("Resetting latency metrics in apiserver...")
body, err := c.Get().AbsPath("/resetMetrics").DoRaw() body, err := c.Get().AbsPath("/ResetMetrics").DoRaw()
if err != nil { if err != nil {
return err return err
} }
...@@ -337,7 +337,7 @@ func getSchedulingLatency(c *client.Client) (SchedulingLatency, error) { ...@@ -337,7 +337,7 @@ func getSchedulingLatency(c *client.Client) (SchedulingLatency, error) {
// Check if master Node is registered // Check if master Node is registered
nodes, err := c.Nodes().List(api.ListOptions{}) nodes, err := c.Nodes().List(api.ListOptions{})
expectNoError(err) ExpectNoError(err)
var data string var data string
var masterRegistered = false var masterRegistered = false
...@@ -351,16 +351,16 @@ func getSchedulingLatency(c *client.Client) (SchedulingLatency, error) { ...@@ -351,16 +351,16 @@ func getSchedulingLatency(c *client.Client) (SchedulingLatency, error) {
Prefix("proxy"). Prefix("proxy").
Namespace(api.NamespaceSystem). Namespace(api.NamespaceSystem).
Resource("pods"). Resource("pods").
Name(fmt.Sprintf("kube-scheduler-%v:%v", testContext.CloudConfig.MasterName, ports.SchedulerPort)). Name(fmt.Sprintf("kube-scheduler-%v:%v", TestContext.CloudConfig.MasterName, ports.SchedulerPort)).
Suffix("metrics"). Suffix("metrics").
Do().Raw() Do().Raw()
expectNoError(err) ExpectNoError(err)
data = string(rawData) data = string(rawData)
} else { } else {
// If master is not registered fall back to old method of using SSH. // If master is not registered fall back to old method of using SSH.
cmd := "curl http://localhost:10251/metrics" cmd := "curl http://localhost:10251/metrics"
sshResult, err := SSH(cmd, getMasterHost()+":22", testContext.Provider) sshResult, err := SSH(cmd, GetMasterHost()+":22", TestContext.Provider)
if err != nil || sshResult.Code != 0 { if err != nil || sshResult.Code != 0 {
return result, fmt.Errorf("unexpected error (code: %d) in ssh connection to master: %#v", sshResult.Code, err) return result, fmt.Errorf("unexpected error (code: %d) in ssh connection to master: %#v", sshResult.Code, err)
} }
...@@ -401,13 +401,13 @@ func VerifySchedulerLatency(c *client.Client) error { ...@@ -401,13 +401,13 @@ func VerifySchedulerLatency(c *client.Client) error {
if err != nil { if err != nil {
return err return err
} }
Logf("Scheduling latency: %s", prettyPrintJSON(latency)) Logf("Scheduling latency: %s", PrettyPrintJSON(latency))
// TODO: Add some reasonable checks once we know more about the values. // TODO: Add some reasonable checks once we know more about the values.
return nil return nil
} }
func prettyPrintJSON(metrics interface{}) string { func PrettyPrintJSON(metrics interface{}) string {
output := &bytes.Buffer{} output := &bytes.Buffer{}
if err := json.NewEncoder(output).Encode(metrics); err != nil { if err := json.NewEncoder(output).Encode(metrics); err != nil {
Logf("Error building encoder: %v", err) Logf("Error building encoder: %v", err)
...@@ -446,8 +446,8 @@ func extractMetricSamples(metricsBlob string) ([]*model.Sample, error) { ...@@ -446,8 +446,8 @@ func extractMetricSamples(metricsBlob string) ([]*model.Sample, error) {
} }
} }
// podLatencyData encapsulates pod startup latency information. // PodLatencyData encapsulates pod startup latency information.
type podLatencyData struct { type PodLatencyData struct {
// Name of the pod // Name of the pod
Name string Name string
// Node this pod was running on // Node this pod was running on
...@@ -456,13 +456,13 @@ type podLatencyData struct { ...@@ -456,13 +456,13 @@ type podLatencyData struct {
Latency time.Duration Latency time.Duration
} }
type latencySlice []podLatencyData type LatencySlice []PodLatencyData
func (a latencySlice) Len() int { return len(a) } func (a LatencySlice) Len() int { return len(a) }
func (a latencySlice) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a LatencySlice) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a latencySlice) Less(i, j int) bool { return a[i].Latency < a[j].Latency } func (a LatencySlice) Less(i, j int) bool { return a[i].Latency < a[j].Latency }
func extractLatencyMetrics(latencies []podLatencyData) LatencyMetric { func ExtractLatencyMetrics(latencies []PodLatencyData) LatencyMetric {
length := len(latencies) length := len(latencies)
perc50 := latencies[int(math.Ceil(float64(length*50)/100))-1].Latency perc50 := latencies[int(math.Ceil(float64(length*50)/100))-1].Latency
perc90 := latencies[int(math.Ceil(float64(length*90)/100))-1].Latency perc90 := latencies[int(math.Ceil(float64(length*90)/100))-1].Latency
...@@ -470,9 +470,9 @@ func extractLatencyMetrics(latencies []podLatencyData) LatencyMetric { ...@@ -470,9 +470,9 @@ func extractLatencyMetrics(latencies []podLatencyData) LatencyMetric {
return LatencyMetric{Perc50: perc50, Perc90: perc90, Perc99: perc99} return LatencyMetric{Perc50: perc50, Perc90: perc90, Perc99: perc99}
} }
// logSuspiciousLatency logs metrics/docker errors from all nodes that had slow startup times // LogSuspiciousLatency logs metrics/docker errors from all nodes that had slow startup times
// If latencyDataLag is nil then it will be populated from latencyData // If latencyDataLag is nil then it will be populated from latencyData
func logSuspiciousLatency(latencyData []podLatencyData, latencyDataLag []podLatencyData, nodeCount int, c *client.Client) { func LogSuspiciousLatency(latencyData []PodLatencyData, latencyDataLag []PodLatencyData, nodeCount int, c *client.Client) {
if latencyDataLag == nil { if latencyDataLag == nil {
latencyDataLag = latencyData latencyDataLag = latencyData
} }
...@@ -489,15 +489,15 @@ func logSuspiciousLatency(latencyData []podLatencyData, latencyDataLag []podLate ...@@ -489,15 +489,15 @@ func logSuspiciousLatency(latencyData []podLatencyData, latencyDataLag []podLate
// the given time.Duration. Since the arrays are sorted we are looking at the last // the given time.Duration. Since the arrays are sorted we are looking at the last
// element which will always be the highest. If the latency is higher than the max Failf // element which will always be the highest. If the latency is higher than the max Failf
// is called. // is called.
func testMaximumLatencyValue(latencies []podLatencyData, max time.Duration, name string) { func testMaximumLatencyValue(latencies []PodLatencyData, max time.Duration, name string) {
highestLatency := latencies[len(latencies)-1] highestLatency := latencies[len(latencies)-1]
if !(highestLatency.Latency <= max) { if !(highestLatency.Latency <= max) {
Failf("%s were not all under %s: %#v", name, max.String(), latencies) Failf("%s were not all under %s: %#v", name, max.String(), latencies)
} }
} }
func printLatencies(latencies []podLatencyData, header string) { func PrintLatencies(latencies []PodLatencyData, header string) {
metrics := extractLatencyMetrics(latencies) metrics := ExtractLatencyMetrics(latencies)
Logf("10%% %s: %v", header, latencies[(len(latencies)*9)/10:]) Logf("10%% %s: %v", header, latencies[(len(latencies)*9)/10:])
Logf("perc50: %v, perc90: %v, perc99: %v", metrics.Perc50, metrics.Perc90, metrics.Perc99) Logf("perc50: %v, perc90: %v, perc99: %v", metrics.Perc50, metrics.Perc90, metrics.Perc99)
} }
...@@ -39,11 +39,11 @@ var prom_registered = false ...@@ -39,11 +39,11 @@ var prom_registered = false
// Reusable function for pushing metrics to prometheus. Handles initialization and so on. // Reusable function for pushing metrics to prometheus. Handles initialization and so on.
func promPushRunningPending(running, pending int) error { func promPushRunningPending(running, pending int) error {
if testContext.PrometheusPushGateway == "" { if TestContext.PrometheusPushGateway == "" {
return nil return nil
} else { } else {
// Register metrics if necessary // Register metrics if necessary
if !prom_registered && testContext.PrometheusPushGateway != "" { if !prom_registered && TestContext.PrometheusPushGateway != "" {
prometheus.Register(runningMetric) prometheus.Register(runningMetric)
prometheus.Register(pendingMetric) prometheus.Register(pendingMetric)
prom_registered = true prom_registered = true
...@@ -57,7 +57,7 @@ func promPushRunningPending(running, pending int) error { ...@@ -57,7 +57,7 @@ func promPushRunningPending(running, pending int) error {
if err := prometheus.Push( if err := prometheus.Push(
"e2e", "e2e",
"none", "none",
testContext.PrometheusPushGateway, //i.e. "127.0.0.1:9091" TestContext.PrometheusPushGateway, //i.e. "127.0.0.1:9091"
); err != nil { ); err != nil {
fmt.Println("failed at pushing to pushgateway ", err) fmt.Println("failed at pushing to pushgateway ", err)
return err return err
......
...@@ -38,9 +38,9 @@ const ( ...@@ -38,9 +38,9 @@ const (
probeDuration = 15 * time.Second probeDuration = 15 * time.Second
) )
type resourceConstraint struct { type ResourceConstraint struct {
cpuConstraint float64 CPUConstraint float64
memoryConstraint uint64 MemoryConstraint uint64
} }
type SingleContainerSummary struct { type SingleContainerSummary struct {
...@@ -67,12 +67,12 @@ func (s *ResourceUsageSummary) PrintHumanReadable() string { ...@@ -67,12 +67,12 @@ func (s *ResourceUsageSummary) PrintHumanReadable() string {
} }
func (s *ResourceUsageSummary) PrintJSON() string { func (s *ResourceUsageSummary) PrintJSON() string {
return prettyPrintJSON(*s) return PrettyPrintJSON(*s)
} }
func computePercentiles(timeSeries []resourceUsagePerContainer, percentilesToCompute []int) map[int]resourceUsagePerContainer { func computePercentiles(timeSeries []ResourceUsagePerContainer, percentilesToCompute []int) map[int]ResourceUsagePerContainer {
if len(timeSeries) == 0 { if len(timeSeries) == 0 {
return make(map[int]resourceUsagePerContainer) return make(map[int]ResourceUsagePerContainer)
} }
dataMap := make(map[string]*usageDataPerContainer) dataMap := make(map[string]*usageDataPerContainer)
for i := range timeSeries { for i := range timeSeries {
...@@ -95,12 +95,12 @@ func computePercentiles(timeSeries []resourceUsagePerContainer, percentilesToCom ...@@ -95,12 +95,12 @@ func computePercentiles(timeSeries []resourceUsagePerContainer, percentilesToCom
sort.Sort(uint64arr(v.memWorkSetData)) sort.Sort(uint64arr(v.memWorkSetData))
} }
result := make(map[int]resourceUsagePerContainer) result := make(map[int]ResourceUsagePerContainer)
for _, perc := range percentilesToCompute { for _, perc := range percentilesToCompute {
data := make(resourceUsagePerContainer) data := make(ResourceUsagePerContainer)
for k, v := range dataMap { for k, v := range dataMap {
percentileIndex := int(math.Ceil(float64(len(v.cpuData)*perc)/100)) - 1 percentileIndex := int(math.Ceil(float64(len(v.cpuData)*perc)/100)) - 1
data[k] = &containerResourceUsage{ data[k] = &ContainerResourceUsage{
Name: k, Name: k,
CPUUsageInCores: v.cpuData[percentileIndex], CPUUsageInCores: v.cpuData[percentileIndex],
MemoryUsageInBytes: v.memUseData[percentileIndex], MemoryUsageInBytes: v.memUseData[percentileIndex],
...@@ -112,8 +112,8 @@ func computePercentiles(timeSeries []resourceUsagePerContainer, percentilesToCom ...@@ -112,8 +112,8 @@ func computePercentiles(timeSeries []resourceUsagePerContainer, percentilesToCom
return result return result
} }
func leftMergeData(left, right map[int]resourceUsagePerContainer) map[int]resourceUsagePerContainer { func leftMergeData(left, right map[int]ResourceUsagePerContainer) map[int]ResourceUsagePerContainer {
result := make(map[int]resourceUsagePerContainer) result := make(map[int]ResourceUsagePerContainer)
for percentile, data := range left { for percentile, data := range left {
result[percentile] = data result[percentile] = data
if _, ok := right[percentile]; !ok { if _, ok := right[percentile]; !ok {
...@@ -133,12 +133,12 @@ type resourceGatherWorker struct { ...@@ -133,12 +133,12 @@ type resourceGatherWorker struct {
containerIDToNameMap map[string]string containerIDToNameMap map[string]string
containerIDs []string containerIDs []string
stopCh chan struct{} stopCh chan struct{}
dataSeries []resourceUsagePerContainer dataSeries []ResourceUsagePerContainer
finished bool finished bool
} }
func (w *resourceGatherWorker) singleProbe() { func (w *resourceGatherWorker) singleProbe() {
data := make(resourceUsagePerContainer) data := make(ResourceUsagePerContainer)
nodeUsage, err := getOneTimeResourceUsageOnNode(w.c, w.nodeName, probeDuration, func() []string { return w.containerIDs }, true) nodeUsage, err := getOneTimeResourceUsageOnNode(w.c, w.nodeName, probeDuration, func() []string { return w.containerIDs }, true)
if err != nil { if err != nil {
Logf("Error while reading data from %v: %v", w.nodeName, err) Logf("Error while reading data from %v: %v", w.nodeName, err)
...@@ -236,7 +236,7 @@ func (g *containerResourceGatherer) startGatheringData() { ...@@ -236,7 +236,7 @@ func (g *containerResourceGatherer) startGatheringData() {
g.getKubeSystemContainersResourceUsage(g.client) g.getKubeSystemContainersResourceUsage(g.client)
} }
func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constraints map[string]resourceConstraint) *ResourceUsageSummary { func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constraints map[string]ResourceConstraint) *ResourceUsageSummary {
close(g.stopCh) close(g.stopCh)
Logf("Closed stop channel. Waiting for %v workers", len(g.workers)) Logf("Closed stop channel. Waiting for %v workers", len(g.workers))
finished := make(chan struct{}) finished := make(chan struct{})
...@@ -261,7 +261,7 @@ func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constrai ...@@ -261,7 +261,7 @@ func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constrai
Logf("Warning! Empty percentile list for stopAndPrintData.") Logf("Warning! Empty percentile list for stopAndPrintData.")
return &ResourceUsageSummary{} return &ResourceUsageSummary{}
} }
data := make(map[int]resourceUsagePerContainer) data := make(map[int]ResourceUsagePerContainer)
for i := range g.workers { for i := range g.workers {
if g.workers[i].finished { if g.workers[i].finished {
stats := computePercentiles(g.workers[i].dataSeries, percentiles) stats := computePercentiles(g.workers[i].dataSeries, percentiles)
...@@ -290,23 +290,23 @@ func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constrai ...@@ -290,23 +290,23 @@ func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constrai
// Name has a form: <pod_name>/<container_name> // Name has a form: <pod_name>/<container_name>
containerName := strings.Split(name, "/")[1] containerName := strings.Split(name, "/")[1]
if constraint, ok := constraints[containerName]; ok { if constraint, ok := constraints[containerName]; ok {
if usage.CPUUsageInCores > constraint.cpuConstraint { if usage.CPUUsageInCores > constraint.CPUConstraint {
violatedConstraints = append( violatedConstraints = append(
violatedConstraints, violatedConstraints,
fmt.Sprintf("Container %v is using %v/%v CPU", fmt.Sprintf("Container %v is using %v/%v CPU",
name, name,
usage.CPUUsageInCores, usage.CPUUsageInCores,
constraint.cpuConstraint, constraint.CPUConstraint,
), ),
) )
} }
if usage.MemoryWorkingSetInBytes > constraint.memoryConstraint { if usage.MemoryWorkingSetInBytes > constraint.MemoryConstraint {
violatedConstraints = append( violatedConstraints = append(
violatedConstraints, violatedConstraints,
fmt.Sprintf("Container %v is using %v/%v MB of memory", fmt.Sprintf("Container %v is using %v/%v MB of memory",
name, name,
float64(usage.MemoryWorkingSetInBytes)/(1024*1024), float64(usage.MemoryWorkingSetInBytes)/(1024*1024),
float64(constraint.memoryConstraint)/(1024*1024), float64(constraint.MemoryConstraint)/(1024*1024),
), ),
) )
} }
......
...@@ -98,7 +98,7 @@ func RegisterFlags() { ...@@ -98,7 +98,7 @@ func RegisterFlags() {
flag.StringVar(&TestContext.KubectlPath, "kubectl-path", "kubectl", "The kubectl binary to use. For development, you might use 'cluster/kubectl.sh' here.") flag.StringVar(&TestContext.KubectlPath, "kubectl-path", "kubectl", "The kubectl binary to use. For development, you might use 'cluster/kubectl.sh' here.")
flag.StringVar(&TestContext.OutputDir, "e2e-output-dir", "/tmp", "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.") flag.StringVar(&TestContext.OutputDir, "e2e-output-dir", "/tmp", "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.")
flag.StringVar(&TestContext.ReportDir, "report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.") flag.StringVar(&TestContext.ReportDir, "report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
flag.StringVar(&testContext.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.") flag.StringVar(&TestContext.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
flag.StringVar(&TestContext.Prefix, "prefix", "e2e", "A prefix to be added to cloud resources created during testing.") flag.StringVar(&TestContext.Prefix, "prefix", "e2e", "A prefix to be added to cloud resources created during testing.")
flag.StringVar(&TestContext.OSDistro, "os-distro", "debian", "The OS distribution of cluster VM instances (debian, trusty, or coreos).") flag.StringVar(&TestContext.OSDistro, "os-distro", "debian", "The OS distribution of cluster VM instances (debian, trusty, or coreos).")
......
...@@ -25,13 +25,14 @@ import ( ...@@ -25,13 +25,14 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
) )
// This test requires that --terminated-pod-gc-threshold=100 be set on the controller manager // This test requires that --terminated-pod-gc-threshold=100 be set on the controller manager
// //
// Slow by design (7 min) // Slow by design (7 min)
var _ = KubeDescribe("Garbage collector [Feature:GarbageCollector] [Slow]", func() { var _ = framework.KubeDescribe("Garbage collector [Feature:GarbageCollector] [Slow]", func() {
f := NewDefaultFramework("garbage-collector") f := framework.NewDefaultFramework("garbage-collector")
It("should handle the creation of 1000 pods", func() { It("should handle the creation of 1000 pods", func() {
var count int var count int
for count < 1000 { for count < 1000 {
...@@ -40,16 +41,16 @@ var _ = KubeDescribe("Garbage collector [Feature:GarbageCollector] [Slow]", func ...@@ -40,16 +41,16 @@ var _ = KubeDescribe("Garbage collector [Feature:GarbageCollector] [Slow]", func
pod.Status.Phase = api.PodFailed pod.Status.Phase = api.PodFailed
pod, err = f.Client.Pods(f.Namespace.Name).UpdateStatus(pod) pod, err = f.Client.Pods(f.Namespace.Name).UpdateStatus(pod)
if err != nil { if err != nil {
Failf("err failing pod: %v", err) framework.Failf("err failing pod: %v", err)
} }
count++ count++
if count%50 == 0 { if count%50 == 0 {
Logf("count: %v", count) framework.Logf("count: %v", count)
} }
} }
Logf("created: %v", count) framework.Logf("created: %v", count)
// The gc controller polls every 30s and fires off a goroutine per // The gc controller polls every 30s and fires off a goroutine per
// pod to terminate. // pod to terminate.
...@@ -62,22 +63,22 @@ var _ = KubeDescribe("Garbage collector [Feature:GarbageCollector] [Slow]", func ...@@ -62,22 +63,22 @@ var _ = KubeDescribe("Garbage collector [Feature:GarbageCollector] [Slow]", func
pollErr := wait.Poll(1*time.Minute, timeout, func() (bool, error) { pollErr := wait.Poll(1*time.Minute, timeout, func() (bool, error) {
pods, err = f.Client.Pods(f.Namespace.Name).List(api.ListOptions{}) pods, err = f.Client.Pods(f.Namespace.Name).List(api.ListOptions{})
if err != nil { if err != nil {
Logf("Failed to list pod %v", err) framework.Logf("Failed to list pod %v", err)
return false, nil return false, nil
} }
if len(pods.Items) != gcThreshold { if len(pods.Items) != gcThreshold {
Logf("Number of observed pods %v, waiting for %v", len(pods.Items), gcThreshold) framework.Logf("Number of observed pods %v, waiting for %v", len(pods.Items), gcThreshold)
return false, nil return false, nil
} }
return true, nil return true, nil
}) })
if pollErr != nil { if pollErr != nil {
Failf("Failed to GC pods within %v, %v pods remaining, error: %v", timeout, len(pods.Items), err) framework.Failf("Failed to GC pods within %v, %v pods remaining, error: %v", timeout, len(pods.Items), err)
} }
}) })
}) })
func createTerminatingPod(f *Framework) (*api.Pod, error) { func createTerminatingPod(f *framework.Framework) (*api.Pod, error) {
uuid := util.NewUUID() uuid := util.NewUUID()
pod := &api.Pod{ pod := &api.Pod{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
......
...@@ -27,15 +27,16 @@ import ( ...@@ -27,15 +27,16 @@ import (
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = KubeDescribe("Generated release_1_2 clientset", func() { var _ = framework.KubeDescribe("Generated release_1_2 clientset", func() {
framework := NewDefaultFramework("clientset") f := framework.NewDefaultFramework("clientset")
It("should create pods, delete pods, watch pods", func() { It("should create pods, delete pods, watch pods", func() {
podClient := framework.Clientset_1_2.Core().Pods(framework.Namespace.Name) podClient := f.Clientset_1_2.Core().Pods(f.Namespace.Name)
By("creating the pod") By("creating the pod")
name := "pod" + string(util.NewUUID()) name := "pod" + string(util.NewUUID())
value := strconv.Itoa(time.Now().Nanosecond()) value := strconv.Itoa(time.Now().Nanosecond())
...@@ -72,7 +73,7 @@ var _ = KubeDescribe("Generated release_1_2 clientset", func() { ...@@ -72,7 +73,7 @@ var _ = KubeDescribe("Generated release_1_2 clientset", func() {
options := api.ListOptions{LabelSelector: selector} options := api.ListOptions{LabelSelector: selector}
pods, err := podClient.List(options) pods, err := podClient.List(options)
if err != nil { if err != nil {
Failf("Failed to query for pods: %v", err) framework.Failf("Failed to query for pods: %v", err)
} }
Expect(len(pods.Items)).To(Equal(0)) Expect(len(pods.Items)).To(Equal(0))
options = api.ListOptions{ options = api.ListOptions{
...@@ -81,7 +82,7 @@ var _ = KubeDescribe("Generated release_1_2 clientset", func() { ...@@ -81,7 +82,7 @@ var _ = KubeDescribe("Generated release_1_2 clientset", func() {
} }
w, err := podClient.Watch(options) w, err := podClient.Watch(options)
if err != nil { if err != nil {
Failf("Failed to set up watch: %v", err) framework.Failf("Failed to set up watch: %v", err)
} }
By("submitting the pod to kubernetes") By("submitting the pod to kubernetes")
...@@ -91,7 +92,7 @@ var _ = KubeDescribe("Generated release_1_2 clientset", func() { ...@@ -91,7 +92,7 @@ var _ = KubeDescribe("Generated release_1_2 clientset", func() {
defer podClient.Delete(pod.Name, api.NewDeleteOptions(0)) defer podClient.Delete(pod.Name, api.NewDeleteOptions(0))
pod, err = podClient.Create(pod) pod, err = podClient.Create(pod)
if err != nil { if err != nil {
Failf("Failed to create pod: %v", err) framework.Failf("Failed to create pod: %v", err)
} }
By("verifying the pod is in kubernetes") By("verifying the pod is in kubernetes")
...@@ -102,7 +103,7 @@ var _ = KubeDescribe("Generated release_1_2 clientset", func() { ...@@ -102,7 +103,7 @@ var _ = KubeDescribe("Generated release_1_2 clientset", func() {
} }
pods, err = podClient.List(options) pods, err = podClient.List(options)
if err != nil { if err != nil {
Failf("Failed to query for pods: %v", err) framework.Failf("Failed to query for pods: %v", err)
} }
Expect(len(pods.Items)).To(Equal(1)) Expect(len(pods.Items)).To(Equal(1))
...@@ -110,19 +111,19 @@ var _ = KubeDescribe("Generated release_1_2 clientset", func() { ...@@ -110,19 +111,19 @@ var _ = KubeDescribe("Generated release_1_2 clientset", func() {
select { select {
case event, _ := <-w.ResultChan(): case event, _ := <-w.ResultChan():
if event.Type != watch.Added { if event.Type != watch.Added {
Failf("Failed to observe pod creation: %v", event) framework.Failf("Failed to observe pod creation: %v", event)
} }
case <-time.After(podStartTimeout): case <-time.After(framework.PodStartTimeout):
Fail("Timeout while waiting for pod creation") Fail("Timeout while waiting for pod creation")
} }
// We need to wait for the pod to be scheduled, otherwise the deletion // We need to wait for the pod to be scheduled, otherwise the deletion
// will be carried out immediately rather than gracefully. // will be carried out immediately rather than gracefully.
expectNoError(framework.WaitForPodRunning(pod.Name)) framework.ExpectNoError(f.WaitForPodRunning(pod.Name))
By("deleting the pod gracefully") By("deleting the pod gracefully")
if err := podClient.Delete(pod.Name, api.NewDeleteOptions(30)); err != nil { if err := podClient.Delete(pod.Name, api.NewDeleteOptions(30)); err != nil {
Failf("Failed to delete pod: %v", err) framework.Failf("Failed to delete pod: %v", err)
} }
By("verifying pod deletion was observed") By("verifying pod deletion was observed")
......
...@@ -24,6 +24,8 @@ import ( ...@@ -24,6 +24,8 @@ import (
"time" "time"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/test/e2e/framework"
) )
// TODO: These should really just use the GCE API client library or at least use // TODO: These should really just use the GCE API client library or at least use
...@@ -36,12 +38,12 @@ func createGCEStaticIP(name string) (string, error) { ...@@ -36,12 +38,12 @@ func createGCEStaticIP(name string) (string, error) {
// NAME REGION ADDRESS STATUS // NAME REGION ADDRESS STATUS
// test-static-ip us-central1 104.197.143.7 RESERVED // test-static-ip us-central1 104.197.143.7 RESERVED
glog.Infof("Creating static IP with name %q in project %q", name, testContext.CloudConfig.ProjectID) glog.Infof("Creating static IP with name %q in project %q", name, framework.TestContext.CloudConfig.ProjectID)
var outputBytes []byte var outputBytes []byte
var err error var err error
for attempts := 0; attempts < 4; attempts++ { for attempts := 0; attempts < 4; attempts++ {
outputBytes, err = exec.Command("gcloud", "compute", "addresses", "create", outputBytes, err = exec.Command("gcloud", "compute", "addresses", "create",
name, "--project", testContext.CloudConfig.ProjectID, name, "--project", framework.TestContext.CloudConfig.ProjectID,
"--region", "us-central1", "-q").CombinedOutput() "--region", "us-central1", "-q").CombinedOutput()
if err == nil { if err == nil {
break break
...@@ -76,7 +78,7 @@ func deleteGCEStaticIP(name string) error { ...@@ -76,7 +78,7 @@ func deleteGCEStaticIP(name string) error {
// test-static-ip us-central1 104.197.143.7 RESERVED // test-static-ip us-central1 104.197.143.7 RESERVED
outputBytes, err := exec.Command("gcloud", "compute", "addresses", "delete", outputBytes, err := exec.Command("gcloud", "compute", "addresses", "delete",
name, "--project", testContext.CloudConfig.ProjectID, name, "--project", framework.TestContext.CloudConfig.ProjectID,
"--region", "us-central1", "-q").CombinedOutput() "--region", "us-central1", "-q").CombinedOutput()
if err != nil { if err != nil {
// Ditch the error, since the stderr in the output is what actually contains // Ditch the error, since the stderr in the output is what actually contains
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
) )
...@@ -34,15 +35,15 @@ const ( ...@@ -34,15 +35,15 @@ const (
// These tests don't seem to be running properly in parallel: issue: #20338. // These tests don't seem to be running properly in parallel: issue: #20338.
// //
var _ = KubeDescribe("Horizontal pod autoscaling (scale resource: CPU)", func() { var _ = framework.KubeDescribe("Horizontal pod autoscaling (scale resource: CPU)", func() {
var rc *ResourceConsumer var rc *ResourceConsumer
f := NewDefaultFramework("horizontal-pod-autoscaling") f := framework.NewDefaultFramework("horizontal-pod-autoscaling")
titleUp := "Should scale from 1 pod to 3 pods and from 3 to 5 and verify decision stability" titleUp := "Should scale from 1 pod to 3 pods and from 3 to 5 and verify decision stability"
titleDown := "Should scale from 5 pods to 3 pods and from 3 to 1 and verify decision stability" titleDown := "Should scale from 5 pods to 3 pods and from 3 to 1 and verify decision stability"
// These tests take ~20 minutes each. // These tests take ~20 minutes each.
KubeDescribe("[Serial] [Slow] Deployment", func() { framework.KubeDescribe("[Serial] [Slow] Deployment", func() {
// CPU tests via deployments // CPU tests via deployments
It(titleUp, func() { It(titleUp, func() {
scaleUp("test-deployment", kindDeployment, rc, f) scaleUp("test-deployment", kindDeployment, rc, f)
...@@ -53,7 +54,7 @@ var _ = KubeDescribe("Horizontal pod autoscaling (scale resource: CPU)", func() ...@@ -53,7 +54,7 @@ var _ = KubeDescribe("Horizontal pod autoscaling (scale resource: CPU)", func()
}) })
// These tests take ~20 minutes each. // These tests take ~20 minutes each.
KubeDescribe("[Serial] [Slow] ReplicaSet", func() { framework.KubeDescribe("[Serial] [Slow] ReplicaSet", func() {
// CPU tests via deployments // CPU tests via deployments
It(titleUp, func() { It(titleUp, func() {
scaleUp("rs", kindReplicaSet, rc, f) scaleUp("rs", kindReplicaSet, rc, f)
...@@ -63,7 +64,7 @@ var _ = KubeDescribe("Horizontal pod autoscaling (scale resource: CPU)", func() ...@@ -63,7 +64,7 @@ var _ = KubeDescribe("Horizontal pod autoscaling (scale resource: CPU)", func()
}) })
}) })
// These tests take ~20 minutes each. // These tests take ~20 minutes each.
KubeDescribe("[Serial] [Slow] ReplicationController", func() { framework.KubeDescribe("[Serial] [Slow] ReplicationController", func() {
// CPU tests via replication controllers // CPU tests via replication controllers
It(titleUp, func() { It(titleUp, func() {
scaleUp("rc", kindRC, rc, f) scaleUp("rc", kindRC, rc, f)
...@@ -73,7 +74,7 @@ var _ = KubeDescribe("Horizontal pod autoscaling (scale resource: CPU)", func() ...@@ -73,7 +74,7 @@ var _ = KubeDescribe("Horizontal pod autoscaling (scale resource: CPU)", func()
}) })
}) })
KubeDescribe("ReplicationController light", func() { framework.KubeDescribe("ReplicationController light", func() {
It("Should scale from 1 pod to 2 pods", func() { It("Should scale from 1 pod to 2 pods", func() {
scaleTest := &HPAScaleTest{ scaleTest := &HPAScaleTest{
initPods: 1, initPods: 1,
...@@ -123,7 +124,7 @@ type HPAScaleTest struct { ...@@ -123,7 +124,7 @@ type HPAScaleTest struct {
// The first state change is due to the CPU being consumed initially, which HPA responds to by changing pod counts. // The first state change is due to the CPU being consumed initially, which HPA responds to by changing pod counts.
// The second state change (optional) is due to the CPU burst parameter, which HPA again responds to. // The second state change (optional) is due to the CPU burst parameter, which HPA again responds to.
// TODO The use of 3 states is arbitrary, we could eventually make this test handle "n" states once this test stabilizes. // TODO The use of 3 states is arbitrary, we could eventually make this test handle "n" states once this test stabilizes.
func (scaleTest *HPAScaleTest) run(name, kind string, rc *ResourceConsumer, f *Framework) { func (scaleTest *HPAScaleTest) run(name, kind string, rc *ResourceConsumer, f *framework.Framework) {
rc = NewDynamicResourceConsumer(name, kind, scaleTest.initPods, scaleTest.totalInitialCPUUsage, 0, 0, scaleTest.perPodCPURequest, 100, f) rc = NewDynamicResourceConsumer(name, kind, scaleTest.initPods, scaleTest.totalInitialCPUUsage, 0, 0, scaleTest.perPodCPURequest, 100, f)
defer rc.CleanUp() defer rc.CleanUp()
createCPUHorizontalPodAutoscaler(rc, scaleTest.targetCPUUtilizationPercent, scaleTest.minPods, scaleTest.maxPods, scaleTest.useV1) createCPUHorizontalPodAutoscaler(rc, scaleTest.targetCPUUtilizationPercent, scaleTest.minPods, scaleTest.maxPods, scaleTest.useV1)
...@@ -137,7 +138,7 @@ func (scaleTest *HPAScaleTest) run(name, kind string, rc *ResourceConsumer, f *F ...@@ -137,7 +138,7 @@ func (scaleTest *HPAScaleTest) run(name, kind string, rc *ResourceConsumer, f *F
} }
} }
func scaleUp(name, kind string, rc *ResourceConsumer, f *Framework) { func scaleUp(name, kind string, rc *ResourceConsumer, f *framework.Framework) {
scaleTest := &HPAScaleTest{ scaleTest := &HPAScaleTest{
initPods: 1, initPods: 1,
totalInitialCPUUsage: 250, totalInitialCPUUsage: 250,
...@@ -153,7 +154,7 @@ func scaleUp(name, kind string, rc *ResourceConsumer, f *Framework) { ...@@ -153,7 +154,7 @@ func scaleUp(name, kind string, rc *ResourceConsumer, f *Framework) {
scaleTest.run(name, kind, rc, f) scaleTest.run(name, kind, rc, f)
} }
func scaleDown(name, kind string, rc *ResourceConsumer, f *Framework) { func scaleDown(name, kind string, rc *ResourceConsumer, f *framework.Framework) {
scaleTest := &HPAScaleTest{ scaleTest := &HPAScaleTest{
initPods: 5, initPods: 5,
totalInitialCPUUsage: 400, totalInitialCPUUsage: 400,
...@@ -192,5 +193,5 @@ func createCPUHorizontalPodAutoscaler(rc *ResourceConsumer, cpu, minReplicas, ma ...@@ -192,5 +193,5 @@ func createCPUHorizontalPodAutoscaler(rc *ResourceConsumer, cpu, minReplicas, ma
} else { } else {
_, errHPA = rc.framework.Client.Extensions().HorizontalPodAutoscalers(rc.framework.Namespace.Name).Create(hpa) _, errHPA = rc.framework.Client.Extensions().HorizontalPodAutoscalers(rc.framework.Namespace.Name).Create(hpa)
} }
expectNoError(errHPA) framework.ExpectNoError(errHPA)
} }
...@@ -25,20 +25,21 @@ import ( ...@@ -25,20 +25,21 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apimachinery/registered" "k8s.io/kubernetes/pkg/apimachinery/registered"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
) )
//TODO : Consolidate this code with the code for emptyDir. //TODO : Consolidate this code with the code for emptyDir.
//This will require some smart. //This will require some smart.
var _ = KubeDescribe("hostPath", func() { var _ = framework.KubeDescribe("hostPath", func() {
framework := NewDefaultFramework("hostpath") f := framework.NewDefaultFramework("hostpath")
var c *client.Client var c *client.Client
var namespace *api.Namespace var namespace *api.Namespace
BeforeEach(func() { BeforeEach(func() {
c = framework.Client c = f.Client
namespace = framework.Namespace namespace = f.Namespace
//cleanup before running the test. //cleanup before running the test.
_ = os.Remove("/tmp/test-file") _ = os.Remove("/tmp/test-file")
...@@ -55,7 +56,7 @@ var _ = KubeDescribe("hostPath", func() { ...@@ -55,7 +56,7 @@ var _ = KubeDescribe("hostPath", func() {
fmt.Sprintf("--fs_type=%v", volumePath), fmt.Sprintf("--fs_type=%v", volumePath),
fmt.Sprintf("--file_mode=%v", volumePath), fmt.Sprintf("--file_mode=%v", volumePath),
} }
testContainerOutput("hostPath mode", c, pod, 0, []string{ framework.TestContainerOutput("hostPath mode", c, pod, 0, []string{
"mode of file \"/test-volume\": dtrwxrwxrwx", // we expect the sticky bit (mode flag t) to be set for the dir "mode of file \"/test-volume\": dtrwxrwxrwx", // we expect the sticky bit (mode flag t) to be set for the dir
}, },
namespace.Name) namespace.Name)
...@@ -82,7 +83,7 @@ var _ = KubeDescribe("hostPath", func() { ...@@ -82,7 +83,7 @@ var _ = KubeDescribe("hostPath", func() {
} }
//Read the content of the file with the second container to //Read the content of the file with the second container to
//verify volumes being shared properly among containers within the pod. //verify volumes being shared properly among containers within the pod.
testContainerOutput("hostPath r/w", c, pod, 1, []string{ framework.TestContainerOutput("hostPath r/w", c, pod, 1, []string{
"content of file \"/test-volume/test-file\": mount-tester new file", "content of file \"/test-volume/test-file\": mount-tester new file",
}, namespace.Name, }, namespace.Name,
) )
......
...@@ -36,6 +36,7 @@ import ( ...@@ -36,6 +36,7 @@ import (
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
utilnet "k8s.io/kubernetes/pkg/util/net" utilnet "k8s.io/kubernetes/pkg/util/net"
"k8s.io/kubernetes/test/e2e/framework"
) )
const ( const (
...@@ -125,7 +126,7 @@ func createSecret(kubeClient *client.Client, ing *extensions.Ingress) (host stri ...@@ -125,7 +126,7 @@ func createSecret(kubeClient *client.Client, ing *extensions.Ingress) (host stri
var k, c bytes.Buffer var k, c bytes.Buffer
tls := ing.Spec.TLS[0] tls := ing.Spec.TLS[0]
host = strings.Join(tls.Hosts, ",") host = strings.Join(tls.Hosts, ",")
Logf("Generating RSA cert for host %v", host) framework.Logf("Generating RSA cert for host %v", host)
if err = generateRSACerts(host, true, &k, &c); err != nil { if err = generateRSACerts(host, true, &k, &c); err != nil {
return return
...@@ -141,7 +142,7 @@ func createSecret(kubeClient *client.Client, ing *extensions.Ingress) (host stri ...@@ -141,7 +142,7 @@ func createSecret(kubeClient *client.Client, ing *extensions.Ingress) (host stri
api.TLSPrivateKeyKey: key, api.TLSPrivateKeyKey: key,
}, },
} }
Logf("Creating secret %v in ns %v with hosts %v for ingress %v", secret.Name, secret.Namespace, host, ing.Name) framework.Logf("Creating secret %v in ns %v with hosts %v for ingress %v", secret.Name, secret.Namespace, host, ing.Name)
_, err = kubeClient.Secrets(ing.Namespace).Create(secret) _, err = kubeClient.Secrets(ing.Namespace).Create(secret)
return host, cert, key, err return host, cert, key, err
} }
...@@ -23,14 +23,15 @@ import ( ...@@ -23,14 +23,15 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/test/e2e/framework"
) )
// [Feature:InitialResources]: Initial resources is an experimental feature, so // [Feature:InitialResources]: Initial resources is an experimental feature, so
// these tests are not run by default. // these tests are not run by default.
// //
// Flaky issue #20272 // Flaky issue #20272
var _ = KubeDescribe("Initial Resources [Feature:InitialResources] [Flaky]", func() { var _ = framework.KubeDescribe("Initial Resources [Feature:InitialResources] [Flaky]", func() {
f := NewDefaultFramework("initial-resources") f := framework.NewDefaultFramework("initial-resources")
It("should set initial resources based on historical data", func() { It("should set initial resources based on historical data", func() {
// TODO(piosz): Add cleanup data in InfluxDB that left from previous tests. // TODO(piosz): Add cleanup data in InfluxDB that left from previous tests.
...@@ -50,7 +51,7 @@ var _ = KubeDescribe("Initial Resources [Feature:InitialResources] [Flaky]", fun ...@@ -50,7 +51,7 @@ var _ = KubeDescribe("Initial Resources [Feature:InitialResources] [Flaky]", fun
}) })
}) })
func runPod(f *Framework, name, image string) *api.Pod { func runPod(f *framework.Framework, name, image string) *api.Pod {
pod := &api.Pod{ pod := &api.Pod{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: name, Name: name,
...@@ -65,7 +66,7 @@ func runPod(f *Framework, name, image string) *api.Pod { ...@@ -65,7 +66,7 @@ func runPod(f *Framework, name, image string) *api.Pod {
}, },
} }
createdPod, err := f.Client.Pods(f.Namespace.Name).Create(pod) createdPod, err := f.Client.Pods(f.Namespace.Name).Create(pod)
expectNoError(err) framework.ExpectNoError(err)
expectNoError(waitForPodRunningInNamespace(f.Client, name, f.Namespace.Name)) framework.ExpectNoError(framework.WaitForPodRunningInNamespace(f.Client, name, f.Namespace.Name))
return createdPod return createdPod
} }
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -39,8 +40,8 @@ const ( ...@@ -39,8 +40,8 @@ const (
jobSelectorKey = "job" jobSelectorKey = "job"
) )
var _ = KubeDescribe("Job", func() { var _ = framework.KubeDescribe("Job", func() {
f := NewDefaultFramework("job") f := framework.NewDefaultFramework("job")
parallelism := 2 parallelism := 2
completions := 4 completions := 4
lotsOfFailures := 5 // more than completions lotsOfFailures := 5 // more than completions
...@@ -101,7 +102,7 @@ var _ = KubeDescribe("Job", func() { ...@@ -101,7 +102,7 @@ var _ = KubeDescribe("Job", func() {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Ensuring job shows many failures") By("Ensuring job shows many failures")
err = wait.Poll(poll, jobTimeout, func() (bool, error) { err = wait.Poll(framework.Poll, jobTimeout, func() (bool, error) {
curr, err := f.Client.Extensions().Jobs(f.Namespace.Name).Get(job.Name) curr, err := f.Client.Extensions().Jobs(f.Namespace.Name).Get(job.Name)
if err != nil { if err != nil {
return false, err return false, err
...@@ -271,7 +272,7 @@ func deleteJob(c *client.Client, ns, name string) error { ...@@ -271,7 +272,7 @@ func deleteJob(c *client.Client, ns, name string) error {
// Wait for all pods to become Running. Only use when pods will run for a long time, or it will be racy. // Wait for all pods to become Running. Only use when pods will run for a long time, or it will be racy.
func waitForAllPodsRunning(c *client.Client, ns, jobName string, parallelism int) error { func waitForAllPodsRunning(c *client.Client, ns, jobName string, parallelism int) error {
label := labels.SelectorFromSet(labels.Set(map[string]string{jobSelectorKey: jobName})) label := labels.SelectorFromSet(labels.Set(map[string]string{jobSelectorKey: jobName}))
return wait.Poll(poll, jobTimeout, func() (bool, error) { return wait.Poll(framework.Poll, jobTimeout, func() (bool, error) {
options := api.ListOptions{LabelSelector: label} options := api.ListOptions{LabelSelector: label}
pods, err := c.Pods(ns).List(options) pods, err := c.Pods(ns).List(options)
if err != nil { if err != nil {
...@@ -289,7 +290,7 @@ func waitForAllPodsRunning(c *client.Client, ns, jobName string, parallelism int ...@@ -289,7 +290,7 @@ func waitForAllPodsRunning(c *client.Client, ns, jobName string, parallelism int
// Wait for job to reach completions. // Wait for job to reach completions.
func waitForJobFinish(c *client.Client, ns, jobName string, completions int) error { func waitForJobFinish(c *client.Client, ns, jobName string, completions int) error {
return wait.Poll(poll, jobTimeout, func() (bool, error) { return wait.Poll(framework.Poll, jobTimeout, func() (bool, error) {
curr, err := c.Extensions().Jobs(ns).Get(jobName) curr, err := c.Extensions().Jobs(ns).Get(jobName)
if err != nil { if err != nil {
return false, err return false, err
...@@ -300,7 +301,7 @@ func waitForJobFinish(c *client.Client, ns, jobName string, completions int) err ...@@ -300,7 +301,7 @@ func waitForJobFinish(c *client.Client, ns, jobName string, completions int) err
// Wait for job fail. // Wait for job fail.
func waitForJobFail(c *client.Client, ns, jobName string) error { func waitForJobFail(c *client.Client, ns, jobName string) error {
return wait.Poll(poll, jobTimeout, func() (bool, error) { return wait.Poll(framework.Poll, jobTimeout, func() (bool, error) {
curr, err := c.Extensions().Jobs(ns).Get(jobName) curr, err := c.Extensions().Jobs(ns).Get(jobName)
if err != nil { if err != nil {
return false, err return false, err
......
...@@ -21,19 +21,20 @@ import ( ...@@ -21,19 +21,20 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = KubeDescribe("Kibana Logging Instances Is Alive", func() { var _ = framework.KubeDescribe("Kibana Logging Instances Is Alive", func() {
f := NewDefaultFramework("kibana-logging") f := framework.NewDefaultFramework("kibana-logging")
BeforeEach(func() { BeforeEach(func() {
// TODO: For now assume we are only testing cluster logging with Elasticsearch // TODO: For now assume we are only testing cluster logging with Elasticsearch
// and Kibana on GCE. Once we are sure that Elasticsearch and Kibana cluster level logging // and Kibana on GCE. Once we are sure that Elasticsearch and Kibana cluster level logging
// works for other providers we should widen this scope of this test. // works for other providers we should widen this scope of this test.
SkipUnlessProviderIs("gce") framework.SkipUnlessProviderIs("gce")
}) })
It("should check that the Kibana logging instance is alive", func() { It("should check that the Kibana logging instance is alive", func() {
...@@ -47,7 +48,7 @@ const ( ...@@ -47,7 +48,7 @@ const (
) )
// ClusterLevelLoggingWithKibana is an end to end test that checks to see if Kibana is alive. // ClusterLevelLoggingWithKibana is an end to end test that checks to see if Kibana is alive.
func ClusterLevelLoggingWithKibana(f *Framework) { func ClusterLevelLoggingWithKibana(f *framework.Framework) {
// graceTime is how long to keep retrying requests for status information. // graceTime is how long to keep retrying requests for status information.
const graceTime = 2 * time.Minute const graceTime = 2 * time.Minute
...@@ -61,7 +62,7 @@ func ClusterLevelLoggingWithKibana(f *Framework) { ...@@ -61,7 +62,7 @@ func ClusterLevelLoggingWithKibana(f *Framework) {
if _, err = s.Get("kibana-logging"); err == nil { if _, err = s.Get("kibana-logging"); err == nil {
break break
} }
Logf("Attempt to check for the existence of the Kibana service failed after %v", time.Since(start)) framework.Logf("Attempt to check for the existence of the Kibana service failed after %v", time.Since(start))
} }
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
...@@ -72,16 +73,16 @@ func ClusterLevelLoggingWithKibana(f *Framework) { ...@@ -72,16 +73,16 @@ func ClusterLevelLoggingWithKibana(f *Framework) {
pods, err := f.Client.Pods(api.NamespaceSystem).List(options) pods, err := f.Client.Pods(api.NamespaceSystem).List(options)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
for _, pod := range pods.Items { for _, pod := range pods.Items {
err = waitForPodRunningInNamespace(f.Client, pod.Name, api.NamespaceSystem) err = framework.WaitForPodRunningInNamespace(f.Client, pod.Name, api.NamespaceSystem)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
} }
By("Checking to make sure we get a response from the Kibana UI.") By("Checking to make sure we get a response from the Kibana UI.")
err = nil err = nil
for start := time.Now(); time.Since(start) < graceTime; time.Sleep(5 * time.Second) { for start := time.Now(); time.Since(start) < graceTime; time.Sleep(5 * time.Second) {
proxyRequest, errProxy := getServicesProxyRequest(f.Client, f.Client.Get()) proxyRequest, errProxy := framework.GetServicesProxyRequest(f.Client, f.Client.Get())
if errProxy != nil { if errProxy != nil {
Logf("After %v failed to get services proxy request: %v", time.Since(start), errProxy) framework.Logf("After %v failed to get services proxy request: %v", time.Since(start), errProxy)
continue continue
} }
// Query against the root URL for Kibana. // Query against the root URL for Kibana.
...@@ -89,7 +90,7 @@ func ClusterLevelLoggingWithKibana(f *Framework) { ...@@ -89,7 +90,7 @@ func ClusterLevelLoggingWithKibana(f *Framework) {
Name("kibana-logging"). Name("kibana-logging").
DoRaw() DoRaw()
if err != nil { if err != nil {
Logf("After %v proxy call to kibana-logging failed: %v", time.Since(start), err) framework.Logf("After %v proxy call to kibana-logging failed: %v", time.Since(start), err)
continue continue
} }
break break
......
...@@ -25,15 +25,16 @@ import ( ...@@ -25,15 +25,16 @@ import (
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
const ( const (
// Interval to poll /runningpods on a node // Interval to framework.Poll /runningpods on a node
pollInterval = 1 * time.Second pollInterval = 1 * time.Second
// Interval to poll /stats/container on a node // Interval to framework.Poll /stats/container on a node
containerStatsPollingInterval = 5 * time.Second containerStatsPollingInterval = 5 * time.Second
) )
...@@ -41,10 +42,10 @@ const ( ...@@ -41,10 +42,10 @@ const (
// podNamePrefix and namespace. // podNamePrefix and namespace.
func getPodMatches(c *client.Client, nodeName string, podNamePrefix string, namespace string) sets.String { func getPodMatches(c *client.Client, nodeName string, podNamePrefix string, namespace string) sets.String {
matches := sets.NewString() matches := sets.NewString()
Logf("Checking pods on node %v via /runningpods endpoint", nodeName) framework.Logf("Checking pods on node %v via /runningpods endpoint", nodeName)
runningPods, err := GetKubeletPods(c, nodeName) runningPods, err := framework.GetKubeletPods(c, nodeName)
if err != nil { if err != nil {
Logf("Error checking running pods on %v: %v", nodeName, err) framework.Logf("Error checking running pods on %v: %v", nodeName, err)
return matches return matches
} }
for _, pod := range runningPods.Items { for _, pod := range runningPods.Items {
...@@ -81,25 +82,25 @@ func waitTillNPodsRunningOnNodes(c *client.Client, nodeNames sets.String, podNam ...@@ -81,25 +82,25 @@ func waitTillNPodsRunningOnNodes(c *client.Client, nodeNames sets.String, podNam
if seen.Len() == targetNumPods { if seen.Len() == targetNumPods {
return true, nil return true, nil
} }
Logf("Waiting for %d pods to be running on the node; %d are currently running;", targetNumPods, seen.Len()) framework.Logf("Waiting for %d pods to be running on the node; %d are currently running;", targetNumPods, seen.Len())
return false, nil return false, nil
}) })
} }
var _ = KubeDescribe("kubelet", func() { var _ = framework.KubeDescribe("kubelet", func() {
var numNodes int var numNodes int
var nodeNames sets.String var nodeNames sets.String
framework := NewDefaultFramework("kubelet") f := framework.NewDefaultFramework("kubelet")
var resourceMonitor *resourceMonitor var resourceMonitor *framework.ResourceMonitor
BeforeEach(func() { BeforeEach(func() {
nodes := ListSchedulableNodesOrDie(framework.Client) nodes := framework.ListSchedulableNodesOrDie(f.Client)
numNodes = len(nodes.Items) numNodes = len(nodes.Items)
nodeNames = sets.NewString() nodeNames = sets.NewString()
for _, node := range nodes.Items { for _, node := range nodes.Items {
nodeNames.Insert(node.Name) nodeNames.Insert(node.Name)
} }
resourceMonitor = newResourceMonitor(framework.Client, targetContainers(), containerStatsPollingInterval) resourceMonitor = framework.NewResourceMonitor(f.Client, framework.TargetContainers(), containerStatsPollingInterval)
resourceMonitor.Start() resourceMonitor.Start()
}) })
...@@ -107,7 +108,7 @@ var _ = KubeDescribe("kubelet", func() { ...@@ -107,7 +108,7 @@ var _ = KubeDescribe("kubelet", func() {
resourceMonitor.Stop() resourceMonitor.Stop()
}) })
KubeDescribe("Clean up pods on node", func() { framework.KubeDescribe("Clean up pods on node", func() {
type DeleteTest struct { type DeleteTest struct {
podsPerNode int podsPerNode int
timeout time.Duration timeout time.Duration
...@@ -123,23 +124,23 @@ var _ = KubeDescribe("kubelet", func() { ...@@ -123,23 +124,23 @@ var _ = KubeDescribe("kubelet", func() {
By(fmt.Sprintf("Creating a RC of %d pods and wait until all pods of this RC are running", totalPods)) By(fmt.Sprintf("Creating a RC of %d pods and wait until all pods of this RC are running", totalPods))
rcName := fmt.Sprintf("cleanup%d-%s", totalPods, string(util.NewUUID())) rcName := fmt.Sprintf("cleanup%d-%s", totalPods, string(util.NewUUID()))
Expect(RunRC(RCConfig{ Expect(framework.RunRC(framework.RCConfig{
Client: framework.Client, Client: f.Client,
Name: rcName, Name: rcName,
Namespace: framework.Namespace.Name, Namespace: f.Namespace.Name,
Image: "gcr.io/google_containers/pause:2.0", Image: "gcr.io/google_containers/pause:2.0",
Replicas: totalPods, Replicas: totalPods,
})).NotTo(HaveOccurred()) })).NotTo(HaveOccurred())
// Perform a sanity check so that we know all desired pods are // Perform a sanity check so that we know all desired pods are
// running on the nodes according to kubelet. The timeout is set to // running on the nodes according to kubelet. The timeout is set to
// only 30 seconds here because RunRC already waited for all pods to // only 30 seconds here because framework.RunRC already waited for all pods to
// transition to the running status. // transition to the running status.
Expect(waitTillNPodsRunningOnNodes(framework.Client, nodeNames, rcName, framework.Namespace.Name, totalPods, Expect(waitTillNPodsRunningOnNodes(f.Client, nodeNames, rcName, f.Namespace.Name, totalPods,
time.Second*30)).NotTo(HaveOccurred()) time.Second*30)).NotTo(HaveOccurred())
resourceMonitor.LogLatest() resourceMonitor.LogLatest()
By("Deleting the RC") By("Deleting the RC")
DeleteRC(framework.Client, framework.Namespace.Name, rcName) framework.DeleteRC(f.Client, f.Namespace.Name, rcName)
// Check that the pods really are gone by querying /runningpods on the // Check that the pods really are gone by querying /runningpods on the
// node. The /runningpods handler checks the container runtime (or its // node. The /runningpods handler checks the container runtime (or its
// cache) and returns a list of running pods. Some possible causes of // cache) and returns a list of running pods. Some possible causes of
...@@ -148,9 +149,9 @@ var _ = KubeDescribe("kubelet", func() { ...@@ -148,9 +149,9 @@ var _ = KubeDescribe("kubelet", func() {
// - a bug in graceful termination (if it is enabled) // - a bug in graceful termination (if it is enabled)
// - docker slow to delete pods (or resource problems causing slowness) // - docker slow to delete pods (or resource problems causing slowness)
start := time.Now() start := time.Now()
Expect(waitTillNPodsRunningOnNodes(framework.Client, nodeNames, rcName, framework.Namespace.Name, 0, Expect(waitTillNPodsRunningOnNodes(f.Client, nodeNames, rcName, f.Namespace.Name, 0,
itArg.timeout)).NotTo(HaveOccurred()) itArg.timeout)).NotTo(HaveOccurred())
Logf("Deleting %d pods on %d nodes completed in %v after the RC was deleted", totalPods, len(nodeNames), framework.Logf("Deleting %d pods on %d nodes completed in %v after the RC was deleted", totalPods, len(nodeNames),
time.Since(start)) time.Since(start))
resourceMonitor.LogCPUSummary() resourceMonitor.LogCPUSummary()
}) })
......
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apimachinery/registered" "k8s.io/kubernetes/pkg/apimachinery/registered"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/test/e2e/framework"
) )
const ( const (
...@@ -37,11 +38,11 @@ const ( ...@@ -37,11 +38,11 @@ const (
type KubeletManagedHostConfig struct { type KubeletManagedHostConfig struct {
hostNetworkPod *api.Pod hostNetworkPod *api.Pod
pod *api.Pod pod *api.Pod
f *Framework f *framework.Framework
} }
var _ = KubeDescribe("KubeletManagedEtcHosts", func() { var _ = framework.KubeDescribe("KubeletManagedEtcHosts", func() {
f := NewDefaultFramework("e2e-kubelet-etc-hosts") f := framework.NewDefaultFramework("e2e-kubelet-etc-hosts")
config := &KubeletManagedHostConfig{ config := &KubeletManagedHostConfig{
f: f, f: f,
} }
...@@ -94,12 +95,12 @@ func (config *KubeletManagedHostConfig) createPodWithHostNetwork() { ...@@ -94,12 +95,12 @@ func (config *KubeletManagedHostConfig) createPodWithHostNetwork() {
func (config *KubeletManagedHostConfig) createPod(podSpec *api.Pod) *api.Pod { func (config *KubeletManagedHostConfig) createPod(podSpec *api.Pod) *api.Pod {
createdPod, err := config.getPodClient().Create(podSpec) createdPod, err := config.getPodClient().Create(podSpec)
if err != nil { if err != nil {
Failf("Failed to create %s pod: %v", podSpec.Name, err) framework.Failf("Failed to create %s pod: %v", podSpec.Name, err)
} }
expectNoError(config.f.WaitForPodRunning(podSpec.Name)) framework.ExpectNoError(config.f.WaitForPodRunning(podSpec.Name))
createdPod, err = config.getPodClient().Get(podSpec.Name) createdPod, err = config.getPodClient().Get(podSpec.Name)
if err != nil { if err != nil {
Failf("Failed to retrieve %s pod: %v", podSpec.Name, err) framework.Failf("Failed to retrieve %s pod: %v", podSpec.Name, err)
} }
return createdPod return createdPod
} }
...@@ -111,31 +112,31 @@ func (config *KubeletManagedHostConfig) getPodClient() client.PodInterface { ...@@ -111,31 +112,31 @@ func (config *KubeletManagedHostConfig) getPodClient() client.PodInterface {
func assertEtcHostsIsKubeletManaged(etcHostsContent string) { func assertEtcHostsIsKubeletManaged(etcHostsContent string) {
isKubeletManaged := strings.Contains(etcHostsContent, etcHostsPartialContent) isKubeletManaged := strings.Contains(etcHostsContent, etcHostsPartialContent)
if !isKubeletManaged { if !isKubeletManaged {
Failf("/etc/hosts file should be kubelet managed, but is not: %q", etcHostsContent) framework.Failf("/etc/hosts file should be kubelet managed, but is not: %q", etcHostsContent)
} }
} }
func assertEtcHostsIsNotKubeletManaged(etcHostsContent string) { func assertEtcHostsIsNotKubeletManaged(etcHostsContent string) {
isKubeletManaged := strings.Contains(etcHostsContent, etcHostsPartialContent) isKubeletManaged := strings.Contains(etcHostsContent, etcHostsPartialContent)
if isKubeletManaged { if isKubeletManaged {
Failf("/etc/hosts file should not be kubelet managed, but is: %q", etcHostsContent) framework.Failf("/etc/hosts file should not be kubelet managed, but is: %q", etcHostsContent)
} }
} }
func (config *KubeletManagedHostConfig) getEtcHostsContent(podName, containerName string) string { func (config *KubeletManagedHostConfig) getEtcHostsContent(podName, containerName string) string {
cmd := kubectlCmd("exec", fmt.Sprintf("--namespace=%v", config.f.Namespace.Name), podName, "-c", containerName, "cat", "/etc/hosts") cmd := framework.KubectlCmd("exec", fmt.Sprintf("--namespace=%v", config.f.Namespace.Name), podName, "-c", containerName, "cat", "/etc/hosts")
stdout, stderr, err := startCmdAndStreamOutput(cmd) stdout, stderr, err := framework.StartCmdAndStreamOutput(cmd)
if err != nil { if err != nil {
Failf("Failed to retrieve /etc/hosts, err: %q", err) framework.Failf("Failed to retrieve /etc/hosts, err: %q", err)
} }
defer stdout.Close() defer stdout.Close()
defer stderr.Close() defer stderr.Close()
buf := make([]byte, 1000) buf := make([]byte, 1000)
var n int var n int
Logf("reading from `kubectl exec` command's stdout") framework.Logf("reading from `kubectl exec` command's stdout")
if n, err = stdout.Read(buf); err != nil { if n, err = stdout.Read(buf); err != nil {
Failf("Failed to read from kubectl exec stdout: %v", err) framework.Failf("Failed to read from kubectl exec stdout: %v", err)
} }
return string(buf[:n]) return string(buf[:n])
} }
......
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/stats" "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/stats"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -41,33 +42,33 @@ const ( ...@@ -41,33 +42,33 @@ const (
type resourceTest struct { type resourceTest struct {
podsPerNode int podsPerNode int
cpuLimits containersCPUSummary cpuLimits framework.ContainersCPUSummary
memLimits resourceUsagePerContainer memLimits framework.ResourceUsagePerContainer
} }
func logPodsOnNodes(c *client.Client, nodeNames []string) { func logPodsOnNodes(c *client.Client, nodeNames []string) {
for _, n := range nodeNames { for _, n := range nodeNames {
podList, err := GetKubeletRunningPods(c, n) podList, err := framework.GetKubeletRunningPods(c, n)
if err != nil { if err != nil {
Logf("Unable to retrieve kubelet pods for node %v", n) framework.Logf("Unable to retrieve kubelet pods for node %v", n)
continue continue
} }
Logf("%d pods are running on node %v", len(podList.Items), n) framework.Logf("%d pods are running on node %v", len(podList.Items), n)
} }
} }
func runResourceTrackingTest(framework *Framework, podsPerNode int, nodeNames sets.String, rm *resourceMonitor, func runResourceTrackingTest(f *framework.Framework, podsPerNode int, nodeNames sets.String, rm *framework.ResourceMonitor,
expectedCPU map[string]map[float64]float64, expectedMemory resourceUsagePerContainer) { expectedCPU map[string]map[float64]float64, expectedMemory framework.ResourceUsagePerContainer) {
numNodes := nodeNames.Len() numNodes := nodeNames.Len()
totalPods := podsPerNode * numNodes totalPods := podsPerNode * numNodes
By(fmt.Sprintf("Creating a RC of %d pods and wait until all pods of this RC are running", totalPods)) By(fmt.Sprintf("Creating a RC of %d pods and wait until all pods of this RC are running", totalPods))
rcName := fmt.Sprintf("resource%d-%s", totalPods, string(util.NewUUID())) rcName := fmt.Sprintf("resource%d-%s", totalPods, string(util.NewUUID()))
// TODO: Use a more realistic workload // TODO: Use a more realistic workload
Expect(RunRC(RCConfig{ Expect(framework.RunRC(framework.RCConfig{
Client: framework.Client, Client: f.Client,
Name: rcName, Name: rcName,
Namespace: framework.Namespace.Name, Namespace: f.Namespace.Name,
Image: "gcr.io/google_containers/pause:2.0", Image: "gcr.io/google_containers/pause:2.0",
Replicas: totalPods, Replicas: totalPods,
})).NotTo(HaveOccurred()) })).NotTo(HaveOccurred())
...@@ -78,38 +79,38 @@ func runResourceTrackingTest(framework *Framework, podsPerNode int, nodeNames se ...@@ -78,38 +79,38 @@ func runResourceTrackingTest(framework *Framework, podsPerNode int, nodeNames se
By("Start monitoring resource usage") By("Start monitoring resource usage")
// Periodically dump the cpu summary until the deadline is met. // Periodically dump the cpu summary until the deadline is met.
// Note that without calling resourceMonitor.Reset(), the stats // Note that without calling framework.ResourceMonitor.Reset(), the stats
// would occupy increasingly more memory. This should be fine // would occupy increasingly more memory. This should be fine
// for the current test duration, but we should reclaim the // for the current test duration, but we should reclaim the
// entries if we plan to monitor longer (e.g., 8 hours). // entries if we plan to monitor longer (e.g., 8 hours).
deadline := time.Now().Add(monitoringTime) deadline := time.Now().Add(monitoringTime)
for time.Now().Before(deadline) { for time.Now().Before(deadline) {
timeLeft := deadline.Sub(time.Now()) timeLeft := deadline.Sub(time.Now())
Logf("Still running...%v left", timeLeft) framework.Logf("Still running...%v left", timeLeft)
if timeLeft < reportingPeriod { if timeLeft < reportingPeriod {
time.Sleep(timeLeft) time.Sleep(timeLeft)
} else { } else {
time.Sleep(reportingPeriod) time.Sleep(reportingPeriod)
} }
logPodsOnNodes(framework.Client, nodeNames.List()) logPodsOnNodes(f.Client, nodeNames.List())
} }
By("Reporting overall resource usage") By("Reporting overall resource usage")
logPodsOnNodes(framework.Client, nodeNames.List()) logPodsOnNodes(f.Client, nodeNames.List())
usageSummary, err := rm.GetLatest() usageSummary, err := rm.GetLatest()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Logf("%s", rm.FormatResourceUsage(usageSummary)) framework.Logf("%s", rm.FormatResourceUsage(usageSummary))
verifyMemoryLimits(framework.Client, expectedMemory, usageSummary) verifyMemoryLimits(f.Client, expectedMemory, usageSummary)
cpuSummary := rm.GetCPUSummary() cpuSummary := rm.GetCPUSummary()
Logf("%s", rm.FormatCPUSummary(cpuSummary)) framework.Logf("%s", rm.FormatCPUSummary(cpuSummary))
verifyCPULimits(expectedCPU, cpuSummary) verifyCPULimits(expectedCPU, cpuSummary)
By("Deleting the RC") By("Deleting the RC")
DeleteRC(framework.Client, framework.Namespace.Name, rcName) framework.DeleteRC(f.Client, f.Namespace.Name, rcName)
} }
func verifyMemoryLimits(c *client.Client, expected resourceUsagePerContainer, actual resourceUsagePerNode) { func verifyMemoryLimits(c *client.Client, expected framework.ResourceUsagePerContainer, actual framework.ResourceUsagePerNode) {
if expected == nil { if expected == nil {
return return
} }
...@@ -132,20 +133,20 @@ func verifyMemoryLimits(c *client.Client, expected resourceUsagePerContainer, ac ...@@ -132,20 +133,20 @@ func verifyMemoryLimits(c *client.Client, expected resourceUsagePerContainer, ac
} }
if len(nodeErrs) > 0 { if len(nodeErrs) > 0 {
errList = append(errList, fmt.Sprintf("node %v:\n %s", nodeName, strings.Join(nodeErrs, ", "))) errList = append(errList, fmt.Sprintf("node %v:\n %s", nodeName, strings.Join(nodeErrs, ", ")))
heapStats, err := getKubeletHeapStats(c, nodeName) heapStats, err := framework.GetKubeletHeapStats(c, nodeName)
if err != nil { if err != nil {
Logf("Unable to get heap stats from %q", nodeName) framework.Logf("Unable to get heap stats from %q", nodeName)
} else { } else {
Logf("Heap stats on %q\n:%v", nodeName, heapStats) framework.Logf("Heap stats on %q\n:%v", nodeName, heapStats)
} }
} }
} }
if len(errList) > 0 { if len(errList) > 0 {
Failf("Memory usage exceeding limits:\n %s", strings.Join(errList, "\n")) framework.Failf("Memory usage exceeding limits:\n %s", strings.Join(errList, "\n"))
} }
} }
func verifyCPULimits(expected containersCPUSummary, actual nodesCPUSummary) { func verifyCPULimits(expected framework.ContainersCPUSummary, actual framework.NodesCPUSummary) {
if expected == nil { if expected == nil {
return return
} }
...@@ -175,30 +176,30 @@ func verifyCPULimits(expected containersCPUSummary, actual nodesCPUSummary) { ...@@ -175,30 +176,30 @@ func verifyCPULimits(expected containersCPUSummary, actual nodesCPUSummary) {
} }
} }
if len(errList) > 0 { if len(errList) > 0 {
Failf("CPU usage exceeding limits:\n %s", strings.Join(errList, "\n")) framework.Failf("CPU usage exceeding limits:\n %s", strings.Join(errList, "\n"))
} }
} }
// Slow by design (1 hour) // Slow by design (1 hour)
var _ = KubeDescribe("Kubelet [Serial] [Slow]", func() { var _ = framework.KubeDescribe("Kubelet [Serial] [Slow]", func() {
var nodeNames sets.String var nodeNames sets.String
framework := NewDefaultFramework("kubelet-perf") f := framework.NewDefaultFramework("kubelet-perf")
var rm *resourceMonitor var rm *framework.ResourceMonitor
BeforeEach(func() { BeforeEach(func() {
nodes := ListSchedulableNodesOrDie(framework.Client) nodes := framework.ListSchedulableNodesOrDie(f.Client)
nodeNames = sets.NewString() nodeNames = sets.NewString()
for _, node := range nodes.Items { for _, node := range nodes.Items {
nodeNames.Insert(node.Name) nodeNames.Insert(node.Name)
} }
rm = newResourceMonitor(framework.Client, targetContainers(), containerStatsPollingPeriod) rm = framework.NewResourceMonitor(f.Client, framework.TargetContainers(), containerStatsPollingPeriod)
rm.Start() rm.Start()
}) })
AfterEach(func() { AfterEach(func() {
rm.Stop() rm.Stop()
}) })
KubeDescribe("regular resource usage tracking", func() { framework.KubeDescribe("regular resource usage tracking", func() {
// We assume that the scheduler will make reasonable scheduling choices // We assume that the scheduler will make reasonable scheduling choices
// and assign ~N pods on the node. // and assign ~N pods on the node.
// Although we want to track N pods per node, there are N + add-on pods // Although we want to track N pods per node, there are N + add-on pods
...@@ -210,27 +211,27 @@ var _ = KubeDescribe("Kubelet [Serial] [Slow]", func() { ...@@ -210,27 +211,27 @@ var _ = KubeDescribe("Kubelet [Serial] [Slow]", func() {
rTests := []resourceTest{ rTests := []resourceTest{
{ {
podsPerNode: 0, podsPerNode: 0,
cpuLimits: containersCPUSummary{ cpuLimits: framework.ContainersCPUSummary{
stats.SystemContainerKubelet: {0.50: 0.06, 0.95: 0.08}, stats.SystemContainerKubelet: {0.50: 0.06, 0.95: 0.08},
stats.SystemContainerRuntime: {0.50: 0.05, 0.95: 0.06}, stats.SystemContainerRuntime: {0.50: 0.05, 0.95: 0.06},
}, },
// We set the memory limits generously because the distribution // We set the memory limits generously because the distribution
// of the addon pods affect the memory usage on each node. // of the addon pods affect the memory usage on each node.
memLimits: resourceUsagePerContainer{ memLimits: framework.ResourceUsagePerContainer{
stats.SystemContainerKubelet: &containerResourceUsage{MemoryRSSInBytes: 70 * 1024 * 1024}, stats.SystemContainerKubelet: &framework.ContainerResourceUsage{MemoryRSSInBytes: 70 * 1024 * 1024},
stats.SystemContainerRuntime: &containerResourceUsage{MemoryRSSInBytes: 85 * 1024 * 1024}, stats.SystemContainerRuntime: &framework.ContainerResourceUsage{MemoryRSSInBytes: 85 * 1024 * 1024},
}, },
}, },
{ {
podsPerNode: 35, podsPerNode: 35,
cpuLimits: containersCPUSummary{ cpuLimits: framework.ContainersCPUSummary{
stats.SystemContainerKubelet: {0.50: 0.12, 0.95: 0.14}, stats.SystemContainerKubelet: {0.50: 0.12, 0.95: 0.14},
stats.SystemContainerRuntime: {0.50: 0.06, 0.95: 0.08}, stats.SystemContainerRuntime: {0.50: 0.06, 0.95: 0.08},
}, },
// We set the memory limits generously because the distribution // We set the memory limits generously because the distribution
// of the addon pods affect the memory usage on each node. // of the addon pods affect the memory usage on each node.
memLimits: resourceUsagePerContainer{ memLimits: framework.ResourceUsagePerContainer{
stats.SystemContainerRuntime: &containerResourceUsage{MemoryRSSInBytes: 100 * 1024 * 1024}, stats.SystemContainerRuntime: &framework.ContainerResourceUsage{MemoryRSSInBytes: 100 * 1024 * 1024},
}, },
}, },
{ {
...@@ -244,18 +245,18 @@ var _ = KubeDescribe("Kubelet [Serial] [Slow]", func() { ...@@ -244,18 +245,18 @@ var _ = KubeDescribe("Kubelet [Serial] [Slow]", func() {
name := fmt.Sprintf( name := fmt.Sprintf(
"for %d pods per node over %v", podsPerNode, monitoringTime) "for %d pods per node over %v", podsPerNode, monitoringTime)
It(name, func() { It(name, func() {
runResourceTrackingTest(framework, podsPerNode, nodeNames, rm, itArg.cpuLimits, itArg.memLimits) runResourceTrackingTest(f, podsPerNode, nodeNames, rm, itArg.cpuLimits, itArg.memLimits)
}) })
} }
}) })
KubeDescribe("experimental resource usage tracking [Feature:ExperimentalResourceUsageTracking]", func() { framework.KubeDescribe("experimental resource usage tracking [Feature:ExperimentalResourceUsageTracking]", func() {
density := []int{100} density := []int{100}
for i := range density { for i := range density {
podsPerNode := density[i] podsPerNode := density[i]
name := fmt.Sprintf( name := fmt.Sprintf(
"for %d pods per node over %v", podsPerNode, monitoringTime) "for %d pods per node over %v", podsPerNode, monitoringTime)
It(name, func() { It(name, func() {
runResourceTrackingTest(framework, podsPerNode, nodeNames, rm, nil, nil) runResourceTrackingTest(f, podsPerNode, nodeNames, rm, nil, nil)
}) })
} }
}) })
......
...@@ -36,6 +36,7 @@ import ( ...@@ -36,6 +36,7 @@ import (
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
utilnet "k8s.io/kubernetes/pkg/util/net" utilnet "k8s.io/kubernetes/pkg/util/net"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
) )
const ( const (
...@@ -63,15 +64,15 @@ type KubeProxyTestConfig struct { ...@@ -63,15 +64,15 @@ type KubeProxyTestConfig struct {
testContainerPod *api.Pod testContainerPod *api.Pod
hostTestContainerPod *api.Pod hostTestContainerPod *api.Pod
endpointPods []*api.Pod endpointPods []*api.Pod
f *Framework f *framework.Framework
nodePortService *api.Service nodePortService *api.Service
loadBalancerService *api.Service loadBalancerService *api.Service
externalAddrs []string externalAddrs []string
nodes []api.Node nodes []api.Node
} }
var _ = KubeDescribe("KubeProxy", func() { var _ = framework.KubeDescribe("KubeProxy", func() {
f := NewDefaultFramework("e2e-kubeproxy") f := framework.NewDefaultFramework("e2e-kubeproxy")
config := &KubeProxyTestConfig{ config := &KubeProxyTestConfig{
f: f, f: f,
} }
...@@ -238,7 +239,7 @@ func (config *KubeProxyTestConfig) dialFromContainer(protocol, containerIP, targ ...@@ -238,7 +239,7 @@ func (config *KubeProxyTestConfig) dialFromContainer(protocol, containerIP, targ
tries) tries)
By(fmt.Sprintf("Dialing from container. Running command:%s", cmd)) By(fmt.Sprintf("Dialing from container. Running command:%s", cmd))
stdout := RunHostCmdOrDie(config.f.Namespace.Name, config.hostTestContainerPod.Name, cmd) stdout := framework.RunHostCmdOrDie(config.f.Namespace.Name, config.hostTestContainerPod.Name, cmd)
var output map[string][]string var output map[string][]string
err := json.Unmarshal([]byte(stdout), &output) err := json.Unmarshal([]byte(stdout), &output)
Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("Could not unmarshal curl response: %s", stdout)) Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("Could not unmarshal curl response: %s", stdout))
...@@ -258,14 +259,14 @@ func (config *KubeProxyTestConfig) dialFromNode(protocol, targetIP string, targe ...@@ -258,14 +259,14 @@ func (config *KubeProxyTestConfig) dialFromNode(protocol, targetIP string, targe
// hitting any other. // hitting any other.
forLoop := fmt.Sprintf("for i in $(seq 1 %d); do %s; echo; sleep %v; done | grep -v '^\\s*$' |sort | uniq -c | wc -l", tries, cmd, hitEndpointRetryDelay) forLoop := fmt.Sprintf("for i in $(seq 1 %d); do %s; echo; sleep %v; done | grep -v '^\\s*$' |sort | uniq -c | wc -l", tries, cmd, hitEndpointRetryDelay)
By(fmt.Sprintf("Dialing from node. command:%s", forLoop)) By(fmt.Sprintf("Dialing from node. command:%s", forLoop))
stdout := RunHostCmdOrDie(config.f.Namespace.Name, config.hostTestContainerPod.Name, forLoop) stdout := framework.RunHostCmdOrDie(config.f.Namespace.Name, config.hostTestContainerPod.Name, forLoop)
Expect(strconv.Atoi(strings.TrimSpace(stdout))).To(BeNumerically("==", expectedCount)) Expect(strconv.Atoi(strings.TrimSpace(stdout))).To(BeNumerically("==", expectedCount))
} }
func (config *KubeProxyTestConfig) getSelfURL(path string, expected string) { func (config *KubeProxyTestConfig) getSelfURL(path string, expected string) {
cmd := fmt.Sprintf("curl -s --connect-timeout 1 http://localhost:10249%s", path) cmd := fmt.Sprintf("curl -s --connect-timeout 1 http://localhost:10249%s", path)
By(fmt.Sprintf("Getting kube-proxy self URL %s", path)) By(fmt.Sprintf("Getting kube-proxy self URL %s", path))
stdout := RunHostCmdOrDie(config.f.Namespace.Name, config.hostTestContainerPod.Name, cmd) stdout := framework.RunHostCmdOrDie(config.f.Namespace.Name, config.hostTestContainerPod.Name, cmd)
Expect(strings.Contains(stdout, expected)).To(BeTrue()) Expect(strings.Contains(stdout, expected)).To(BeTrue())
} }
...@@ -421,23 +422,23 @@ func (config *KubeProxyTestConfig) waitForLoadBalancerIngressSetup() { ...@@ -421,23 +422,23 @@ func (config *KubeProxyTestConfig) waitForLoadBalancerIngressSetup() {
func (config *KubeProxyTestConfig) createTestPods() { func (config *KubeProxyTestConfig) createTestPods() {
testContainerPod := config.createTestPodSpec() testContainerPod := config.createTestPodSpec()
hostTestContainerPod := NewHostExecPodSpec(config.f.Namespace.Name, hostTestPodName) hostTestContainerPod := framework.NewHostExecPodSpec(config.f.Namespace.Name, hostTestPodName)
config.createPod(testContainerPod) config.createPod(testContainerPod)
config.createPod(hostTestContainerPod) config.createPod(hostTestContainerPod)
expectNoError(config.f.WaitForPodRunning(testContainerPod.Name)) framework.ExpectNoError(config.f.WaitForPodRunning(testContainerPod.Name))
expectNoError(config.f.WaitForPodRunning(hostTestContainerPod.Name)) framework.ExpectNoError(config.f.WaitForPodRunning(hostTestContainerPod.Name))
var err error var err error
config.testContainerPod, err = config.getPodClient().Get(testContainerPod.Name) config.testContainerPod, err = config.getPodClient().Get(testContainerPod.Name)
if err != nil { if err != nil {
Failf("Failed to retrieve %s pod: %v", testContainerPod.Name, err) framework.Failf("Failed to retrieve %s pod: %v", testContainerPod.Name, err)
} }
config.hostTestContainerPod, err = config.getPodClient().Get(hostTestContainerPod.Name) config.hostTestContainerPod, err = config.getPodClient().Get(hostTestContainerPod.Name)
if err != nil { if err != nil {
Failf("Failed to retrieve %s pod: %v", hostTestContainerPod.Name, err) framework.Failf("Failed to retrieve %s pod: %v", hostTestContainerPod.Name, err)
} }
} }
...@@ -445,7 +446,7 @@ func (config *KubeProxyTestConfig) createService(serviceSpec *api.Service) *api. ...@@ -445,7 +446,7 @@ func (config *KubeProxyTestConfig) createService(serviceSpec *api.Service) *api.
_, err := config.getServiceClient().Create(serviceSpec) _, err := config.getServiceClient().Create(serviceSpec)
Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("Failed to create %s service: %v", serviceSpec.Name, err)) Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("Failed to create %s service: %v", serviceSpec.Name, err))
err = waitForService(config.f.Client, config.f.Namespace.Name, serviceSpec.Name, true, 5*time.Second, 45*time.Second) err = framework.WaitForService(config.f.Client, config.f.Namespace.Name, serviceSpec.Name, true, 5*time.Second, 45*time.Second)
Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("error while waiting for service:%s err: %v", serviceSpec.Name, err)) Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("error while waiting for service:%s err: %v", serviceSpec.Name, err))
createdService, err := config.getServiceClient().Get(serviceSpec.Name) createdService, err := config.getServiceClient().Get(serviceSpec.Name)
...@@ -462,11 +463,11 @@ func (config *KubeProxyTestConfig) setup() { ...@@ -462,11 +463,11 @@ func (config *KubeProxyTestConfig) setup() {
} }
By("Getting node addresses") By("Getting node addresses")
nodeList := ListSchedulableNodesOrDie(config.f.Client) nodeList := framework.ListSchedulableNodesOrDie(config.f.Client)
config.externalAddrs = NodeAddresses(nodeList, api.NodeExternalIP) config.externalAddrs = framework.NodeAddresses(nodeList, api.NodeExternalIP)
if len(config.externalAddrs) < 2 { if len(config.externalAddrs) < 2 {
// fall back to legacy IPs // fall back to legacy IPs
config.externalAddrs = NodeAddresses(nodeList, api.NodeLegacyHostIP) config.externalAddrs = framework.NodeAddresses(nodeList, api.NodeLegacyHostIP)
} }
Expect(len(config.externalAddrs)).To(BeNumerically(">=", 2), fmt.Sprintf("At least two nodes necessary with an external or LegacyHostIP")) Expect(len(config.externalAddrs)).To(BeNumerically(">=", 2), fmt.Sprintf("At least two nodes necessary with an external or LegacyHostIP"))
config.nodes = nodeList.Items config.nodes = nodeList.Items
...@@ -500,7 +501,7 @@ func (config *KubeProxyTestConfig) cleanup() { ...@@ -500,7 +501,7 @@ func (config *KubeProxyTestConfig) cleanup() {
} }
func (config *KubeProxyTestConfig) createNetProxyPods(podName string, selector map[string]string) []*api.Pod { func (config *KubeProxyTestConfig) createNetProxyPods(podName string, selector map[string]string) []*api.Pod {
nodes := ListSchedulableNodesOrDie(config.f.Client) nodes := framework.ListSchedulableNodesOrDie(config.f.Client)
// create pods, one for each node // create pods, one for each node
createdPods := make([]*api.Pod, 0, len(nodes.Items)) createdPods := make([]*api.Pod, 0, len(nodes.Items))
...@@ -515,9 +516,9 @@ func (config *KubeProxyTestConfig) createNetProxyPods(podName string, selector m ...@@ -515,9 +516,9 @@ func (config *KubeProxyTestConfig) createNetProxyPods(podName string, selector m
// wait that all of them are up // wait that all of them are up
runningPods := make([]*api.Pod, 0, len(nodes.Items)) runningPods := make([]*api.Pod, 0, len(nodes.Items))
for _, p := range createdPods { for _, p := range createdPods {
expectNoError(config.f.WaitForPodReady(p.Name)) framework.ExpectNoError(config.f.WaitForPodReady(p.Name))
rp, err := config.getPodClient().Get(p.Name) rp, err := config.getPodClient().Get(p.Name)
expectNoError(err) framework.ExpectNoError(err)
runningPods = append(runningPods, rp) runningPods = append(runningPods, rp)
} }
...@@ -529,14 +530,14 @@ func (config *KubeProxyTestConfig) deleteNetProxyPod() { ...@@ -529,14 +530,14 @@ func (config *KubeProxyTestConfig) deleteNetProxyPod() {
config.getPodClient().Delete(pod.Name, api.NewDeleteOptions(0)) config.getPodClient().Delete(pod.Name, api.NewDeleteOptions(0))
config.endpointPods = config.endpointPods[1:] config.endpointPods = config.endpointPods[1:]
// wait for pod being deleted. // wait for pod being deleted.
err := waitForPodToDisappear(config.f.Client, config.f.Namespace.Name, pod.Name, labels.Everything(), time.Second, wait.ForeverTestTimeout) err := framework.WaitForPodToDisappear(config.f.Client, config.f.Namespace.Name, pod.Name, labels.Everything(), time.Second, wait.ForeverTestTimeout)
if err != nil { if err != nil {
Failf("Failed to delete %s pod: %v", pod.Name, err) framework.Failf("Failed to delete %s pod: %v", pod.Name, err)
} }
// wait for endpoint being removed. // wait for endpoint being removed.
err = waitForServiceEndpointsNum(config.f.Client, config.f.Namespace.Name, nodePortServiceName, len(config.endpointPods), time.Second, wait.ForeverTestTimeout) err = framework.WaitForServiceEndpointsNum(config.f.Client, config.f.Namespace.Name, nodePortServiceName, len(config.endpointPods), time.Second, wait.ForeverTestTimeout)
if err != nil { if err != nil {
Failf("Failed to remove endpoint from service: %s", nodePortServiceName) framework.Failf("Failed to remove endpoint from service: %s", nodePortServiceName)
} }
// wait for kube-proxy to catch up with the pod being deleted. // wait for kube-proxy to catch up with the pod being deleted.
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
...@@ -545,7 +546,7 @@ func (config *KubeProxyTestConfig) deleteNetProxyPod() { ...@@ -545,7 +546,7 @@ func (config *KubeProxyTestConfig) deleteNetProxyPod() {
func (config *KubeProxyTestConfig) createPod(pod *api.Pod) *api.Pod { func (config *KubeProxyTestConfig) createPod(pod *api.Pod) *api.Pod {
createdPod, err := config.getPodClient().Create(pod) createdPod, err := config.getPodClient().Create(pod)
if err != nil { if err != nil {
Failf("Failed to create %s pod: %v", pod.Name, err) framework.Failf("Failed to create %s pod: %v", pod.Name, err)
} }
return createdPod return createdPod
} }
......
...@@ -21,13 +21,14 @@ import ( ...@@ -21,13 +21,14 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = KubeDescribe("LimitRange", func() { var _ = framework.KubeDescribe("LimitRange", func() {
f := NewDefaultFramework("limitrange") f := framework.NewDefaultFramework("limitrange")
It("should create a LimitRange with defaults and ensure pod has those defaults applied.", func() { It("should create a LimitRange with defaults and ensure pod has those defaults applied.", func() {
By("Creating a LimitRange") By("Creating a LimitRange")
...@@ -63,7 +64,7 @@ var _ = KubeDescribe("LimitRange", func() { ...@@ -63,7 +64,7 @@ var _ = KubeDescribe("LimitRange", func() {
err = equalResourceRequirement(expected, pod.Spec.Containers[i].Resources) err = equalResourceRequirement(expected, pod.Spec.Containers[i].Resources)
if err != nil { if err != nil {
// Print the pod to help in debugging. // Print the pod to help in debugging.
Logf("Pod %+v does not have the expected requirements", pod) framework.Logf("Pod %+v does not have the expected requirements", pod)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
} }
} }
...@@ -84,7 +85,7 @@ var _ = KubeDescribe("LimitRange", func() { ...@@ -84,7 +85,7 @@ var _ = KubeDescribe("LimitRange", func() {
err = equalResourceRequirement(expected, pod.Spec.Containers[i].Resources) err = equalResourceRequirement(expected, pod.Spec.Containers[i].Resources)
if err != nil { if err != nil {
// Print the pod to help in debugging. // Print the pod to help in debugging.
Logf("Pod %+v does not have the expected requirements", pod) framework.Logf("Pod %+v does not have the expected requirements", pod)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
} }
} }
...@@ -103,12 +104,12 @@ var _ = KubeDescribe("LimitRange", func() { ...@@ -103,12 +104,12 @@ var _ = KubeDescribe("LimitRange", func() {
}) })
func equalResourceRequirement(expected api.ResourceRequirements, actual api.ResourceRequirements) error { func equalResourceRequirement(expected api.ResourceRequirements, actual api.ResourceRequirements) error {
Logf("Verifying requests: expected %s with actual %s", expected.Requests, actual.Requests) framework.Logf("Verifying requests: expected %s with actual %s", expected.Requests, actual.Requests)
err := equalResourceList(expected.Requests, actual.Requests) err := equalResourceList(expected.Requests, actual.Requests)
if err != nil { if err != nil {
return err return err
} }
Logf("Verifying limits: expected %v with actual %v", expected.Limits, actual.Limits) framework.Logf("Verifying limits: expected %v with actual %v", expected.Limits, actual.Limits)
err = equalResourceList(expected.Limits, actual.Limits) err = equalResourceList(expected.Limits, actual.Limits)
if err != nil { if err != nil {
return err return err
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -47,45 +48,45 @@ const ( ...@@ -47,45 +48,45 @@ const (
// the ginkgo.skip list (see driver.go). // the ginkgo.skip list (see driver.go).
// To run this suite you must explicitly ask for it by setting the // To run this suite you must explicitly ask for it by setting the
// -t/--test flag or ginkgo.focus flag. // -t/--test flag or ginkgo.focus flag.
var _ = KubeDescribe("Load capacity", func() { var _ = framework.KubeDescribe("Load capacity", func() {
var c *client.Client var c *client.Client
var nodeCount int var nodeCount int
var ns string var ns string
var configs []*RCConfig var configs []*framework.RCConfig
// Gathers metrics before teardown // Gathers metrics before teardown
// TODO add flag that allows to skip cleanup on failure // TODO add flag that allows to skip cleanup on failure
AfterEach(func() { AfterEach(func() {
// Verify latency metrics // Verify latency metrics
highLatencyRequests, err := HighLatencyRequests(c) highLatencyRequests, err := framework.HighLatencyRequests(c)
expectNoError(err, "Too many instances metrics above the threshold") framework.ExpectNoError(err, "Too many instances metrics above the threshold")
Expect(highLatencyRequests).NotTo(BeNumerically(">", 0)) Expect(highLatencyRequests).NotTo(BeNumerically(">", 0))
}) })
// Explicitly put here, to delete namespace at the end of the test // Explicitly put here, to delete namespace at the end of the test
// (after measuring latency metrics, etc.). // (after measuring latency metrics, etc.).
options := FrameworkOptions{ options := framework.FrameworkOptions{
clientQPS: 50, ClientQPS: 50,
clientBurst: 100, ClientBurst: 100,
} }
framework := NewFramework("load", options) f := framework.NewFramework("load", options)
framework.NamespaceDeletionTimeout = time.Hour f.NamespaceDeletionTimeout = time.Hour
BeforeEach(func() { BeforeEach(func() {
c = framework.Client c = f.Client
ns = framework.Namespace.Name ns = f.Namespace.Name
nodes := ListSchedulableNodesOrDie(c) nodes := framework.ListSchedulableNodesOrDie(c)
nodeCount = len(nodes.Items) nodeCount = len(nodes.Items)
Expect(nodeCount).NotTo(BeZero()) Expect(nodeCount).NotTo(BeZero())
// Terminating a namespace (deleting the remaining objects from it - which // Terminating a namespace (deleting the remaining objects from it - which
// generally means events) can affect the current run. Thus we wait for all // generally means events) can affect the current run. Thus we wait for all
// terminating namespace to be finally deleted before starting this test. // terminating namespace to be finally deleted before starting this test.
err := checkTestingNSDeletedExcept(c, ns) err := framework.CheckTestingNSDeletedExcept(c, ns)
expectNoError(err) framework.ExpectNoError(err)
expectNoError(resetMetrics(c)) framework.ExpectNoError(framework.ResetMetrics(c))
}) })
type Load struct { type Load struct {
...@@ -166,8 +167,8 @@ func computeRCCounts(total int) (int, int, int) { ...@@ -166,8 +167,8 @@ func computeRCCounts(total int) (int, int, int) {
return smallRCCount, mediumRCCount, bigRCCount return smallRCCount, mediumRCCount, bigRCCount
} }
func generateRCConfigs(totalPods int, image string, command []string, c *client.Client, ns string) []*RCConfig { func generateRCConfigs(totalPods int, image string, command []string, c *client.Client, ns string) []*framework.RCConfig {
configs := make([]*RCConfig, 0) configs := make([]*framework.RCConfig, 0)
smallRCCount, mediumRCCount, bigRCCount := computeRCCounts(totalPods) smallRCCount, mediumRCCount, bigRCCount := computeRCCounts(totalPods)
configs = append(configs, generateRCConfigsForGroup(c, ns, smallRCGroupName, smallRCSize, smallRCCount, image, command)...) configs = append(configs, generateRCConfigsForGroup(c, ns, smallRCGroupName, smallRCSize, smallRCCount, image, command)...)
...@@ -177,10 +178,10 @@ func generateRCConfigs(totalPods int, image string, command []string, c *client. ...@@ -177,10 +178,10 @@ func generateRCConfigs(totalPods int, image string, command []string, c *client.
return configs return configs
} }
func generateRCConfigsForGroup(c *client.Client, ns, groupName string, size, count int, image string, command []string) []*RCConfig { func generateRCConfigsForGroup(c *client.Client, ns, groupName string, size, count int, image string, command []string) []*framework.RCConfig {
configs := make([]*RCConfig, 0, count) configs := make([]*framework.RCConfig, 0, count)
for i := 1; i <= count; i++ { for i := 1; i <= count; i++ {
config := &RCConfig{ config := &framework.RCConfig{
Client: c, Client: c,
Name: groupName + "-" + strconv.Itoa(i), Name: groupName + "-" + strconv.Itoa(i),
Namespace: ns, Namespace: ns,
...@@ -200,7 +201,7 @@ func sleepUpTo(d time.Duration) { ...@@ -200,7 +201,7 @@ func sleepUpTo(d time.Duration) {
time.Sleep(time.Duration(rand.Int63n(d.Nanoseconds()))) time.Sleep(time.Duration(rand.Int63n(d.Nanoseconds())))
} }
func createAllRC(configs []*RCConfig, creatingTime time.Duration) { func createAllRC(configs []*framework.RCConfig, creatingTime time.Duration) {
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(len(configs)) wg.Add(len(configs))
for _, config := range configs { for _, config := range configs {
...@@ -209,15 +210,15 @@ func createAllRC(configs []*RCConfig, creatingTime time.Duration) { ...@@ -209,15 +210,15 @@ func createAllRC(configs []*RCConfig, creatingTime time.Duration) {
wg.Wait() wg.Wait()
} }
func createRC(wg *sync.WaitGroup, config *RCConfig, creatingTime time.Duration) { func createRC(wg *sync.WaitGroup, config *framework.RCConfig, creatingTime time.Duration) {
defer GinkgoRecover() defer GinkgoRecover()
defer wg.Done() defer wg.Done()
sleepUpTo(creatingTime) sleepUpTo(creatingTime)
expectNoError(RunRC(*config), fmt.Sprintf("creating rc %s", config.Name)) framework.ExpectNoError(framework.RunRC(*config), fmt.Sprintf("creating rc %s", config.Name))
} }
func scaleAllRC(configs []*RCConfig, scalingTime time.Duration) { func scaleAllRC(configs []*framework.RCConfig, scalingTime time.Duration) {
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(len(configs)) wg.Add(len(configs))
for _, config := range configs { for _, config := range configs {
...@@ -228,13 +229,13 @@ func scaleAllRC(configs []*RCConfig, scalingTime time.Duration) { ...@@ -228,13 +229,13 @@ func scaleAllRC(configs []*RCConfig, scalingTime time.Duration) {
// Scales RC to a random size within [0.5*size, 1.5*size] and lists all the pods afterwards. // Scales RC to a random size within [0.5*size, 1.5*size] and lists all the pods afterwards.
// Scaling happens always based on original size, not the current size. // Scaling happens always based on original size, not the current size.
func scaleRC(wg *sync.WaitGroup, config *RCConfig, scalingTime time.Duration) { func scaleRC(wg *sync.WaitGroup, config *framework.RCConfig, scalingTime time.Duration) {
defer GinkgoRecover() defer GinkgoRecover()
defer wg.Done() defer wg.Done()
sleepUpTo(scalingTime) sleepUpTo(scalingTime)
newSize := uint(rand.Intn(config.Replicas) + config.Replicas/2) newSize := uint(rand.Intn(config.Replicas) + config.Replicas/2)
expectNoError(ScaleRC(config.Client, config.Namespace, config.Name, newSize, true), framework.ExpectNoError(framework.ScaleRC(config.Client, config.Namespace, config.Name, newSize, true),
fmt.Sprintf("scaling rc %s for the first time", config.Name)) fmt.Sprintf("scaling rc %s for the first time", config.Name))
selector := labels.SelectorFromSet(labels.Set(map[string]string{"name": config.Name})) selector := labels.SelectorFromSet(labels.Set(map[string]string{"name": config.Name}))
options := api.ListOptions{ options := api.ListOptions{
...@@ -242,10 +243,10 @@ func scaleRC(wg *sync.WaitGroup, config *RCConfig, scalingTime time.Duration) { ...@@ -242,10 +243,10 @@ func scaleRC(wg *sync.WaitGroup, config *RCConfig, scalingTime time.Duration) {
ResourceVersion: "0", ResourceVersion: "0",
} }
_, err := config.Client.Pods(config.Namespace).List(options) _, err := config.Client.Pods(config.Namespace).List(options)
expectNoError(err, fmt.Sprintf("listing pods from rc %v", config.Name)) framework.ExpectNoError(err, fmt.Sprintf("listing pods from rc %v", config.Name))
} }
func deleteAllRC(configs []*RCConfig, deletingTime time.Duration) { func deleteAllRC(configs []*framework.RCConfig, deletingTime time.Duration) {
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(len(configs)) wg.Add(len(configs))
for _, config := range configs { for _, config := range configs {
...@@ -254,10 +255,10 @@ func deleteAllRC(configs []*RCConfig, deletingTime time.Duration) { ...@@ -254,10 +255,10 @@ func deleteAllRC(configs []*RCConfig, deletingTime time.Duration) {
wg.Wait() wg.Wait()
} }
func deleteRC(wg *sync.WaitGroup, config *RCConfig, deletingTime time.Duration) { func deleteRC(wg *sync.WaitGroup, config *framework.RCConfig, deletingTime time.Duration) {
defer GinkgoRecover() defer GinkgoRecover()
defer wg.Done() defer wg.Done()
sleepUpTo(deletingTime) sleepUpTo(deletingTime)
expectNoError(DeleteRC(config.Client, config.Namespace, config.Name), fmt.Sprintf("deleting rc %s", config.Name)) framework.ExpectNoError(framework.DeleteRC(config.Client, config.Namespace, config.Name), fmt.Sprintf("deleting rc %s", config.Name))
} }
...@@ -24,30 +24,31 @@ import ( ...@@ -24,30 +24,31 @@ import (
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = KubeDescribe("Mesos", func() { var _ = framework.KubeDescribe("Mesos", func() {
framework := NewDefaultFramework("pods") f := framework.NewDefaultFramework("pods")
var c *client.Client var c *client.Client
var ns string var ns string
BeforeEach(func() { BeforeEach(func() {
SkipUnlessProviderIs("mesos/docker") framework.SkipUnlessProviderIs("mesos/docker")
c = framework.Client c = f.Client
ns = framework.Namespace.Name ns = f.Namespace.Name
}) })
It("applies slave attributes as labels", func() { It("applies slave attributes as labels", func() {
nodeClient := framework.Client.Nodes() nodeClient := f.Client.Nodes()
rackA := labels.SelectorFromSet(map[string]string{"k8s.mesosphere.io/attribute-rack": "1"}) rackA := labels.SelectorFromSet(map[string]string{"k8s.mesosphere.io/attribute-rack": "1"})
options := api.ListOptions{LabelSelector: rackA} options := api.ListOptions{LabelSelector: rackA}
nodes, err := nodeClient.List(options) nodes, err := nodeClient.List(options)
if err != nil { if err != nil {
Failf("Failed to query for node: %v", err) framework.Failf("Failed to query for node: %v", err)
} }
Expect(len(nodes.Items)).To(Equal(1)) Expect(len(nodes.Items)).To(Equal(1))
...@@ -61,14 +62,14 @@ var _ = KubeDescribe("Mesos", func() { ...@@ -61,14 +62,14 @@ var _ = KubeDescribe("Mesos", func() {
}) })
It("starts static pods on every node in the mesos cluster", func() { It("starts static pods on every node in the mesos cluster", func() {
client := framework.Client client := f.Client
expectNoError(allNodesReady(client, wait.ForeverTestTimeout), "all nodes ready") framework.ExpectNoError(framework.AllNodesReady(client, wait.ForeverTestTimeout), "all nodes ready")
nodelist := ListSchedulableNodesOrDie(framework.Client) nodelist := framework.ListSchedulableNodesOrDie(f.Client)
const ns = "static-pods" const ns = "static-pods"
numpods := len(nodelist.Items) numpods := len(nodelist.Items)
expectNoError(waitForPodsRunningReady(ns, numpods, wait.ForeverTestTimeout), framework.ExpectNoError(framework.WaitForPodsRunningReady(ns, numpods, wait.ForeverTestTimeout),
fmt.Sprintf("number of static pods in namespace %s is %d", ns, numpods)) fmt.Sprintf("number of static pods in namespace %s is %d", ns, numpods))
}) })
...@@ -98,13 +99,13 @@ var _ = KubeDescribe("Mesos", func() { ...@@ -98,13 +99,13 @@ var _ = KubeDescribe("Mesos", func() {
}, },
}, },
}) })
expectNoError(err) framework.ExpectNoError(err)
expectNoError(waitForPodRunningInNamespace(c, podName, ns)) framework.ExpectNoError(framework.WaitForPodRunningInNamespace(c, podName, ns))
pod, err := c.Pods(ns).Get(podName) pod, err := c.Pods(ns).Get(podName)
expectNoError(err) framework.ExpectNoError(err)
nodeClient := framework.Client.Nodes() nodeClient := f.Client.Nodes()
// schedule onto node with rack=2 being assigned to the "public" role // schedule onto node with rack=2 being assigned to the "public" role
rack2 := labels.SelectorFromSet(map[string]string{ rack2 := labels.SelectorFromSet(map[string]string{
...@@ -112,7 +113,7 @@ var _ = KubeDescribe("Mesos", func() { ...@@ -112,7 +113,7 @@ var _ = KubeDescribe("Mesos", func() {
}) })
options := api.ListOptions{LabelSelector: rack2} options := api.ListOptions{LabelSelector: rack2}
nodes, err := nodeClient.List(options) nodes, err := nodeClient.List(options)
expectNoError(err) framework.ExpectNoError(err)
Expect(nodes.Items[0].Name).To(Equal(pod.Spec.NodeName)) Expect(nodes.Items[0].Name).To(Equal(pod.Spec.NodeName))
}) })
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/metrics" "k8s.io/kubernetes/pkg/metrics"
"k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -77,23 +78,23 @@ func checkMetrics(response metrics.Metrics, assumedMetrics map[string][]string) ...@@ -77,23 +78,23 @@ func checkMetrics(response metrics.Metrics, assumedMetrics map[string][]string)
Expect(invalidLabels).To(BeEmpty()) Expect(invalidLabels).To(BeEmpty())
} }
var _ = KubeDescribe("MetricsGrabber", func() { var _ = framework.KubeDescribe("MetricsGrabber", func() {
framework := NewDefaultFramework("metrics-grabber") f := framework.NewDefaultFramework("metrics-grabber")
var c *client.Client var c *client.Client
var grabber *metrics.MetricsGrabber var grabber *metrics.MetricsGrabber
BeforeEach(func() { BeforeEach(func() {
var err error var err error
c = framework.Client c = f.Client
expectNoError(err) framework.ExpectNoError(err)
grabber, err = metrics.NewMetricsGrabber(c, true, true, true, true) grabber, err = metrics.NewMetricsGrabber(c, true, true, true, true)
expectNoError(err) framework.ExpectNoError(err)
}) })
It("should grab all metrics from API server.", func() { It("should grab all metrics from API server.", func() {
By("Connecting to /metrics endpoint") By("Connecting to /metrics endpoint")
unknownMetrics := sets.NewString() unknownMetrics := sets.NewString()
response, err := grabber.GrabFromApiServer(unknownMetrics) response, err := grabber.GrabFromApiServer(unknownMetrics)
expectNoError(err) framework.ExpectNoError(err)
Expect(unknownMetrics).To(BeEmpty()) Expect(unknownMetrics).To(BeEmpty())
checkMetrics(metrics.Metrics(response), metrics.KnownApiServerMetrics) checkMetrics(metrics.Metrics(response), metrics.KnownApiServerMetrics)
...@@ -101,10 +102,10 @@ var _ = KubeDescribe("MetricsGrabber", func() { ...@@ -101,10 +102,10 @@ var _ = KubeDescribe("MetricsGrabber", func() {
It("should grab all metrics from a Kubelet.", func() { It("should grab all metrics from a Kubelet.", func() {
By("Proxying to Node through the API server") By("Proxying to Node through the API server")
nodes := ListSchedulableNodesOrDie(c) nodes := framework.ListSchedulableNodesOrDie(c)
Expect(nodes.Items).NotTo(BeEmpty()) Expect(nodes.Items).NotTo(BeEmpty())
response, err := grabber.GrabFromKubelet(nodes.Items[0].Name) response, err := grabber.GrabFromKubelet(nodes.Items[0].Name)
expectNoError(err) framework.ExpectNoError(err)
checkNecessaryMetrics(metrics.Metrics(response), metrics.NecessaryKubeletMetrics) checkNecessaryMetrics(metrics.Metrics(response), metrics.NecessaryKubeletMetrics)
}) })
...@@ -112,7 +113,7 @@ var _ = KubeDescribe("MetricsGrabber", func() { ...@@ -112,7 +113,7 @@ var _ = KubeDescribe("MetricsGrabber", func() {
By("Proxying to Pod through the API server") By("Proxying to Pod through the API server")
// Check if master Node is registered // Check if master Node is registered
nodes, err := c.Nodes().List(api.ListOptions{}) nodes, err := c.Nodes().List(api.ListOptions{})
expectNoError(err) framework.ExpectNoError(err)
var masterRegistered = false var masterRegistered = false
for _, node := range nodes.Items { for _, node := range nodes.Items {
...@@ -121,12 +122,12 @@ var _ = KubeDescribe("MetricsGrabber", func() { ...@@ -121,12 +122,12 @@ var _ = KubeDescribe("MetricsGrabber", func() {
} }
} }
if !masterRegistered { if !masterRegistered {
Logf("Master is node registered. Skipping testing Scheduler metrics.") framework.Logf("Master is node registered. Skipping testing Scheduler metrics.")
return return
} }
unknownMetrics := sets.NewString() unknownMetrics := sets.NewString()
response, err := grabber.GrabFromScheduler(unknownMetrics) response, err := grabber.GrabFromScheduler(unknownMetrics)
expectNoError(err) framework.ExpectNoError(err)
Expect(unknownMetrics).To(BeEmpty()) Expect(unknownMetrics).To(BeEmpty())
checkMetrics(metrics.Metrics(response), metrics.KnownSchedulerMetrics) checkMetrics(metrics.Metrics(response), metrics.KnownSchedulerMetrics)
...@@ -136,7 +137,7 @@ var _ = KubeDescribe("MetricsGrabber", func() { ...@@ -136,7 +137,7 @@ var _ = KubeDescribe("MetricsGrabber", func() {
By("Proxying to Pod through the API server") By("Proxying to Pod through the API server")
// Check if master Node is registered // Check if master Node is registered
nodes, err := c.Nodes().List(api.ListOptions{}) nodes, err := c.Nodes().List(api.ListOptions{})
expectNoError(err) framework.ExpectNoError(err)
var masterRegistered = false var masterRegistered = false
for _, node := range nodes.Items { for _, node := range nodes.Items {
...@@ -145,12 +146,12 @@ var _ = KubeDescribe("MetricsGrabber", func() { ...@@ -145,12 +146,12 @@ var _ = KubeDescribe("MetricsGrabber", func() {
} }
} }
if !masterRegistered { if !masterRegistered {
Logf("Master is node registered. Skipping testing ControllerManager metrics.") framework.Logf("Master is node registered. Skipping testing ControllerManager metrics.")
return return
} }
unknownMetrics := sets.NewString() unknownMetrics := sets.NewString()
response, err := grabber.GrabFromControllerManager(unknownMetrics) response, err := grabber.GrabFromControllerManager(unknownMetrics)
expectNoError(err) framework.ExpectNoError(err)
Expect(unknownMetrics).To(BeEmpty()) Expect(unknownMetrics).To(BeEmpty())
checkMetrics(metrics.Metrics(response), metrics.KnownControllerManagerMetrics) checkMetrics(metrics.Metrics(response), metrics.KnownControllerManagerMetrics)
......
...@@ -26,15 +26,16 @@ import ( ...@@ -26,15 +26,16 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
) )
var _ = KubeDescribe("Monitoring", func() { var _ = framework.KubeDescribe("Monitoring", func() {
f := NewDefaultFramework("monitoring") f := framework.NewDefaultFramework("monitoring")
BeforeEach(func() { BeforeEach(func() {
SkipUnlessProviderIs("gce") framework.SkipUnlessProviderIs("gce")
}) })
It("should verify monitoring pods and all cluster nodes are available on influxdb using heapster.", func() { It("should verify monitoring pods and all cluster nodes are available on influxdb using heapster.", func() {
...@@ -190,7 +191,7 @@ func getInfluxdbData(c *client.Client, query string, tag string) (map[string]boo ...@@ -190,7 +191,7 @@ func getInfluxdbData(c *client.Client, query string, tag string) (map[string]boo
return nil, fmt.Errorf("expected exactly one series for query %q.", query) return nil, fmt.Errorf("expected exactly one series for query %q.", query)
} }
if len(response.Results[0].Series[0].Columns) != 1 { if len(response.Results[0].Series[0].Columns) != 1 {
Failf("Expected one column for query %q. Found %v", query, response.Results[0].Series[0].Columns) framework.Failf("Expected one column for query %q. Found %v", query, response.Results[0].Series[0].Columns)
} }
result := map[string]bool{} result := map[string]bool{}
for _, value := range response.Results[0].Series[0].Values { for _, value := range response.Results[0].Series[0].Values {
...@@ -216,20 +217,20 @@ func validatePodsAndNodes(c *client.Client, expectedPods, expectedNodes []string ...@@ -216,20 +217,20 @@ func validatePodsAndNodes(c *client.Client, expectedPods, expectedNodes []string
pods, err := getInfluxdbData(c, podlistQuery, "pod_id") pods, err := getInfluxdbData(c, podlistQuery, "pod_id")
if err != nil { if err != nil {
// We don't fail the test here because the influxdb service might still not be running. // We don't fail the test here because the influxdb service might still not be running.
Logf("failed to query list of pods from influxdb. Query: %q, Err: %v", podlistQuery, err) framework.Logf("failed to query list of pods from influxdb. Query: %q, Err: %v", podlistQuery, err)
return false return false
} }
nodes, err := getInfluxdbData(c, nodelistQuery, "hostname") nodes, err := getInfluxdbData(c, nodelistQuery, "hostname")
if err != nil { if err != nil {
Logf("failed to query list of nodes from influxdb. Query: %q, Err: %v", nodelistQuery, err) framework.Logf("failed to query list of nodes from influxdb. Query: %q, Err: %v", nodelistQuery, err)
return false return false
} }
if !expectedItemsExist(expectedPods, pods) { if !expectedItemsExist(expectedPods, pods) {
Logf("failed to find all expected Pods.\nExpected: %v\nActual: %v", expectedPods, pods) framework.Logf("failed to find all expected Pods.\nExpected: %v\nActual: %v", expectedPods, pods)
return false return false
} }
if !expectedItemsExist(expectedNodes, nodes) { if !expectedItemsExist(expectedNodes, nodes) {
Logf("failed to find all expected Nodes.\nExpected: %v\nActual: %v", expectedNodes, nodes) framework.Logf("failed to find all expected Nodes.\nExpected: %v\nActual: %v", expectedNodes, nodes)
return false return false
} }
return true return true
...@@ -238,12 +239,12 @@ func validatePodsAndNodes(c *client.Client, expectedPods, expectedNodes []string ...@@ -238,12 +239,12 @@ func validatePodsAndNodes(c *client.Client, expectedPods, expectedNodes []string
func testMonitoringUsingHeapsterInfluxdb(c *client.Client) { func testMonitoringUsingHeapsterInfluxdb(c *client.Client) {
// Check if heapster pods and services are up. // Check if heapster pods and services are up.
expectedPods, err := verifyExpectedRcsExistAndGetExpectedPods(c) expectedPods, err := verifyExpectedRcsExistAndGetExpectedPods(c)
expectNoError(err) framework.ExpectNoError(err)
expectNoError(expectedServicesExist(c)) framework.ExpectNoError(expectedServicesExist(c))
// TODO: Wait for all pods and services to be running. // TODO: Wait for all pods and services to be running.
expectedNodes, err := getAllNodesInCluster(c) expectedNodes, err := getAllNodesInCluster(c)
expectNoError(err) framework.ExpectNoError(err)
startTime := time.Now() startTime := time.Now()
for { for {
if validatePodsAndNodes(c, expectedPods, expectedNodes) { if validatePodsAndNodes(c, expectedPods, expectedNodes) {
...@@ -256,7 +257,7 @@ func testMonitoringUsingHeapsterInfluxdb(c *client.Client) { ...@@ -256,7 +257,7 @@ func testMonitoringUsingHeapsterInfluxdb(c *client.Client) {
} }
time.Sleep(sleepBetweenAttempts) time.Sleep(sleepBetweenAttempts)
} }
Failf("monitoring using heapster and influxdb test failed") framework.Failf("monitoring using heapster and influxdb test failed")
} }
func printDebugInfo(c *client.Client) { func printDebugInfo(c *client.Client) {
...@@ -264,10 +265,10 @@ func printDebugInfo(c *client.Client) { ...@@ -264,10 +265,10 @@ func printDebugInfo(c *client.Client) {
options := api.ListOptions{LabelSelector: set.AsSelector()} options := api.ListOptions{LabelSelector: set.AsSelector()}
podList, err := c.Pods(api.NamespaceSystem).List(options) podList, err := c.Pods(api.NamespaceSystem).List(options)
if err != nil { if err != nil {
Logf("Error while listing pods %v", err) framework.Logf("Error while listing pods %v", err)
return return
} }
for _, pod := range podList.Items { for _, pod := range podList.Items {
Logf("Kubectl output:\n%v", runKubectlOrDie("log", pod.Name, "--namespace=kube-system")) framework.Logf("Kubectl output:\n%v", framework.RunKubectlOrDie("log", pod.Name, "--namespace=kube-system"))
} }
} }
...@@ -26,12 +26,13 @@ import ( ...@@ -26,12 +26,13 @@ import (
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
func extinguish(f *Framework, totalNS int, maxAllowedAfterDel int, maxSeconds int) { func extinguish(f *framework.Framework, totalNS int, maxAllowedAfterDel int, maxSeconds int) {
var err error var err error
By("Creating testing namespaces") By("Creating testing namespaces")
...@@ -50,13 +51,13 @@ func extinguish(f *Framework, totalNS int, maxAllowedAfterDel int, maxSeconds in ...@@ -50,13 +51,13 @@ func extinguish(f *Framework, totalNS int, maxAllowedAfterDel int, maxSeconds in
//Wait 10 seconds, then SEND delete requests for all the namespaces. //Wait 10 seconds, then SEND delete requests for all the namespaces.
By("Waiting 10 seconds") By("Waiting 10 seconds")
time.Sleep(time.Duration(10 * time.Second)) time.Sleep(time.Duration(10 * time.Second))
deleted, err := deleteNamespaces(f.Client, []string{"nslifetest"}, nil /* skipFilter */) deleted, err := framework.DeleteNamespaces(f.Client, []string{"nslifetest"}, nil /* skipFilter */)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(len(deleted)).To(Equal(totalNS)) Expect(len(deleted)).To(Equal(totalNS))
By("Waiting for namespaces to vanish") By("Waiting for namespaces to vanish")
//Now POLL until all namespaces have been eradicated. //Now POLL until all namespaces have been eradicated.
expectNoError(wait.Poll(2*time.Second, time.Duration(maxSeconds)*time.Second, framework.ExpectNoError(wait.Poll(2*time.Second, time.Duration(maxSeconds)*time.Second,
func() (bool, error) { func() (bool, error) {
var cnt = 0 var cnt = 0
nsList, err := f.Client.Namespaces().List(api.ListOptions{}) nsList, err := f.Client.Namespaces().List(api.ListOptions{})
...@@ -69,14 +70,14 @@ func extinguish(f *Framework, totalNS int, maxAllowedAfterDel int, maxSeconds in ...@@ -69,14 +70,14 @@ func extinguish(f *Framework, totalNS int, maxAllowedAfterDel int, maxSeconds in
} }
} }
if cnt > maxAllowedAfterDel { if cnt > maxAllowedAfterDel {
Logf("Remaining namespaces : %v", cnt) framework.Logf("Remaining namespaces : %v", cnt)
return false, nil return false, nil
} }
return true, nil return true, nil
})) }))
} }
func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *Framework) { func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *framework.Framework) {
var err error var err error
By("Creating a test namespace") By("Creating a test namespace")
...@@ -84,7 +85,7 @@ func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *Framework) { ...@@ -84,7 +85,7 @@ func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *Framework) {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Waiting for a default service account to be provisioned in namespace") By("Waiting for a default service account to be provisioned in namespace")
err = waitForDefaultServiceAccountInNamespace(f.Client, namespace.Name) err = framework.WaitForDefaultServiceAccountInNamespace(f.Client, namespace.Name)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Creating a pod in the namespace") By("Creating a pod in the namespace")
...@@ -105,7 +106,7 @@ func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *Framework) { ...@@ -105,7 +106,7 @@ func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *Framework) {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Waiting for the pod to have running status") By("Waiting for the pod to have running status")
expectNoError(waitForPodRunningInNamespace(f.Client, pod.Name, pod.Namespace)) framework.ExpectNoError(framework.WaitForPodRunningInNamespace(f.Client, pod.Name, pod.Namespace))
By("Deleting the namespace") By("Deleting the namespace")
err = f.Client.Namespaces().Delete(namespace.Name) err = f.Client.Namespaces().Delete(namespace.Name)
...@@ -113,7 +114,7 @@ func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *Framework) { ...@@ -113,7 +114,7 @@ func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *Framework) {
By("Waiting for the namespace to be removed.") By("Waiting for the namespace to be removed.")
maxWaitSeconds := int64(60) + *pod.Spec.TerminationGracePeriodSeconds maxWaitSeconds := int64(60) + *pod.Spec.TerminationGracePeriodSeconds
expectNoError(wait.Poll(1*time.Second, time.Duration(maxWaitSeconds)*time.Second, framework.ExpectNoError(wait.Poll(1*time.Second, time.Duration(maxWaitSeconds)*time.Second,
func() (bool, error) { func() (bool, error) {
_, err = f.Client.Namespaces().Get(namespace.Name) _, err = f.Client.Namespaces().Get(namespace.Name)
if err != nil && errors.IsNotFound(err) { if err != nil && errors.IsNotFound(err) {
...@@ -127,7 +128,7 @@ func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *Framework) { ...@@ -127,7 +128,7 @@ func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *Framework) {
Expect(err).To(HaveOccurred()) Expect(err).To(HaveOccurred())
} }
func ensureServicesAreRemovedWhenNamespaceIsDeleted(f *Framework) { func ensureServicesAreRemovedWhenNamespaceIsDeleted(f *framework.Framework) {
var err error var err error
By("Creating a test namespace") By("Creating a test namespace")
...@@ -135,7 +136,7 @@ func ensureServicesAreRemovedWhenNamespaceIsDeleted(f *Framework) { ...@@ -135,7 +136,7 @@ func ensureServicesAreRemovedWhenNamespaceIsDeleted(f *Framework) {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Waiting for a default service account to be provisioned in namespace") By("Waiting for a default service account to be provisioned in namespace")
err = waitForDefaultServiceAccountInNamespace(f.Client, namespace.Name) err = framework.WaitForDefaultServiceAccountInNamespace(f.Client, namespace.Name)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Creating a service in the namespace") By("Creating a service in the namespace")
...@@ -165,7 +166,7 @@ func ensureServicesAreRemovedWhenNamespaceIsDeleted(f *Framework) { ...@@ -165,7 +166,7 @@ func ensureServicesAreRemovedWhenNamespaceIsDeleted(f *Framework) {
By("Waiting for the namespace to be removed.") By("Waiting for the namespace to be removed.")
maxWaitSeconds := int64(60) maxWaitSeconds := int64(60)
expectNoError(wait.Poll(1*time.Second, time.Duration(maxWaitSeconds)*time.Second, framework.ExpectNoError(wait.Poll(1*time.Second, time.Duration(maxWaitSeconds)*time.Second,
func() (bool, error) { func() (bool, error) {
_, err = f.Client.Namespaces().Get(namespace.Name) _, err = f.Client.Namespaces().Get(namespace.Name)
if err != nil && errors.IsNotFound(err) { if err != nil && errors.IsNotFound(err) {
...@@ -207,9 +208,9 @@ func ensureServicesAreRemovedWhenNamespaceIsDeleted(f *Framework) { ...@@ -207,9 +208,9 @@ func ensureServicesAreRemovedWhenNamespaceIsDeleted(f *Framework) {
// that each have a variable amount of content in the associated Namespace. // that each have a variable amount of content in the associated Namespace.
// When run in [Serial] this test appears to delete Namespace objects at a // When run in [Serial] this test appears to delete Namespace objects at a
// rate of approximately 1 per second. // rate of approximately 1 per second.
var _ = KubeDescribe("Namespaces [Serial]", func() { var _ = framework.KubeDescribe("Namespaces [Serial]", func() {
f := NewDefaultFramework("namespaces") f := framework.NewDefaultFramework("namespaces")
It("should ensure that all pods are removed when a namespace is deleted.", It("should ensure that all pods are removed when a namespace is deleted.",
func() { ensurePodsAreRemovedWhenNamespaceIsDeleted(f) }) func() { ensurePodsAreRemovedWhenNamespaceIsDeleted(f) })
......
...@@ -24,13 +24,14 @@ import ( ...@@ -24,13 +24,14 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = KubeDescribe("Networking", func() { var _ = framework.KubeDescribe("Networking", func() {
f := NewDefaultFramework("nettest") f := framework.NewDefaultFramework("nettest")
var svcname = "nettest" var svcname = "nettest"
...@@ -41,16 +42,16 @@ var _ = KubeDescribe("Networking", func() { ...@@ -41,16 +42,16 @@ var _ = KubeDescribe("Networking", func() {
By("Executing a successful http request from the external internet") By("Executing a successful http request from the external internet")
resp, err := http.Get("http://google.com") resp, err := http.Get("http://google.com")
if err != nil { if err != nil {
Failf("Unable to connect/talk to the internet: %v", err) framework.Failf("Unable to connect/talk to the internet: %v", err)
} }
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
Failf("Unexpected error code, expected 200, got, %v (%v)", resp.StatusCode, resp) framework.Failf("Unexpected error code, expected 200, got, %v (%v)", resp.StatusCode, resp)
} }
}) })
It("should provide Internet connection for containers [Conformance]", func() { It("should provide Internet connection for containers [Conformance]", func() {
By("Running container which tries to wget google.com") By("Running container which tries to wget google.com")
expectNoError(CheckConnectivityToHost(f, "", "wget-test", "google.com")) framework.ExpectNoError(framework.CheckConnectivityToHost(f, "", "wget-test", "google.com"))
}) })
// First test because it has no dependencies on variables created later on. // First test because it has no dependencies on variables created later on.
...@@ -69,7 +70,7 @@ var _ = KubeDescribe("Networking", func() { ...@@ -69,7 +70,7 @@ var _ = KubeDescribe("Networking", func() {
AbsPath(test.path). AbsPath(test.path).
DoRaw() DoRaw()
if err != nil { if err != nil {
Failf("Failed: %v\nBody: %s", err, string(data)) framework.Failf("Failed: %v\nBody: %s", err, string(data))
} }
} }
}) })
...@@ -97,30 +98,30 @@ var _ = KubeDescribe("Networking", func() { ...@@ -97,30 +98,30 @@ var _ = KubeDescribe("Networking", func() {
}, },
}) })
if err != nil { if err != nil {
Failf("unable to create test service named [%s] %v", svc.Name, err) framework.Failf("unable to create test service named [%s] %v", svc.Name, err)
} }
// Clean up service // Clean up service
defer func() { defer func() {
By("Cleaning up the service") By("Cleaning up the service")
if err = f.Client.Services(f.Namespace.Name).Delete(svc.Name); err != nil { if err = f.Client.Services(f.Namespace.Name).Delete(svc.Name); err != nil {
Failf("unable to delete svc %v: %v", svc.Name, err) framework.Failf("unable to delete svc %v: %v", svc.Name, err)
} }
}() }()
By("Creating a webserver (pending) pod on each node") By("Creating a webserver (pending) pod on each node")
nodes, err := GetReadyNodes(f) nodes, err := framework.GetReadyNodes(f)
expectNoError(err) framework.ExpectNoError(err)
if len(nodes.Items) == 1 { if len(nodes.Items) == 1 {
// in general, the test requires two nodes. But for local development, often a one node cluster // in general, the test requires two nodes. But for local development, often a one node cluster
// is created, for simplicity and speed. (see issue #10012). We permit one-node test // is created, for simplicity and speed. (see issue #10012). We permit one-node test
// only in some cases // only in some cases
if !providerIs("local") { if !framework.ProviderIs("local") {
Failf(fmt.Sprintf("The test requires two Ready nodes on %s, but found just one.", testContext.Provider)) framework.Failf(fmt.Sprintf("The test requires two Ready nodes on %s, but found just one.", framework.TestContext.Provider))
} }
Logf("Only one ready node is detected. The test has limited scope in such setting. " + framework.Logf("Only one ready node is detected. The test has limited scope in such setting. " +
"Rerun it with at least two nodes to get complete coverage.") "Rerun it with at least two nodes to get complete coverage.")
} }
...@@ -131,7 +132,7 @@ var _ = KubeDescribe("Networking", func() { ...@@ -131,7 +132,7 @@ var _ = KubeDescribe("Networking", func() {
By("Cleaning up the webserver pods") By("Cleaning up the webserver pods")
for _, podName := range podNames { for _, podName := range podNames {
if err = f.Client.Pods(f.Namespace.Name).Delete(podName, nil); err != nil { if err = f.Client.Pods(f.Namespace.Name).Delete(podName, nil); err != nil {
Logf("Failed to delete pod %s: %v", podName, err) framework.Logf("Failed to delete pod %s: %v", podName, err)
} }
} }
}() }()
...@@ -148,7 +149,7 @@ var _ = KubeDescribe("Networking", func() { ...@@ -148,7 +149,7 @@ var _ = KubeDescribe("Networking", func() {
//once response OK, evaluate response body for pass/fail. //once response OK, evaluate response body for pass/fail.
var body []byte var body []byte
getDetails := func() ([]byte, error) { getDetails := func() ([]byte, error) {
proxyRequest, errProxy := getServicesProxyRequest(f.Client, f.Client.Get()) proxyRequest, errProxy := framework.GetServicesProxyRequest(f.Client, f.Client.Get())
if errProxy != nil { if errProxy != nil {
return nil, errProxy return nil, errProxy
} }
...@@ -159,7 +160,7 @@ var _ = KubeDescribe("Networking", func() { ...@@ -159,7 +160,7 @@ var _ = KubeDescribe("Networking", func() {
} }
getStatus := func() ([]byte, error) { getStatus := func() ([]byte, error) {
proxyRequest, errProxy := getServicesProxyRequest(f.Client, f.Client.Get()) proxyRequest, errProxy := framework.GetServicesProxyRequest(f.Client, f.Client.Get())
if errProxy != nil { if errProxy != nil {
return nil, errProxy return nil, errProxy
} }
...@@ -174,61 +175,61 @@ var _ = KubeDescribe("Networking", func() { ...@@ -174,61 +175,61 @@ var _ = KubeDescribe("Networking", func() {
timeout := time.Now().Add(3 * time.Minute) timeout := time.Now().Add(3 * time.Minute)
for i := 0; !passed && timeout.After(time.Now()); i++ { for i := 0; !passed && timeout.After(time.Now()); i++ {
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
Logf("About to make a proxy status call") framework.Logf("About to make a proxy status call")
start := time.Now() start := time.Now()
body, err = getStatus() body, err = getStatus()
Logf("Proxy status call returned in %v", time.Since(start)) framework.Logf("Proxy status call returned in %v", time.Since(start))
if err != nil { if err != nil {
Logf("Attempt %v: service/pod still starting. (error: '%v')", i, err) framework.Logf("Attempt %v: service/pod still starting. (error: '%v')", i, err)
continue continue
} }
// Finally, we pass/fail the test based on if the container's response body, as to whether or not it was able to find peers. // Finally, we pass/fail the test based on if the container's response body, as to whether or not it was able to find peers.
switch { switch {
case string(body) == "pass": case string(body) == "pass":
Logf("Passed on attempt %v. Cleaning up.", i) framework.Logf("Passed on attempt %v. Cleaning up.", i)
passed = true passed = true
case string(body) == "running": case string(body) == "running":
Logf("Attempt %v: test still running", i) framework.Logf("Attempt %v: test still running", i)
case string(body) == "fail": case string(body) == "fail":
if body, err = getDetails(); err != nil { if body, err = getDetails(); err != nil {
Failf("Failed on attempt %v. Cleaning up. Error reading details: %v", i, err) framework.Failf("Failed on attempt %v. Cleaning up. Error reading details: %v", i, err)
} else { } else {
Failf("Failed on attempt %v. Cleaning up. Details:\n%s", i, string(body)) framework.Failf("Failed on attempt %v. Cleaning up. Details:\n%s", i, string(body))
} }
case strings.Contains(string(body), "no endpoints available"): case strings.Contains(string(body), "no endpoints available"):
Logf("Attempt %v: waiting on service/endpoints", i) framework.Logf("Attempt %v: waiting on service/endpoints", i)
default: default:
Logf("Unexpected response:\n%s", body) framework.Logf("Unexpected response:\n%s", body)
} }
} }
if !passed { if !passed {
if body, err = getDetails(); err != nil { if body, err = getDetails(); err != nil {
Failf("Timed out. Cleaning up. Error reading details: %v", err) framework.Failf("Timed out. Cleaning up. Error reading details: %v", err)
} else { } else {
Failf("Timed out. Cleaning up. Details:\n%s", string(body)) framework.Failf("Timed out. Cleaning up. Details:\n%s", string(body))
} }
} }
Expect(string(body)).To(Equal("pass")) Expect(string(body)).To(Equal("pass"))
}) })
// Marked with [Flaky] until the tests prove themselves stable. // Marked with [Flaky] until the tests prove themselves stable.
KubeDescribe("[Flaky] Granular Checks", func() { framework.KubeDescribe("[Flaky] Granular Checks", func() {
It("should function for pod communication on a single node", func() { It("should function for pod communication on a single node", func() {
By("Picking a node") By("Picking a node")
nodes, err := GetReadyNodes(f) nodes, err := framework.GetReadyNodes(f)
expectNoError(err) framework.ExpectNoError(err)
node := nodes.Items[0] node := nodes.Items[0]
By("Creating a webserver pod") By("Creating a webserver pod")
podName := "same-node-webserver" podName := "same-node-webserver"
defer f.Client.Pods(f.Namespace.Name).Delete(podName, nil) defer f.Client.Pods(f.Namespace.Name).Delete(podName, nil)
ip := LaunchWebserverPod(f, podName, node.Name) ip := framework.LaunchWebserverPod(f, podName, node.Name)
By("Checking that the webserver is accessible from a pod on the same node") By("Checking that the webserver is accessible from a pod on the same node")
expectNoError(CheckConnectivityToHost(f, node.Name, "same-node-wget", ip)) framework.ExpectNoError(framework.CheckConnectivityToHost(f, node.Name, "same-node-wget", ip))
}) })
It("should function for pod communication between nodes", func() { It("should function for pod communication between nodes", func() {
...@@ -236,11 +237,11 @@ var _ = KubeDescribe("Networking", func() { ...@@ -236,11 +237,11 @@ var _ = KubeDescribe("Networking", func() {
podClient := f.Client.Pods(f.Namespace.Name) podClient := f.Client.Pods(f.Namespace.Name)
By("Picking multiple nodes") By("Picking multiple nodes")
nodes, err := GetReadyNodes(f) nodes, err := framework.GetReadyNodes(f)
expectNoError(err) framework.ExpectNoError(err)
if len(nodes.Items) == 1 { if len(nodes.Items) == 1 {
Skipf("The test requires two Ready nodes on %s, but found just one.", testContext.Provider) framework.Skipf("The test requires two Ready nodes on %s, but found just one.", framework.TestContext.Provider)
} }
node1 := nodes.Items[0] node1 := nodes.Items[0]
...@@ -249,15 +250,15 @@ var _ = KubeDescribe("Networking", func() { ...@@ -249,15 +250,15 @@ var _ = KubeDescribe("Networking", func() {
By("Creating a webserver pod") By("Creating a webserver pod")
podName := "different-node-webserver" podName := "different-node-webserver"
defer podClient.Delete(podName, nil) defer podClient.Delete(podName, nil)
ip := LaunchWebserverPod(f, podName, node1.Name) ip := framework.LaunchWebserverPod(f, podName, node1.Name)
By("Checking that the webserver is accessible from a pod on a different node") By("Checking that the webserver is accessible from a pod on a different node")
expectNoError(CheckConnectivityToHost(f, node2.Name, "different-node-wget", ip)) framework.ExpectNoError(framework.CheckConnectivityToHost(f, node2.Name, "different-node-wget", ip))
}) })
}) })
}) })
func LaunchNetTestPodPerNode(f *Framework, nodes *api.NodeList, name, version string) []string { func LaunchNetTestPodPerNode(f *framework.Framework, nodes *api.NodeList, name, version string) []string {
podNames := []string{} podNames := []string{}
totalPods := len(nodes.Items) totalPods := len(nodes.Items)
...@@ -291,7 +292,7 @@ func LaunchNetTestPodPerNode(f *Framework, nodes *api.NodeList, name, version st ...@@ -291,7 +292,7 @@ func LaunchNetTestPodPerNode(f *Framework, nodes *api.NodeList, name, version st
}, },
}) })
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Logf("Created pod %s on node %s", pod.ObjectMeta.Name, node.Name) framework.Logf("Created pod %s on node %s", pod.ObjectMeta.Name, node.Name)
podNames = append(podNames, pod.ObjectMeta.Name) podNames = append(podNames, pod.ObjectMeta.Name)
} }
return podNames return podNames
......
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -64,19 +65,19 @@ const ( ...@@ -64,19 +65,19 @@ const (
// 7. Observe that the pod in pending status schedules on that node. // 7. Observe that the pod in pending status schedules on that node.
// //
// Flaky issue #20015. We have no clear path for how to test this functionality in a non-flaky way. // Flaky issue #20015. We have no clear path for how to test this functionality in a non-flaky way.
var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() { var _ = framework.KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() {
var c *client.Client var c *client.Client
var unfilledNodeName, recoveredNodeName string var unfilledNodeName, recoveredNodeName string
framework := NewDefaultFramework("node-outofdisk") f := framework.NewDefaultFramework("node-outofdisk")
BeforeEach(func() { BeforeEach(func() {
c = framework.Client c = f.Client
nodelist := ListSchedulableNodesOrDie(c) nodelist := framework.ListSchedulableNodesOrDie(c)
// Skip this test on small clusters. No need to fail since it is not a use // Skip this test on small clusters. No need to fail since it is not a use
// case that any cluster of small size needs to support. // case that any cluster of small size needs to support.
SkipUnlessNodeCountIsAtLeast(2) framework.SkipUnlessNodeCountIsAtLeast(2)
unfilledNodeName = nodelist.Items[0].Name unfilledNodeName = nodelist.Items[0].Name
for _, node := range nodelist.Items[1:] { for _, node := range nodelist.Items[1:] {
...@@ -86,7 +87,7 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() { ...@@ -86,7 +87,7 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() {
AfterEach(func() { AfterEach(func() {
nodelist := ListSchedulableNodesOrDie(c) nodelist := framework.ListSchedulableNodesOrDie(c)
Expect(len(nodelist.Items)).ToNot(BeZero()) Expect(len(nodelist.Items)).ToNot(BeZero())
for _, node := range nodelist.Items { for _, node := range nodelist.Items {
if unfilledNodeName == node.Name || recoveredNodeName == node.Name { if unfilledNodeName == node.Name || recoveredNodeName == node.Name {
...@@ -98,11 +99,11 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() { ...@@ -98,11 +99,11 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() {
It("runs out of disk space", func() { It("runs out of disk space", func() {
unfilledNode, err := c.Nodes().Get(unfilledNodeName) unfilledNode, err := c.Nodes().Get(unfilledNodeName)
expectNoError(err) framework.ExpectNoError(err)
By(fmt.Sprintf("Calculating CPU availability on node %s", unfilledNode.Name)) By(fmt.Sprintf("Calculating CPU availability on node %s", unfilledNode.Name))
milliCpu, err := availCpu(c, unfilledNode) milliCpu, err := availCpu(c, unfilledNode)
expectNoError(err) framework.ExpectNoError(err)
// Per pod CPU should be just enough to fit only (numNodeOODPods - 1) pods on the given // Per pod CPU should be just enough to fit only (numNodeOODPods - 1) pods on the given
// node. We compute this value by dividing the available CPU capacity on the node by // node. We compute this value by dividing the available CPU capacity on the node by
...@@ -111,7 +112,7 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() { ...@@ -111,7 +112,7 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() {
// subtracting 1% from the value, we directly use 0.99 as the multiplier. // subtracting 1% from the value, we directly use 0.99 as the multiplier.
podCPU := int64(float64(milliCpu/(numNodeOODPods-1)) * 0.99) podCPU := int64(float64(milliCpu/(numNodeOODPods-1)) * 0.99)
ns := framework.Namespace.Name ns := f.Namespace.Name
podClient := c.Pods(ns) podClient := c.Pods(ns)
By("Creating pods and waiting for all but one pods to be scheduled") By("Creating pods and waiting for all but one pods to be scheduled")
...@@ -120,9 +121,9 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() { ...@@ -120,9 +121,9 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() {
name := fmt.Sprintf("pod-node-outofdisk-%d", i) name := fmt.Sprintf("pod-node-outofdisk-%d", i)
createOutOfDiskPod(c, ns, name, podCPU) createOutOfDiskPod(c, ns, name, podCPU)
expectNoError(framework.WaitForPodRunning(name)) framework.ExpectNoError(f.WaitForPodRunning(name))
pod, err := podClient.Get(name) pod, err := podClient.Get(name)
expectNoError(err) framework.ExpectNoError(err)
Expect(pod.Spec.NodeName).To(Equal(unfilledNodeName)) Expect(pod.Spec.NodeName).To(Equal(unfilledNodeName))
} }
...@@ -140,7 +141,7 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() { ...@@ -140,7 +141,7 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() {
}.AsSelector() }.AsSelector()
options := api.ListOptions{FieldSelector: selector} options := api.ListOptions{FieldSelector: selector}
schedEvents, err := c.Events(ns).List(options) schedEvents, err := c.Events(ns).List(options)
expectNoError(err) framework.ExpectNoError(err)
if len(schedEvents.Items) > 0 { if len(schedEvents.Items) > 0 {
return true, nil return true, nil
...@@ -149,7 +150,7 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() { ...@@ -149,7 +150,7 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() {
} }
}) })
nodelist := ListSchedulableNodesOrDie(c) nodelist := framework.ListSchedulableNodesOrDie(c)
Expect(len(nodelist.Items)).To(BeNumerically(">", 1)) Expect(len(nodelist.Items)).To(BeNumerically(">", 1))
nodeToRecover := nodelist.Items[1] nodeToRecover := nodelist.Items[1]
...@@ -159,9 +160,9 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() { ...@@ -159,9 +160,9 @@ var _ = KubeDescribe("NodeOutOfDisk [Serial] [Flaky] [Disruptive]", func() {
recoveredNodeName = nodeToRecover.Name recoveredNodeName = nodeToRecover.Name
By(fmt.Sprintf("Verifying that pod %s schedules on node %s", pendingPodName, recoveredNodeName)) By(fmt.Sprintf("Verifying that pod %s schedules on node %s", pendingPodName, recoveredNodeName))
expectNoError(framework.WaitForPodRunning(pendingPodName)) framework.ExpectNoError(f.WaitForPodRunning(pendingPodName))
pendingPod, err := podClient.Get(pendingPodName) pendingPod, err := podClient.Get(pendingPodName)
expectNoError(err) framework.ExpectNoError(err)
Expect(pendingPod.Spec.NodeName).To(Equal(recoveredNodeName)) Expect(pendingPod.Spec.NodeName).To(Equal(recoveredNodeName))
}) })
}) })
...@@ -191,7 +192,7 @@ func createOutOfDiskPod(c *client.Client, ns, name string, milliCPU int64) { ...@@ -191,7 +192,7 @@ func createOutOfDiskPod(c *client.Client, ns, name string, milliCPU int64) {
} }
_, err := podClient.Create(pod) _, err := podClient.Create(pod)
expectNoError(err) framework.ExpectNoError(err)
} }
// availCpu calculates the available CPU on a given node by subtracting the CPU requested by // availCpu calculates the available CPU on a given node by subtracting the CPU requested by
...@@ -218,7 +219,7 @@ func availCpu(c *client.Client, node *api.Node) (int64, error) { ...@@ -218,7 +219,7 @@ func availCpu(c *client.Client, node *api.Node) (int64, error) {
// is in turn obtained internally from cadvisor. // is in turn obtained internally from cadvisor.
func availSize(c *client.Client, node *api.Node) (uint64, error) { func availSize(c *client.Client, node *api.Node) (uint64, error) {
statsResource := fmt.Sprintf("api/v1/proxy/nodes/%s/stats/", node.Name) statsResource := fmt.Sprintf("api/v1/proxy/nodes/%s/stats/", node.Name)
Logf("Querying stats for node %s using url %s", node.Name, statsResource) framework.Logf("Querying stats for node %s using url %s", node.Name, statsResource)
res, err := c.Get().AbsPath(statsResource).Timeout(time.Minute).Do().Raw() res, err := c.Get().AbsPath(statsResource).Timeout(time.Minute).Do().Raw()
if err != nil { if err != nil {
return 0, fmt.Errorf("error querying cAdvisor API: %v", err) return 0, fmt.Errorf("error querying cAdvisor API: %v", err)
...@@ -236,21 +237,21 @@ func availSize(c *client.Client, node *api.Node) (uint64, error) { ...@@ -236,21 +237,21 @@ func availSize(c *client.Client, node *api.Node) (uint64, error) {
// below the lowDiskSpaceThreshold mark. // below the lowDiskSpaceThreshold mark.
func fillDiskSpace(c *client.Client, node *api.Node) { func fillDiskSpace(c *client.Client, node *api.Node) {
avail, err := availSize(c, node) avail, err := availSize(c, node)
expectNoError(err, "Node %s: couldn't obtain available disk size %v", node.Name, err) framework.ExpectNoError(err, "Node %s: couldn't obtain available disk size %v", node.Name, err)
fillSize := (avail - lowDiskSpaceThreshold + (100 * mb)) fillSize := (avail - lowDiskSpaceThreshold + (100 * mb))
Logf("Node %s: disk space available %d bytes", node.Name, avail) framework.Logf("Node %s: disk space available %d bytes", node.Name, avail)
By(fmt.Sprintf("Node %s: creating a file of size %d bytes to fill the available disk space", node.Name, fillSize)) By(fmt.Sprintf("Node %s: creating a file of size %d bytes to fill the available disk space", node.Name, fillSize))
cmd := fmt.Sprintf("fallocate -l %d test.img", fillSize) cmd := fmt.Sprintf("fallocate -l %d test.img", fillSize)
expectNoError(issueSSHCommand(cmd, testContext.Provider, node)) framework.ExpectNoError(framework.IssueSSHCommand(cmd, framework.TestContext.Provider, node))
ood := waitForNodeToBe(c, node.Name, api.NodeOutOfDisk, true, nodeOODTimeOut) ood := framework.WaitForNodeToBe(c, node.Name, api.NodeOutOfDisk, true, nodeOODTimeOut)
Expect(ood).To(BeTrue(), "Node %s did not run out of disk within %v", node.Name, nodeOODTimeOut) Expect(ood).To(BeTrue(), "Node %s did not run out of disk within %v", node.Name, nodeOODTimeOut)
avail, err = availSize(c, node) avail, err = availSize(c, node)
Logf("Node %s: disk space available %d bytes", node.Name, avail) framework.Logf("Node %s: disk space available %d bytes", node.Name, avail)
Expect(avail < lowDiskSpaceThreshold).To(BeTrue()) Expect(avail < lowDiskSpaceThreshold).To(BeTrue())
} }
...@@ -258,8 +259,8 @@ func fillDiskSpace(c *client.Client, node *api.Node) { ...@@ -258,8 +259,8 @@ func fillDiskSpace(c *client.Client, node *api.Node) {
func recoverDiskSpace(c *client.Client, node *api.Node) { func recoverDiskSpace(c *client.Client, node *api.Node) {
By(fmt.Sprintf("Recovering disk space on node %s", node.Name)) By(fmt.Sprintf("Recovering disk space on node %s", node.Name))
cmd := "rm -f test.img" cmd := "rm -f test.img"
expectNoError(issueSSHCommand(cmd, testContext.Provider, node)) framework.ExpectNoError(framework.IssueSSHCommand(cmd, framework.TestContext.Provider, node))
ood := waitForNodeToBe(c, node.Name, api.NodeOutOfDisk, false, nodeOODTimeOut) ood := framework.WaitForNodeToBe(c, node.Name, api.NodeOutOfDisk, false, nodeOODTimeOut)
Expect(ood).To(BeTrue(), "Node %s's out of disk condition status did not change to false within %v", node.Name, nodeOODTimeOut) Expect(ood).To(BeTrue(), "Node %s's out of disk condition status did not change to false within %v", node.Name, nodeOODTimeOut)
} }
...@@ -26,18 +26,19 @@ import ( ...@@ -26,18 +26,19 @@ import (
"k8s.io/kubernetes/pkg/api/testapi" "k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/test/e2e/framework"
) )
// This test needs privileged containers, which are disabled by default. Run // This test needs privileged containers, which are disabled by default. Run
// the test with "go run hack/e2e.go ... --ginkgo.focus=[Feature:Volumes]" // the test with "go run hack/e2e.go ... --ginkgo.focus=[Feature:Volumes]"
var _ = KubeDescribe("PersistentVolumes [Feature:Volumes]", func() { var _ = framework.KubeDescribe("PersistentVolumes [Feature:Volumes]", func() {
framework := NewDefaultFramework("pv") f := framework.NewDefaultFramework("pv")
var c *client.Client var c *client.Client
var ns string var ns string
BeforeEach(func() { BeforeEach(func() {
c = framework.Client c = f.Client
ns = framework.Namespace.Name ns = f.Namespace.Name
}) })
It("NFS volume can be created, bound, retrieved, unbound, and used by a pod", func() { It("NFS volume can be created, bound, retrieved, unbound, and used by a pod", func() {
...@@ -54,47 +55,47 @@ var _ = KubeDescribe("PersistentVolumes [Feature:Volumes]", func() { ...@@ -54,47 +55,47 @@ var _ = KubeDescribe("PersistentVolumes [Feature:Volumes]", func() {
pod := startVolumeServer(c, config) pod := startVolumeServer(c, config)
serverIP := pod.Status.PodIP serverIP := pod.Status.PodIP
Logf("NFS server IP address: %v", serverIP) framework.Logf("NFS server IP address: %v", serverIP)
pv := makePersistentVolume(serverIP) pv := makePersistentVolume(serverIP)
pvc := makePersistentVolumeClaim(ns) pvc := makePersistentVolumeClaim(ns)
Logf("Creating PersistentVolume using NFS") framework.Logf("Creating PersistentVolume using NFS")
pv, err := c.PersistentVolumes().Create(pv) pv, err := c.PersistentVolumes().Create(pv)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Logf("Creating PersistentVolumeClaim") framework.Logf("Creating PersistentVolumeClaim")
pvc, err = c.PersistentVolumeClaims(ns).Create(pvc) pvc, err = c.PersistentVolumeClaims(ns).Create(pvc)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
// allow the binder a chance to catch up. should not be more than 20s. // allow the binder a chance to catch up. should not be more than 20s.
waitForPersistentVolumePhase(api.VolumeBound, c, pv.Name, 1*time.Second, 30*time.Second) framework.WaitForPersistentVolumePhase(api.VolumeBound, c, pv.Name, 1*time.Second, 30*time.Second)
pv, err = c.PersistentVolumes().Get(pv.Name) pv, err = c.PersistentVolumes().Get(pv.Name)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
if pv.Spec.ClaimRef == nil { if pv.Spec.ClaimRef == nil {
Failf("Expected PersistentVolume to be bound, but got nil ClaimRef: %+v", pv) framework.Failf("Expected PersistentVolume to be bound, but got nil ClaimRef: %+v", pv)
} }
Logf("Deleting PersistentVolumeClaim to trigger PV Recycling") framework.Logf("Deleting PersistentVolumeClaim to trigger PV Recycling")
err = c.PersistentVolumeClaims(ns).Delete(pvc.Name) err = c.PersistentVolumeClaims(ns).Delete(pvc.Name)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
// allow the recycler a chance to catch up. it has to perform NFS scrub, which can be slow in e2e. // allow the recycler a chance to catch up. it has to perform NFS scrub, which can be slow in e2e.
waitForPersistentVolumePhase(api.VolumeAvailable, c, pv.Name, 5*time.Second, 300*time.Second) framework.WaitForPersistentVolumePhase(api.VolumeAvailable, c, pv.Name, 5*time.Second, 300*time.Second)
pv, err = c.PersistentVolumes().Get(pv.Name) pv, err = c.PersistentVolumes().Get(pv.Name)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
if pv.Spec.ClaimRef != nil { if pv.Spec.ClaimRef != nil {
Failf("Expected PersistentVolume to be unbound, but found non-nil ClaimRef: %+v", pv) framework.Failf("Expected PersistentVolume to be unbound, but found non-nil ClaimRef: %+v", pv)
} }
// The NFS Server pod we're using contains an index.html file // The NFS Server pod we're using contains an index.html file
// Verify the file was really scrubbed from the volume // Verify the file was really scrubbed from the volume
podTemplate := makeCheckPod(ns, serverIP) podTemplate := makeCheckPod(ns, serverIP)
checkpod, err := c.Pods(ns).Create(podTemplate) checkpod, err := c.Pods(ns).Create(podTemplate)
expectNoError(err, "Failed to create checker pod: %v", err) framework.ExpectNoError(err, "Failed to create checker pod: %v", err)
err = waitForPodSuccessInNamespace(c, checkpod.Name, checkpod.Spec.Containers[0].Name, checkpod.Namespace) err = framework.WaitForPodSuccessInNamespace(c, checkpod.Name, checkpod.Spec.Containers[0].Name, checkpod.Namespace)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
}) })
}) })
......
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