Skip to content

Commit

Permalink
Fix ES and Cassandra tests which were failing on OpenShift (#275)
Browse files Browse the repository at this point in the history
* Fix ES and Cassandra tests which were failing on OpenShift

Signed-off-by: Kevin Earls <kearls@kevinearls.com>
  • Loading branch information
kevinearls authored and jpkrohling committed Mar 7, 2019
1 parent 24937ef commit 898bb43
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ OUTPUT_BINARY ?= "$(BIN_DIR)/$(OPERATOR_NAME)"
VERSION_PKG ?= "github.com/jaegertracing/jaeger-operator/pkg/version"
JAEGER_VERSION ?= "$(shell grep -v '\#' jaeger.version)"
OPERATOR_VERSION ?= "$(shell git describe --tags)"
STORAGE_NAMESPACE ?= "storage"

LD_FLAGS ?= "-X $(VERSION_PKG).version=$(OPERATOR_VERSION) -X $(VERSION_PKG).buildDate=$(VERSION_DATE) -X $(VERSION_PKG).defaultJaeger=$(JAEGER_VERSION)"
PACKAGES := $(shell go list ./cmd/... ./pkg/...)
Expand Down Expand Up @@ -86,24 +87,29 @@ e2e-tests-smoke: prepare-e2e-tests
.PHONY: e2e-tests-cassandra
e2e-tests-cassandra: prepare-e2e-tests cassandra
@echo Running Cassandra end-to-end tests...
@go test -tags=cassandra ./test/e2e/... -kubeconfig $(KUBERNETES_CONFIG) -namespacedMan ../../deploy/test/namespace-manifests.yaml -globalMan ../../deploy/crds/jaegertracing_v1_jaeger_crd.yaml -root .
@STORAGE_NAMESPACE=$(STORAGE_NAMESPACE) go test -tags=cassandra ./test/e2e/... -kubeconfig $(KUBERNETES_CONFIG) -namespacedMan ../../deploy/test/namespace-manifests.yaml -globalMan ../../deploy/crds/jaegertracing_v1_jaeger_crd.yaml -root .

.PHONY: e2e-tests-es
e2e-tests-es: prepare-e2e-tests es
@echo Running Elasticsearch end-to-end tests...
@go test -tags=elasticsearch ./test/e2e/... -kubeconfig $(KUBERNETES_CONFIG) -namespacedMan ../../deploy/test/namespace-manifests.yaml -globalMan ../../deploy/crds/jaegertracing_v1_jaeger_crd.yaml -root .
@STORAGE_NAMESPACE=$(STORAGE_NAMESPACE) go test -tags=elasticsearch ./test/e2e/... -kubeconfig $(KUBERNETES_CONFIG) -namespacedMan ../../deploy/test/namespace-manifests.yaml -globalMan ../../deploy/crds/jaegertracing_v1_jaeger_crd.yaml -root .

.PHONY: run
run: crd
@bash -c 'trap "exit 0" INT; OPERATOR_NAME=${OPERATOR_NAME} KUBERNETES_CONFIG=${KUBERNETES_CONFIG} WATCH_NAMESPACE=${WATCH_NAMESPACE} go run -ldflags ${LD_FLAGS} main.go start'

.PHONY: es
es:
@kubectl create -f ./test/elasticsearch.yml 2>&1 | grep -v "already exists" || true
es: storage
@kubectl create -f ./test/elasticsearch.yml --namespace $(STORAGE_NAMESPACE) 2>&1 | grep -v "already exists" || true

.PHONY: cassandra
cassandra:
@kubectl create -f ./test/cassandra.yml 2>&1 | grep -v "already exists" || true
cassandra: storage
@kubectl create -f ./test/cassandra.yml --namespace $(STORAGE_NAMESPACE) 2>&1 | grep -v "already exists" || true

.PHONY: storage
storage:
@echo Creating namespace $(STORAGE_NAMESPACE)
@kubectl create namespace $(STORAGE_NAMESPACE) 2>&1 | grep -v "already exists" || true

.PHONY: clean
clean:
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func cassandraTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx)
Strategy: "allInOne",
Storage: v1.JaegerStorageSpec{
Type: "cassandra",
Options: v1.NewOptions(map[string]interface{}{"cassandra.servers": "cassandra.default.svc", "cassandra.keyspace": "jaeger_v1_datacenter1"}),
Options: v1.NewOptions(map[string]interface{}{"cassandra.servers": cassandraServiceName, "cassandra.keyspace": "jaeger_v1_datacenter1"}),
CassandraCreateSchema: v1.JaegerCassandraCreateSchemaSpec{
Datacenter: "datacenter1",
},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/es_index_cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func esIndexCleanerTest(t *testing.T, f *framework.Framework, testCtx *framework
Storage: v1.JaegerStorageSpec{
Type: "elasticsearch",
Options: v1.NewOptions(map[string]interface{}{
"es.server-urls": "http://elasticsearch.default.svc:9200",
"es.server-urls": esServerUrls,
}),
EsIndexCleaner:v1.JaegerEsIndexCleanerSpec{
Schedule: "*/1 * * * *",
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/production_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func simpleProd(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) er
return fmt.Errorf("could not get namespace: %v", err)
}

err = WaitForStatefulset(t, f.KubeClient, "default", "elasticsearch", retryInterval, timeout)
err = WaitForStatefulset(t, f.KubeClient, storageNamespace, "elasticsearch", retryInterval, timeout)
if err != nil {
return err
}
Expand All @@ -47,7 +47,7 @@ func simpleProd(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) er
Storage: v1.JaegerStorageSpec{
Type: "elasticsearch",
Options: v1.NewOptions(map[string]interface{}{
"es.server-urls": "http://elasticsearch.default.svc:9200",
"es.server-urls": esServerUrls,
}),
},
},
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/spark_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func SparkDependenciesElasticsearch(t *testing.T) {
storage := v1.JaegerStorageSpec{
Type: "elasticsearch",
Options: v1.NewOptions(map[string]interface{}{
"es.server-urls": "http://elasticsearch.default.svc:9200",
"es.server-urls": esServerUrls,
}),
}
if err := sparkTest(t, framework.Global, testCtx, storage); err != nil {
Expand All @@ -32,7 +32,7 @@ func SparkDependenciesCassandra(t *testing.T) {

storage := v1.JaegerStorageSpec{
Type: "cassandra",
Options: v1.NewOptions(map[string]interface{}{"cassandra.servers": "cassandra.default.svc", "cassandra.keyspace": "jaeger_v1_datacenter1"}),
Options: v1.NewOptions(map[string]interface{}{"cassandra.servers": cassandraServiceName, "cassandra.keyspace": "jaeger_v1_datacenter1"}),
CassandraCreateSchema:v1.JaegerCassandraCreateSchemaSpec{Datacenter:"datacenter1", Mode: "prod"},
}
if err := sparkTest(t, framework.Global, testCtx, storage); err != nil {
Expand Down
8 changes: 6 additions & 2 deletions test/e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package e2e

import (
"fmt"
"os"
"strings"
"testing"
"time"
Expand All @@ -14,8 +15,11 @@ import (
)

var (
retryInterval = time.Second * 5
timeout = time.Minute * 1
retryInterval = time.Second * 5
timeout = time.Minute * 1
storageNamespace = os.Getenv("STORAGE_NAMESPACE")
esServerUrls = "http://elasticsearch." + storageNamespace + ".svc:9200"
cassandraServiceName = "cassandra." + storageNamespace + ".svc"
)

// GetPod returns pod name
Expand Down

0 comments on commit 898bb43

Please sign in to comment.