mirror of https://github.com/k3s-io/k3s
Merge pull request #74586 from danielqsj/patch3
fix golint failures for test/e2e/cloud|kubectl|servicecatalogpull/564/head
commit
493b261057
|
@ -650,7 +650,6 @@ test/e2e/apps
|
|||
test/e2e/auth
|
||||
test/e2e/autoscaling
|
||||
test/e2e/chaosmonkey
|
||||
test/e2e/cloud
|
||||
test/e2e/common
|
||||
test/e2e/framework
|
||||
test/e2e/framework/providers/gce
|
||||
|
@ -658,14 +657,12 @@ test/e2e/framework/providers/kubemark
|
|||
test/e2e/instrumentation
|
||||
test/e2e/instrumentation/logging
|
||||
test/e2e/instrumentation/monitoring
|
||||
test/e2e/kubectl
|
||||
test/e2e/lifecycle
|
||||
test/e2e/lifecycle/bootstrap
|
||||
test/e2e/network
|
||||
test/e2e/node
|
||||
test/e2e/scalability
|
||||
test/e2e/scheduling
|
||||
test/e2e/servicecatalog
|
||||
test/e2e/storage
|
||||
test/e2e/storage/drivers
|
||||
test/e2e/storage/testsuites
|
||||
|
|
|
@ -18,6 +18,7 @@ package cloud
|
|||
|
||||
import "k8s.io/kubernetes/test/e2e/framework"
|
||||
|
||||
// SIGDescribe annotates the test with the SIG label.
|
||||
func SIGDescribe(text string, body func()) bool {
|
||||
return framework.KubeDescribe("[sig-cloud-provider] "+text, body)
|
||||
}
|
||||
|
|
|
@ -24,23 +24,23 @@ import (
|
|||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = SIGDescribe("[Feature:CloudProvider][Disruptive] Nodes", func() {
|
||||
f := framework.NewDefaultFramework("cloudprovider")
|
||||
var c clientset.Interface
|
||||
|
||||
BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func() {
|
||||
// Only supported in AWS/GCE because those are the only cloud providers
|
||||
// where E2E test are currently running.
|
||||
framework.SkipUnlessProviderIs("aws", "gce", "gke")
|
||||
c = f.ClientSet
|
||||
})
|
||||
|
||||
It("should be deleted on API server if it doesn't exist in the cloud provider", func() {
|
||||
By("deleting a node on the cloud provider")
|
||||
ginkgo.It("should be deleted on API server if it doesn't exist in the cloud provider", func() {
|
||||
ginkgo.By("deleting a node on the cloud provider")
|
||||
|
||||
nodeDeleteCandidates := framework.GetReadySchedulableNodesOrDie(c)
|
||||
nodeToDelete := nodeDeleteCandidates.Items[0]
|
||||
|
@ -54,8 +54,8 @@ var _ = SIGDescribe("[Feature:CloudProvider][Disruptive] Nodes", func() {
|
|||
}
|
||||
|
||||
newNodes, err := framework.CheckNodesReady(c, len(origNodes.Items)-1, 5*time.Minute)
|
||||
Expect(err).To(BeNil())
|
||||
Expect(len(newNodes)).To(Equal(len(origNodes.Items) - 1))
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
gomega.Expect(len(newNodes)).To(gomega.Equal(len(origNodes.Items) - 1))
|
||||
|
||||
_, err = c.CoreV1().Nodes().Get(nodeToDelete.Name, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
|
|
|
@ -18,6 +18,7 @@ package kubectl
|
|||
|
||||
import "github.com/onsi/ginkgo"
|
||||
|
||||
// SIGDescribe annotates the test with the SIG label.
|
||||
func SIGDescribe(text string, body func()) bool {
|
||||
return ginkgo.Describe("[sig-cli] "+text, body)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -39,8 +39,8 @@ import (
|
|||
testutils "k8s.io/kubernetes/test/utils"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -116,6 +116,7 @@ func pfPod(expectedClientData, chunks, chunkSize, chunkIntervalMillis string, bi
|
|||
}
|
||||
}
|
||||
|
||||
// WaitForTerminatedContainer wait till a given container be terminated for a given pod.
|
||||
func WaitForTerminatedContainer(f *framework.Framework, pod *v1.Pod, containerName string) error {
|
||||
return framework.WaitForPodCondition(f.ClientSet, f.Namespace.Name, pod.Name, "container terminated", framework.PodStartTimeout, func(pod *v1.Pod) (bool, error) {
|
||||
if len(testutils.TerminatedContainers(pod)[containerName]) > 0 {
|
||||
|
@ -199,7 +200,7 @@ func runPortForward(ns, podName string, port int) *portForwardCommand {
|
|||
}
|
||||
|
||||
func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
|
||||
By("Creating the target pod")
|
||||
ginkgo.By("Creating the target pod")
|
||||
pod := pfPod("", "10", "10", "100", fmt.Sprintf("%s", bindAddress))
|
||||
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
|
||||
framework.Failf("Couldn't create pod: %v", err)
|
||||
|
@ -208,21 +209,21 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
|
|||
framework.Failf("Pod did not start running: %v", err)
|
||||
}
|
||||
|
||||
By("Running 'kubectl port-forward'")
|
||||
ginkgo.By("Running 'kubectl port-forward'")
|
||||
cmd := runPortForward(f.Namespace.Name, pod.Name, 80)
|
||||
defer cmd.Stop()
|
||||
|
||||
By("Dialing the local port")
|
||||
ginkgo.By("Dialing the local port")
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port))
|
||||
if err != nil {
|
||||
framework.Failf("Couldn't connect to port %d: %v", cmd.port, err)
|
||||
}
|
||||
defer func() {
|
||||
By("Closing the connection to the local port")
|
||||
ginkgo.By("Closing the connection to the local port")
|
||||
conn.Close()
|
||||
}()
|
||||
|
||||
By("Reading data from the local port")
|
||||
ginkgo.By("Reading data from the local port")
|
||||
fromServer, err := ioutil.ReadAll(conn)
|
||||
if err != nil {
|
||||
framework.Failf("Unexpected error reading data from the server: %v", err)
|
||||
|
@ -232,22 +233,22 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
|
|||
framework.Failf("Expected %q from server, got %q", e, a)
|
||||
}
|
||||
|
||||
By("Waiting for the target pod to stop running")
|
||||
ginkgo.By("Waiting for the target pod to stop running")
|
||||
if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil {
|
||||
framework.Failf("Container did not terminate: %v", err)
|
||||
}
|
||||
|
||||
By("Verifying logs")
|
||||
Eventually(func() (string, error) {
|
||||
ginkgo.By("Verifying logs")
|
||||
gomega.Eventually(func() (string, error) {
|
||||
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester")
|
||||
}, postStartWaitTimeout, podCheckInterval).Should(SatisfyAll(
|
||||
ContainSubstring("Accepted client connection"),
|
||||
ContainSubstring("Done"),
|
||||
}, postStartWaitTimeout, podCheckInterval).Should(gomega.SatisfyAll(
|
||||
gomega.ContainSubstring("Accepted client connection"),
|
||||
gomega.ContainSubstring("Done"),
|
||||
))
|
||||
}
|
||||
|
||||
func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
|
||||
By("Creating the target pod")
|
||||
ginkgo.By("Creating the target pod")
|
||||
pod := pfPod("abc", "1", "1", "1", fmt.Sprintf("%s", bindAddress))
|
||||
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
|
||||
framework.Failf("Couldn't create pod: %v", err)
|
||||
|
@ -256,35 +257,35 @@ func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
|
|||
framework.Failf("Pod did not start running: %v", err)
|
||||
}
|
||||
|
||||
By("Running 'kubectl port-forward'")
|
||||
ginkgo.By("Running 'kubectl port-forward'")
|
||||
cmd := runPortForward(f.Namespace.Name, pod.Name, 80)
|
||||
defer cmd.Stop()
|
||||
|
||||
By("Dialing the local port")
|
||||
ginkgo.By("Dialing the local port")
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port))
|
||||
if err != nil {
|
||||
framework.Failf("Couldn't connect to port %d: %v", cmd.port, err)
|
||||
}
|
||||
|
||||
By("Closing the connection to the local port")
|
||||
ginkgo.By("Closing the connection to the local port")
|
||||
conn.Close()
|
||||
|
||||
By("Waiting for the target pod to stop running")
|
||||
ginkgo.By("Waiting for the target pod to stop running")
|
||||
if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil {
|
||||
framework.Failf("Container did not terminate: %v", err)
|
||||
}
|
||||
|
||||
By("Verifying logs")
|
||||
Eventually(func() (string, error) {
|
||||
ginkgo.By("Verifying logs")
|
||||
gomega.Eventually(func() (string, error) {
|
||||
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester")
|
||||
}, postStartWaitTimeout, podCheckInterval).Should(SatisfyAll(
|
||||
ContainSubstring("Accepted client connection"),
|
||||
ContainSubstring("Expected to read 3 bytes from client, but got 0 instead"),
|
||||
}, postStartWaitTimeout, podCheckInterval).Should(gomega.SatisfyAll(
|
||||
gomega.ContainSubstring("Accepted client connection"),
|
||||
gomega.ContainSubstring("Expected to read 3 bytes from client, but got 0 instead"),
|
||||
))
|
||||
}
|
||||
|
||||
func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework) {
|
||||
By("Creating the target pod")
|
||||
ginkgo.By("Creating the target pod")
|
||||
pod := pfPod("abc", "10", "10", "100", fmt.Sprintf("%s", bindAddress))
|
||||
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
|
||||
framework.Failf("Couldn't create pod: %v", err)
|
||||
|
@ -293,11 +294,11 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
|
|||
framework.Failf("Pod did not start running: %v", err)
|
||||
}
|
||||
|
||||
By("Running 'kubectl port-forward'")
|
||||
ginkgo.By("Running 'kubectl port-forward'")
|
||||
cmd := runPortForward(f.Namespace.Name, pod.Name, 80)
|
||||
defer cmd.Stop()
|
||||
|
||||
By("Dialing the local port")
|
||||
ginkgo.By("Dialing the local port")
|
||||
addr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port))
|
||||
if err != nil {
|
||||
framework.Failf("Error resolving tcp addr: %v", err)
|
||||
|
@ -307,17 +308,17 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
|
|||
framework.Failf("Couldn't connect to port %d: %v", cmd.port, err)
|
||||
}
|
||||
defer func() {
|
||||
By("Closing the connection to the local port")
|
||||
ginkgo.By("Closing the connection to the local port")
|
||||
conn.Close()
|
||||
}()
|
||||
|
||||
By("Sending the expected data to the local port")
|
||||
ginkgo.By("Sending the expected data to the local port")
|
||||
fmt.Fprint(conn, "abc")
|
||||
|
||||
By("Closing the write half of the client's connection")
|
||||
ginkgo.By("Closing the write half of the client's connection")
|
||||
conn.CloseWrite()
|
||||
|
||||
By("Reading data from the local port")
|
||||
ginkgo.By("Reading data from the local port")
|
||||
fromServer, err := ioutil.ReadAll(conn)
|
||||
if err != nil {
|
||||
framework.Failf("Unexpected error reading data from the server: %v", err)
|
||||
|
@ -327,26 +328,26 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
|
|||
framework.Failf("Expected %q from server, got %q", e, a)
|
||||
}
|
||||
|
||||
By("Waiting for the target pod to stop running")
|
||||
ginkgo.By("Waiting for the target pod to stop running")
|
||||
if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil {
|
||||
framework.Failf("Container did not terminate: %v", err)
|
||||
}
|
||||
|
||||
By("Verifying logs")
|
||||
Eventually(func() (string, error) {
|
||||
ginkgo.By("Verifying logs")
|
||||
gomega.Eventually(func() (string, error) {
|
||||
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester")
|
||||
}, postStartWaitTimeout, podCheckInterval).Should(SatisfyAll(
|
||||
ContainSubstring("Accepted client connection"),
|
||||
ContainSubstring("Received expected client data"),
|
||||
ContainSubstring("Done"),
|
||||
}, postStartWaitTimeout, podCheckInterval).Should(gomega.SatisfyAll(
|
||||
gomega.ContainSubstring("Accepted client connection"),
|
||||
gomega.ContainSubstring("Received expected client data"),
|
||||
gomega.ContainSubstring("Done"),
|
||||
))
|
||||
}
|
||||
|
||||
func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
|
||||
config, err := framework.LoadConfig()
|
||||
Expect(err).NotTo(HaveOccurred(), "unable to get base config")
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unable to get base config")
|
||||
|
||||
By("Creating the pod")
|
||||
ginkgo.By("Creating the pod")
|
||||
pod := pfPod("def", "10", "10", "100", fmt.Sprintf("%s", bindAddress))
|
||||
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
|
||||
framework.Failf("Couldn't create pod: %v", err)
|
||||
|
@ -369,7 +370,7 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
|
|||
}
|
||||
defer ws.Close()
|
||||
|
||||
Eventually(func() error {
|
||||
gomega.Eventually(func() error {
|
||||
channel, msg, err := wsRead(ws)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to read completely from websocket %s: %v", url.String(), err)
|
||||
|
@ -381,9 +382,9 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
|
|||
return fmt.Errorf("Received the wrong port: %d", p)
|
||||
}
|
||||
return nil
|
||||
}, time.Minute, 10*time.Second).Should(BeNil())
|
||||
}, time.Minute, 10*time.Second).Should(gomega.BeNil())
|
||||
|
||||
Eventually(func() error {
|
||||
gomega.Eventually(func() error {
|
||||
channel, msg, err := wsRead(ws)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to read completely from websocket %s: %v", url.String(), err)
|
||||
|
@ -395,18 +396,18 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
|
|||
return fmt.Errorf("Received the wrong port: %d", p)
|
||||
}
|
||||
return nil
|
||||
}, time.Minute, 10*time.Second).Should(BeNil())
|
||||
}, time.Minute, 10*time.Second).Should(gomega.BeNil())
|
||||
|
||||
By("Sending the expected data to the local port")
|
||||
ginkgo.By("Sending the expected data to the local port")
|
||||
err = wsWrite(ws, 0, []byte("def"))
|
||||
if err != nil {
|
||||
framework.Failf("Failed to write to websocket %s: %v", url.String(), err)
|
||||
}
|
||||
|
||||
By("Reading data from the local port")
|
||||
ginkgo.By("Reading data from the local port")
|
||||
buf := bytes.Buffer{}
|
||||
expectedData := bytes.Repeat([]byte("x"), 100)
|
||||
Eventually(func() error {
|
||||
gomega.Eventually(func() error {
|
||||
channel, msg, err := wsRead(ws)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to read completely from websocket %s: %v", url.String(), err)
|
||||
|
@ -419,14 +420,14 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
|
|||
return fmt.Errorf("Expected %q from server, got %q", expectedData, buf.Bytes())
|
||||
}
|
||||
return nil
|
||||
}, time.Minute, 10*time.Second).Should(BeNil())
|
||||
}, time.Minute, 10*time.Second).Should(gomega.BeNil())
|
||||
|
||||
By("Verifying logs")
|
||||
Eventually(func() (string, error) {
|
||||
ginkgo.By("Verifying logs")
|
||||
gomega.Eventually(func() (string, error) {
|
||||
return framework.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, "portforwardtester")
|
||||
}, postStartWaitTimeout, podCheckInterval).Should(SatisfyAll(
|
||||
ContainSubstring("Accepted client connection"),
|
||||
ContainSubstring("Received expected client data"),
|
||||
}, postStartWaitTimeout, podCheckInterval).Should(gomega.SatisfyAll(
|
||||
gomega.ContainSubstring("Accepted client connection"),
|
||||
gomega.ContainSubstring("Received expected client data"),
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -435,21 +436,21 @@ var _ = SIGDescribe("Kubectl Port forwarding", func() {
|
|||
|
||||
framework.KubeDescribe("With a server listening on 0.0.0.0", func() {
|
||||
framework.KubeDescribe("that expects a client request", func() {
|
||||
It("should support a client that connects, sends NO DATA, and disconnects", func() {
|
||||
ginkgo.It("should support a client that connects, sends NO DATA, and disconnects", func() {
|
||||
doTestMustConnectSendNothing("0.0.0.0", f)
|
||||
})
|
||||
It("should support a client that connects, sends DATA, and disconnects", func() {
|
||||
ginkgo.It("should support a client that connects, sends DATA, and disconnects", func() {
|
||||
doTestMustConnectSendDisconnect("0.0.0.0", f)
|
||||
})
|
||||
})
|
||||
|
||||
framework.KubeDescribe("that expects NO client request", func() {
|
||||
It("should support a client that connects, sends DATA, and disconnects", func() {
|
||||
ginkgo.It("should support a client that connects, sends DATA, and disconnects", func() {
|
||||
doTestConnectSendDisconnect("0.0.0.0", f)
|
||||
})
|
||||
})
|
||||
|
||||
It("should support forwarding over websockets", func() {
|
||||
ginkgo.It("should support forwarding over websockets", func() {
|
||||
doTestOverWebSockets("0.0.0.0", f)
|
||||
})
|
||||
})
|
||||
|
@ -457,21 +458,21 @@ var _ = SIGDescribe("Kubectl Port forwarding", func() {
|
|||
// kubectl port-forward may need elevated privileges to do its job.
|
||||
framework.KubeDescribe("With a server listening on localhost", func() {
|
||||
framework.KubeDescribe("that expects a client request", func() {
|
||||
It("should support a client that connects, sends NO DATA, and disconnects", func() {
|
||||
ginkgo.It("should support a client that connects, sends NO DATA, and disconnects", func() {
|
||||
doTestMustConnectSendNothing("localhost", f)
|
||||
})
|
||||
It("should support a client that connects, sends DATA, and disconnects", func() {
|
||||
ginkgo.It("should support a client that connects, sends DATA, and disconnects", func() {
|
||||
doTestMustConnectSendDisconnect("localhost", f)
|
||||
})
|
||||
})
|
||||
|
||||
framework.KubeDescribe("that expects NO client request", func() {
|
||||
It("should support a client that connects, sends DATA, and disconnects", func() {
|
||||
ginkgo.It("should support a client that connects, sends DATA, and disconnects", func() {
|
||||
doTestConnectSendDisconnect("localhost", f)
|
||||
})
|
||||
})
|
||||
|
||||
It("should support forwarding over websockets", func() {
|
||||
ginkgo.It("should support forwarding over websockets", func() {
|
||||
doTestOverWebSockets("localhost", f)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -18,6 +18,7 @@ package servicecatalog
|
|||
|
||||
import "github.com/onsi/ginkgo"
|
||||
|
||||
// SIGDescribe annotates the test with the SIG label.
|
||||
func SIGDescribe(text string, body func()) bool {
|
||||
return ginkgo.Describe("[sig-service-catalog] "+text, body)
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ import (
|
|||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
)
|
||||
|
||||
|
@ -39,7 +39,7 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
|
|||
f := framework.NewDefaultFramework("podpreset")
|
||||
|
||||
var podClient *framework.PodClient
|
||||
BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func() {
|
||||
// only run on gce for the time being til we find an easier way to update
|
||||
// the admission controllers used on the others
|
||||
framework.SkipUnlessProviderIs("gce")
|
||||
|
@ -47,8 +47,8 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
|
|||
})
|
||||
|
||||
// Simplest case: all pods succeed promptly
|
||||
It("should create a pod preset", func() {
|
||||
By("Creating a pod preset")
|
||||
ginkgo.It("should create a pod preset", func() {
|
||||
ginkgo.By("Creating a pod preset")
|
||||
|
||||
pip := &settings.PodPreset{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
@ -77,9 +77,9 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
|
|||
if errors.IsNotFound(err) {
|
||||
framework.Skipf("podpresets requires k8s.io/api/settings/v1alpha1 to be enabled")
|
||||
}
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
|
||||
By("creating the pod")
|
||||
ginkgo.By("creating the pod")
|
||||
name := "pod-preset-pod"
|
||||
value := strconv.Itoa(time.Now().Nanosecond())
|
||||
pod := &v1.Pod{
|
||||
|
@ -102,30 +102,30 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
|
|||
},
|
||||
}
|
||||
|
||||
By("setting up watch")
|
||||
ginkgo.By("setting up watch")
|
||||
selector := labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err := podClient.List(options)
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to query for pod")
|
||||
Expect(len(pods.Items)).To(Equal(0))
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to query for pod")
|
||||
gomega.Expect(len(pods.Items)).To(gomega.Equal(0))
|
||||
options = metav1.ListOptions{
|
||||
LabelSelector: selector.String(),
|
||||
ResourceVersion: pods.ListMeta.ResourceVersion,
|
||||
}
|
||||
w, err := podClient.Watch(options)
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to set up watch")
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to set up watch")
|
||||
|
||||
By("submitting the pod to kubernetes")
|
||||
ginkgo.By("submitting the pod to kubernetes")
|
||||
podClient.Create(pod)
|
||||
|
||||
By("verifying the pod is in kubernetes")
|
||||
ginkgo.By("verifying the pod is in kubernetes")
|
||||
selector = labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))
|
||||
options = metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err = podClient.List(options)
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to query for pod")
|
||||
Expect(len(pods.Items)).To(Equal(1))
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to query for pod")
|
||||
gomega.Expect(len(pods.Items)).To(gomega.Equal(1))
|
||||
|
||||
By("verifying pod creation was observed")
|
||||
ginkgo.By("verifying pod creation was observed")
|
||||
select {
|
||||
case event, _ := <-w.ResultChan():
|
||||
if event.Type != watch.Added {
|
||||
|
@ -139,10 +139,10 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
|
|||
// may be carried out immediately rather than gracefully.
|
||||
framework.ExpectNoError(f.WaitForPodRunning(pod.Name))
|
||||
|
||||
By("ensuring pod is modified")
|
||||
ginkgo.By("ensuring pod is modified")
|
||||
// save the running pod
|
||||
pod, err = podClient.Get(pod.Name, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to GET scheduled pod")
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to GET scheduled pod")
|
||||
|
||||
// check the annotation is there
|
||||
if _, ok := pod.Annotations["podpreset.admission.kubernetes.io/podpreset-hello"]; !ok {
|
||||
|
@ -155,8 +155,8 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
|
|||
}
|
||||
})
|
||||
|
||||
It("should not modify the pod on conflict", func() {
|
||||
By("Creating a pod preset")
|
||||
ginkgo.It("should not modify the pod on conflict", func() {
|
||||
ginkgo.By("Creating a pod preset")
|
||||
|
||||
pip := &settings.PodPreset{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
@ -185,9 +185,9 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
|
|||
if errors.IsNotFound(err) {
|
||||
framework.Skipf("podpresets requires k8s.io/api/settings/v1alpha1 to be enabled")
|
||||
}
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
|
||||
By("creating the pod")
|
||||
ginkgo.By("creating the pod")
|
||||
name := "pod-preset-pod"
|
||||
value := strconv.Itoa(time.Now().Nanosecond())
|
||||
originalPod := &v1.Pod{
|
||||
|
@ -211,30 +211,30 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
|
|||
},
|
||||
}
|
||||
|
||||
By("setting up watch")
|
||||
ginkgo.By("setting up watch")
|
||||
selector := labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err := podClient.List(options)
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to query for pod")
|
||||
Expect(len(pods.Items)).To(Equal(0))
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to query for pod")
|
||||
gomega.Expect(len(pods.Items)).To(gomega.Equal(0))
|
||||
options = metav1.ListOptions{
|
||||
LabelSelector: selector.String(),
|
||||
ResourceVersion: pods.ListMeta.ResourceVersion,
|
||||
}
|
||||
w, err := podClient.Watch(options)
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to set up watch")
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to set up watch")
|
||||
|
||||
By("submitting the pod to kubernetes")
|
||||
ginkgo.By("submitting the pod to kubernetes")
|
||||
podClient.Create(originalPod)
|
||||
|
||||
By("verifying the pod is in kubernetes")
|
||||
ginkgo.By("verifying the pod is in kubernetes")
|
||||
selector = labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))
|
||||
options = metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err = podClient.List(options)
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to query for pod")
|
||||
Expect(len(pods.Items)).To(Equal(1))
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to query for pod")
|
||||
gomega.Expect(len(pods.Items)).To(gomega.Equal(1))
|
||||
|
||||
By("verifying pod creation was observed")
|
||||
ginkgo.By("verifying pod creation was observed")
|
||||
select {
|
||||
case event, _ := <-w.ResultChan():
|
||||
if event.Type != watch.Added {
|
||||
|
@ -248,10 +248,10 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
|
|||
// may be carried out immediately rather than gracefully.
|
||||
framework.ExpectNoError(f.WaitForPodRunning(originalPod.Name))
|
||||
|
||||
By("ensuring pod is modified")
|
||||
ginkgo.By("ensuring pod is modified")
|
||||
// save the running pod
|
||||
pod, err := podClient.Get(originalPod.Name, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to GET scheduled pod")
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to GET scheduled pod")
|
||||
|
||||
// check the annotation is not there
|
||||
if _, ok := pod.Annotations["podpreset.admission.kubernetes.io/podpreset-hello"]; ok {
|
||||
|
|
Loading…
Reference in New Issue