-
Notifications
You must be signed in to change notification settings - Fork 345
/
Copy pathcassandra.go
81 lines (70 loc) · 2.29 KB
/
cassandra.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package e2e
import (
goctx "context"
"fmt"
"testing"
"github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1"
framework "github.com/operator-framework/operator-sdk/pkg/test"
"github.com/operator-framework/operator-sdk/pkg/test/e2eutil"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Cassandra runs a test with Cassandra as the backing storage
func Cassandra(t *testing.T) {
ctx := prepare(t)
defer ctx.Cleanup()
if err := cassandraTest(t, framework.Global, ctx); err != nil {
t.Fatal(err)
}
}
func cassandraTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) error {
cleanupOptions := &framework.CleanupOptions{TestContext: ctx, Timeout: timeout, RetryInterval: retryInterval}
namespace, err := ctx.GetNamespace()
if err != nil {
return fmt.Errorf("could not get namespace: %v", err)
}
j := &v1alpha1.Jaeger{
TypeMeta: metav1.TypeMeta{
Kind: "Jaeger",
APIVersion: "io.jaegertracing/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "with-cassandra",
Namespace: namespace,
},
Spec: v1alpha1.JaegerSpec{
Strategy: "allInOne",
Storage: v1alpha1.JaegerStorageSpec{
Type: "cassandra",
Options: v1alpha1.NewOptions(map[string]interface{}{"cassandra.servers": "cassandra.default.svc", "cassandra.keyspace": "jaeger_v1_datacenter1"}),
CassandraCreateSchema: v1alpha1.JaegerCassandraCreateSchemaSpec{
Datacenter: "datacenter1",
},
},
},
}
logrus.Infof("passing %v", j)
err = f.Client.Create(goctx.TODO(), j, cleanupOptions)
if err != nil {
return err
}
err = WaitForJob(t, f.KubeClient, namespace, "with-cassandra-cassandra-schema-job", retryInterval, timeout)
if err != nil {
return err
}
err = e2eutil.WaitForDeployment(t, f.KubeClient, namespace, "with-cassandra", 1, retryInterval, timeout)
if err != nil {
return err
}
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", "14268"}, f.KubeConfig)
if err != nil {
return err
}
defer portForw.Close()
defer close(closeChan)
return SmokeTest("http://localhost:16686/api/traces", "http://localhost:14268/api/traces", "foobar", retryInterval, timeout)
}