Skip to content

Commit

Permalink
Fix issue with e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay committed Dec 4, 2018
1 parent f90dcca commit 1a835f5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
3 changes: 0 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ required = [
non-go = false
unused-packages = false

[[constraint]]
[[override]]
name = "github.com/pkg/errors"
version = "0.8.0"
6 changes: 2 additions & 4 deletions test/e2e/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

8 changes: 7 additions & 1 deletion test/e2e/port_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package e2e
import (
"bytes"
"fmt"
"net/url"
"net/http"
"net/url"
"strings"

"k8s.io/client-go/rest"
Expand Down Expand Up @@ -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
}
12 changes: 4 additions & 8 deletions test/e2e/production_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
10 changes: 5 additions & 5 deletions test/e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit 1a835f5

Please sign in to comment.