Skip to content

Commit 1626aa5

Browse files
authored
Merge pull request kubernetes#77053 from SataQiu/fix-golint-test-20190425
Fix golint failures of test/e2e/lifecycle
2 parents 6a48257 + 1d8615a commit 1626aa5

File tree

10 files changed

+167
-167
lines changed

10 files changed

+167
-167
lines changed

hack/.golint_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ test/e2e/chaosmonkey
619619
test/e2e/common
620620
test/e2e/framework
621621
test/e2e/framework/providers/gce
622-
test/e2e/lifecycle
623622
test/e2e/lifecycle/bootstrap
624623
test/e2e/network
625624
test/e2e/node

test/e2e/lifecycle/addon_update.go

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ import (
3030
clientset "k8s.io/client-go/kubernetes"
3131
"k8s.io/kubernetes/test/e2e/framework"
3232

33-
. "github.com/onsi/ginkgo"
34-
. "github.com/onsi/gomega"
33+
"github.com/onsi/ginkgo"
34+
"github.com/onsi/gomega"
3535
imageutils "k8s.io/kubernetes/test/utils/image"
3636
)
3737

3838
// TODO: it would probably be slightly better to build up the objects
3939
// in the code and then serialize to yaml.
40-
var reconcile_addon_controller = `
40+
var reconcileAddonController = `
4141
apiVersion: v1
4242
kind: ReplicationController
4343
metadata:
@@ -65,7 +65,7 @@ spec:
6565
`
6666

6767
// Should update "reconcile" class addon.
68-
var reconcile_addon_controller_updated = `
68+
var reconcileAddonControllerUpdated = `
6969
apiVersion: v1
7070
kind: ReplicationController
7171
metadata:
@@ -93,7 +93,7 @@ spec:
9393
protocol: TCP
9494
`
9595

96-
var ensure_exists_addon_service = `
96+
var ensureExistsAddonService = `
9797
apiVersion: v1
9898
kind: Service
9999
metadata:
@@ -112,7 +112,7 @@ spec:
112112
`
113113

114114
// Should create but don't update "ensure exist" class addon.
115-
var ensure_exists_addon_service_updated = `
115+
var ensureExistsAddonServiceUpdated = `
116116
apiVersion: v1
117117
kind: Service
118118
metadata:
@@ -131,7 +131,7 @@ spec:
131131
k8s-app: addon-ensure-exists-test
132132
`
133133

134-
var deprecated_label_addon_service = `
134+
var deprecatedLabelAddonService = `
135135
apiVersion: v1
136136
kind: Service
137137
metadata:
@@ -150,7 +150,7 @@ spec:
150150
`
151151

152152
// Should update addon with label "kubernetes.io/cluster-service=true".
153-
var deprecated_label_addon_service_updated = `
153+
var deprecatedLabelAddonServiceUpdated = `
154154
apiVersion: v1
155155
kind: Service
156156
metadata:
@@ -170,7 +170,7 @@ spec:
170170
`
171171

