Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix golint failures of test/e2e/lifecycle #77053

Merged
merged 1 commit into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion hack/.golint_failures
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@ test/e2e/chaosmonkey
test/e2e/common
test/e2e/framework
test/e2e/framework/providers/gce
test/e2e/lifecycle
test/e2e/lifecycle/bootstrap
test/e2e/network
test/e2e/node
Expand Down
64 changes: 32 additions & 32 deletions test/e2e/lifecycle/addon_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ import (
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
imageutils "k8s.io/kubernetes/test/utils/image"
)

// TODO: it would probably be slightly better to build up the objects
// in the code and then serialize to yaml.
var reconcile_addon_controller = `
var reconcileAddonController = `
apiVersion: v1
kind: ReplicationController
metadata:
Expand Down Expand Up @@ -65,7 +65,7 @@ spec:
`

// Should update "reconcile" class addon.
var reconcile_addon_controller_updated = `
var reconcileAddonControllerUpdated = `
apiVersion: v1
kind: ReplicationController
metadata:
Expand Down Expand Up @@ -93,7 +93,7 @@ spec:
protocol: TCP
`

var ensure_exists_addon_service = `
var ensureExistsAddonService = `
apiVersion: v1
kind: Service
metadata:
Expand All @@ -112,7 +112,7 @@ spec:
`

// Should create but don't update "ensure exist" class addon.
var ensure_exists_addon_service_updated = `
var ensureExistsAddonServiceUpdated = `
apiVersion: v1
kind: Service
metadata:
Expand All @@ -131,7 +131,7 @@ spec:
k8s-app: addon-ensure-exists-test
`

var deprecated_label_addon_service = `
var deprecatedLabelAddonService = `
apiVersion: v1
kind: Service
metadata:
Expand All @@ -150,7 +150,7 @@ spec:
`

// Should update addon with label "kubernetes.io/cluster-service=true".
var deprecated_label_addon_service_updated = `
var deprecatedLabelAddonServiceUpdated = `
apiVersion: v1
kind: Service
metadata:
Expand All @@ -170,7 +170,7 @@ spec:
`

// Should not create addon without valid label.
var invalid_addon_controller = `
var invalidAddonController = `
apiVersion: v1
kind: ReplicationController
metadata:
Expand Down Expand Up @@ -214,7 +214,7 @@ var _ = SIGDescribe("Addon update", func() {
var sshClient *ssh.Client
f := framework.NewDefaultFramework("addon-update-test")

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

var err error
sshClient, err = getMasterSSHClient()
Expect(err).NotTo(HaveOccurred(), "Failed to get the master SSH client.")
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to get the master SSH client.")
})

AfterEach(func() {
ginkgo.AfterEach(func() {
if sshClient != nil {
sshClient.Close()
}
})

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

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

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

var remoteFiles []stringPair = []stringPair{
{fmt.Sprintf(reconcile_addon_controller, addonNsName, serveHostnameImage), rcAddonReconcile},
{fmt.Sprintf(reconcile_addon_controller_updated, addonNsName, serveHostnameImage), rcAddonReconcileUpdated},
{fmt.Sprintf(deprecated_label_addon_service, addonNsName), svcAddonDeprecatedLabel},
{fmt.Sprintf(deprecated_label_addon_service_updated, addonNsName), svcAddonDeprecatedLabelUpdated},
{fmt.Sprintf(ensure_exists_addon_service, addonNsName), svcAddonEnsureExists},
{fmt.Sprintf(ensure_exists_addon_service_updated, addonNsName), svcAddonEnsureExistsUpdated},
{fmt.Sprintf(invalid_addon_controller, addonNsName, serveHostnameImage), rcInvalid},
{fmt.Sprintf(reconcileAddonController, addonNsName, serveHostnameImage), rcAddonReconcile},
{fmt.Sprintf(reconcileAddonControllerUpdated, addonNsName, serveHostnameImage), rcAddonReconcileUpdated},
{fmt.Sprintf(deprecatedLabelAddonService, addonNsName), svcAddonDeprecatedLabel},
{fmt.Sprintf(deprecatedLabelAddonServiceUpdated, addonNsName), svcAddonDeprecatedLabelUpdated},
{fmt.Sprintf(ensureExistsAddonService, addonNsName), svcAddonEnsureExists},
{fmt.Sprintf(ensureExistsAddonServiceUpdated, addonNsName), svcAddonEnsureExistsUpdated},
{fmt.Sprintf(invalidAddonController, addonNsName, serveHostnameImage), rcInvalid},
}

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

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

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

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

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

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

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

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

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

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

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

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

func sshExec(client *ssh.Client, cmd string) (string, string, int, error) {
Expand Down
50 changes: 25 additions & 25 deletions test/e2e/lifecycle/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"k8s.io/kubernetes/test/e2e/upgrades/storage"
"k8s.io/kubernetes/test/utils/junit"

. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo"
)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

BeforeEach(func() {
ginkgo.BeforeEach(func() {
framework.SkipUnlessProviderIs("gce")
})

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

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

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

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

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

Expand Down Expand Up @@ -385,7 +385,7 @@ func (cma *chaosMonkeyAdapter) Test(sem *chaosmonkey.Semaphore) {
defer finalizeUpgradeTest(start, cma.testReport)
defer ready()
if skippable, ok := cma.test.(upgrades.Skippable); ok && skippable.Skip(cma.upgCtx) {
By("skipping test " + cma.test.Name())
ginkgo.By("skipping test " + cma.test.Name())
cma.testReport.Skipped = "skipping test " + cma.test.Name()
return
}
Expand Down
1 change: 1 addition & 0 deletions test/e2e/lifecycle/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package lifecycle

import "github.com/onsi/ginkgo"

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