Skip to content

Commit

Permalink
test: Fix looping tests
Browse files Browse the repository at this point in the history
Tell the shell to exit on first error, otherwise the last curl's
success will determine the whole test's success, i.e., any failing
curls other than the last will be ignored.

Fixes: 58be565 ("test: Unroll curl requests in K8sService suite")
Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
  • Loading branch information
jrajahalme authored and joestringer committed May 20, 2020
1 parent f829636 commit 2d4cc76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/k8sT/Services.go
Expand Up @@ -141,7 +141,7 @@ var _ = Describe("K8sServicesTest", func() {
pods, err := kubectl.GetPodNames(helpers.DefaultNamespace, clientPodLabel)
ExpectWithOffset(1, err).Should(BeNil(), "cannot retrieve pod names by filter %q", testDSClient)
count := 10
cmd := fmt.Sprintf(`/bin/sh -c 'for i in $(seq 1 %d); do %s; done'`, count, helpers.CurlFailNoStats(url))
cmd := fmt.Sprintf(`/bin/sh -c 'set -e; for i in $(seq 1 %d); do %s; done'`, count, helpers.CurlFailNoStats(url))
for _, pod := range pods {
By("Making %d curl requests from %s pod to service %s", count, pod, url)
res := kubectl.ExecPodCmd(helpers.DefaultNamespace, pod, cmd)
Expand Down Expand Up @@ -372,7 +372,7 @@ var _ = Describe("K8sServicesTest", func() {

doRequests := func(url string, count int, fromPod string) {
By("Making %d curl requests from pod (host netns) %s to %q", count, fromPod, url)
cmd := fmt.Sprintf(`/bin/sh -c 'for i in $(seq 1 %d); do %s; done'`, count,
cmd := fmt.Sprintf(`/bin/sh -c 'set -e; for i in $(seq 1 %d); do %s; done'`, count,
helpers.CurlFailNoStats(url))
res, err := kubectl.ExecInHostNetNS(context.TODO(), fromPod, cmd)
ExpectWithOffset(1, err).To(BeNil(), "Cannot run curl in host netns")
Expand Down

0 comments on commit 2d4cc76

Please sign in to comment.