Skip to content

Commit

Permalink
fix golint failure in e2e/common/[p-r]*
Browse files Browse the repository at this point in the history
  • Loading branch information
k-toyoda-pi committed May 26, 2019
1 parent 16d33c4 commit 028cd65
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 138 deletions.
15 changes: 8 additions & 7 deletions test/e2e/common/privileged.go
Expand Up @@ -19,14 +19,15 @@ package common
import (
"fmt"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/test/e2e/framework"
imageutils "k8s.io/kubernetes/test/utils/image"
)

// PrivilegedPodTestConfig is configuration struct for privileged pod test
type PrivilegedPodTestConfig struct {
f *framework.Framework

Expand All @@ -45,15 +46,15 @@ var _ = framework.KubeDescribe("PrivilegedPod [NodeConformance]", func() {
notPrivilegedContainer: "not-privileged-container",
}

It("should enable privileged commands [LinuxOnly]", func() {
ginkgo.It("should enable privileged commands [LinuxOnly]", func() {
// Windows does not support privileged containers.
By("Creating a pod with a privileged container")
ginkgo.By("Creating a pod with a privileged container")
config.createPods()

By("Executing in the privileged container")
ginkgo.By("Executing in the privileged container")
config.run(config.privilegedContainer, true)

By("Executing in the non-privileged container")
ginkgo.By("Executing in the non-privileged container")
config.run(config.notPrivilegedContainer, false)
})
})
Expand All @@ -75,7 +76,7 @@ func (c *PrivilegedPodTestConfig) run(containerName string, expectSuccess bool)
framework.ExpectNoError(err,
fmt.Sprintf("could not remove dummy1 link: %v", err))
} else {
Expect(err).To(HaveOccurred(), msg)
gomega.Expect(err).To(gomega.HaveOccurred(), msg)
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/e2e/common/projected_combined.go
Expand Up @@ -25,10 +25,10 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
imageutils "k8s.io/kubernetes/test/utils/image"

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

var _ = Describe("[sig-storage] Projected combined", func() {
var _ = ginkgo.Describe("[sig-storage] Projected combined", func() {
f := framework.NewDefaultFramework("projected")

// Test multiple projections
Expand Down Expand Up @@ -61,11 +61,11 @@ var _ = Describe("[sig-storage] Projected combined", func() {
},
}

By(fmt.Sprintf("Creating configMap with name %s", configMap.Name))
ginkgo.By(fmt.Sprintf("Creating configMap with name %s", configMap.Name))
if configMap, err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
}
By(fmt.Sprintf("Creating secret with name %s", secret.Name))
ginkgo.By(fmt.Sprintf("Creating secret with name %s", secret.Name))
if secret, err = f.ClientSet.CoreV1().Secrets(f.Namespace.Name).Create(secret); err != nil {
framework.Failf("unable to create test secret %s: %v", secret.Name, err)
}
Expand Down
64 changes: 32 additions & 32 deletions test/e2e/common/projected_configmap.go
Expand Up @@ -26,11 +26,11 @@ 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 _ = Describe("[sig-storage] Projected configMap", func() {
var _ = ginkgo.Describe("[sig-storage] Projected configMap", func() {
f := framework.NewDefaultFramework("projected")

/*
Expand All @@ -53,7 +53,7 @@ var _ = Describe("[sig-storage] Projected configMap", func() {
doProjectedConfigMapE2EWithoutMappings(f, 0, 0, &defaultMode)
})

It("should be consumable from pods in volume as non-root with defaultMode and fsGroup set [NodeFeature:FSGroup]", func() {
ginkgo.It("should be consumable from pods in volume as non-root with defaultMode and fsGroup set [NodeFeature:FSGroup]", func() {
defaultMode := int32(0440) /* setting fsGroup sets mode to at least 440 */
doProjectedConfigMapE2EWithoutMappings(f, 1000, 1001, &defaultMode)
})
Expand All @@ -68,7 +68,7 @@ var _ = Describe("[sig-storage] Projected configMap", func() {
doProjectedConfigMapE2EWithoutMappings(f, 1000, 0, nil)
})

It("should be consumable from pods in volume as non-root with FSGroup [NodeFeature:FSGroup]", func() {
ginkgo.It("should be consumable from pods in volume as non-root with FSGroup [NodeFeature:FSGroup]", func() {
doProjectedConfigMapE2EWithoutMappings(f, 1000, 1001, nil)
})

Expand Down Expand Up @@ -102,7 +102,7 @@ var _ = Describe("[sig-storage] Projected configMap", func() {
doProjectedConfigMapE2EWithMappings(f, 1000, 0, nil)
})

It("should be consumable from pods in volume with mappings as non-root with FSGroup [NodeFeature:FSGroup]", func() {
ginkgo.It("should be consumable from pods in volume with mappings as non-root with FSGroup [NodeFeature:FSGroup]", func() {
doProjectedConfigMapE2EWithMappings(f, 1000, 1001, nil)
})

Expand All @@ -129,7 +129,7 @@ var _ = Describe("[sig-storage] Projected configMap", func() {
},
}

By(fmt.Sprintf("Creating projection with configMap that has name %s", configMap.Name))
ginkgo.By(fmt.Sprintf("Creating projection with configMap that has name %s", configMap.Name))
var err error
if configMap, err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
Expand Down Expand Up @@ -175,23 +175,23 @@ var _ = Describe("[sig-storage] Projected configMap", func() {
RestartPolicy: v1.RestartPolicyNever,
},
}
By("Creating the pod")
ginkgo.By("Creating the pod")
f.PodClient().CreateSync(pod)

pollLogs := func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, containerName)
}

Eventually(pollLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("value-1"))
gomega.Eventually(pollLogs, podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("value-1"))

By(fmt.Sprintf("Updating configmap %v", configMap.Name))
ginkgo.By(fmt.Sprintf("Updating configmap %v", configMap.Name))
configMap.ResourceVersion = "" // to force update
configMap.Data["data-1"] = "value-2"
_, err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Update(configMap)
framework.ExpectNoError(err, "Failed to update configmap %q in namespace %q", configMap.Name, f.Namespace.Name)

By("waiting to observe update in volume")
Eventually(pollLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("value-2"))
ginkgo.By("waiting to observe update in volume")
gomega.Eventually(pollLogs, podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("value-2"))
})

/*
Expand Down Expand Up @@ -244,13 +244,13 @@ var _ = Describe("[sig-storage] Projected configMap", func() {
},
}

By(fmt.Sprintf("Creating configMap with name %s", deleteConfigMap.Name))
ginkgo.By(fmt.Sprintf("Creating configMap with name %s", deleteConfigMap.Name))
var err error
if deleteConfigMap, err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Create(deleteConfigMap); err != nil {
framework.Failf("unable to create test configMap %s: %v", deleteConfigMap.Name, err)
}

By(fmt.Sprintf("Creating configMap with name %s", updateConfigMap.Name))
ginkgo.By(fmt.Sprintf("Creating configMap with name %s", updateConfigMap.Name))
if updateConfigMap, err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Create(updateConfigMap); err != nil {
framework.Failf("unable to create test configMap %s: %v", updateConfigMap.Name, err)
}
Expand Down Expand Up @@ -354,45 +354,45 @@ var _ = Describe("[sig-storage] Projected configMap", func() {
RestartPolicy: v1.RestartPolicyNever,
},
}
By("Creating the pod")
ginkgo.By("Creating the pod")
f.PodClient().CreateSync(pod)

pollCreateLogs := func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, createContainerName)
}
Eventually(pollCreateLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("Error reading file /etc/projected-configmap-volumes/create/data-1"))
gomega.Eventually(pollCreateLogs, podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("Error reading file /etc/projected-configmap-volumes/create/data-1"))

pollUpdateLogs := func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, updateContainerName)
}
Eventually(pollUpdateLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("Error reading file /etc/projected-configmap-volumes/update/data-3"))
gomega.Eventually(pollUpdateLogs, podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("Error reading file /etc/projected-configmap-volumes/update/data-3"))

pollDeleteLogs := func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, deleteContainerName)
}
Eventually(pollDeleteLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("value-1"))
gomega.Eventually(pollDeleteLogs, podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("value-1"))

By(fmt.Sprintf("Deleting configmap %v", deleteConfigMap.Name))
ginkgo.By(fmt.Sprintf("Deleting configmap %v", deleteConfigMap.Name))
err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Delete(deleteConfigMap.Name, &metav1.DeleteOptions{})
framework.ExpectNoError(err, "Failed to delete configmap %q in namespace %q", deleteConfigMap.Name, f.Namespace.Name)

By(fmt.Sprintf("Updating configmap %v", updateConfigMap.Name))
ginkgo.By(fmt.Sprintf("Updating configmap %v", updateConfigMap.Name))
updateConfigMap.ResourceVersion = "" // to force update
delete(updateConfigMap.Data, "data-1")
updateConfigMap.Data["data-3"] = "value-3"
_, err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Update(updateConfigMap)
framework.ExpectNoError(err, "Failed to update configmap %q in namespace %q", updateConfigMap.Name, f.Namespace.Name)

By(fmt.Sprintf("Creating configMap with name %s", createConfigMap.Name))
ginkgo.By(fmt.Sprintf("Creating configMap with name %s", createConfigMap.Name))
if createConfigMap, err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Create(createConfigMap); err != nil {
framework.Failf("unable to create test configMap %s: %v", createConfigMap.Name, err)
}

By("waiting to observe update in volume")
ginkgo.By("waiting to observe update in volume")

Eventually(pollCreateLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("value-1"))
Eventually(pollUpdateLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("value-3"))
Eventually(pollDeleteLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("Error reading file /etc/projected-configmap-volumes/delete/data-1"))
gomega.Eventually(pollCreateLogs, podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("value-1"))
gomega.Eventually(pollUpdateLogs, podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("value-3"))
gomega.Eventually(pollDeleteLogs, podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("Error reading file /etc/projected-configmap-volumes/delete/data-1"))
})

/*
Expand All @@ -410,7 +410,7 @@ var _ = Describe("[sig-storage] Projected configMap", func() {
configMap = newConfigMap(f, name)
)

By(fmt.Sprintf("Creating configMap with name %s", configMap.Name))
ginkgo.By(fmt.Sprintf("Creating configMap with name %s", configMap.Name))
var err error
if configMap, err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
Expand Down Expand Up @@ -488,21 +488,21 @@ var _ = Describe("[sig-storage] Projected configMap", func() {
//The pod is in pending during volume creation until the configMap objects are available
//or until mount the configMap volume times out. There is no configMap object defined for the pod, so it should return timout exception unless it is marked optional.
//Slow (~5 mins)
It("Should fail non-optional pod creation due to configMap object does not exist [Slow]", func() {
ginkgo.It("Should fail non-optional pod creation due to configMap object does not exist [Slow]", func() {
volumeMountPath := "/etc/projected-configmap-volumes"
podName := "pod-projected-configmaps-" + string(uuid.NewUUID())
err := createNonOptionalConfigMapPod(f, volumeMountPath, podName)
Expect(err).To(HaveOccurred(), "created pod %q with non-optional configMap in namespace %q", podName, f.Namespace.Name)
gomega.Expect(err).To(gomega.HaveOccurred(), "created pod %q with non-optional configMap in namespace %q", podName, f.Namespace.Name)
})

//ConfigMap object defined for the pod, If a key is specified which is not present in the ConfigMap,
// the volume setup will error unless it is marked optional, during the pod creation.
//Slow (~5 mins)
It("Should fail non-optional pod creation due to the key in the configMap object does not exist [Slow]", func() {
ginkgo.It("Should fail non-optional pod creation due to the key in the configMap object does not exist [Slow]", func() {
volumeMountPath := "/etc/configmap-volumes"
podName := "pod-configmaps-" + string(uuid.NewUUID())
err := createNonOptionalConfigMapPodWithConfig(f, volumeMountPath, podName)
Expect(err).To(HaveOccurred(), "created pod %q with non-optional configMap in namespace %q", podName, f.Namespace.Name)
gomega.Expect(err).To(gomega.HaveOccurred(), "created pod %q with non-optional configMap in namespace %q", podName, f.Namespace.Name)
})
})

Expand All @@ -517,7 +517,7 @@ func doProjectedConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup
configMap = newConfigMap(f, name)
)

By(fmt.Sprintf("Creating configMap with name %s", configMap.Name))
ginkgo.By(fmt.Sprintf("Creating configMap with name %s", configMap.Name))
var err error
if configMap, err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
Expand Down Expand Up @@ -598,7 +598,7 @@ func doProjectedConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup in
configMap = newConfigMap(f, name)
)

By(fmt.Sprintf("Creating configMap with name %s", configMap.Name))
ginkgo.By(fmt.Sprintf("Creating configMap with name %s", configMap.Name))

var err error
if configMap, err = f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
Expand Down
32 changes: 16 additions & 16 deletions test/e2e/common/projected_downwardapi.go
Expand Up @@ -26,17 +26,17 @@ 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 _ = Describe("[sig-storage] Projected downwardAPI", func() {
var _ = ginkgo.Describe("[sig-storage] Projected downwardAPI", func() {
f := framework.NewDefaultFramework("projected")

// How long to wait for a log pod to be displayed
const podLogTimeout = 2 * time.Minute
var podClient *framework.PodClient
BeforeEach(func() {
ginkgo.BeforeEach(func() {
podClient = f.PodClient()
})

Expand Down Expand Up @@ -86,7 +86,7 @@ var _ = Describe("[sig-storage] Projected downwardAPI", func() {
})
})

It("should provide podname as non-root with fsgroup [NodeFeature:FSGroup]", func() {
ginkgo.It("should provide podname as non-root with fsgroup [NodeFeature:FSGroup]", func() {
podName := "metadata-volume-" + string(uuid.NewUUID())
uid := int64(1001)
gid := int64(1234)
Expand All @@ -100,7 +100,7 @@ var _ = Describe("[sig-storage] Projected downwardAPI", func() {
})
})

It("should provide podname as non-root with fsgroup and defaultMode [NodeFeature:FSGroup]", func() {
ginkgo.It("should provide podname as non-root with fsgroup and defaultMode [NodeFeature:FSGroup]", func() {
podName := "metadata-volume-" + string(uuid.NewUUID())
uid := int64(1001)
gid := int64(1234)
Expand Down Expand Up @@ -128,23 +128,23 @@ var _ = Describe("[sig-storage] Projected downwardAPI", func() {
podName := "labelsupdate" + string(uuid.NewUUID())
pod := projectedDownwardAPIVolumePodForUpdateTest(podName, labels, map[string]string{}, "/etc/podinfo/labels")
containerName := "client-container"
By("Creating the pod")
ginkgo.By("Creating the pod")
podClient.CreateSync(pod)

Eventually(func() (string, error) {
gomega.Eventually(func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, containerName)
},
podLogTimeout, framework.Poll).Should(ContainSubstring("key1=\"value1\"\n"))
podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("key1=\"value1\"\n"))

//modify labels
podClient.Update(podName, func(pod *v1.Pod) {
pod.Labels["key3"] = "value3"
})

Eventually(func() (string, error) {
gomega.Eventually(func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, containerName)
},
podLogTimeout, framework.Poll).Should(ContainSubstring("key3=\"value3\"\n"))
podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("key3=\"value3\"\n"))
})

/*
Expand All @@ -159,26 +159,26 @@ var _ = Describe("[sig-storage] Projected downwardAPI", func() {
pod := projectedDownwardAPIVolumePodForUpdateTest(podName, map[string]string{}, annotations, "/etc/podinfo/annotations")

containerName := "client-container"
By("Creating the pod")
ginkgo.By("Creating the pod")
podClient.CreateSync(pod)

pod, err := podClient.Get(pod.Name, metav1.GetOptions{})
framework.ExpectNoError(err, "Failed to get pod %q", pod.Name)

Eventually(func() (string, error) {
gomega.Eventually(func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, containerName)
},
podLogTimeout, framework.Poll).Should(ContainSubstring("builder=\"bar\"\n"))
podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("builder=\"bar\"\n"))

//modify annotations
podClient.Update(podName, func(pod *v1.Pod) {
pod.Annotations["builder"] = "foo"
})

Eventually(func() (string, error) {
gomega.Eventually(func() (string, error) {
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, containerName)
},
podLogTimeout, framework.Poll).Should(ContainSubstring("builder=\"foo\"\n"))
podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("builder=\"foo\"\n"))
})

/*
Expand Down

0 comments on commit 028cd65

Please sign in to comment.