Skip to content

Commit 6322025

Browse files
committed
fix golint failures for test/e2e/upgrades
1 parent 7c8498a commit 6322025

14 files changed

+184
-168
lines changed

hack/.golint_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,6 @@ test/e2e/storage/testsuites
687687
test/e2e/storage/utils
688688
test/e2e/storage/vsphere
689689
test/e2e/ui
690-
test/e2e/upgrades
691690
test/e2e/windows
692691
test/e2e_kubeadm
693692
test/e2e_node

test/e2e/lifecycle/cluster_upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var gpuUpgradeTests = []upgrades.Test{
6666
}
6767

6868
var statefulsetUpgradeTests = []upgrades.Test{
69-
&upgrades.MySqlUpgradeTest{},
69+
&upgrades.MySQLUpgradeTest{},
7070
&upgrades.EtcdUpgradeTest{},
7171
&upgrades.CassandraUpgradeTest{},
7272
}

test/e2e/upgrades/apparmor.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"k8s.io/kubernetes/test/e2e/common"
2323
"k8s.io/kubernetes/test/e2e/framework"
2424

25-
. "github.com/onsi/ginkgo"
26-
. "github.com/onsi/gomega"
25+
"github.com/onsi/ginkgo"
26+
"github.com/onsi/gomega"
2727
"github.com/onsi/gomega/gstruct"
2828
)
2929

@@ -32,8 +32,10 @@ type AppArmorUpgradeTest struct {
3232
pod *api.Pod
3333
}
3434

35+
// Name returns the tracking name of the test.
3536
func (AppArmorUpgradeTest) Name() string { return "apparmor-upgrade" }
3637

