Merge pull request #74487 from danielqsj/window

Fix golint failures for e2e/windows
pull/564/head
Kubernetes Prow Robot 2019-03-04 19:27:11 -08:00 committed by GitHub
commit e2f42845d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 56 deletions

View File

@ -658,7 +658,6 @@ test/e2e/storage/drivers
test/e2e/storage/testsuites
test/e2e/storage/utils
test/e2e/storage/vsphere
test/e2e/windows
test/e2e_kubeadm
test/e2e_node
test/e2e_node/builder

View File

@ -32,20 +32,20 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
imageutils "k8s.io/kubernetes/test/utils/image"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
)
var _ = SIGDescribe("[Feature:Windows] Density [Serial] [Slow]", func() {
f := framework.NewDefaultFramework("density-test-windows")
BeforeEach(func() {
ginkgo.BeforeEach(func() {
// NOTE(vyta): these tests are Windows specific
framework.SkipUnlessNodeOSDistroIs("windows")
})
Context("create a batch of pods", func() {
ginkgo.Context("create a batch of pods", func() {
// TODO(coufon): the values are generous, set more precise limits with benchmark data
// and add more tests
dTests := []densityTest{
@ -66,7 +66,7 @@ var _ = SIGDescribe("[Feature:Windows] Density [Serial] [Slow]", func() {
for _, testArg := range dTests {
itArg := testArg
desc := fmt.Sprintf("latency/resource should be within limit when create %d pods with %v interval", itArg.podsNr, itArg.interval)
It(desc, func() {
ginkgo.It(desc, func() {
itArg.createMethod = "batch"
runDensityBatchTest(f, itArg)
@ -114,15 +114,15 @@ func runDensityBatchTest(f *framework.Framework, testArg densityTest) (time.Dura
go controller.Run(stopCh)
defer close(stopCh)
By("Creating a batch of pods")
ginkgo.By("Creating a batch of pods")
// It returns a map['pod name']'creation time' containing the creation timestamps
createTimes := createBatchPodWithRateControl(f, pods, testArg.interval)
By("Waiting for all Pods to be observed by the watch...")
ginkgo.By("Waiting for all Pods to be observed by the watch...")
Eventually(func() bool {
gomega.Eventually(func() bool {
return len(watchTimes) == testArg.podsNr
}, 10*time.Minute, 10*time.Second).Should(BeTrue())
}, 10*time.Minute, 10*time.Second).Should(gomega.BeTrue())
if len(watchTimes) < testArg.podsNr {
framework.Failf("Timeout reached waiting for all Pods to be observed by the watch.")
@ -138,7 +138,7 @@ func runDensityBatchTest(f *framework.Framework, testArg densityTest) (time.Dura
for name, create := range createTimes {
watch, ok := watchTimes[name]
Expect(ok).To(Equal(true))
gomega.Expect(ok).To(gomega.Equal(true))
e2eLags = append(e2eLags,
framework.PodLatencyData{Name: name, Latency: watch.Time.Sub(create.Time)})
@ -182,7 +182,7 @@ func newInformerWatchPod(f *framework.Framework, mutex *sync.Mutex, watchTimes m
checkPodRunning := func(p *v1.Pod) {
mutex.Lock()
defer mutex.Unlock()
defer GinkgoRecover()
defer ginkgo.GinkgoRecover()
if p.Status.Phase == v1.PodRunning {
if _, found := watchTimes[p.Name]; !found {
@ -208,12 +208,12 @@ func newInformerWatchPod(f *framework.Framework, mutex *sync.Mutex, watchTimes m
cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
p, ok := obj.(*v1.Pod)
Expect(ok).To(Equal(true))
gomega.Expect(ok).To(gomega.Equal(true))
go checkPodRunning(p)
},
UpdateFunc: func(oldObj, newObj interface{}) {
p, ok := newObj.(*v1.Pod)
Expect(ok).To(Equal(true))
gomega.Expect(ok).To(gomega.Equal(true))
go checkPodRunning(p)
},
},
@ -288,14 +288,14 @@ func deletePodsSync(f *framework.Framework, pods []*v1.Pod) {
for _, pod := range pods {
wg.Add(1)
go func(pod *v1.Pod) {
defer GinkgoRecover()
defer ginkgo.GinkgoRecover()
defer wg.Done()
err := f.PodClient().Delete(pod.ObjectMeta.Name, metav1.NewDeleteOptions(30))
Expect(err).NotTo(HaveOccurred())
gomega.Expect(err).NotTo(gomega.HaveOccurred())
Expect(framework.WaitForPodToDisappear(f.ClientSet, f.Namespace.Name, pod.ObjectMeta.Name, labels.Everything(),
30*time.Second, 10*time.Minute)).NotTo(HaveOccurred())
gomega.Expect(framework.WaitForPodToDisappear(f.ClientSet, f.Namespace.Name, pod.ObjectMeta.Name, labels.Everything(),
30*time.Second, 10*time.Minute)).NotTo(gomega.HaveOccurred())
}(pod)
}
wg.Wait()

View File

@ -18,6 +18,7 @@ package windows
import "github.com/onsi/ginkgo"
// SIGDescribe annotates the test with the SIG label.
func SIGDescribe(text string, body func()) bool {
return ginkgo.Describe("[sig-windows] "+text, body)
}

View File

@ -25,8 +25,8 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
imageutils "k8s.io/kubernetes/test/utils/image"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
)
const (
@ -42,27 +42,27 @@ var (
var _ = SIGDescribe("Hybrid cluster network", func() {
f := framework.NewDefaultFramework("hybrid-network")
BeforeEach(func() {
ginkgo.BeforeEach(func() {
framework.SkipUnlessNodeOSDistroIs("windows")
})
Context("for all supported CNIs", func() {
ginkgo.Context("for all supported CNIs", func() {
It("should have stable networking for Linux and Windows pods", func() {
By("creating linux and windows pods")
ginkgo.It("should have stable networking for Linux and Windows pods", func() {
ginkgo.By("creating linux and windows pods")
linuxPod := createTestPod(f, linuxBusyBoxImage, linuxOS)
windowsPod := createTestPod(f, windowsBusyBoximage, windowsOS)
By("checking connectivity to 8.8.8.8 53 (google.com) from Linux")
ginkgo.By("checking connectivity to 8.8.8.8 53 (google.com) from Linux")
assertConsistentConnectivity(f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck("8.8.8.8", 53))
By("checking connectivity to www.google.com from Windows")
ginkgo.By("checking connectivity to www.google.com from Windows")
assertConsistentConnectivity(f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck("www.google.com"))
By("checking connectivity from Linux to Windows")
ginkgo.By("checking connectivity from Linux to Windows")
assertConsistentConnectivity(f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck(windowsPod.Status.PodIP, 80))
By("checking connectivity from Windows to Linux")
ginkgo.By("checking connectivity from Windows to Linux")
assertConsistentConnectivity(f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck(linuxPod.Status.PodIP))
})
@ -77,11 +77,11 @@ var (
)
func assertConsistentConnectivity(f *framework.Framework, podName string, os string, cmd []string) {
Consistently(func() error {
By(fmt.Sprintf("checking connectivity of %s-container in %s", os, podName))
gomega.Consistently(func() error {
ginkgo.By(fmt.Sprintf("checking connectivity of %s-container in %s", os, podName))
_, _, err := f.ExecCommandInContainerWithFullOutput(podName, os+"-container", cmd...)
return err
}, duration, pollInterval).ShouldNot(HaveOccurred())
}, duration, pollInterval).ShouldNot(gomega.HaveOccurred())
}
func linuxCheck(address string, port int) []string {

View File

@ -20,21 +20,21 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo"
)
// NOTE(claudiub): Spawning Pods With HostNetwork enabled is not currently supported by Windows Kubelet.
// TODO(claudiub): Remove this test suite once this PR merges:
// https://github.com/kubernetes/kubernetes/pull/69525
var _ = Describe("[sig-network] [sig-windows] Networking", func() {
var _ = ginkgo.Describe("[sig-network] [sig-windows] Networking", func() {
f := framework.NewDefaultFramework("pod-network-test")
BeforeEach(func() {
ginkgo.BeforeEach(func() {
// NOTE(claudiub): These tests are Windows specific.
framework.SkipUnlessNodeOSDistroIs("windows")
})
Describe("Granular Checks: Pods", func() {
ginkgo.Describe("Granular Checks: Pods", func() {
// Try to hit all endpoints through a test container, retry 5 times,
// expect exactly one unique hostname. Each of these endpoints reports
@ -45,7 +45,7 @@ var _ = Describe("[sig-network] [sig-windows] Networking", func() {
Description: Create a hostexec pod that is capable of curl to netcat commands. Create a test Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081 for udp. The netserver service proxies are created on specified number of nodes.
The kubectl exec on the webserver container MUST reach a http port on the each of service proxy endpoints in the cluster and the request MUST be successful. Container will execute curl command to reach the service port within specified max retry limit and MUST result in reporting unique hostnames.
*/
It("should function for intra-pod communication: http", func() {
ginkgo.It("should function for intra-pod communication: http", func() {
config := framework.NewCoreNetworkingTestConfig(f, false)
for _, endpointPod := range config.EndpointPods {
config.DialFromTestContainer("http", endpointPod.Status.PodIP, framework.EndpointHttpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
@ -58,7 +58,7 @@ var _ = Describe("[sig-network] [sig-windows] Networking", func() {
Description: Create a hostexec pod that is capable of curl to netcat commands. Create a test Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081 for udp. The netserver service proxies are created on specified number of nodes.
The kubectl exec on the webserver container MUST reach a udp port on the each of service proxy endpoints in the cluster and the request MUST be successful. Container will execute curl command to reach the service port within specified max retry limit and MUST result in reporting unique hostnames.
*/
It("should function for intra-pod communication: udp", func() {
ginkgo.It("should function for intra-pod communication: udp", func() {
config := framework.NewCoreNetworkingTestConfig(f, false)
for _, endpointPod := range config.EndpointPods {
config.DialFromTestContainer("udp", endpointPod.Status.PodIP, framework.EndpointUdpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
@ -71,7 +71,7 @@ var _ = Describe("[sig-network] [sig-windows] Networking", func() {
Description: Create a hostexec pod that is capable of curl to netcat commands. Create a test Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081 for udp. The netserver service proxies are created on specified number of nodes.
The kubectl exec on the webserver container MUST reach a http port on the each of service proxy endpoints in the cluster using a http post(protocol=tcp) and the request MUST be successful. Container will execute curl command to reach the service port within specified max retry limit and MUST result in reporting unique hostnames.
*/
It("should function for node-pod communication: http", func() {
ginkgo.It("should function for node-pod communication: http", func() {
config := framework.NewCoreNetworkingTestConfig(f, false)
for _, endpointPod := range config.EndpointPods {
config.DialFromNode("http", endpointPod.Status.PodIP, framework.EndpointHttpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
@ -84,7 +84,7 @@ var _ = Describe("[sig-network] [sig-windows] Networking", func() {
Description: Create a hostexec pod that is capable of curl to netcat commands. Create a test Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081 for udp. The netserver service proxies are created on specified number of nodes.
The kubectl exec on the webserver container MUST reach a http port on the each of service proxy endpoints in the cluster using a http post(protocol=udp) and the request MUST be successful. Container will execute curl command to reach the service port within specified max retry limit and MUST result in reporting unique hostnames.
*/
It("should function for node-pod communication: udp", func() {
ginkgo.It("should function for node-pod communication: udp", func() {
config := framework.NewCoreNetworkingTestConfig(f, false)
for _, endpointPod := range config.EndpointPods {
config.DialFromNode("udp", endpointPod.Status.PodIP, framework.EndpointUdpPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))

View File

@ -25,8 +25,8 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
imageutils "k8s.io/kubernetes/test/utils/image"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
)
const (
@ -55,27 +55,27 @@ var _ = SIGDescribe("Windows volume mounts ", func() {
},
}
)
BeforeEach(func() {
ginkgo.BeforeEach(func() {
framework.SkipUnlessNodeOSDistroIs("windows")
})
Context("check volume mount permissions", func() {
ginkgo.Context("check volume mount permissions", func() {
It("container should have readOnly permissions on emptyDir", func() {
ginkgo.It("container should have readOnly permissions on emptyDir", func() {
By("creating a container with readOnly permissions on emptyDir volume")
ginkgo.By("creating a container with readOnly permissions on emptyDir volume")
doReadOnlyTest(f, emptyDirSource, emptyDirVolumePath)
By("creating two containers, one with readOnly permissions the other with read-write permissions on emptyDir volume")
ginkgo.By("creating two containers, one with readOnly permissions the other with read-write permissions on emptyDir volume")
doReadWriteReadOnlyTest(f, emptyDirSource, emptyDirVolumePath)
})
It("container should have readOnly permissions on hostMapPath", func() {
ginkgo.It("container should have readOnly permissions on hostMapPath", func() {
By("creating a container with readOnly permissions on hostMap volume")
ginkgo.By("creating a container with readOnly permissions on hostMap volume")
doReadOnlyTest(f, hostMapSource, hostMapPath)
By("creating two containers, one with readOnly permissions the other with read-write permissions on hostMap volume")
ginkgo.By("creating two containers, one with readOnly permissions the other with read-write permissions on hostMap volume")
doReadWriteReadOnlyTest(f, hostMapSource, hostMapPath)
})
@ -95,7 +95,7 @@ func doReadOnlyTest(f *framework.Framework, source v1.VolumeSource, volumePath s
_, stderr, _ := f.ExecCommandInContainerWithFullOutput(podName, containerName, cmd...)
Expect(stderr).To(Equal("Access is denied."))
gomega.Expect(stderr).To(gomega.Equal("Access is denied."))
}
@ -123,18 +123,18 @@ func doReadWriteReadOnlyTest(f *framework.Framework, source v1.VolumeSource, vol
cmd := []string{"cmd", "/c", "echo windows-volume-test", ">", filePath}
stdout_rw, stderr_rw, err_rw := f.ExecCommandInContainerWithFullOutput(podName, rwcontainerName, cmd...)
msg := fmt.Sprintf("cmd: %v, stdout: %q, stderr: %q", cmd, stdout_rw, stderr_rw)
Expect(err_rw).NotTo(HaveOccurred(), msg)
stdoutRW, stderrRW, errRW := f.ExecCommandInContainerWithFullOutput(podName, rwcontainerName, cmd...)
msg := fmt.Sprintf("cmd: %v, stdout: %q, stderr: %q", cmd, stdoutRW, stderrRW)
gomega.Expect(errRW).NotTo(gomega.HaveOccurred(), msg)
_, stderr, _ := f.ExecCommandInContainerWithFullOutput(podName, containerName, cmd...)
Expect(stderr).To(Equal("Access is denied."))
gomega.Expect(stderr).To(gomega.Equal("Access is denied."))
readcmd := []string{"cmd", "/c", "type", filePath}
readout, readerr, err := f.ExecCommandInContainerWithFullOutput(podName, containerName, readcmd...)
readmsg := fmt.Sprintf("cmd: %v, stdout: %q, stderr: %q", readcmd, readout, readerr)
Expect(readout).To(Equal("windows-volume-test"))
Expect(err).NotTo(HaveOccurred(), readmsg)
gomega.Expect(readout).To(gomega.Equal("windows-volume-test"))
gomega.Expect(err).NotTo(gomega.HaveOccurred(), readmsg)
}
func testPodWithROVolume(podName string, source v1.VolumeSource, path string) *v1.Pod {