Skip to content

Commit

Permalink
Make deployment test reproducible when randomness is involved
Browse files Browse the repository at this point in the history
  • Loading branch information
tnozicka committed Nov 29, 2017
1 parent 086cc82 commit 705e69b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/extended/deployments/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() {
_, err := oc.Run("create").Args("-f", simpleDeploymentFixture).Output()
o.Expect(err).NotTo(o.HaveOccurred())

r := rand.New(rand.NewSource(g.GinkgoRandomSeed()))
iterations := 15
for i := 0; i < iterations; i++ {
if rand.Float32() < 0.2 {
time.Sleep(time.Duration(rand.Float32() * rand.Float32() * float32(time.Second)))
if r.Float32() < 0.2 {
time.Sleep(time.Duration(r.Float32() * r.Float32() * float32(time.Second)))
}
switch n := rand.Float32(); {
switch n := r.Float32(); {

case n < 0.4:
// trigger a new deployment
Expand Down Expand Up @@ -111,7 +112,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() {
for _, pod := range pods {
e2e.Logf("%02d: deleting deployer pod %s", i, pod.Name)
options := metav1.NewDeleteOptions(0)
if rand.Float32() < 0.5 {
if r.Float32() < 0.5 {
options = nil
}
if err := oc.KubeClient().CoreV1().Pods(oc.Namespace()).Delete(pod.Name, options); err != nil {
Expand Down

0 comments on commit 705e69b

Please sign in to comment.