38+
// Skip returns true when this test can be skipped.
3739
func (AppArmorUpgradeTest) Skip(upgCtx UpgradeContext) bool {
3840
supportedImages := make(map[string]bool)
3941
for _, d := range common.AppArmorDistros {
@@ -50,11 +52,11 @@ func (AppArmorUpgradeTest) Skip(upgCtx UpgradeContext) bool {
5052

5153
// Setup creates a secret and then verifies that a pod can consume it.
5254
func (t *AppArmorUpgradeTest) Setup(f *framework.Framework) {
53-
By("Loading AppArmor profiles to nodes")
55+
ginkgo.By("Loading AppArmor profiles to nodes")
5456
common.LoadAppArmorProfiles(f)
5557

5658
// Create the initial test pod.
57-
By("Creating a long-running AppArmor enabled pod.")
59+
ginkgo.By("Creating a long-running AppArmor enabled pod.")
5860
t.pod = common.CreateAppArmorTestPod(f, false, false)
5961

6062
// Verify initial state.
@@ -76,32 +78,32 @@ func (t *AppArmorUpgradeTest) Test(f *framework.Framework, done <-chan struct{},
7678
// Teardown cleans up any remaining resources.
7779
func (t *AppArmorUpgradeTest) Teardown(f *framework.Framework) {
7880
// rely on the namespace deletion to clean up everything
79-
By("Logging container failures")
81+
ginkgo.By("Logging container failures")
8082
framework.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf)
8183
}
8284

8385
func (t *AppArmorUpgradeTest) verifyPodStillUp(f *framework.Framework) {
84-
By("Verifying an AppArmor profile is continuously enforced for a pod")
86+
ginkgo.By("Verifying an AppArmor profile is continuously enforced for a pod")
8587
pod, err := f.PodClient().Get(t.pod.Name, metav1.GetOptions{})
8688
framework.ExpectNoError(err, "Should be able to get pod")
87-
Expect(pod.Status.Phase).To(Equal(api.PodRunning), "Pod should stay running")
88-
Expect(pod.Status.ContainerStatuses[0].State.Running).NotTo(BeNil(), "Container should be running")
89-
Expect(pod.Status.ContainerStatuses[0].RestartCount).To(BeZero(), "Container should not need to be restarted")
89+
gomega.Expect(pod.Status.Phase).To(gomega.Equal(api.PodRunning), "Pod should stay running")
90+
gomega.Expect(pod.Status.ContainerStatuses[0].State.Running).NotTo(gomega.BeNil(), "Container should be running")
91+
gomega.Expect(pod.Status.ContainerStatuses[0].RestartCount).To(gomega.BeZero(), "Container should not need to be restarted")
9092
}
9193

9294
func (t *AppArmorUpgradeTest) verifyNewPodSucceeds(f *framework.Framework) {
93-
By("Verifying an AppArmor profile is enforced for a new pod")
95+
ginkgo.By("Verifying an AppArmor profile is enforced for a new pod")
9496
common.CreateAppArmorTestPod(f, false, true)
9597
}
9698

9799
func (t *AppArmorUpgradeTest) verifyNodesAppArmorEnabled(f *framework.Framework) {
98-
By("Verifying nodes are AppArmor enabled")
100+
ginkgo.By("Verifying nodes are AppArmor enabled")
99101
nodes, err := f.ClientSet.CoreV1().Nodes().List(metav1.ListOptions{})
100102
framework.ExpectNoError(err, "Failed to list nodes")
101103
for _, node := range nodes.Items {
102-
Expect(node.Status.Conditions).To(gstruct.MatchElements(conditionType, gstruct.IgnoreExtras, gstruct.Elements{
104+
gomega.Expect(node.Status.Conditions).To(gstruct.MatchElements(conditionType, gstruct.IgnoreExtras, gstruct.Elements{
103105
"Ready": gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{
104-
"Message": ContainSubstring("AppArmor enabled"),
106+
"Message": gomega.ContainSubstring("AppArmor enabled"),
105107
}),
106108
}))
107109
}

test/e2e/upgrades/cassandra.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"sync"
2626
"time"
2727

28-
. "github.com/onsi/ginkgo"
29-
. "github.com/onsi/gomega"
28+
"github.com/onsi/ginkgo"
29+
"github.com/onsi/gomega"
3030

3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
"k8s.io/apimachinery/pkg/util/version"
@@ -60,7 +60,7 @@ func (CassandraUpgradeTest) Skip(upgCtx UpgradeContext) bool {
6060
}
6161

6262
func cassandraKubectlCreate(ns, file string) {
63-
input := string(testfiles.ReadOrDie(filepath.Join(cassandraManifestPath, file), Fail))
63+
input := string(testfiles.ReadOrDie(filepath.Join(cassandraManifestPath, file), ginkgo.Fail))
6464
framework.RunKubectlOrDieInput(input, "create", "-f", "-", fmt.Sprintf("--namespace=%s", ns))
6565
}
6666

@@ -75,16 +75,16 @@ func (t *CassandraUpgradeTest) Setup(f *framework.Framework) {
7575
statefulsetTimeout := 10 * time.Minute
7676
t.ssTester = framework.NewStatefulSetTester(f.ClientSet)
7777

78-
By("Creating a PDB")
78+
ginkgo.By("Creating a PDB")
7979
cassandraKubectlCreate(ns, "pdb.yaml")
8080

81-
By("Creating a Cassandra StatefulSet")
81+
ginkgo.By("Creating a Cassandra StatefulSet")
8282
t.ssTester.CreateStatefulSet(cassandraManifestPath, ns)
8383

84-
By("Creating a cassandra-test-server deployment")
84+
ginkgo.By("Creating a cassandra-test-server deployment")
8585
cassandraKubectlCreate(ns, "tester.yaml")
8686

87-
By("Getting the ingress IPs from the services")
87+
ginkgo.By("Getting the ingress IPs from the services")
8888
err := wait.PollImmediate(statefulsetPoll, statefulsetTimeout, func() (bool, error) {
8989
if t.ip = t.getServiceIP(f, ns, "test-server"); t.ip == "" {
9090
return false, nil
@@ -95,18 +95,18 @@ func (t *CassandraUpgradeTest) Setup(f *framework.Framework) {
9595
}
9696
return true, nil
9797
})
98-
Expect(err).NotTo(HaveOccurred())
98+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
9999
framework.Logf("Service endpoint is up")
100100

101-
By("Adding 2 dummy users")
102-
Expect(t.addUser("Alice")).NotTo(HaveOccurred())
103-
Expect(t.addUser("Bob")).NotTo(HaveOccurred())
101+
ginkgo.By("Adding 2 dummy users")
102+
gomega.Expect(t.addUser("Alice")).NotTo(gomega.HaveOccurred())
103+
gomega.Expect(t.addUser("Bob")).NotTo(gomega.HaveOccurred())
104104
t.successfulWrites = 2
105105

106-
By("Verifying that the users exist")
106+
ginkgo.By("Verifying that the users exist")
107107
users, err := t.listUsers()
108-
Expect(err).NotTo(HaveOccurred())
109-
Expect(len(users)).To(Equal(2))
108+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
109+
gomega.Expect(len(users)).To(gomega.Equal(2))
110110
}
111111

112112
// listUsers gets a list of users from the db via the tester service.
@@ -151,7 +151,7 @@ func (t *CassandraUpgradeTest) addUser(name string) error {
151151
// getServiceIP is a helper method to extract the Ingress IP from the service.
152152
func (t *CassandraUpgradeTest) getServiceIP(f *framework.Framework, ns, svcName string) string {
153153
svc, err := f.ClientSet.CoreV1().Services(ns).Get(svcName, metav1.GetOptions{})
154-
Expect(err).NotTo(HaveOccurred())
154+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
155155
ingress := svc.Status.LoadBalancer.Ingress
156156
if len(ingress) == 0 {
157157
return ""
@@ -165,7 +165,7 @@ func (t *CassandraUpgradeTest) getServiceIP(f *framework.Framework, ns, svcName
165165
// ratio is over a certain threshold (0.75). We also verify that we get
166166
// at least the same number of rows back as we successfully wrote.
167167
func (t *CassandraUpgradeTest) Test(f *framework.Framework, done <-chan struct{}, upgrade UpgradeType) {
168-
By("Continuously polling the database during upgrade.")
168+
ginkgo.By("Continuously polling the database during upgrade.")
169169
var (
170170
success, failures, writeAttempts, lastUserCount int
171171
mu sync.Mutex
@@ -199,19 +199,19 @@ func (t *CassandraUpgradeTest) Test(f *framework.Framework, done <-chan struct{}
199199
}, 10*time.Millisecond, done)
200200
framework.Logf("got %d users; want >=%d", lastUserCount, t.successfulWrites)
201201

202-
Expect(lastUserCount >= t.successfulWrites).To(BeTrue())
202+
gomega.Expect(lastUserCount >= t.successfulWrites).To(gomega.BeTrue())
203203
ratio := float64(success) / float64(success+failures)
204204
framework.Logf("Successful gets %d/%d=%v", success, success+failures, ratio)
205205
ratio = float64(t.successfulWrites) / float64(writeAttempts)
206206
framework.Logf("Successful writes %d/%d=%v", t.successfulWrites, writeAttempts, ratio)
207207
framework.Logf("Errors: %v", errors)
208208
// TODO(maisem): tweak this value once we have a few test runs.
209-
Expect(ratio > 0.75).To(BeTrue())
209+
gomega.Expect(ratio > 0.75).To(gomega.BeTrue())
210210
}
211211

212212
// Teardown does one final check of the data's availability.
213213
func (t *CassandraUpgradeTest) Teardown(f *framework.Framework) {
214214
users, err := t.listUsers()
215-
Expect(err).NotTo(HaveOccurred())
216-
Expect(len(users) >= t.successfulWrites).To(BeTrue())
215+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
216+
gomega.Expect(len(users) >= t.successfulWrites).To(gomega.BeTrue())
217217
}

test/e2e/upgrades/configmaps.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"k8s.io/kubernetes/test/e2e/framework"
2525
imageutils "k8s.io/kubernetes/test/utils/image"
2626

27-
. "github.com/onsi/ginkgo"
27+
"github.com/onsi/ginkgo"
2828
"k8s.io/apimachinery/pkg/util/uuid"
2929
)
3030

@@ -34,6 +34,7 @@ type ConfigMapUpgradeTest struct {
3434
configMap *v1.ConfigMap
3535
}
3636

37+
// Name returns the tracking name of the test.
3738
func (ConfigMapUpgradeTest) Name() string {
3839
return "[sig-storage] [sig-api-machinery] configmap-upgrade"
3940
}
@@ -54,21 +55,21 @@ func (t *ConfigMapUpgradeTest) Setup(f *framework.Framework) {
5455
},
5556
}
5657

57-
By("Creating a ConfigMap")
58+
ginkgo.By("Creating a ConfigMap")
5859
var err error
5960
if t.configMap, err = f.ClientSet.CoreV1().ConfigMaps(ns.Name).Create(t.configMap); err != nil {
6061
framework.Failf("unable to create test ConfigMap %s: %v", t.configMap.Name, err)
6162
}
6263

63-
By("Making sure the ConfigMap is consumable")
64+
ginkgo.By("Making sure the ConfigMap is consumable")
6465
t.testPod(f)
6566
}
6667

6768
// Test waits for the upgrade to complete, and then verifies that a
6869
// pod can still consume the ConfigMap.
6970
func (t *ConfigMapUpgradeTest) Test(f *framework.Framework, done <-chan struct{}, upgrade UpgradeType) {
7071
<-done
71-
By("Consuming the ConfigMap after upgrade")
72+
ginkgo.By("Consuming the ConfigMap after upgrade")
7273
t.testPod(f)
7374
}
7475

test/e2e/upgrades/etcd.go

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"sync"
2626
"time"
2727

28-
. "github.com/onsi/ginkgo"
29-
. "github.com/onsi/gomega"
28+
"github.com/onsi/ginkgo"
29+
"github.com/onsi/gomega"
3030

3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
"k8s.io/apimachinery/pkg/util/version"
@@ -37,14 +37,17 @@ import (
3737

3838
const manifestPath = "test/e2e/testing-manifests/statefulset/etcd"
3939

40+
// EtcdUpgradeTest tests that etcd is writable before and after a cluster upgrade.
4041
type EtcdUpgradeTest struct {
4142
ip string
4243
successfulWrites int
4344
ssTester *framework.StatefulSetTester
4445
}
4546

47+
// Name returns the tracking name of the test.
4648
func (EtcdUpgradeTest) Name() string { return "etcd-upgrade" }
4749

50+
// Skip returns true when this test can be skipped.
4851
func (EtcdUpgradeTest) Skip(upgCtx UpgradeContext) bool {
4952
minVersion := version.MustParseSemantic("1.6.0")
5053
for _, vCtx := range upgCtx.Versions {
@@ -56,26 +59,27 @@ func (EtcdUpgradeTest) Skip(upgCtx UpgradeContext) bool {
5659
}
5760

5861
func kubectlCreate(ns, file string) {
59-
input := string(testfiles.ReadOrDie(filepath.Join(manifestPath, file), Fail))
62+
input := string(testfiles.ReadOrDie(filepath.Join(manifestPath, file), ginkgo.Fail))
6063
framework.RunKubectlOrDieInput(input, "create", "-f", "-", fmt.Sprintf("--namespace=%s", ns))
6164
}
6265

66+
// Setup creates etcd statefulset and then verifies that the etcd is writable.
6367
func (t *EtcdUpgradeTest) Setup(f *framework.Framework) {
6468
ns := f.Namespace.Name
6569
statefulsetPoll := 30 * time.Second
6670
statefulsetTimeout := 10 * time.Minute
6771
t.ssTester = framework.NewStatefulSetTester(f.ClientSet)
6872

69-
By("Creating a PDB")
73+
ginkgo.By("Creating a PDB")
7074
kubectlCreate(ns, "pdb.yaml")
7175

72-
By("Creating an etcd StatefulSet")
76+
ginkgo.By("Creating an etcd StatefulSet")
7377
t.ssTester.CreateStatefulSet(manifestPath, ns)
7478

75-
By("Creating an etcd--test-server deployment")
79+
ginkgo.By("Creating an etcd--test-server deployment")
7680
kubectlCreate(ns, "tester.yaml")
7781

78-
By("Getting the ingress IPs from the services")
82+
ginkgo.By("Getting the ingress IPs from the services")
7983
err := wait.PollImmediate(statefulsetPoll, statefulsetTimeout, func() (bool, error) {
8084
if t.ip = t.getServiceIP(f, ns, "test-server"); t.ip == "" {
8185
return false, nil
@@ -86,18 +90,18 @@ func (t *EtcdUpgradeTest) Setup(f *framework.Framework) {
8690
}
8791
return true, nil
8892
})
89-
Expect(err).NotTo(HaveOccurred())
93+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
9094
framework.Logf("Service endpoint is up")
9195

92-
By("Adding 2 dummy users")
93-
Expect(t.addUser("Alice")).NotTo(HaveOccurred())
94-
Expect(t.addUser("Bob")).NotTo(HaveOccurred())
96+
ginkgo.By("Adding 2 dummy users")
97+
gomega.Expect(t.addUser("Alice")).NotTo(gomega.HaveOccurred())
98+
gomega.Expect(t.addUser("Bob")).NotTo(gomega.HaveOccurred())
9599
t.successfulWrites = 2
96100

97-
By("Verifying that the users exist")
101+
ginkgo.By("Verifying that the users exist")
98102
users, err := t.listUsers()
99-
Expect(err).NotTo(HaveOccurred())
100-
Expect(len(users)).To(Equal(2))
103+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
104+
gomega.Expect(len(users)).To(gomega.Equal(2))
101105
}
102106

103107
func (t *EtcdUpgradeTest) listUsers() ([]string, error) {
@@ -139,16 +143,17 @@ func (t *EtcdUpgradeTest) addUser(name string) error {
139143

140144
func (t *EtcdUpgradeTest) getServiceIP(f *framework.Framework, ns, svcName string) string {
141145
svc, err := f.ClientSet.CoreV1().Services(ns).Get(svcName, metav1.GetOptions{})
142-
Expect(err).NotTo(HaveOccurred())
146+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
143147
ingress := svc.Status.LoadBalancer.Ingress
144148
if len(ingress) == 0 {
145149
return ""
146150
}
147151
return ingress[0].IP
148152
}
149153

154+
// Test waits for upgrade to complete and verifies if etcd is writable.
150155
func (t *EtcdUpgradeTest) Test(f *framework.Framework, done <-chan struct{}, upgrade UpgradeType) {
151-
By("Continuously polling the database during upgrade.")
156+
ginkgo.By("Continuously polling the database during upgrade.")
152157
var (
153158
success, failures, writeAttempts, lastUserCount int
154159
mu sync.Mutex
@@ -182,19 +187,19 @@ func (t *EtcdUpgradeTest) Test(f *framework.Framework, done <-chan struct{}, upg
182187
}, 10*time.Millisecond, done)
183188
framework.Logf("got %d users; want >=%d", lastUserCount, t.successfulWrites)
184189

185-
Expect(lastUserCount >= t.successfulWrites).To(BeTrue())
190+
gomega.Expect(lastUserCount >= t.successfulWrites).To(gomega.BeTrue())
186191
ratio := float64(success) / float64(success+failures)
187192
framework.Logf("Successful gets %d/%d=%v", success, success+failures, ratio)
188193
ratio = float64(t.successfulWrites) / float64(writeAttempts)
189194
framework.Logf("Successful writes %d/%d=%v", t.successfulWrites, writeAttempts, ratio)
190195
framework.Logf("Errors: %v", errors)
191196
// TODO(maisem): tweak this value once we have a few test runs.
192-
Expect(ratio > 0.75).To(BeTrue())
197+
gomega.Expect(ratio > 0.75).To(gomega.BeTrue())
193198
}
194199

195200
// Teardown does one final check of the data's availability.
196201
func (t *EtcdUpgradeTest) Teardown(f *framework.Framework) {
197202
users, err := t.listUsers()
198-
Expect(err).NotTo(HaveOccurred())
199-
Expect(len(users) >= t.successfulWrites).To(BeTrue())
203+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
204+
gomega.Expect(len(users) >= t.successfulWrites).To(gomega.BeTrue())
200205
}

0 commit comments

Comments
 (0)