@@ -26,8 +26,8 @@ import (
26
26
"k8s.io/kubernetes/test/e2e/framework"
27
27
"k8s.io/kubernetes/test/e2e/upgrades"
28
28
29
- . "github.com/onsi/ginkgo"
30
- . "github.com/onsi/gomega"
29
+ "github.com/onsi/ginkgo"
30
+ "github.com/onsi/gomega"
31
31
imageutils "k8s.io/kubernetes/test/utils/image"
32
32
)
33
33
@@ -46,6 +46,7 @@ type DeploymentUpgradeTest struct {
46
46
newRSUID types.UID
47
47
}
48
48
49
+ // Name returns the tracking name of the test.
49
50
func (DeploymentUpgradeTest ) Name () string { return "[sig-apps] deployment-upgrade" }
50
51
51
52
// Setup creates a deployment and makes sure it has a new and an old replicaset running.
@@ -57,15 +58,15 @@ func (t *DeploymentUpgradeTest) Setup(f *framework.Framework) {
57
58
deploymentClient := c .AppsV1 ().Deployments (ns )
58
59
rsClient := c .AppsV1 ().ReplicaSets (ns )
59
60
60
- By (fmt .Sprintf ("Creating a deployment %q with 1 replica in namespace %q" , deploymentName , ns ))
61
+ ginkgo . By (fmt .Sprintf ("Creating a deployment %q with 1 replica in namespace %q" , deploymentName , ns ))
61
62
d := framework .NewDeployment (deploymentName , int32 (1 ), map [string ]string {"test" : "upgrade" }, "nginx" , nginxImage , apps .RollingUpdateDeploymentStrategyType )
62
63
deployment , err := deploymentClient .Create (d )
63
64
framework .ExpectNoError (err )
64
65
65
- By (fmt .Sprintf ("Waiting deployment %q to complete" , deploymentName ))
66
+ ginkgo . By (fmt .Sprintf ("Waiting deployment %q to complete" , deploymentName ))
66
67
framework .ExpectNoError (framework .WaitForDeploymentComplete (c , deployment ))
67
68
68
- By (fmt .Sprintf ("Getting replicaset revision 1 of deployment %q" , deploymentName ))
69
+ ginkgo . By (fmt .Sprintf ("Getting replicaset revision 1 of deployment %q" , deploymentName ))
69
70
rsSelector , err := metav1 .LabelSelectorAsSelector (d .Spec .Selector )
70
71
framework .ExpectNoError (err )
71
72
rsList , err := rsClient .List (metav1.ListOptions {LabelSelector : rsSelector .String ()})
@@ -76,28 +77,28 @@ func (t *DeploymentUpgradeTest) Setup(f *framework.Framework) {
76
77
}
77
78
t .oldRSUID = rss [0 ].UID
78
79
79
- By (fmt .Sprintf ("Waiting for revision of the deployment %q to become 1" , deploymentName ))
80
+ ginkgo . By (fmt .Sprintf ("Waiting for revision of the deployment %q to become 1" , deploymentName ))
80
81
framework .ExpectNoError (framework .WaitForDeploymentRevision (c , deployment , "1" ))
81
82
82
83
// Trigger a new rollout so that we have some history.
83
- By (fmt .Sprintf ("Triggering a new rollout for deployment %q" , deploymentName ))
84
+ ginkgo . By (fmt .Sprintf ("Triggering a new rollout for deployment %q" , deploymentName ))
84
85
deployment , err = framework .UpdateDeploymentWithRetries (c , ns , deploymentName , func (update * apps.Deployment ) {
85
86
update .Spec .Template .Spec .Containers [0 ].Name = "updated-name"
86
87
})
87
88
framework .ExpectNoError (err )
88
89
89
- By (fmt .Sprintf ("Waiting deployment %q to complete" , deploymentName ))
90
+ ginkgo . By (fmt .Sprintf ("Waiting deployment %q to complete" , deploymentName ))
90
91
framework .ExpectNoError (framework .WaitForDeploymentComplete (c , deployment ))
91
92
92
- By (fmt .Sprintf ("Getting replicasets revision 1 and 2 of deployment %q" , deploymentName ))
93
+ ginkgo . By (fmt .Sprintf ("Getting replicasets revision 1 and 2 of deployment %q" , deploymentName ))
93
94
rsList , err = rsClient .List (metav1.ListOptions {LabelSelector : rsSelector .String ()})
94
95
framework .ExpectNoError (err )
95
96
rss = rsList .Items
96
97
if len (rss ) != 2 {
97
98
framework .ExpectNoError (fmt .Errorf ("expected 2 replicaset, got %d" , len (rss )))
98
99
}
99
100
100
- By (fmt .Sprintf ("Checking replicaset of deployment %q that is created before rollout survives the rollout" , deploymentName ))
101
+ ginkgo . By (fmt .Sprintf ("Checking replicaset of deployment %q that is created before rollout survives the rollout" , deploymentName ))
101
102
switch t .oldRSUID {
102
103
case rss [0 ].UID :
103
104
t .newRSUID = rss [1 ].UID
@@ -107,7 +108,7 @@ func (t *DeploymentUpgradeTest) Setup(f *framework.Framework) {
107
108
framework .ExpectNoError (fmt .Errorf ("old replicaset with UID %q does not survive rollout" , t .oldRSUID ))
108
109
}
109
110
110
- By (fmt .Sprintf ("Waiting for revision of the deployment %q to become 2" , deploymentName ))
111
+ ginkgo . By (fmt .Sprintf ("Waiting for revision of the deployment %q to become 2" , deploymentName ))
111
112
framework .ExpectNoError (framework .WaitForDeploymentRevision (c , deployment , "2" ))
112
113
113
114
t .oldDeploymentUID = deployment .UID
@@ -116,7 +117,7 @@ func (t *DeploymentUpgradeTest) Setup(f *framework.Framework) {
116
117
// Test checks whether the replicasets for a deployment are the same after an upgrade.
117
118
func (t * DeploymentUpgradeTest ) Test (f * framework.Framework , done <- chan struct {}, upgrade upgrades.UpgradeType ) {
118
119
// Block until upgrade is done
119
- By (fmt .Sprintf ("Waiting for upgrade to finish before checking replicasets for deployment %q" , deploymentName ))
120
+ ginkgo . By (fmt .Sprintf ("Waiting for upgrade to finish before checking replicasets for deployment %q" , deploymentName ))
120
121
<- done
121
122
122
123
c := f .ClientSet
@@ -127,10 +128,10 @@ func (t *DeploymentUpgradeTest) Test(f *framework.Framework, done <-chan struct{
127
128
deployment , err := deploymentClient .Get (deploymentName , metav1.GetOptions {})
128
129
framework .ExpectNoError (err )
129
130
130
- By (fmt .Sprintf ("Checking UID to verify deployment %q survives upgrade" , deploymentName ))
131
- Expect (deployment .UID ).To (Equal (t .oldDeploymentUID ))
131
+ ginkgo . By (fmt .Sprintf ("Checking UID to verify deployment %q survives upgrade" , deploymentName ))
132
+ gomega . Expect (deployment .UID ).To (gomega . Equal (t .oldDeploymentUID ))
132
133
133
- By (fmt .Sprintf ("Verifying deployment %q does not create new replicasets" , deploymentName ))
134
+ ginkgo . By (fmt .Sprintf ("Verifying deployment %q does not create new replicasets" , deploymentName ))
134
135
rsSelector , err := metav1 .LabelSelectorAsSelector (deployment .Spec .Selector )
135
136
framework .ExpectNoError (err )
136
137
rsList , err := rsClient .List (metav1.ListOptions {LabelSelector : rsSelector .String ()})
@@ -142,27 +143,27 @@ func (t *DeploymentUpgradeTest) Test(f *framework.Framework, done <-chan struct{
142
143
143
144
switch t .oldRSUID {
144
145
case rss [0 ].UID :
145
- Expect (rss [1 ].UID ).To (Equal (t .newRSUID ))
146
+ gomega . Expect (rss [1 ].UID ).To (gomega . Equal (t .newRSUID ))
146
147
case rss [1 ].UID :
147
- Expect (rss [0 ].UID ).To (Equal (t .newRSUID ))
148
+ gomega . Expect (rss [0 ].UID ).To (gomega . Equal (t .newRSUID ))
148
149
default :
149
150
framework .ExpectNoError (fmt .Errorf ("new replicasets are created during upgrade of deployment %q" , deploymentName ))
150
151
}
151
152
152
- By (fmt .Sprintf ("Verifying revision of the deployment %q is still 2" , deploymentName ))
153
- Expect (deployment .Annotations [deploymentutil .RevisionAnnotation ]).To (Equal ("2" ))
153
+ ginkgo . By (fmt .Sprintf ("Verifying revision of the deployment %q is still 2" , deploymentName ))
154
+ gomega . Expect (deployment .Annotations [deploymentutil .RevisionAnnotation ]).To (gomega . Equal ("2" ))
154
155
155
- By (fmt .Sprintf ("Waiting for deployment %q to complete adoption" , deploymentName ))
156
+ ginkgo . By (fmt .Sprintf ("Waiting for deployment %q to complete adoption" , deploymentName ))
156
157
framework .ExpectNoError (framework .WaitForDeploymentComplete (c , deployment ))
157
158
158
159
// Verify the upgraded deployment is active by scaling up the deployment by 1
159
- By (fmt .Sprintf ("Scaling up replicaset of deployment %q by 1" , deploymentName ))
160
+ ginkgo . By (fmt .Sprintf ("Scaling up replicaset of deployment %q by 1" , deploymentName ))
160
161
_ , err = framework .UpdateDeploymentWithRetries (c , ns , deploymentName , func (deployment * apps.Deployment ) {
161
162
* deployment .Spec .Replicas = * deployment .Spec .Replicas + 1
162
163
})
163
164
framework .ExpectNoError (err )
164
165
165
- By (fmt .Sprintf ("Waiting for deployment %q to complete after scaling" , deploymentName ))
166
+ ginkgo . By (fmt .Sprintf ("Waiting for deployment %q to complete after scaling" , deploymentName ))
166
167
framework .ExpectNoError (framework .WaitForDeploymentComplete (c , deployment ))
167
168
}
168
169
0 commit comments