mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-06 19:52:42 +00:00
test: fix ginkgolinter issues
All of these issues were reported by https://github.com/nunnatsa/ginkgolinter. Fixing these issues is useful (several expressions get simpler, using framework.ExpectNoError is better because it has additional support for failures) and a necessary step for enabling that linter in our golangci-lint invocation.
This commit is contained in:
@@ -134,7 +134,7 @@ var _ = SIGDescribe("Kubelet", func() {
|
||||
*/
|
||||
framework.ConformanceIt("should be possible to delete [NodeConformance]", func(ctx context.Context) {
|
||||
err := podClient.Delete(ctx, podName, metav1.DeleteOptions{})
|
||||
gomega.Expect(err).To(gomega.BeNil(), fmt.Sprintf("Error deleting Pod %v", err))
|
||||
framework.ExpectNoError(err, "deleting Pod")
|
||||
})
|
||||
})
|
||||
ginkgo.Context("when scheduling an agnhost Pod with hostAliases", func() {
|
||||
|
@@ -64,7 +64,7 @@ var _ = SIGDescribe("NodeLease", func() {
|
||||
return nil
|
||||
}, 5*time.Minute, 5*time.Second).Should(gomega.BeNil())
|
||||
// check basic expectations for the lease
|
||||
gomega.Expect(expectLease(lease, nodeName)).To(gomega.BeNil())
|
||||
framework.ExpectNoError(expectLease(lease, nodeName))
|
||||
|
||||
ginkgo.By("check that node lease is updated at least once within the lease duration")
|
||||
gomega.Eventually(ctx, func() error {
|
||||
@@ -126,7 +126,7 @@ var _ = SIGDescribe("NodeLease", func() {
|
||||
return nil
|
||||
}, 5*time.Minute, 5*time.Second).Should(gomega.BeNil())
|
||||
// check basic expectations for the lease
|
||||
gomega.Expect(expectLease(lease, nodeName)).To(gomega.BeNil())
|
||||
framework.ExpectNoError(expectLease(lease, nodeName))
|
||||
leaseDuration := time.Duration(*lease.Spec.LeaseDurationSeconds) * time.Second
|
||||
|
||||
ginkgo.By("verify NodeStatus report period is longer than lease duration")
|
||||
|
@@ -148,11 +148,12 @@ var _ = SIGDescribe("Sysctls [LinuxOnly] [NodeConformance]", func() {
|
||||
client := f.ClientSet.CoreV1().Pods(f.Namespace.Name)
|
||||
_, err := client.Create(ctx, pod, metav1.CreateOptions{})
|
||||
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
gomega.Expect(err.Error()).To(gomega.ContainSubstring(`Invalid value: "foo-"`))
|
||||
gomega.Expect(err.Error()).To(gomega.ContainSubstring(`Invalid value: "bar.."`))
|
||||
gomega.Expect(err.Error()).NotTo(gomega.ContainSubstring(`safe-and-unsafe`))
|
||||
gomega.Expect(err.Error()).NotTo(gomega.ContainSubstring("kernel.shmmax"))
|
||||
gomega.Expect(err).To(gomega.MatchError(gomega.SatisfyAll(
|
||||
gomega.ContainSubstring(`Invalid value: "foo-"`),
|
||||
gomega.ContainSubstring(`Invalid value: "bar.."`),
|
||||
gomega.Not(gomega.ContainSubstring(`safe-and-unsafe`)),
|
||||
gomega.Not(gomega.ContainSubstring("kernel.shmmax")),
|
||||
)))
|
||||
})
|
||||
|
||||
// Pod is created with kernel.msgmax, an unsafe sysctl.
|
||||
|
Reference in New Issue
Block a user