Merge pull request #14790 from yujuhong/restart_count

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot
2015-10-01 11:34:32 -07:00
2 changed files with 13 additions and 9 deletions

View File

@@ -35,7 +35,11 @@ import (
. "github.com/onsi/gomega"
)
func runLivenessTest(c *client.Client, ns string, podDescr *api.Pod, expectNumRestarts int) {
const (
defaultObservationTimeout = time.Minute * 2
)
func runLivenessTest(c *client.Client, ns string, podDescr *api.Pod, expectNumRestarts int, timeout time.Duration) {
By(fmt.Sprintf("Creating pod %s in namespace %s", podDescr.Name, ns))
_, err := c.Pods(ns).Create(podDescr)
expectNoError(err, fmt.Sprintf("creating pod %s", podDescr.Name))
@@ -61,7 +65,7 @@ func runLivenessTest(c *client.Client, ns string, podDescr *api.Pod, expectNumRe
By(fmt.Sprintf("Initial restart count of pod %s is %d", podDescr.Name, initialRestartCount))
// Wait for the restart state to be as desired.
deadline := time.Now().Add(2 * time.Minute)
deadline := time.Now().Add(timeout)
lastRestartCount := initialRestartCount
observedRestarts := 0
for start := time.Now(); time.Now().Before(deadline); time.Sleep(2 * time.Second) {
@@ -482,7 +486,7 @@ var _ = Describe("Pods", func() {
},
},
},
}, 1)
}, 1, defaultObservationTimeout)
})
It("should *not* be restarted with a docker exec \"cat /tmp/health\" liveness probe", func() {
@@ -508,7 +512,7 @@ var _ = Describe("Pods", func() {
},
},
},
}, 0)
}, 0, defaultObservationTimeout)
})
It("should be restarted with a /healthz http liveness probe", func() {
@@ -535,10 +539,10 @@ var _ = Describe("Pods", func() {
},
},
},
}, 1)
}, 1, defaultObservationTimeout)
})
PIt("should have monotonically increasing restart count", func() {
It("should have monotonically increasing restart count", func() {
runLivenessTest(framework.Client, framework.Namespace.Name, &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "liveness-http",
@@ -562,7 +566,7 @@ var _ = Describe("Pods", func() {
},
},
},
}, 8)
}, 5, time.Minute*5)
})
It("should *not* be restarted with a /healthz http liveness probe", func() {
@@ -595,7 +599,7 @@ var _ = Describe("Pods", func() {
},
},
},
}, 0)
}, 0, defaultObservationTimeout)
})
// The following tests for remote command execution and port forwarding are