From 577336738bf5d26accd0af3d4d6b2cc3f6ecdc9a Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Tue, 24 Mar 2020 16:58:46 +0100 Subject: [PATCH] test: Extend "Checks service on same node" test case Extend the test case by adding a check whether sending a request from a pod to a service endpoint on the same node via ClusterIP works. Signed-off-by: Martynas Pumputis --- test/k8sT/Services.go | 13 +++++++++++-- test/k8sT/manifests/demo.yaml | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/test/k8sT/Services.go b/test/k8sT/Services.go index 356339d25fc0..ded53d668f5d 100644 --- a/test/k8sT/Services.go +++ b/test/k8sT/Services.go @@ -202,14 +202,17 @@ var _ = Describe("K8sServicesTest", func() { "cluster-ip-same-node.log") defer monitorStop() + httpSVCURL := fmt.Sprintf("http://%s/", clusterIP) + tftpSVCURL := fmt.Sprintf("tftp://%s/hello", clusterIP) + k8s1Name, _ := getNodeInfo(helpers.K8s1) status, err := kubectl.ExecInHostNetNS(context.TODO(), k8s1Name, - helpers.CurlFail("http://%s/", clusterIP)) + helpers.CurlFail(httpSVCURL)) Expect(err).To(BeNil(), "Cannot run curl in host netns") status.ExpectSuccess("cannot curl to service IP from host") status, err = kubectl.ExecInHostNetNS(context.TODO(), k8s1Name, - helpers.CurlFail("tftp://%s/hello", clusterIP)) + helpers.CurlFail(tftpSVCURL)) Expect(err).To(BeNil(), "Cannot run curl in host netns") status.ExpectSuccess("cannot curl to service IP from host") ciliumPods, err := kubectl.GetCiliumPods(helpers.CiliumNamespace) @@ -219,6 +222,12 @@ var _ = Describe("K8sServicesTest", func() { service.ExpectSuccess("Cannot retrieve services on cilium Pod") service.ExpectContains(clusterIP, "ClusterIP is not present in the cilium service list") } + for i := 0; i < 10; i++ { + // Send requests from "app2" pod which runs on the same node as + // "app1" pods + testCurlRequest("id=app2", httpSVCURL) + testCurlRequest("id=app2", tftpSVCURL) + } }, 300) It("Checks service accessing itself (hairpin flow)", func() { diff --git a/test/k8sT/manifests/demo.yaml b/test/k8sT/manifests/demo.yaml index 670bee22743c..b9137cb317b4 100644 --- a/test/k8sT/manifests/demo.yaml +++ b/test/k8sT/manifests/demo.yaml @@ -87,6 +87,8 @@ spec: command: [ "sleep" ] args: - "1000h" + # k8sT/Services.go:"Checks service on same node" requires the pod to be + # scheduled on the same node as app1 nodeSelector: "cilium.io/ci-node": k8s1 ---