diff --git a/.gitignore b/.gitignore index 73ffa5b0ded..98d80385785 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,5 @@ cmd/collector/collector-linux cmd/query/query cmd/query/query-linux cmd/query/jaeger-ui-build/ -crossdock/crossdock -crossdock/.build/ +crossdock/crossdock-linux run-crossdock.log diff --git a/Makefile b/Makefile index 30c9d64977d..d63a2333e19 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ THRIFT_GEN_DIR=thrift-gen PASS=$(shell printf "\033[32mPASS\033[0m") FAIL=$(shell printf "\033[31mFAIL\033[0m") COLORIZE=$(SED) ''/PASS/s//$(PASS)/'' | $(SED) ''/FAIL/s//$(FAIL)/'' -DOCKER_NAMESPACE?=$(USER) +DOCKER_NAMESPACE?=jaegertracing DOCKER_TAG?=latest .DEFAULT_GOAL := test-and-lint @@ -116,8 +116,13 @@ build-query-linux: build-collector-linux: CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./cmd/collector/collector-linux ./cmd/collector/main.go +.PHONY: docker-no-ui +docker-no-ui: build-agent-linux build-collector-linux build-query-linux build-crossdock-linux + mkdir -p jaeger-ui-build/build/ + make docker-images-only + .PHONY: docker -docker: build_ui build-agent-linux build-collector-linux build-query-linux docker-images-only +docker: build_ui docker-no-ui .PHONY: docker-images-only docker-images-only: @@ -129,32 +134,33 @@ docker-images-only: echo "Finished building $$component ==============" ; \ done rm -rf cmd/query/jaeger-ui-build + docker build -t $(DOCKER_NAMESPACE)/test-driver:${DOCKER_TAG} crossdock/ + @echo "Finished building test-driver ==============" ; \ .PHONY: docker-push docker-push: + @while [ -z "$$CONFIRM" ]; do \ + read -r -p "Do you really want to push images to repository \"${DOCKER_NAMESPACE}\"? [y/N] " CONFIRM; \ + done ; \ + if [ $$CONFIRM != "y" ] && [ $$CONFIRM != "Y" ]; then \ + echo "Exiting." ; exit 1 ; \ + fi for component in agent cassandra-schema collector query ; do \ docker push $(DOCKER_NAMESPACE)/jaeger-$$component ; \ done .PHONY: build-crossdock-linux build-crossdock-linux: - CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./crossdock/crossdock ./crossdock/main.go - -.PHONY: build-crossdock-bin -build-crossdock-bin: - make build-crossdock-linux - make build-query-linux - make build-collector-linux - make build-agent-linux + CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./crossdock/crossdock-linux ./crossdock/main.go include crossdock/rules.mk .PHONY: build-crossdock -build-crossdock: build-crossdock-bin +build-crossdock: docker-no-ui make crossdock .PHONY: build-crossdock-fresh -build-crossdock-fresh: build-crossdock-bin +build-crossdock-fresh: build-crossdock-linux make crossdock-fresh .PHONY: cover diff --git a/cmd/query/app/static_handler.go b/cmd/query/app/static_handler.go index 9c82fd2fbd8..86d78ad7c00 100644 --- a/cmd/query/app/static_handler.go +++ b/cmd/query/app/static_handler.go @@ -27,10 +27,6 @@ import ( "github.com/pkg/errors" ) -const ( - defaultStaticAssetsRoot = "jaeger-ui-build/build/" -) - var ( staticRootFiles = []string{"favicon.ico"} configPattern = regexp.MustCompile("JAEGER_CONFIG *= *DEFAULT_CONFIG;") @@ -45,7 +41,7 @@ type StaticAssetsHandler struct { // NewStaticAssetsHandler returns a StaticAssetsHandler func NewStaticAssetsHandler(staticAssetsRoot string, uiConfig string) (*StaticAssetsHandler, error) { if staticAssetsRoot == "" { - staticAssetsRoot = defaultStaticAssetsRoot + return nil, nil } if !strings.HasSuffix(staticAssetsRoot, "/") { staticAssetsRoot = staticAssetsRoot + "/" diff --git a/cmd/query/app/static_handler_test.go b/cmd/query/app/static_handler_test.go index 6324d7e6d39..c8c165ab24a 100644 --- a/cmd/query/app/static_handler_test.go +++ b/cmd/query/app/static_handler_test.go @@ -47,8 +47,15 @@ func TestStaticAssetsHandler(t *testing.T) { } func TestDefaultStaticAssetsRoot(t *testing.T) { - _, err := NewStaticAssetsHandler("", "") - assert.EqualError(t, err, "Cannot read UI static assets: open jaeger-ui-build/build/index.html: no such file or directory") + handler, err := NewStaticAssetsHandler("", "") + assert.Nil(t, handler) + assert.Nil(t, err) +} + +func TestNotExistingUiConfig(t *testing.T) { + handler, err := NewStaticAssetsHandler("/foo/bar", "") + assert.Equal(t, "Cannot read UI static assets: open /foo/bar/index.html: no such file or directory", err.Error()) + assert.Nil(t, handler) } func TestRegisterRoutesHandler(t *testing.T) { diff --git a/cmd/query/main.go b/cmd/query/main.go index 5da985da454..4a15d9d81dd 100644 --- a/cmd/query/main.go +++ b/cmd/query/main.go @@ -98,13 +98,9 @@ func main() { app.HandlerOptions.Prefix(queryOpts.Prefix), app.HandlerOptions.Logger(logger), app.HandlerOptions.Tracer(tracer)) - staticHandler, err := app.NewStaticAssetsHandler(queryOpts.StaticAssets, queryOpts.UIConfig) - if err != nil { - logger.Fatal("Could not create static assets handler", zap.Error(err)) - } r := mux.NewRouter() apiHandler.RegisterRoutes(r) - staticHandler.RegisterRoutes(r) + registerStaticHandler(r, logger, queryOpts) portStr := ":" + strconv.Itoa(queryOpts.Port) recoveryHandler := recoveryhandler.NewRecoveryHandler(logger, true) @@ -139,3 +135,15 @@ func main() { logger.Fatal(error.Error()) } } + +func registerStaticHandler(r *mux.Router, logger *zap.Logger, qOpts *builder.QueryOptions) { + staticHandler, err := app.NewStaticAssetsHandler(qOpts.StaticAssets, qOpts.UIConfig) + if err != nil { + logger.Fatal("Could not create static assets handler", zap.Error(err)) + } + if staticHandler != nil { + staticHandler.RegisterRoutes(r) + } else { + logger.Info("Static handler is not registered") + } +} diff --git a/cmd/standalone/main.go b/cmd/standalone/main.go index bea4d447334..a3adf7a43a1 100644 --- a/cmd/standalone/main.go +++ b/cmd/standalone/main.go @@ -221,13 +221,9 @@ func startQuery( queryApp.HandlerOptions.Prefix(qOpts.Prefix), queryApp.HandlerOptions.Logger(logger), queryApp.HandlerOptions.Tracer(tracer)) - staticHandler, err := queryApp.NewStaticAssetsHandler(qOpts.StaticAssets, qOpts.UIConfig) - if err != nil { - logger.Fatal("Could not create static assets handler", zap.Error(err)) - } r := mux.NewRouter() apiHandler.RegisterRoutes(r) - staticHandler.RegisterRoutes(r) + registerStaticHandler(r, logger, qOpts) portStr := ":" + strconv.Itoa(qOpts.Port) recoveryHandler := recoveryhandler.NewRecoveryHandler(logger, true) logger.Info("Starting jaeger-query HTTP server", zap.Int("port", qOpts.Port)) @@ -235,3 +231,15 @@ func startQuery( logger.Fatal("Could not launch jaeger-query service", zap.Error(err)) } } + +func registerStaticHandler(r *mux.Router, logger *zap.Logger, qOpts *query.QueryOptions) { + staticHandler, err := queryApp.NewStaticAssetsHandler(qOpts.StaticAssets, qOpts.UIConfig) + if err != nil { + logger.Fatal("Could not create static assets handler", zap.Error(err)) + } + if staticHandler != nil { + staticHandler.RegisterRoutes(r) + } else { + logger.Info("Static handler is not registered") + } +} diff --git a/crossdock/Dockerfile b/crossdock/Dockerfile index 8a619570b24..d65daa9de7c 100644 --- a/crossdock/Dockerfile +++ b/crossdock/Dockerfile @@ -1,8 +1,6 @@ -FROM gliderlabs/alpine -ADD crossdock / -CMD ["/crossdock"] -EXPOSE 8080 +FROM scratch + +COPY crossdock-linux /go/bin/ -COPY .build/scripts/* /scripts/ -COPY .build/cmd/* /cmd/ -COPY .build/ui/* /ui/ +EXPOSE 8080 +CMD ["/go/bin/crossdock-linux"] diff --git a/crossdock/docker-compose.yml b/crossdock/docker-compose.yml index ae672b341fc..d9a0b138b43 100644 --- a/crossdock/docker-compose.yml +++ b/crossdock/docker-compose.yml @@ -4,6 +4,9 @@ services: crossdock: image: crossdock/crossdock links: + - jaeger-query + - jaeger-collector + - jaeger-agent - test_driver - go - node @@ -27,23 +30,29 @@ services: image: jaegertracing/xdock-go ports: - "8080-8082" + links: + - "jaeger-agent:test_driver" node: image: jaegertracing/xdock-node ports: - "8080-8082" + links: + - "jaeger-agent:test_driver" java: image: jaegertracing/xdock-java ports: - "8080-8082" - depends_on: - - test_driver + links: + - "jaeger-agent:test_driver" python: image: jaegertracing/xdock-py ports: - "8080-8082" + links: + - "jaeger-agent:test_driver" zipkin-brave-json: image: jaegertracing/xdock-zipkin-brave @@ -51,6 +60,8 @@ services: - "8080-8081" environment: - ENCODING=JSON + links: + - "jaeger-collector:test_driver" zipkin-brave-thrift: image: jaegertracing/xdock-zipkin-brave @@ -58,17 +69,15 @@ services: - "8080-8081" environment: - ENCODING=THRIFT - - - cassandra: - image: "cassandra:3.9" + links: + - "jaeger-collector:test_driver" test_driver: - build: . - image: jaegertracing/test-driver:latest - links: - - cassandra - depends_on: - - cassandra + image: jaegertracing/test-driver ports: - "8080" + + jaeger-query: +# override to disable static files + command: ["/go/bin/query-linux", "--query.static-files=", "--cassandra.keyspace=jaeger_v1_dc1", "--cassandra.servers=cassandra"] + diff --git a/crossdock/main.go b/crossdock/main.go index f87cc54e097..60f8d014cd2 100644 --- a/crossdock/main.go +++ b/crossdock/main.go @@ -15,47 +15,21 @@ package main import ( - "bufio" - "fmt" - "io" "net/http" - "os" - "os/exec" "sync" "time" "github.com/crossdock/crossdock-go" - "github.com/gocql/gocql" - "github.com/uber/tchannel-go" "go.uber.org/zap" - "golang.org/x/net/context" "github.com/uber/jaeger/crossdock/services" - "github.com/uber/jaeger/pkg/cassandra" - gocqlw "github.com/uber/jaeger/pkg/cassandra/gocql" ) const ( behaviorEndToEnd = "endtoend" collectorService = "Collector" - agentService = "Agent" queryService = "Query" - - cmdDir = "/cmd/" - collectorCmd = cmdDir + "jaeger-collector" - agentCmd = cmdDir + "jaeger-agent" - queryCmd = cmdDir + "jaeger-query" - - collectorHostPort = "localhost:14267" - agentURL = "http://test_driver:5778" - queryServiceURL = "http://127.0.0.1:16686" - - schema = "/scripts/schema.cql" - - jaegerKeyspace = "jaeger" - - cassandraHost = "cassandra" ) var ( @@ -89,14 +63,13 @@ func main() { } func (h *clientHandler) initialize() { - InitializeStorage(logger) - logger.Info("Cassandra started") - startCollector(logger) - logger.Info("Collector started") - agentService := startAgent("", logger) - logger.Info("Agent started") - queryService := startQueryService("", logger) + httpHealthCheck(logger, queryService, "http://jaeger-query:16687") logger.Info("Query started") + httpHealthCheck(logger, collectorService, "http://jaeger-collector:14269") + logger.Info("Collector started") + queryService := services.NewQueryService("http://jaeger-query:16686", logger) + agentService := services.NewAgentService("http://jaeger-agent:5778", logger) + traceHandler := services.NewTraceHandler(queryService, agentService, logger) h.Lock() defer h.Unlock() @@ -114,135 +87,14 @@ func (h *clientHandler) isInitialized() bool { return h.initialized } -// startCollector starts the jaeger collector as a background process. -func startCollector(logger *zap.Logger) { - forkCmd( - logger, - collectorCmd, - "--cassandra.keyspace=jaeger", - "--cassandra.servers=cassandra", - "--collector.zipkin.http-port=9411", - ) - tChannelHealthCheck(logger, collectorService, collectorHostPort) -} - -// startQueryService initiates the query service as a background process. -func startQueryService(url string, logger *zap.Logger) services.QueryService { - forkCmd( - logger, - queryCmd, - "--query.static-files=/ui/", - "--cassandra.keyspace=jaeger", - "--cassandra.servers=cassandra", - ) - if url == "" { - url = queryServiceURL - } - healthCheck(logger, queryService, url) - return services.NewQueryService(url, logger) -} - -// startAgent initializes the jaeger agent as a background process. -func startAgent(url string, logger *zap.Logger) services.AgentService { - forkCmd( - logger, - agentCmd, - "--collector.host-port=localhost:14267", - "--processor.zipkin-compact.server-host-port=test_driver:5775", - "--processor.jaeger-compact.server-host-port=test_driver:6831", - "--processor.jaeger-binary.server-host-port=test_driver:6832", - ) - if url == "" { - url = agentURL - } - healthCheck(logger, agentService, agentURL) - return services.NewAgentService(url, logger) -} - -func forkCmd(logger *zap.Logger, cmd string, args ...string) { - c := exec.Command(cmd, args...) - - fwdStream := func(name string, pipe func() (io.ReadCloser, error), dest *os.File) { - stream, err := pipe() - if err != nil { - logger.Fatal("Error creating pipe for "+name, zap.String("cmd", cmd), zap.Error(err)) - } - go func() { - scanner := bufio.NewScanner(stream) - for scanner.Scan() { - fmt.Fprintf(dest, "%s[%s] => %s\n", cmd, name, scanner.Text()) - } - }() - } - - fwdStream("stdout", c.StdoutPipe, os.Stdout) - fwdStream("stderr", c.StderrPipe, os.Stderr) - - logger.Info("starting child process", zap.String("cmd", cmd)) - if err := c.Start(); err != nil { - logger.Fatal("Failed to fork sub-command", zap.String("cmd", cmd), zap.Error(err)) - } -} - -// InitializeStorage initializes cassandra instances. -func InitializeStorage(logger *zap.Logger) { - session := initializeCassandra(logger, cassandraHost, 4) - if session == nil { - logger.Fatal("Failed to initialize cassandra session") - } - logger.Info("Initialized cassandra session") - err := services.InitializeCassandraSchema(session, schema, jaegerKeyspace, logger) - if err != nil { - logger.Fatal("Could not initialize cassandra schema", zap.Error(err)) - } -} - -func newCassandraCluster(host string, protoVersion int) (cassandra.Session, error) { - cluster := gocql.NewCluster(host) - cluster.ProtoVersion = protoVersion - cluster.Timeout = 30 * time.Second - session, err := cluster.CreateSession() - if err != nil { - return nil, err - } - return gocqlw.WrapCQLSession(session), nil -} - -func initializeCassandra(logger *zap.Logger, host string, protoVersion int) cassandra.Session { - var session cassandra.Session - var err error - for i := 0; i < 60; i++ { - session, err = newCassandraCluster(host, protoVersion) - if err == nil { - break - } - logger.Warn("Failed to initialize cassandra session", zap.String("host", host), zap.Error(err)) - time.Sleep(1 * time.Second) - } - return session -} - -func healthCheck(logger *zap.Logger, service, healthURL string) { - for i := 0; i < 100; i++ { - _, err := http.Get(healthURL) - if err == nil { - return - } - logger.Warn("Health check failed", zap.String("service", service), zap.Error(err)) - time.Sleep(100 * time.Millisecond) - } - logger.Fatal("All health checks failed", zap.String("service", service)) -} - -func tChannelHealthCheck(logger *zap.Logger, service, hostPort string) { - channel, _ := tchannel.NewChannel("test_driver", nil) +func httpHealthCheck(logger *zap.Logger, service, healthURL string) { for i := 0; i < 100; i++ { - err := channel.Ping(context.Background(), hostPort) - if err == nil { + res, err := http.Get(healthURL) + if err == nil && res.StatusCode == 204 { return } logger.Warn("Health check failed", zap.String("service", service), zap.Error(err)) - time.Sleep(100 * time.Millisecond) + time.Sleep(500 * time.Millisecond) } logger.Fatal("All health checks failed", zap.String("service", service)) } diff --git a/crossdock/rules.mk b/crossdock/rules.mk index e2a3ba64521..7d6ac53d58a 100644 --- a/crossdock/rules.mk +++ b/crossdock/rules.mk @@ -1,63 +1,18 @@ XDOCK_YAML=crossdock/docker-compose.yml - -BUILD_DIR = crossdock/.build -CMD_DIR = $(BUILD_DIR)/cmd -SCRIPTS_DIR = $(BUILD_DIR)/scripts -UI_DIR = $(BUILD_DIR)/ui - -SCHEMA = $(SCRIPTS_DIR)/schema.cql -SCHEMA_SRC = plugin/storage/cassandra/schema/create.sh - -QUERY_SRC = cmd/query/query-linux -QUERY_DST = $(CMD_DIR)/jaeger-query - -# we don't actually need full UI in crossdock, so we simply provide a dummy index.html -QUERY_INDEX_SRC = cmd/query/app/fixture/index.html -QUERY_INDEX_DST = $(UI_DIR)/index.html - -AGENT_SRC = cmd/agent/agent-linux -AGENT_DST = $(CMD_DIR)/jaeger-agent - -COLLECTOR_SRC = cmd/collector/collector-linux -COLLECTOR_DST = $(CMD_DIR)/jaeger-collector - -$(BUILD_DIR): - mkdir -p $(BUILD_DIR) - -$(CMD_DIR): $(BUILD_DIR) - mkdir -p $(CMD_DIR) - -$(SCRIPTS_DIR): $(BUILD_DIR) - mkdir -p $(SCRIPTS_DIR) - -$(UI_DIR): $(BUILD_DIR) - mkdir -p $(UI_DIR) - -$(SCHEMA): $(SCRIPTS_DIR) $(SCHEMA_SRC) - MODE=test KEYSPACE=jaeger $(SCHEMA_SRC) | cat -s > $(SCHEMA) - -$(QUERY_INDEX_DST): $(UI_DIR) - cp $(QUERY_INDEX_SRC) $(QUERY_INDEX_DST) - -.PHONY: crossdock-copy-bin -crossdock-copy-bin: $(CMD_DIR) - cp $(QUERY_SRC) $(QUERY_DST) - cp $(AGENT_SRC) $(AGENT_DST) - cp $(COLLECTOR_SRC) $(COLLECTOR_DST) +JAEGER_COMPOSE_YAML=docker-compose/jaeger-docker-compose.yml .PHONY: crossdock -crossdock: $(SCHEMA) $(QUERY_INDEX_DST) crossdock-copy-bin - docker-compose -f $(XDOCK_YAML) kill test_driver go node java python - docker-compose -f $(XDOCK_YAML) rm -f test_driver - docker-compose -f $(XDOCK_YAML) build test_driver - docker-compose -f $(XDOCK_YAML) run crossdock 2>&1 | tee run-crossdock.log +crossdock: + docker-compose -f $(JAEGER_COMPOSE_YAML) -f $(XDOCK_YAML) kill + docker-compose -f $(JAEGER_COMPOSE_YAML) -f $(XDOCK_YAML) rm -f test_driver + docker-compose -f $(JAEGER_COMPOSE_YAML) -f $(XDOCK_YAML) run crossdock 2>&1 | tee run-crossdock.log grep 'Tests passed!' run-crossdock.log -.PHONY: crossdock-fresh -crossdock-fresh: $(SCHEMA) crossdock-copy-bin - docker-compose -f $(XDOCK_YAML) down --rmi all - docker-compose -f $(XDOCK_YAML) run crossdock - .PHONE: crossdock-logs crossdock-logs: - docker-compose -f $(XDOCK_YAML) logs + docker-compose -f $(JAEGER_COMPOSE_YAML) -f $(XDOCK_YAML) logs + +.PHONE: crossdock-clean +crossdock-clean: + docker-compose -f $(JAEGER_COMPOSE_YAML) -f $(XDOCK_YAML) down + diff --git a/crossdock/services/fixtures/test-schema.cql b/crossdock/services/fixtures/test-schema.cql deleted file mode 100644 index 566b15948cd..00000000000 --- a/crossdock/services/fixtures/test-schema.cql +++ /dev/null @@ -1 +0,0 @@ -CREATE KEYSPACE IF NOT EXISTS jaeger; diff --git a/crossdock/services/storage.go b/crossdock/services/storage.go deleted file mode 100644 index 1519ce8b46d..00000000000 --- a/crossdock/services/storage.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2017 Uber Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package services - -import ( - "fmt" - "io/ioutil" - "strings" - - "github.com/pkg/errors" - "go.uber.org/zap" - - "github.com/uber/jaeger/pkg/cassandra" -) - -// InitializeCassandraSchema applies a schema to the cassandra keyspace -func InitializeCassandraSchema(session cassandra.Session, schemaFile, keyspace string, logger *zap.Logger) error { - logger.Info("Creating Cassandra schema", zap.String("keyspace", keyspace), zap.String("file", schemaFile)) - buf, err := ioutil.ReadFile(schemaFile) - if err != nil { - return err - } - file := string(buf) - // Split file into individual queries. - schemaQueries := strings.Split(file, ";") - dropKeyspaceQuery := fmt.Sprintf("DROP KEYSPACE IF EXISTS %s", keyspace) - schemaQueries = append([]string{dropKeyspaceQuery}, schemaQueries...) - for _, schemaQuery := range schemaQueries { - schemaQuery = strings.TrimSpace(schemaQuery) - if schemaQuery == "" { - continue - } - logger.Info("Executing", zap.String("query", schemaQuery)) - if err := session.Query(schemaQuery + ";").Exec(); err != nil { - return errors.Wrap(err, fmt.Sprintf("Failed to apply a schema query: %s", schemaQuery)) - } - } - return nil -} diff --git a/crossdock/services/storage_test.go b/crossdock/services/storage_test.go deleted file mode 100644 index 648e71f4160..00000000000 --- a/crossdock/services/storage_test.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2017 Uber Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package services - -import ( - "errors" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "go.uber.org/zap" - - "github.com/uber/jaeger/pkg/cassandra/mocks" -) - -type storageTest struct { - session *mocks.Session -} - -func withStorage(fn func(s *storageTest)) { - session := &mocks.Session{} - s := &storageTest{ - session: session, - } - fn(s) -} - -func TestInitializeCassandraSchema(t *testing.T) { - schemaFile := "fixtures/test-schema.cql" - - testCases := []struct { - caption string - schemaFile string - queryError error - expectedError string - }{ - { - caption: "success", - schemaFile: schemaFile, - }, - { - caption: "query error", - schemaFile: schemaFile, - queryError: errors.New("query error"), - expectedError: "Failed to apply a schema query: DROP KEYSPACE IF EXISTS: query error", - }, - { - caption: "schema error", - expectedError: "open : no such file or directory", - }, - } - for _, tc := range testCases { - testCase := tc // capture loop var - t.Run(testCase.caption, func(t *testing.T) { - withStorage(func(s *storageTest) { - query := &mocks.Query{} - query.On("Exec").Return(testCase.queryError) - session := &mocks.Session{} - session.On("Query", mock.AnythingOfType("string"), matchEverything()).Return(query) - - err := InitializeCassandraSchema(session, testCase.schemaFile, "", zap.NewNop()) - if testCase.expectedError == "" { - assert.NoError(t, err) - } else { - assert.EqualError(t, err, testCase.expectedError) - } - }) - }) - } -} - -func matchEverything() interface{} { - return mock.MatchedBy(func(v []interface{}) bool { return true }) -} diff --git a/docker-compose/jaeger-docker-compose.yml b/docker-compose/jaeger-docker-compose.yml new file mode 100644 index 00000000000..ec9f11cf466 --- /dev/null +++ b/docker-compose/jaeger-docker-compose.yml @@ -0,0 +1,43 @@ +version: '2' + +services: + jaeger-collector: + image: jaegertracing/jaeger-collector + command: ["/go/bin/collector-linux", "--cassandra.keyspace=jaeger_v1_dc1", "--cassandra.servers=cassandra", "--collector.zipkin.http-port=9411"] + ports: + - "14269" + - "14268:14268" + - "14267" + - "9411:9411" + restart: on-failure + depends_on: + - cassandra-schema + + jaeger-query: + image: jaegertracing/jaeger-query + command: ["/go/bin/query-linux", "--query.static-files=/go/jaeger-ui/", "--cassandra.keyspace=jaeger_v1_dc1", "--cassandra.servers=cassandra"] + ports: + - "16686:16686" + - "16687" + restart: on-failure + + jaeger-agent: + image: jaegertracing/jaeger-agent + command: ["/go/bin/agent-linux", "--collector.host-port=jaeger-collector:14267"] + ports: + - "5775:5775/udp" + - "6831:6831/udp" + - "6832:6832/udp" + - "5778:5778" + restart: on-failure + depends_on: + - jaeger-collector + + cassandra: + image: cassandra:3.9 + + cassandra-schema: + image: jaegertracing/jaeger-cassandra-schema + depends_on: + - cassandra + diff --git a/travis/install-crossdock-deps.sh b/travis/install-crossdock-deps.sh index f2e15fe7a2b..fb07181c261 100644 --- a/travis/install-crossdock-deps.sh +++ b/travis/install-crossdock-deps.sh @@ -6,7 +6,7 @@ docker version # Install docker-compose sudo rm -f /usr/local/bin/docker-compose -curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose -chmod +x docker-compose -sudo mv docker-compose /usr/local/bin +curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /tmp/docker-compose +chmod +x /tmp/docker-compose +sudo mv /tmp/docker-compose /usr/local/bin docker-compose version