Skip to content

Commit

Permalink
Updates to the cleanup DC test
Browse files Browse the repository at this point in the history
* use a more lightweight image to run in application pods
* don't run pre-hook since it's not required
* wait for the DC timeout for a complete deployment

Signed-off-by: Michail Kargakis <mkargaki@redhat.com>
  • Loading branch information
0xmichalis committed Jul 6, 2017
1 parent 60caae1 commit c3ba2ab
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
10 changes: 6 additions & 4 deletions test/extended/deployments/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,12 +833,13 @@ var _ = g.Describe("deploymentconfigs", func() {
g.It("should never persist more old deployments than acceptable after being observed by the controller", func() {
revisionHistoryLimit := 3 // as specified in the fixture

_, err := oc.Run("create").Args("-f", historyLimitedDeploymentFixture).Output()
dc, err := createDeploymentConfig(oc, historyLimitedDeploymentFixture)
o.Expect(err).NotTo(o.HaveOccurred())
deploymentTimeout := time.Duration(*dc.Spec.Strategy.RollingParams.TimeoutSeconds) * time.Second

iterations := 10
for i := 0; i < iterations; i++ {
o.Expect(waitForLatestCondition(oc, "history-limit", deploymentRunTimeout, deploymentReachedCompletion)).NotTo(o.HaveOccurred(),
o.Expect(waitForLatestCondition(oc, "history-limit", deploymentTimeout, deploymentReachedCompletion)).NotTo(o.HaveOccurred(),
"the current deployment needs to have finished before attempting to trigger a new deployment through configuration change")
e2e.Logf("%02d: triggering a new deployment with config change", i)
out, err := oc.Run("set", "env").Args("dc/history-limit", fmt.Sprintf("A=%d", i)).Output()
Expand All @@ -848,7 +849,7 @@ var _ = g.Describe("deploymentconfigs", func() {

o.Expect(waitForSyncedConfig(oc, "history-limit", deploymentRunTimeout)).NotTo(o.HaveOccurred())
g.By("waiting for the deployment to complete")
o.Expect(waitForLatestCondition(oc, "history-limit", deploymentRunTimeout, deploymentReachedCompletion)).NotTo(o.HaveOccurred())
o.Expect(waitForLatestCondition(oc, "history-limit", deploymentTimeout, deploymentReachedCompletion)).NotTo(o.HaveOccurred())
o.Expect(waitForSyncedConfig(oc, "history-limit", deploymentRunTimeout)).NotTo(o.HaveOccurred(),
"the controller needs to have synced with the updated deployment configuration before checking that the revision history limits are being adhered to")
var pollErr error
Expand Down Expand Up @@ -876,8 +877,9 @@ var _ = g.Describe("deploymentconfigs", func() {
return true, nil
})
if err == wait.ErrWaitTimeout {
o.Expect(pollErr).NotTo(o.HaveOccurred())
err = pollErr
}
o.Expect(err).NotTo(o.HaveOccurred())
})
})

Expand Down
21 changes: 21 additions & 0 deletions test/extended/deployments/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,27 @@ func createFixture(oc *exutil.CLI, fixture string) (string, string, error) {
return resource, parts[1], nil
}

func createDeploymentConfig(oc *exutil.CLI, fixture string) (*deployapi.DeploymentConfig, error) {
_, name, err := createFixture(oc, fixture)
if err != nil {
return nil, err
}
var pollErr error
var dc *deployapi.DeploymentConfig
err = wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) {
dc, err = oc.Client().DeploymentConfigs(oc.Namespace()).Get(name, metav1.GetOptions{})
if err != nil {
pollErr = err
return false, nil
}
return true, nil
})
if err == wait.ErrWaitTimeout {
err = pollErr
}
return dc, err
}

func DeploymentConfigFailureTrap(oc *exutil.CLI, name string, failed bool) {
failureTrap(oc, name, failed)
}
Expand Down
12 changes: 1 addition & 11 deletions test/extended/testdata/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions test/extended/testdata/deployments/deployment-history-limit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@ metadata:
name: history-limit
spec:
replicas: 1
selector:
name: history-limit
strategy:
type: Rolling
rollingParams:
pre:
failurePolicy: Abort
execNewPod:
containerName: myapp
command:
- /bin/echo
- test pre hook executed
template:
metadata:
labels:
name: history-limit
spec:
containers:
- image: "docker.io/centos:centos7"
- image: "docker.io/alpine:3.6"
imagePullPolicy: IfNotPresent
name: myapp
command:
Expand Down

0 comments on commit c3ba2ab

Please sign in to comment.