172172
// Should not create addon without valid label.
173-
var invalid_addon_controller = `
173+
var invalidAddonController = `
174174
apiVersion: v1
175175
kind: ReplicationController
176176
metadata:
@@ -214,7 +214,7 @@ var _ = SIGDescribe("Addon update", func() {
214214
var sshClient *ssh.Client
215215
f := framework.NewDefaultFramework("addon-update-test")
216216

217-
BeforeEach(func() {
217+
ginkgo.BeforeEach(func() {
218218
// This test requires:
219219
// - SSH master access
220220
// ... so the provider check should be identical to the intersection of
@@ -225,17 +225,17 @@ var _ = SIGDescribe("Addon update", func() {
225225

226226
var err error
227227
sshClient, err = getMasterSSHClient()
228-
Expect(err).NotTo(HaveOccurred(), "Failed to get the master SSH client.")
228+
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to get the master SSH client.")
229229
})
230230

231-
AfterEach(func() {
231+
ginkgo.AfterEach(func() {
232232
if sshClient != nil {
233233
sshClient.Close()
234234
}
235235
})
236236

237237
// WARNING: the test is not parallel-friendly!
238-
It("should propagate add-on file changes [Slow]", func() {
238+
ginkgo.It("should propagate add-on file changes [Slow]", func() {
239239
// This test requires:
240240
// - SSH
241241
// - master access
@@ -244,7 +244,7 @@ var _ = SIGDescribe("Addon update", func() {
244244
framework.SkipUnlessProviderIs("gce")
245245

246246
//these tests are long, so I squeezed several cases in one scenario
247-
Expect(sshClient).NotTo(BeNil())
247+
gomega.Expect(sshClient).NotTo(gomega.BeNil())
248248
dir = f.Namespace.Name // we use it only to give a unique string for each test execution
249249

250250
temporaryRemotePathPrefix := "addon-test-dir"
@@ -262,18 +262,18 @@ var _ = SIGDescribe("Addon update", func() {
262262
svcAddonEnsureExistsUpdated := "addon-ensure-exists-service-updated.yaml"
263263

264264
var remoteFiles []stringPair = []stringPair{
265-
{fmt.Sprintf(reconcile_addon_controller, addonNsName, serveHostnameImage), rcAddonReconcile},
266-
{fmt.Sprintf(reconcile_addon_controller_updated, addonNsName, serveHostnameImage), rcAddonReconcileUpdated},
267-
{fmt.Sprintf(deprecated_label_addon_service, addonNsName), svcAddonDeprecatedLabel},
268-
{fmt.Sprintf(deprecated_label_addon_service_updated, addonNsName), svcAddonDeprecatedLabelUpdated},
269-
{fmt.Sprintf(ensure_exists_addon_service, addonNsName), svcAddonEnsureExists},
270-
{fmt.Sprintf(ensure_exists_addon_service_updated, addonNsName), svcAddonEnsureExistsUpdated},
271-
{fmt.Sprintf(invalid_addon_controller, addonNsName, serveHostnameImage), rcInvalid},
265+
{fmt.Sprintf(reconcileAddonController, addonNsName, serveHostnameImage), rcAddonReconcile},
266+
{fmt.Sprintf(reconcileAddonControllerUpdated, addonNsName, serveHostnameImage), rcAddonReconcileUpdated},
267+
{fmt.Sprintf(deprecatedLabelAddonService, addonNsName), svcAddonDeprecatedLabel},
268+
{fmt.Sprintf(deprecatedLabelAddonServiceUpdated, addonNsName), svcAddonDeprecatedLabelUpdated},
269+
{fmt.Sprintf(ensureExistsAddonService, addonNsName), svcAddonEnsureExists},
270+
{fmt.Sprintf(ensureExistsAddonServiceUpdated, addonNsName), svcAddonEnsureExistsUpdated},
271+
{fmt.Sprintf(invalidAddonController, addonNsName, serveHostnameImage), rcInvalid},
272272
}
273273

274274
for _, p := range remoteFiles {
275275
err := writeRemoteFile(sshClient, p.data, temporaryRemotePath, p.fileName, 0644)
276-
Expect(err).NotTo(HaveOccurred(), "Failed to write file %q at remote path %q with ssh client %+v", p.fileName, temporaryRemotePath, sshClient)
276+
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to write file %q at remote path %q with ssh client %+v", p.fileName, temporaryRemotePath, sshClient)
277277
}
278278

279279
// directory on kubernetes-master
@@ -282,31 +282,31 @@ var _ = SIGDescribe("Addon update", func() {
282282

283283
// cleanup from previous tests
284284
_, _, _, err := sshExec(sshClient, fmt.Sprintf("sudo rm -rf %s", destinationDirPrefix))
285-
Expect(err).NotTo(HaveOccurred(), "Failed to remove remote dir %q with ssh client %+v", destinationDirPrefix, sshClient)
285+
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to remove remote dir %q with ssh client %+v", destinationDirPrefix, sshClient)
286286

287287
defer sshExec(sshClient, fmt.Sprintf("sudo rm -rf %s", destinationDirPrefix)) // ignore result in cleanup
288288
sshExecAndVerify(sshClient, fmt.Sprintf("sudo mkdir -p %s", destinationDir))
289289

290-
By("copy invalid manifests to the destination dir")
290+
ginkgo.By("copy invalid manifests to the destination dir")
291291
sshExecAndVerify(sshClient, fmt.Sprintf("sudo cp %s/%s %s/%s", temporaryRemotePath, rcInvalid, destinationDir, rcInvalid))
292292
// we will verify at the end of the test that the objects weren't created from the invalid manifests
293293

294-
By("copy new manifests")
294+
ginkgo.By("copy new manifests")
295295
sshExecAndVerify(sshClient, fmt.Sprintf("sudo cp %s/%s %s/%s", temporaryRemotePath, rcAddonReconcile, destinationDir, rcAddonReconcile))
296296
sshExecAndVerify(sshClient, fmt.Sprintf("sudo cp %s/%s %s/%s", temporaryRemotePath, svcAddonDeprecatedLabel, destinationDir, svcAddonDeprecatedLabel))
297297
sshExecAndVerify(sshClient, fmt.Sprintf("sudo cp %s/%s %s/%s", temporaryRemotePath, svcAddonEnsureExists, destinationDir, svcAddonEnsureExists))
298298
// Delete the "ensure exist class" addon at the end.
299299
defer func() {
300300
framework.Logf("Cleaning up ensure exist class addon.")
301-
Expect(f.ClientSet.CoreV1().Services(addonNsName).Delete("addon-ensure-exists-test", nil)).NotTo(HaveOccurred())
301+
gomega.Expect(f.ClientSet.CoreV1().Services(addonNsName).Delete("addon-ensure-exists-test", nil)).NotTo(gomega.HaveOccurred())
302302
}()
303303

304304
waitForReplicationControllerInAddonTest(f.ClientSet, addonNsName, "addon-reconcile-test", true)
305305
waitForServiceInAddonTest(f.ClientSet, addonNsName, "addon-deprecated-label-test", true)
306306
waitForServiceInAddonTest(f.ClientSet, addonNsName, "addon-ensure-exists-test", true)
307307

308308
// Replace the manifests with new contents.
309-
By("update manifests")
309+
ginkgo.By("update manifests")
310310
sshExecAndVerify(sshClient, fmt.Sprintf("sudo cp %s/%s %s/%s", temporaryRemotePath, rcAddonReconcileUpdated, destinationDir, rcAddonReconcile))
311311
sshExecAndVerify(sshClient, fmt.Sprintf("sudo cp %s/%s %s/%s", temporaryRemotePath, svcAddonDeprecatedLabelUpdated, destinationDir, svcAddonDeprecatedLabel))
312312
sshExecAndVerify(sshClient, fmt.Sprintf("sudo cp %s/%s %s/%s", temporaryRemotePath, svcAddonEnsureExistsUpdated, destinationDir, svcAddonEnsureExists))
@@ -320,7 +320,7 @@ var _ = SIGDescribe("Addon update", func() {
320320
ensureExistSelector := labels.SelectorFromSet(labels.Set(map[string]string{"newLabel": "addon-ensure-exists-test"}))
321321
waitForServicewithSelectorInAddonTest(f.ClientSet, addonNsName, false, ensureExistSelector)
322322

323-
By("remove manifests")
323+
ginkgo.By("remove manifests")
324324
sshExecAndVerify(sshClient, fmt.Sprintf("sudo rm %s/%s", destinationDir, rcAddonReconcile))
325325
sshExecAndVerify(sshClient, fmt.Sprintf("sudo rm %s/%s", destinationDir, svcAddonDeprecatedLabel))
326326
sshExecAndVerify(sshClient, fmt.Sprintf("sudo rm %s/%s", destinationDir, svcAddonEnsureExists))
@@ -330,9 +330,9 @@ var _ = SIGDescribe("Addon update", func() {
330330
// "Ensure exist class" addon will not be deleted when manifest is removed.
331331
waitForServiceInAddonTest(f.ClientSet, addonNsName, "addon-ensure-exists-test", true)
332332

333-
By("verify invalid addons weren't created")
333+
ginkgo.By("verify invalid addons weren't created")
334334
_, err = f.ClientSet.CoreV1().ReplicationControllers(addonNsName).Get("invalid-addon-test", metav1.GetOptions{})
335-
Expect(err).To(HaveOccurred())
335+
gomega.Expect(err).To(gomega.HaveOccurred())
336336

337337
// Invalid addon manifests and the "ensure exist class" addon will be deleted by the deferred function.
338338
})
@@ -384,8 +384,8 @@ func getMasterSSHClient() (*ssh.Client, error) {
384384

385385
func sshExecAndVerify(client *ssh.Client, cmd string) {
386386
_, _, rc, err := sshExec(client, cmd)
387-
Expect(err).NotTo(HaveOccurred(), "Failed to execute %q with ssh client %+v", cmd, client)
388-
Expect(rc).To(Equal(0), "error return code from executing command on the cluster: %s", cmd)
387+
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to execute %q with ssh client %+v", cmd, client)
388+
gomega.Expect(rc).To(gomega.Equal(0), "error return code from executing command on the cluster: %s", cmd)
389389
}
390390

391391
func sshExec(client *ssh.Client, cmd string) (string, string, int, error) {

test/e2e/lifecycle/cluster_upgrade.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
"k8s.io/kubernetes/test/e2e/upgrades/storage"
3838
"k8s.io/kubernetes/test/utils/junit"
3939

40-
. "github.com/onsi/ginkgo"
40+
"github.com/onsi/ginkgo"
4141
)
4242

4343
var (
@@ -86,8 +86,8 @@ var _ = SIGDescribe("Upgrade [Feature:Upgrade]", func() {
8686
// Create the frameworks here because we can only create them
8787
// in a "Describe".
8888
testFrameworks := createUpgradeFrameworks(upgradeTests)
89-
Describe("master upgrade", func() {
90-
It("should maintain a functioning cluster [Feature:MasterUpgrade]", func() {
89+
ginkgo.Describe("master upgrade", func() {
90+
ginkgo.It("should maintain a functioning cluster [Feature:MasterUpgrade]", func() {
9191
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), *upgradeTarget)
9292
framework.ExpectNoError(err)
9393

@@ -109,8 +109,8 @@ var _ = SIGDescribe("Upgrade [Feature:Upgrade]", func() {
109109
})
110110
})
111111

112-
Describe("node upgrade", func() {
113-
It("should maintain a functioning cluster [Feature:NodeUpgrade]", func() {
112+
ginkgo.Describe("node upgrade", func() {
113+
ginkgo.It("should maintain a functioning cluster [Feature:NodeUpgrade]", func() {
114114
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), *upgradeTarget)
115115
framework.ExpectNoError(err)
116116

@@ -131,8 +131,8 @@ var _ = SIGDescribe("Upgrade [Feature:Upgrade]", func() {
131131
})
132132
})
133133

134-
Describe("cluster upgrade", func() {
135-
It("should maintain a functioning cluster [Feature:ClusterUpgrade]", func() {
134+
ginkgo.Describe("cluster upgrade", func() {
135+
ginkgo.It("should maintain a functioning cluster [Feature:ClusterUpgrade]", func() {
136136
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), *upgradeTarget)
137137
framework.ExpectNoError(err)
138138

@@ -160,8 +160,8 @@ var _ = SIGDescribe("Downgrade [Feature:Downgrade]", func() {
160160
// in a "Describe".
161161
testFrameworks := createUpgradeFrameworks(upgradeTests)
162162

163-
Describe("cluster downgrade", func() {
164-
It("should maintain a functioning cluster [Feature:ClusterDowngrade]", func() {
163+
ginkgo.Describe("cluster downgrade", func() {
164+
ginkgo.It("should maintain a functioning cluster [Feature:ClusterDowngrade]", func() {
165165
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), *upgradeTarget)
166166
framework.ExpectNoError(err)
167167

@@ -190,8 +190,8 @@ var _ = SIGDescribe("etcd Upgrade [Feature:EtcdUpgrade]", func() {
190190
// Create the frameworks here because we can only create them
191191
// in a "Describe".
192192
testFrameworks := createUpgradeFrameworks(upgradeTests)
193-
Describe("etcd upgrade", func() {
194-
It("should maintain a functioning cluster", func() {
193+
ginkgo.Describe("etcd upgrade", func() {
194+
ginkgo.It("should maintain a functioning cluster", func() {
195195
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), "")
196196
framework.ExpectNoError(err)
197197

@@ -215,8 +215,8 @@ var _ = SIGDescribe("gpu Upgrade [Feature:GPUUpgrade]", func() {
215215
// Create the frameworks here because we can only create them
216216
// in a "Describe".
217217
testFrameworks := createUpgradeFrameworks(gpuUpgradeTests)
218-
Describe("master upgrade", func() {
219-
It("should NOT disrupt gpu pod [Feature:GPUMasterUpgrade]", func() {
218+
ginkgo.Describe("master upgrade", func() {
219+
ginkgo.It("should NOT disrupt gpu pod [Feature:GPUMasterUpgrade]", func() {
220220
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), *upgradeTarget)
221221
framework.ExpectNoError(err)
222222

@@ -233,8 +233,8 @@ var _ = SIGDescribe("gpu Upgrade [Feature:GPUUpgrade]", func() {
233233
runUpgradeSuite(f, gpuUpgradeTests, testFrameworks, testSuite, upgCtx, upgrades.MasterUpgrade, upgradeFunc)
234234
})
235235
})
236-
Describe("cluster upgrade", func() {
237-
It("should be able to run gpu pod after upgrade [Feature:GPUClusterUpgrade]", func() {
236+
ginkgo.Describe("cluster upgrade", func() {
237+
ginkgo.It("should be able to run gpu pod after upgrade [Feature:GPUClusterUpgrade]", func() {
238238
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), *upgradeTarget)
239239
framework.ExpectNoError(err)
240240

@@ -253,8 +253,8 @@ var _ = SIGDescribe("gpu Upgrade [Feature:GPUUpgrade]", func() {
253253
runUpgradeSuite(f, gpuUpgradeTests, testFrameworks, testSuite, upgCtx, upgrades.ClusterUpgrade, upgradeFunc)
254254
})
255255
})
256-
Describe("cluster downgrade", func() {
257-
It("should be able to run gpu pod after downgrade [Feature:GPUClusterDowngrade]", func() {
256+
ginkgo.Describe("cluster downgrade", func() {
257+
ginkgo.It("should be able to run gpu pod after downgrade [Feature:GPUClusterDowngrade]", func() {
258258
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), *upgradeTarget)
259259
framework.ExpectNoError(err)
260260

@@ -275,14 +275,14 @@ var _ = SIGDescribe("gpu Upgrade [Feature:GPUUpgrade]", func() {
275275
})
276276
})
277277

278-
var _ = Describe("[sig-apps] stateful Upgrade [Feature:StatefulUpgrade]", func() {
278+
var _ = ginkgo.Describe("[sig-apps] stateful Upgrade [Feature:StatefulUpgrade]", func() {
279279
f := framework.NewDefaultFramework("stateful-upgrade")
280280

281281
// Create the frameworks here because we can only create them
282282
// in a "Describe".
283283
testFrameworks := createUpgradeFrameworks(statefulsetUpgradeTests)
284284
framework.KubeDescribe("stateful upgrade", func() {
285-
It("should maintain a functioning cluster", func() {
285+
ginkgo.It("should maintain a functioning cluster", func() {
286286
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), *upgradeTarget)
287287
framework.ExpectNoError(err)
288288

@@ -306,14 +306,14 @@ var _ = Describe("[sig-apps] stateful Upgrade [Feature:StatefulUpgrade]", func()
306306
var _ = SIGDescribe("kube-proxy migration [Feature:KubeProxyDaemonSetMigration]", func() {
307307
f := framework.NewDefaultFramework("kube-proxy-ds-migration")
308308

309-
BeforeEach(func() {
309+
ginkgo.BeforeEach(func() {
310310
framework.SkipUnlessProviderIs("gce")
311311
})
312312

313-
Describe("Upgrade kube-proxy from static pods to a DaemonSet", func() {
313+
ginkgo.Describe("Upgrade kube-proxy from static pods to a DaemonSet", func() {
314314
testFrameworks := createUpgradeFrameworks(kubeProxyUpgradeTests)
315315

316-
It("should maintain a functioning cluster [Feature:KubeProxyDaemonSetUpgrade]", func() {
316+
ginkgo.It("should maintain a functioning cluster [Feature:KubeProxyDaemonSetUpgrade]", func() {
317317
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), *upgradeTarget)
318318
framework.ExpectNoError(err)
319319

@@ -337,10 +337,10 @@ var _ = SIGDescribe("kube-proxy migration [Feature:KubeProxyDaemonSetMigration]"
337337
})
338338
})
339339

340-
Describe("Downgrade kube-proxy from a DaemonSet to static pods", func() {
340+
ginkgo.Describe("Downgrade kube-proxy from a DaemonSet to static pods", func() {
341341
testFrameworks := createUpgradeFrameworks(kubeProxyDowngradeTests)
342342

343-
It("should maintain a functioning cluster [Feature:KubeProxyDaemonSetDowngrade]", func() {
343+
ginkgo.It("should maintain a functioning cluster [Feature:KubeProxyDaemonSetDowngrade]", func() {
344344
upgCtx, err := getUpgradeContext(f.ClientSet.Discovery(), *upgradeTarget)
345345
framework.ExpectNoError(err)
346346

@@ -385,7 +385,7 @@ func (cma *chaosMonkeyAdapter) Test(sem *chaosmonkey.Semaphore) {
385385
defer finalizeUpgradeTest(start, cma.testReport)
386386
defer ready()
387387
if skippable, ok := cma.test.(upgrades.Skippable); ok && skippable.Skip(cma.upgCtx) {
388-
By("skipping test " + cma.test.Name())
388+
ginkgo.By("skipping test " + cma.test.Name())
389389
cma.testReport.Skipped = "skipping test " + cma.test.Name()
390390
return
391391
}

test/e2e/lifecycle/framework.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package lifecycle
1818

1919
import "github.com/onsi/ginkgo"
2020

21+
// SIGDescribe annotates the test with the SIG label.
2122
func SIGDescribe(text string, body func()) bool {
2223
return ginkgo.Describe("[sig-cluster-lifecycle] "+text, body)
2324
}

0 commit comments

Comments
 (0)