Skip to content

Commit

Permalink
Add modeke test to elastic
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay committed Dec 3, 2018
1 parent 712bda4 commit 61df808
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 24 deletions.
30 changes: 7 additions & 23 deletions test/e2e/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package e2e
import (
goctx "context"
"fmt"
"github.com/pkg/errors"
"k8s.io/client-go/kubernetes"
"strings"
"testing"

"github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1"
Expand Down Expand Up @@ -43,10 +40,12 @@ func cassandraTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx)
},
Spec: v1alpha1.JaegerSpec{
Strategy: "allInOne",
AllInOne: v1alpha1.JaegerAllInOneSpec{},
Storage: v1alpha1.JaegerStorageSpec{
Type: "cassandra",
Options: v1alpha1.NewOptions(map[string]interface{}{"cassandra.servers": "cassandra.default.svc"}),
Options: v1alpha1.NewOptions(map[string]interface{}{"cassandra.servers": "cassandra.default.svc", "cassandra.keyspace": "jaeger_v1_datacenter1"}),
CassandraCreateSchema: v1alpha1.JaegerCassandraCreateSchemaSpec{
Datacenter: "datacenter1",
},
},
},
}
Expand All @@ -67,33 +66,18 @@ func cassandraTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx)
return err
}

podName, err := GetPodName(namespace, "with-cassandra", f.KubeClient)
jaegerPod, err := GetPod(namespace, "with-cassandra", "with-cassandra", f.KubeClient)
if err != nil {
return err
}
portForw, closeChan, err := CreatePortForward(namespace, podName, []string{"16686:16686", "14268:14268"}, f.KubeConfig)
portForw, closeChan, err := CreatePortForward(namespace, jaegerPod.Name, []string{"16686:16686", "14268:14268"}, f.KubeConfig)
if err != nil {
return err
}
defer close(closeChan)
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)
}

func GetPodName(namespace, ownerNamePrefix string, kubeclient kubernetes.Interface) (string, error) {
pods, err := kubeclient.CoreV1().Pods(namespace).List(metav1.ListOptions{IncludeUninitialized:true})
if err != nil {
return "", err
}
for _, pod := range pods.Items {
for _, or := range pod.OwnerReferences {

if strings.HasPrefix(or.Name, ownerNamePrefix) {
return pod.Name, nil
}
}
}
return "", errors.New(fmt.Sprintf("could not find pod of owner %s", ownerNamePrefix))
}
30 changes: 29 additions & 1 deletion test/e2e/production_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,33 @@ func simpleProd(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) er
return err
}

return e2eutil.WaitForDeployment(t, f.KubeClient, namespace, "simple-prod-query", 1, retryInterval, timeout)
err = e2eutil.WaitForDeployment(t, f.KubeClient, namespace, "simple-prod-query", 1, retryInterval, timeout)
if err != nil {
return err
}
queryPod, err := GetPod(namespace, "simple-prod-query","simple-prod", f.KubeClient)
if err != nil {
return err
}
collectorPod, err := GetPod(namespace, "simple-prod-collector","simple-prod", f.KubeClient)
if err != nil {
return err
}
portForw, closeChan, err := CreatePortForward(namespace, queryPod.Name, []string{"16686: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)
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)
}
28 changes: 28 additions & 0 deletions test/e2e/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package e2e

import (
"errors"
"fmt"
"k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes"
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// 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})
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) {
return pod, nil
}
}
}
}
return v1.Pod{}, errors.New(fmt.Sprintf("could not find pod of owner %s", ownerNamePrefix))
}

0 comments on commit 61df808

Please sign in to comment.