From 38ebcd70930ecdb6baad0ce372244360d88562de Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Tue, 4 Dec 2018 10:59:20 +0100 Subject: [PATCH] Fix issue with e2e tests Signed-off-by: Pavol Loffay --- Gopkg.lock | 3 --- Gopkg.toml | 2 +- test/e2e/cassandra.go | 6 ++---- test/e2e/port_forward.go | 8 +++++++- test/e2e/production_test.go | 12 ++++-------- test/e2e/utils.go | 10 +++++----- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 3224c980a..5b283eaca 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -934,7 +934,6 @@ "github.com/operator-framework/operator-sdk/pkg/test", "github.com/operator-framework/operator-sdk/pkg/test/e2eutil", "github.com/operator-framework/operator-sdk/version", - "github.com/pkg/errors", "github.com/sirupsen/logrus", "github.com/spf13/cobra", "github.com/spf13/viper", @@ -955,10 +954,8 @@ "k8s.io/client-go/kubernetes", "k8s.io/client-go/kubernetes/scheme", "k8s.io/client-go/rest", - "k8s.io/client-go/tools/clientcmd", "k8s.io/client-go/tools/portforward", "k8s.io/client-go/transport/spdy", - "k8s.io/client-go/util/homedir", "k8s.io/code-generator/cmd/client-gen", "k8s.io/code-generator/cmd/conversion-gen", "k8s.io/code-generator/cmd/deepcopy-gen", diff --git a/Gopkg.toml b/Gopkg.toml index 437a11b0f..aa460dfb2 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -72,6 +72,6 @@ required = [ non-go = false unused-packages = false -[[constraint]] +[[override]] name = "github.com/pkg/errors" version = "0.8.0" diff --git a/test/e2e/cassandra.go b/test/e2e/cassandra.go index 161ffbf15..8257146ef 100644 --- a/test/e2e/cassandra.go +++ b/test/e2e/cassandra.go @@ -66,18 +66,16 @@ func cassandraTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) return err } - jaegerPod, err := GetPod(namespace, "with-cassandra", "with-cassandra", f.KubeClient) + jaegerPod, err := GetPod(namespace, "with-cassandra", "jaegertracing/all-in-one", f.KubeClient) if err != nil { return err } - portForw, closeChan, err := CreatePortForward(namespace, jaegerPod.Name, []string{"16686:16686", "14268:14268"}, f.KubeConfig) + portForw, closeChan, err := CreatePortForward(namespace, jaegerPod.Name, []string{"16686", "14268"}, f.KubeConfig) if err != nil { return err } defer portForw.Close() defer close(closeChan) - go func() { portForw.ForwardPorts() }() - <- portForw.Ready return SmokeTest("http://localhost:16686/api/traces", "http://localhost:14268/api/traces", "foobar", retryInterval, timeout) } diff --git a/test/e2e/port_forward.go b/test/e2e/port_forward.go index 2feb48966..40211a50a 100644 --- a/test/e2e/port_forward.go +++ b/test/e2e/port_forward.go @@ -3,8 +3,8 @@ package e2e import ( "bytes" "fmt" - "net/url" "net/http" + "net/url" "strings" "k8s.io/client-go/rest" @@ -39,5 +39,11 @@ func CreatePortForward(namespace, pod string, ports []string, kConfig *rest.Conf fmt.Println(out.String()) } }() + go func() { + if err := forwarder.ForwardPorts(); err != nil { + panic(err) + } + }() + <- forwarder.Ready return forwarder, stopChan, nil } diff --git a/test/e2e/production_test.go b/test/e2e/production_test.go index 7f0566370..55f29d601 100644 --- a/test/e2e/production_test.go +++ b/test/e2e/production_test.go @@ -68,29 +68,25 @@ func simpleProd(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) er if err != nil { return err } - queryPod, err := GetPod(namespace, "simple-prod-query","simple-prod", f.KubeClient) + queryPod, err := GetPod(namespace, "simple-prod-query","jaegertracing/jaeger-query", f.KubeClient) if err != nil { return err } - collectorPod, err := GetPod(namespace, "simple-prod-collector","simple-prod", f.KubeClient) + collectorPod, err := GetPod(namespace, "simple-prod-collector","jaegertracing/jaeger-collector", f.KubeClient) if err != nil { return err } - portForw, closeChan, err := CreatePortForward(namespace, queryPod.Name, []string{"16686:16686"}, f.KubeConfig) + portForw, closeChan, err := CreatePortForward(namespace, queryPod.Name, []string{"16686"}, f.KubeConfig) if err != nil { return err } defer portForw.Close() defer close(closeChan) - go func() { portForw.ForwardPorts() }() - <- portForw.Ready - portForwColl, closeChanColl, err := CreatePortForward(namespace, collectorPod.Name, []string{"14268:14268"}, f.KubeConfig) + portForwColl, closeChanColl, err := CreatePortForward(namespace, collectorPod.Name, []string{"14268"}, f.KubeConfig) if err != nil { return err } defer portForwColl.Close() defer close(closeChanColl) - go func() { portForwColl.ForwardPorts() }() - <- portForwColl.Ready return SmokeTest("http://localhost:16686/api/traces", "http://localhost:14268/api/traces", "foobar", retryInterval, timeout) } diff --git a/test/e2e/utils.go b/test/e2e/utils.go index ae2c350f2..d70b4ddea 100644 --- a/test/e2e/utils.go +++ b/test/e2e/utils.go @@ -11,19 +11,19 @@ import ( ) // GetPod returns pod name -func GetPod(namespace, namePrefix, ownerNamePrefix string, kubeclient kubernetes.Interface) (v1.Pod, error) { - pods, err := kubeclient.CoreV1().Pods(namespace).List(metav1.ListOptions{IncludeUninitialized:true}) +func GetPod(namespace, namePrefix, containsImage string, kubeclient kubernetes.Interface) (v1.Pod, error) { + pods, err := kubeclient.CoreV1().Pods(namespace).List(metav1.ListOptions{}) if err != nil { return v1.Pod{}, err } for _, pod := range pods.Items { if strings.HasPrefix(pod.Name, namePrefix) { - for _, or := range pod.OwnerReferences { - if strings.HasPrefix(or.Name, ownerNamePrefix) { + for _, c := range pod.Spec.Containers { + if strings.Contains(c.Image, containsImage) { return pod, nil } } } } - return v1.Pod{}, errors.New(fmt.Sprintf("could not find pod of owner %s", ownerNamePrefix)) + return v1.Pod{}, errors.New(fmt.Sprintf("could not find pod with image %s", containsImage)) }