Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f4de3ea6
Commit
f4de3ea6
authored
Feb 22, 2016
by
Brian Grant
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #21710 from janetkuo/flake-event-order
Don't rely on events in deployment rollback e2e test
parents
c833a148
eaa4eb10
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
29 deletions
+42
-29
deployment.go
test/e2e/deployment.go
+26
-29
util.go
test/e2e/util.go
+16
-0
No files found.
test/e2e/deployment.go
View file @
f4de3ea6
...
...
@@ -655,10 +655,11 @@ func testRollbackDeployment(f *Framework) {
// testRollbackDeploymentRSNoRevision tests that deployment supports rollback even when there's old replica set without revision.
// An old replica set without revision is created, and then a deployment is created (v1). The deployment shouldn't add revision
// annotation to the old replica set. Then rollback the deployment to last revision, and it should fail and emit related event.
// Then update the deployment to v2 and rollback it to v1 should succeed and emit related event, now the deployment
// becomes v3. Then rollback the deployment to v10 (doesn't exist in history) should fail and emit related event.
// Finally, rollback the deployment (v3) to v3 should be no-op and emit related event.
// annotation to the old replica set. Then rollback the deployment to last revision, and it should fail.
// Then update the deployment to v2 and rollback it to v1 should succeed, now the deployment
// becomes v3. Then rollback the deployment to v10 (doesn't exist in history) should fail.
// Finally, rollback the deployment (v3) to v3 should be no-op.
// TODO: When we finished reporting rollback status in deployment status, check the rollback status here in each case.
func
testRollbackDeploymentRSNoRevision
(
f
*
Framework
)
{
ns
:=
f
.
Namespace
.
Name
unversionedClient
:=
f
.
Client
...
...
@@ -720,13 +721,12 @@ func testRollbackDeploymentRSNoRevision(f *Framework) {
err
=
c
.
Extensions
()
.
Deployments
(
ns
)
.
Rollback
(
rollback
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
// There should be revision not found event since there's no last revision
waitForEvents
(
unversionedClient
,
ns
,
deployment
,
2
)
events
,
err
:=
c
.
Events
(
ns
)
.
Search
(
deployment
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
events
.
Items
[
1
]
.
Reason
)
.
Should
(
Equal
(
deploymentutil
.
RollbackRevisionNotFound
))
// Wait until the rollback is done
waitForRollbackDone
(
c
,
deployment
)
// TODO: report RollbackRevisionNotFound in deployment status and check it here
// Check if it's still revision 1
// The pod template shouldn't change since there's no last revision
// Check if the deployment is still revision 1 and still has the old pod template
checkDeploymentRevision
(
c
,
ns
,
deploymentName
,
"1"
,
deploymentImageName
,
deploymentImage
)
// Update the deployment to create redis pods.
...
...
@@ -754,46 +754,43 @@ func testRollbackDeploymentRSNoRevision(f *Framework) {
err
=
waitForDeploymentStatus
(
c
,
ns
,
deploymentName
,
deploymentReplicas
,
deploymentReplicas
-
1
,
deploymentReplicas
+
1
,
0
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
// There should be rollback event after we rollback to revision 1
waitForEvents
(
unversionedClient
,
ns
,
deployment
,
5
)
events
,
err
=
c
.
Events
(
ns
)
.
Search
(
deployment
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
events
.
Items
[
4
]
.
Reason
)
.
Should
(
Equal
(
deploymentutil
.
RollbackDone
))
// Wait until the rollback is done
waitForRollbackDone
(
c
,
deployment
)
// TODO: report RollbackDone in deployment status and check it here
// The pod template should be updated to the one in revision 1
// Check if it's updated to revision 3 correctly
checkDeploymentRevision
(
c
,
ns
,
deploymentName
,
"3"
,
deploymentImageName
,
deploymentImage
)
// Update the deploymentRollback to rollback to revision 10
// Since there's no revision 10 in history, it should stay as revision 3
, and emit an event
// Since there's no revision 10 in history, it should stay as revision 3
revision
=
10
Logf
(
"rolling back deployment %s to revision %d"
,
deploymentName
,
revision
)
rollback
=
newDeploymentRollback
(
deploymentName
,
nil
,
revision
)
err
=
c
.
Extensions
()
.
Deployments
(
ns
)
.
Rollback
(
rollback
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
// There should be revision not found event since there's no revision 10
waitForEvents
(
unversionedClient
,
ns
,
deployment
,
7
)
events
,
err
=
c
.
Events
(
ns
)
.
Search
(
deployment
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
events
.
Items
[
6
]
.
Reason
)
.
Should
(
Equal
(
deploymentutil
.
RollbackRevisionNotFound
))
// Wait until the rollback is done
waitForRollbackDone
(
c
,
deployment
)
// TODO: report RollbackRevisionNotFound in deployment status and check it here
// Check if it's still revision 3
// The pod template shouldn't change since there's no revision 10
// Check if it's still revision 3 and still has the old pod template
checkDeploymentRevision
(
c
,
ns
,
deploymentName
,
"3"
,
deploymentImageName
,
deploymentImage
)
// Update the deploymentRollback to rollback to revision 3
// Since it's already revision 3, it should be no-op
and emit an event
// Since it's already revision 3, it should be no-op
revision
=
3
Logf
(
"rolling back deployment %s to revision %d"
,
deploymentName
,
revision
)
rollback
=
newDeploymentRollback
(
deploymentName
,
nil
,
revision
)
err
=
c
.
Extensions
()
.
Deployments
(
ns
)
.
Rollback
(
rollback
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
// There should be revision template unchanged event since it's already revision 3
waitForEvents
(
unversionedClient
,
ns
,
deployment
,
8
)
events
,
err
=
c
.
Events
(
ns
)
.
Search
(
deployment
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
events
.
Items
[
7
]
.
Reason
)
.
Should
(
Equal
(
deploymentutil
.
RollbackTemplateUnchanged
))
// Wait until the rollback is done
waitForRollbackDone
(
c
,
deployment
)
// TODO: report RollbackTemplateUnchanged in deployment status and check it here
// Check if it's still revision 3
// The pod template shouldn't change since it's already revision 3
// Check if it's still revision 3 and still has the old pod template
checkDeploymentRevision
(
c
,
ns
,
deploymentName
,
"3"
,
deploymentImageName
,
deploymentImage
)
}
test/e2e/util.go
View file @
f4de3ea6
...
...
@@ -2213,6 +2213,22 @@ func waitForPartialEvents(c *client.Client, ns string, objOrRef runtime.Object,
})
}
// waitForRollbackDone waits for the given deployment finishes rollback.
func
waitForRollbackDone
(
c
*
clientset
.
Clientset
,
deployment
*
extensions
.
Deployment
)
(
err
error
)
{
deployments
:=
c
.
Extensions
()
.
Deployments
(
deployment
.
Namespace
)
name
:=
deployment
.
Name
return
wait
.
Poll
(
10
*
time
.
Millisecond
,
1
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
if
deployment
,
err
=
deployments
.
Get
(
name
);
err
!=
nil
{
return
false
,
err
}
// When deployment's RollbackTo is empty, the rollback is done.
if
deployment
.
Spec
.
RollbackTo
==
nil
{
return
true
,
nil
}
return
false
,
nil
})
}
type
updateDeploymentFunc
func
(
d
*
extensions
.
Deployment
)
func
updateDeploymentWithRetries
(
c
*
clientset
.
Clientset
,
namespace
,
name
string
,
applyUpdate
updateDeploymentFunc
)
(
deployment
*
extensions
.
Deployment
,
err
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment