Skip to content

Commit 91bd1ac

Browse files
committed
fix golint failures of test/e2e/apimachinery
1 parent 9946d92 commit 91bd1ac

17 files changed

+890
-896
lines changed

hack/.golint_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,6 @@ staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder
632632
staging/src/k8s.io/sample-controller/pkg/apis/samplecontroller
633633
staging/src/k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1
634634
test/e2e
635-
test/e2e/apimachinery
636635
test/e2e/apps
637636
test/e2e/auth
638637
test/e2e/autoscaling

test/e2e/apimachinery/aggregator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import (
4444
samplev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1"
4545
"k8s.io/utils/pointer"
4646

47-
. "github.com/onsi/ginkgo"
47+
"github.com/onsi/ginkgo"
4848
)
4949

5050
var serverAggregatorVersion = utilversion.MustParseSemantic("v1.10.0")
@@ -62,7 +62,7 @@ var _ = SIGDescribe("Aggregator", func() {
6262
// We want cleanTest to happen before the namespace cleanup AfterEach
6363
// inserted by NewDefaultFramework, so we put this AfterEach in front
6464
// of NewDefaultFramework.
65-
AfterEach(func() {
65+
ginkgo.AfterEach(func() {
6666
cleanTest(c, aggrclient, ns)
6767
})
6868

@@ -71,7 +71,7 @@ var _ = SIGDescribe("Aggregator", func() {
7171
// We want namespace initialization BeforeEach inserted by
7272
// NewDefaultFramework to happen before this, so we put this BeforeEach
7373
// after NewDefaultFramework.
74-
BeforeEach(func() {
74+
ginkgo.BeforeEach(func() {
7575
c = f.ClientSet
7676
ns = f.Namespace.Name
7777
aggrclient = f.AggregatorClient
@@ -102,10 +102,10 @@ func cleanTest(client clientset.Interface, aggrclient *aggregatorclient.Clientse
102102
_ = client.RbacV1beta1().ClusterRoleBindings().Delete("wardler:"+namespace+":sample-apiserver-reader", nil)
103103
}
104104

105-
// A basic test if the sample-apiserver code from 1.10 and compiled against 1.10
105+
// TestSampleAPIServer is a basic test if the sample-apiserver code from 1.10 and compiled against 1.10
106106
// will work on the current Aggregator/API-Server.
107107
func TestSampleAPIServer(f *framework.Framework, image string) {
108-
By("Registering the sample API server.")
108+
ginkgo.By("Registering the sample API server.")
109109
client := f.ClientSet
110110
restClient := client.Discovery().RESTClient()
111111
aggrclient := f.AggregatorClient

test/e2e/apimachinery/chunking.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
"reflect"
2424
"time"
2525

26-
. "github.com/onsi/ginkgo"
27-
. "github.com/onsi/gomega"
26+
"github.com/onsi/ginkgo"
27+
"github.com/onsi/gomega"
2828

2929
"k8s.io/api/core/v1"
3030
"k8s.io/apimachinery/pkg/api/errors"
@@ -40,11 +40,11 @@ const numberOfTotalResources = 400
4040
var _ = SIGDescribe("Servers with support for API chunking", func() {
4141
f := framework.NewDefaultFramework("chunking")
4242

43-
BeforeEach(func() {
43+
ginkgo.BeforeEach(func() {
4444
ns := f.Namespace.Name
4545
c := f.ClientSet
4646
client := c.CoreV1().PodTemplates(ns)
47-
By("creating a large number of resources")
47+
ginkgo.By("creating a large number of resources")
4848
workqueue.ParallelizeUntil(context.TODO(), 20, numberOfTotalResources, func(i int) {
4949
for tries := 3; tries >= 0; tries-- {
5050
_, err := client.Create(&v1.PodTemplate{
@@ -64,65 +64,65 @@ var _ = SIGDescribe("Servers with support for API chunking", func() {
6464
}
6565
framework.Logf("Got an error creating template %d: %v", i, err)
6666
}
67-
Fail("Unable to create template %d, exiting", i)
67+
ginkgo.Fail("Unable to create template %d, exiting", i)
6868
})
6969
})
7070

71-
It("should return chunks of results for list calls", func() {
71+
ginkgo.It("should return chunks of results for list calls", func() {
7272
ns := f.Namespace.Name
7373
c := f.ClientSet
7474
client := c.CoreV1().PodTemplates(ns)
75-
By("retrieving those results in paged fashion several times")
75+
ginkgo.By("retrieving those results in paged fashion several times")
7676
for i := 0; i < 3; i++ {
7777
opts := metav1.ListOptions{}
7878
found := 0
7979
var lastRV string
8080
for {
8181
opts.Limit = int64(rand.Int31n(numberOfTotalResources/10) + 1)
8282
list, err := client.List(opts)
83-
Expect(err).ToNot(HaveOccurred(), "failed to list pod templates in namespace: %s, given limit: %d", ns, opts.Limit)
83+
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "failed to list pod templates in namespace: %s, given limit: %d", ns, opts.Limit)
8484
framework.Logf("Retrieved %d/%d results with rv %s and continue %s", len(list.Items), opts.Limit, list.ResourceVersion, list.Continue)
85-
Expect(len(list.Items)).To(BeNumerically("<=", opts.Limit))
85+
gomega.Expect(len(list.Items)).To(gomega.BeNumerically("<=", opts.Limit))
8686

8787
if len(lastRV) == 0 {
8888
lastRV = list.ResourceVersion
8989
}
90-
Expect(list.ResourceVersion).To(Equal(lastRV))
90+
gomega.Expect(list.ResourceVersion).To(gomega.Equal(lastRV))
9191
for _, item := range list.Items {
92-
Expect(item.Name).To(Equal(fmt.Sprintf("template-%04d", found)))
92+
gomega.Expect(item.Name).To(gomega.Equal(fmt.Sprintf("template-%04d", found)))
9393
found++
9494
}
9595
if len(list.Continue) == 0 {
9696
break
9797
}
9898
opts.Continue = list.Continue
9999
}
100-
Expect(found).To(BeNumerically("==", numberOfTotalResources))
100+
gomega.Expect(found).To(gomega.BeNumerically("==", numberOfTotalResources))
101101
}
102102

103-
By("retrieving those results all at once")
103+
ginkgo.By("retrieving those results all at once")
104104
opts := metav1.ListOptions{Limit: numberOfTotalResources + 1}
105105
list, err := client.List(opts)
106-
Expect(err).ToNot(HaveOccurred(), "failed to list pod templates in namespace: %s, given limit: %d", ns, opts.Limit)
107-
Expect(list.Items).To(HaveLen(numberOfTotalResources))
106+
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "failed to list pod templates in namespace: %s, given limit: %d", ns, opts.Limit)
107+
gomega.Expect(list.Items).To(gomega.HaveLen(numberOfTotalResources))
108108
})
109109

110-
It("should support continue listing from the last key if the original version has been compacted away, though the list is inconsistent", func() {
110+
ginkgo.It("should support continue listing from the last key if the original version has been compacted away, though the list is inconsistent", func() {
111111
ns := f.Namespace.Name
112112
c := f.ClientSet
113113
client := c.CoreV1().PodTemplates(ns)
114114

115-
By("retrieving the first page")
115+
ginkgo.By("retrieving the first page")
116116
oneTenth := int64(numberOfTotalResources / 10)
117117
opts := metav1.ListOptions{}
118118
opts.Limit = oneTenth
119119
list, err := client.List(opts)
120-
Expect(err).ToNot(HaveOccurred(), "failed to list pod templates in namespace: %s, given limit: %d", ns, opts.Limit)
120+
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "failed to list pod templates in namespace: %s, given limit: %d", ns, opts.Limit)
121121
firstToken := list.Continue
122122
firstRV := list.ResourceVersion
123123
framework.Logf("Retrieved %d/%d results with rv %s and continue %s", len(list.Items), opts.Limit, list.ResourceVersion, firstToken)
124124

125-
By("retrieving the second page until the token expires")
125+
ginkgo.By("retrieving the second page until the token expires")
126126
opts.Continue = firstToken
127127
var inconsistentToken string
128128
wait.Poll(20*time.Second, 2*storagebackend.DefaultCompactInterval, func() (bool, error) {
@@ -147,36 +147,36 @@ var _ = SIGDescribe("Servers with support for API chunking", func() {
147147
return true, nil
148148
})
149149

150-
By("retrieving the second page again with the token received with the error message")
150+
ginkgo.By("retrieving the second page again with the token received with the error message")
151151
opts.Continue = inconsistentToken
152152
list, err = client.List(opts)
153-
Expect(err).ToNot(HaveOccurred(), "failed to list pod templates in namespace: %s, given inconsistent continue token %s and limit: %d", ns, opts.Continue, opts.Limit)
154-
Expect(list.ResourceVersion).ToNot(Equal(firstRV))
155-
Expect(len(list.Items)).To(BeNumerically("==", opts.Limit))
153+
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "failed to list pod templates in namespace: %s, given inconsistent continue token %s and limit: %d", ns, opts.Continue, opts.Limit)
154+
gomega.Expect(list.ResourceVersion).ToNot(gomega.Equal(firstRV))
155+
gomega.Expect(len(list.Items)).To(gomega.BeNumerically("==", opts.Limit))
156156
found := oneTenth
157157
for _, item := range list.Items {
158-
Expect(item.Name).To(Equal(fmt.Sprintf("template-%04d", found)))
158+
gomega.Expect(item.Name).To(gomega.Equal(fmt.Sprintf("template-%04d", found)))
159159
found++
160160
}
161161

162-
By("retrieving all remaining pages")
162+
ginkgo.By("retrieving all remaining pages")
163163
opts.Continue = list.Continue
164164
lastRV := list.ResourceVersion
165165
for {
166166
list, err := client.List(opts)
167-
Expect(err).ToNot(HaveOccurred(), "failed to list pod templates in namespace: %s, given limit: %d", ns, opts.Limit)
167+
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "failed to list pod templates in namespace: %s, given limit: %d", ns, opts.Limit)
168168
framework.Logf("Retrieved %d/%d results with rv %s and continue %s", len(list.Items), opts.Limit, list.ResourceVersion, list.Continue)
169-
Expect(len(list.Items)).To(BeNumerically("<=", opts.Limit))
170-
Expect(list.ResourceVersion).To(Equal(lastRV))
169+
gomega.Expect(len(list.Items)).To(gomega.BeNumerically("<=", opts.Limit))
170+
gomega.Expect(list.ResourceVersion).To(gomega.Equal(lastRV))
171171
for _, item := range list.Items {
172-
Expect(item.Name).To(Equal(fmt.Sprintf("template-%04d", found)))
172+
gomega.Expect(item.Name).To(gomega.Equal(fmt.Sprintf("template-%04d", found)))
173173
found++
174174
}
175175
if len(list.Continue) == 0 {
176176
break
177177
}
178178
opts.Continue = list.Continue
179179
}
180-
Expect(found).To(BeNumerically("==", numberOfTotalResources))
180+
gomega.Expect(found).To(gomega.BeNumerically("==", numberOfTotalResources))
181181
})
182182
})

0 commit comments

Comments
 (0)