From 1c88b09d8ee4afa8ad098600dd274847aa84c14f Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Thu, 22 Aug 2019 13:55:08 +0200 Subject: [PATCH 1/3] Add Elasticsearch version flag Signed-off-by: Pavol Loffay --- pkg/es/client.go | 2 +- pkg/es/config/config.go | 30 ++++++++++------ pkg/es/mocks/Client.go | 29 +++++---------- pkg/es/mocks/IndexService.go | 21 +++-------- pkg/es/mocks/IndicesCreateService.go | 25 ++++--------- pkg/es/mocks/IndicesExistsService.go | 21 +++-------- pkg/es/mocks/MultiSearchService.go | 25 ++++--------- pkg/es/mocks/SearchService.go | 25 ++++--------- pkg/es/mocks/TemplateCreateService.go | 25 ++++--------- pkg/es/wrapper/wrapper.go | 10 +++--- plugin/storage/es/dependencystore/schema.go | 2 +- .../es/dependencystore/storage_test.go | 2 +- plugin/storage/es/factory.go | 2 +- plugin/storage/es/factory_test.go | 2 +- plugin/storage/es/options.go | 7 ++++ .../storage/integration/elasticsearch_test.go | 4 +-- .../integration/token_propagation_test.go | 35 ++----------------- scripts/travis/es-integration-test.sh | 28 ++++++++------- 18 files changed, 102 insertions(+), 193 deletions(-) diff --git a/pkg/es/client.go b/pkg/es/client.go index ec9cf45fa01..bdfbb1c7af7 100644 --- a/pkg/es/client.go +++ b/pkg/es/client.go @@ -31,7 +31,7 @@ type Client interface { Search(indices ...string) SearchService MultiSearch() MultiSearchService io.Closer - GetVersion() int + GetVersion() uint } // IndicesExistsService is an abstraction for elastic.IndicesExistsService diff --git a/pkg/es/config/config.go b/pkg/es/config/config.go index a7012446f0c..4b556101187 100644 --- a/pkg/es/config/config.go +++ b/pkg/es/config/config.go @@ -63,6 +63,7 @@ type Configuration struct { TLS TLSConfig UseReadWriteAliases bool CreateIndexTemplates bool + Version uint } // TLSConfig describes the configuration properties to connect tls enabled ElasticSearch cluster @@ -89,6 +90,7 @@ type ClientBuilder interface { GetTokenFilePath() string IsEnabled() bool IsCreateIndexTemplates() bool + GetVersion() uint } // NewClient creates a new ElasticSearch client @@ -157,18 +159,21 @@ func (c *Configuration) NewClient(logger *zap.Logger, metricsFactory metrics.Fac return nil, err } - // Determine ElasticSearch Version - pingResult, _, err := rawClient.Ping(c.Servers[0]).Do(context.Background()) - if err != nil { - return nil, err - } - esVersion, err := strconv.Atoi(string(pingResult.Version.Number[0])) - if err != nil { - return nil, err + if c.Version == 0 { + // Determine ElasticSearch Version + pingResult, _, err := rawClient.Ping(c.Servers[0]).Do(context.Background()) + if err != nil { + return nil, err + } + esVersion, err := strconv.Atoi(string(pingResult.Version.Number[0])) + if err != nil { + return nil, err + } + logger.Info("Elasticsearch detected", zap.Int("version", esVersion)) + c.Version = uint(esVersion) } - logger.Info("Elasticsearch detected", zap.Int("version", esVersion)) - return eswrapper.WrapESClient(rawClient, service, esVersion), nil + return eswrapper.WrapESClient(rawClient, service, c.Version), nil } // ApplyDefaults copies settings from source unless its own value is non-zero. @@ -243,6 +248,11 @@ func (c *Configuration) GetAllTagsAsFields() bool { return c.AllTagsAsFields } +// GetVersion returns Elasticsearch version +func (c *Configuration) GetVersion() uint { + return c.Version +} + // GetTagDotReplacement returns character is used to replace dots in tag keys, when // the tag is stored as object field. func (c *Configuration) GetTagDotReplacement() string { diff --git a/pkg/es/mocks/Client.go b/pkg/es/mocks/Client.go index 58be0f1b095..e3ae0233005 100644 --- a/pkg/es/mocks/Client.go +++ b/pkg/es/mocks/Client.go @@ -1,24 +1,11 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. -// Copyright (c) 2019 The Jaeger Authors. -// -// 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 mocks -import es "github.com/jaegertracing/jaeger/pkg/es" -import mock "github.com/stretchr/testify/mock" +import ( + es "github.com/jaegertracing/jaeger/pkg/es" + mock "github.com/stretchr/testify/mock" +) // Client is an autogenerated mock type for the Client type type Client struct { @@ -72,14 +59,14 @@ func (_m *Client) CreateTemplate(id string) es.TemplateCreateService { } // GetVersion provides a mock function with given fields: -func (_m *Client) GetVersion() int { +func (_m *Client) GetVersion() uint { ret := _m.Called() - var r0 int - if rf, ok := ret.Get(0).(func() int); ok { + var r0 uint + if rf, ok := ret.Get(0).(func() uint); ok { r0 = rf() } else { - r0 = ret.Get(0).(int) + r0 = ret.Get(0).(uint) } return r0 diff --git a/pkg/es/mocks/IndexService.go b/pkg/es/mocks/IndexService.go index 89d373ac1d8..526a8ee1294 100644 --- a/pkg/es/mocks/IndexService.go +++ b/pkg/es/mocks/IndexService.go @@ -1,24 +1,11 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. -// Copyright (c) 2019 The Jaeger Authors. -// -// 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 mocks -import es "github.com/jaegertracing/jaeger/pkg/es" -import mock "github.com/stretchr/testify/mock" +import ( + es "github.com/jaegertracing/jaeger/pkg/es" + mock "github.com/stretchr/testify/mock" +) // IndexService is an autogenerated mock type for the IndexService type type IndexService struct { diff --git a/pkg/es/mocks/IndicesCreateService.go b/pkg/es/mocks/IndicesCreateService.go index eef1aa50b7f..3f5d3a16b24 100644 --- a/pkg/es/mocks/IndicesCreateService.go +++ b/pkg/es/mocks/IndicesCreateService.go @@ -1,26 +1,15 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. -// Copyright (c) 2019 The Jaeger Authors. -// -// 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 mocks +import ( + context "context" -package mocks + es "github.com/jaegertracing/jaeger/pkg/es" + elastic "github.com/olivere/elastic" -import context "context" -import elastic "github.com/olivere/elastic" -import es "github.com/jaegertracing/jaeger/pkg/es" -import mock "github.com/stretchr/testify/mock" + mock "github.com/stretchr/testify/mock" +) // IndicesCreateService is an autogenerated mock type for the IndicesCreateService type type IndicesCreateService struct { diff --git a/pkg/es/mocks/IndicesExistsService.go b/pkg/es/mocks/IndicesExistsService.go index 7ab21af3e25..f6b53a6f354 100644 --- a/pkg/es/mocks/IndicesExistsService.go +++ b/pkg/es/mocks/IndicesExistsService.go @@ -1,25 +1,12 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. -// Copyright (c) 2019 The Jaeger Authors. -// -// 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 mocks -import context "context" +import ( + context "context" -import mock "github.com/stretchr/testify/mock" + mock "github.com/stretchr/testify/mock" +) // IndicesExistsService is an autogenerated mock type for the IndicesExistsService type type IndicesExistsService struct { diff --git a/pkg/es/mocks/MultiSearchService.go b/pkg/es/mocks/MultiSearchService.go index e204734343e..06351c0efb7 100644 --- a/pkg/es/mocks/MultiSearchService.go +++ b/pkg/es/mocks/MultiSearchService.go @@ -1,26 +1,15 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. -// Copyright (c) 2019 The Jaeger Authors. -// -// 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 mocks +import ( + context "context" -package mocks + es "github.com/jaegertracing/jaeger/pkg/es" + elastic "github.com/olivere/elastic" -import context "context" -import elastic "github.com/olivere/elastic" -import es "github.com/jaegertracing/jaeger/pkg/es" -import mock "github.com/stretchr/testify/mock" + mock "github.com/stretchr/testify/mock" +) // MultiSearchService is an autogenerated mock type for the MultiSearchService type type MultiSearchService struct { diff --git a/pkg/es/mocks/SearchService.go b/pkg/es/mocks/SearchService.go index 6cc725521b4..56904550b19 100644 --- a/pkg/es/mocks/SearchService.go +++ b/pkg/es/mocks/SearchService.go @@ -1,26 +1,15 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. -// Copyright (c) 2019 The Jaeger Authors. -// -// 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 mocks +import ( + context "context" -package mocks + es "github.com/jaegertracing/jaeger/pkg/es" + elastic "github.com/olivere/elastic" -import context "context" -import elastic "github.com/olivere/elastic" -import es "github.com/jaegertracing/jaeger/pkg/es" -import mock "github.com/stretchr/testify/mock" + mock "github.com/stretchr/testify/mock" +) // SearchService is an autogenerated mock type for the SearchService type type SearchService struct { diff --git a/pkg/es/mocks/TemplateCreateService.go b/pkg/es/mocks/TemplateCreateService.go index 77db1ece9d1..8437f943103 100644 --- a/pkg/es/mocks/TemplateCreateService.go +++ b/pkg/es/mocks/TemplateCreateService.go @@ -1,26 +1,15 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. -// Copyright (c) 2019 The Jaeger Authors. -// -// 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 mocks +import ( + context "context" -package mocks + es "github.com/jaegertracing/jaeger/pkg/es" + elastic "github.com/olivere/elastic" -import context "context" -import elastic "github.com/olivere/elastic" -import es "github.com/jaegertracing/jaeger/pkg/es" -import mock "github.com/stretchr/testify/mock" + mock "github.com/stretchr/testify/mock" +) // TemplateCreateService is an autogenerated mock type for the TemplateCreateService type type TemplateCreateService struct { diff --git a/pkg/es/wrapper/wrapper.go b/pkg/es/wrapper/wrapper.go index 07d2b15c6e5..9df3a251857 100644 --- a/pkg/es/wrapper/wrapper.go +++ b/pkg/es/wrapper/wrapper.go @@ -29,16 +29,16 @@ import ( type ClientWrapper struct { client *elastic.Client bulkService *elastic.BulkProcessor - esVersion int + esVersion uint } // GetVersion returns the ElasticSearch Version -func (c ClientWrapper) GetVersion() int { +func (c ClientWrapper) GetVersion() uint { return c.esVersion } // WrapESClient creates a ESClient out of *elastic.Client. -func WrapESClient(client *elastic.Client, s *elastic.BulkProcessor, esVersion int) ClientWrapper { +func WrapESClient(client *elastic.Client, s *elastic.BulkProcessor, esVersion uint) ClientWrapper { return ClientWrapper{client: client, bulkService: s, esVersion: esVersion} } @@ -152,11 +152,11 @@ func (c TemplateCreateServiceWrapper) Do(ctx context.Context) (*elastic.IndicesP type IndexServiceWrapper struct { bulkIndexReq *elastic.BulkIndexRequest bulkService *elastic.BulkProcessor - esVersion int + esVersion uint } // WrapESIndexService creates an ESIndexService out of *elastic.ESIndexService. -func WrapESIndexService(indexService *elastic.BulkIndexRequest, bulkService *elastic.BulkProcessor, esVersion int) IndexServiceWrapper { +func WrapESIndexService(indexService *elastic.BulkIndexRequest, bulkService *elastic.BulkProcessor, esVersion uint) IndexServiceWrapper { return IndexServiceWrapper{bulkIndexReq: indexService, bulkService: bulkService, esVersion: esVersion} } diff --git a/plugin/storage/es/dependencystore/schema.go b/plugin/storage/es/dependencystore/schema.go index bb87bdb1438..f869692a237 100644 --- a/plugin/storage/es/dependencystore/schema.go +++ b/plugin/storage/es/dependencystore/schema.go @@ -31,7 +31,7 @@ const dependenciesMapping7 = `{ "mappings":{} }` -func getMapping(version int) string { +func getMapping(version uint) string { if version == 7 { return dependenciesMapping7 } diff --git a/plugin/storage/es/dependencystore/storage_test.go b/plugin/storage/es/dependencystore/storage_test.go index a9badc93e2d..91b71e9cc02 100644 --- a/plugin/storage/es/dependencystore/storage_test.go +++ b/plugin/storage/es/dependencystore/storage_test.go @@ -76,7 +76,7 @@ func TestWriteDependencies(t *testing.T) { createIndexError error writeError error expectedError string - esVersion int + esVersion uint }{ { createIndexError: errors.New("index not created"), diff --git a/plugin/storage/es/factory.go b/plugin/storage/es/factory.go index 4961ff3d637..7960470ce6f 100644 --- a/plugin/storage/es/factory.go +++ b/plugin/storage/es/factory.go @@ -199,7 +199,7 @@ func createSpanWriter( } // GetMappings returns span and service mappings -func GetMappings(shards, replicas int64, esVersion int) (string, string) { +func GetMappings(shards, replicas int64, esVersion uint) (string, string) { if esVersion == 7 { return fixMapping(loadMapping("/jaeger-span-7.json"), shards, replicas), fixMapping(loadMapping("/jaeger-service-7.json"), shards, replicas) diff --git a/plugin/storage/es/factory_test.go b/plugin/storage/es/factory_test.go index 7b619436ace..245237bce80 100644 --- a/plugin/storage/es/factory_test.go +++ b/plugin/storage/es/factory_test.go @@ -52,7 +52,7 @@ func (m *mockClientBuilder) NewClient(logger *zap.Logger, metricsFactory metrics tService.On("Body", mock.Anything).Return(tService) tService.On("Do", context.Background()).Return(nil, m.createTemplateError) c.On("CreateTemplate", mock.Anything).Return(tService) - c.On("GetVersion").Return(6) + c.On("GetVersion").Return(uint(6)) return c, nil } return nil, m.err diff --git a/plugin/storage/es/options.go b/plugin/storage/es/options.go index 42308a39ee4..2aca7954660 100644 --- a/plugin/storage/es/options.go +++ b/plugin/storage/es/options.go @@ -54,6 +54,7 @@ const ( suffixReadAlias = ".use-aliases" suffixCreateIndexTemplate = ".create-index-templates" suffixEnabled = ".enabled" + suffixVersion = ".version" ) // TODO this should be moved next to config.Configuration struct (maybe ./flags package) @@ -96,6 +97,7 @@ func NewOptions(primaryNamespace string, otherNamespaces ...string) *Options { TagDotReplacement: "@", Enabled: true, CreateIndexTemplates: true, + Version: 0, }, servers: "http://127.0.0.1:9200", namespace: primaryNamespace, @@ -221,6 +223,10 @@ func addFlags(flagSet *flag.FlagSet, nsConfig *namespaceConfig) { nsConfig.namespace+suffixCreateIndexTemplate, nsConfig.CreateIndexTemplates, "Create index templates at application startup. Set to false when templates are installed manually.") + flagSet.Uint( + nsConfig.namespace+suffixVersion, + 0, + "The major Elasticsearch version. The not specified value enables auto-detection from Elasticsearch API.") if nsConfig.namespace == archiveNamespace { flagSet.Bool( nsConfig.namespace+suffixEnabled, @@ -264,6 +270,7 @@ func initFromViper(cfg *namespaceConfig, v *viper.Viper) { cfg.UseReadWriteAliases = v.GetBool(cfg.namespace + suffixReadAlias) cfg.Enabled = v.GetBool(cfg.namespace + suffixEnabled) cfg.CreateIndexTemplates = v.GetBool(cfg.namespace + suffixCreateIndexTemplate) + cfg.Version = uint(v.GetInt(cfg.namespace + suffixVersion)) // TODO: Need to figure out a better way for do this. cfg.AllowTokenFromContext = v.GetBool(spanstore.StoragePropagationKey) } diff --git a/plugin/storage/integration/elasticsearch_test.go b/plugin/storage/integration/elasticsearch_test.go index 22bd3eb2cb5..8c53a437404 100644 --- a/plugin/storage/integration/elasticsearch_test.go +++ b/plugin/storage/integration/elasticsearch_test.go @@ -56,7 +56,7 @@ type ESStorageIntegration struct { logger *zap.Logger } -func (s *ESStorageIntegration) getVersion() (int, error) { +func (s *ESStorageIntegration) getVersion() (uint, error) { pingResult, _, err := s.client.Ping(queryURL).Do(context.Background()) if err != nil { return 0, err @@ -65,7 +65,7 @@ func (s *ESStorageIntegration) getVersion() (int, error) { if err != nil { return 0, err } - return esVersion, nil + return uint(esVersion), nil } func (s *ESStorageIntegration) initializeES(allTagsAsFields, archive bool) error { diff --git a/plugin/storage/integration/token_propagation_test.go b/plugin/storage/integration/token_propagation_test.go index 8f82a988947..c3b7dd965d0 100644 --- a/plugin/storage/integration/token_propagation_test.go +++ b/plugin/storage/integration/token_propagation_test.go @@ -19,16 +19,12 @@ package integration import ( "context" "encoding/json" - "net/http" - "os" - "os/exec" - "strings" - "testing" - "time" - "github.com/olivere/elastic" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "net/http" + "strings" + "testing" ) const bearerToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsIm5hbWUiOiJKb2huIERvZSIsImlhdCI" @@ -40,16 +36,6 @@ type esTokenPropagationTestHandler struct { } func (h *esTokenPropagationTestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - // Return the elasticsearch version - if r.URL.Path == "/" { - ret := new(elastic.PingResult) - ret.Version.Number = "7.3.0" - json_ret, _ := json.Marshal(ret) - w.Header().Add("Content-Type", "application/json; charset=UTF-8") - w.Write(json_ret) - return - } - authValue := r.Header.Get("Authorization") if authValue != "" { headerValue := strings.Split(authValue, " ") @@ -102,19 +88,6 @@ func TestBearTokenPropagation(t *testing.T) { defer srv.Shutdown(context.Background()) go createElasticSearchMock(srv, t) - // Wait for http server to start - time.Sleep(100 * time.Millisecond) - - // Path relative to plugin/storage/integration/token_propagation_test.go - cmd := exec.Command("../../../cmd/query/query-linux", "--es.server-urls=http://127.0.0.1:9200", "--es.tls=false", "--query.bearer-token-propagation=true") - cmd.Env = []string{"SPAN_STORAGE_TYPE=elasticsearch"} - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err := cmd.Start() - assert.NoError(t, err) - - // Wait for query service to start - time.Sleep(100 * time.Millisecond) // Test cases. for _, testCase := range testCases { @@ -130,6 +103,4 @@ func TestBearTokenPropagation(t *testing.T) { assert.Equal(t, resp.StatusCode, http.StatusOK) } } - - cmd.Process.Kill() } diff --git a/scripts/travis/es-integration-test.sh b/scripts/travis/es-integration-test.sh index a85ece18840..6cc9b347217 100755 --- a/scripts/travis/es-integration-test.sh +++ b/scripts/travis/es-integration-test.sh @@ -2,22 +2,26 @@ set -e -run_integration_test() { - ES_VERSION=$1 - docker pull docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION} - CID=$(docker run --rm -d -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" -e "xpack.security.enabled=false" -e "xpack.monitoring.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION}) - STORAGE=elasticsearch make storage-integration-test - make index-cleaner-integration-test - docker kill $CID -} - -run_integration_test "5.6.16" -run_integration_test "6.8.2" -run_integration_test "7.3.0" +#run_integration_test() { +# ES_VERSION=$1 +# docker pull docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION} +# CID=$(docker run --rm -d -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" -e "xpack.security.enabled=false" -e "xpack.monitoring.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION}) +# STORAGE=elasticsearch make storage-integration-test +# make index-cleaner-integration-test +# docker kill $CID +#} +# +#run_integration_test "5.6.16" +#run_integration_test "6.8.2" +#run_integration_test "7.3.0" echo "Executing token propatagion test" # Mock UI, needed only for build query service. make build-crossdock-ui-placeholder GOOS=linux make build-query + +SPAN_STORAGE_TYPE=elasticsearch ./cmd/query/query-linux --es.server-urls=http://127.0.0.1:9200 --es.tls=false --es.version=7 --query.bearer-token-propagation=true & +PID=$(echo $!) make token-propagation-integration-test +kill -9 ${PID} From 7731fab270faecf9b76fe698262ae3bd899ee05c Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Thu, 22 Aug 2019 13:55:44 +0200 Subject: [PATCH 2/3] Add back tests Signed-off-by: Pavol Loffay --- scripts/travis/es-integration-test.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/travis/es-integration-test.sh b/scripts/travis/es-integration-test.sh index 6cc9b347217..fd68ea1dd36 100755 --- a/scripts/travis/es-integration-test.sh +++ b/scripts/travis/es-integration-test.sh @@ -2,18 +2,18 @@ set -e -#run_integration_test() { -# ES_VERSION=$1 -# docker pull docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION} -# CID=$(docker run --rm -d -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" -e "xpack.security.enabled=false" -e "xpack.monitoring.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION}) -# STORAGE=elasticsearch make storage-integration-test -# make index-cleaner-integration-test -# docker kill $CID -#} -# -#run_integration_test "5.6.16" -#run_integration_test "6.8.2" -#run_integration_test "7.3.0" +run_integration_test() { + ES_VERSION=$1 + docker pull docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION} + CID=$(docker run --rm -d -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" -e "xpack.security.enabled=false" -e "xpack.monitoring.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION}) + STORAGE=elasticsearch make storage-integration-test + make index-cleaner-integration-test + docker kill $CID +} + +run_integration_test "5.6.16" +run_integration_test "6.8.2" +run_integration_test "7.3.0" echo "Executing token propatagion test" From aa2f526161becfdcfcddbba0b9a6d2464792d0af Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Thu, 22 Aug 2019 16:24:30 +0200 Subject: [PATCH 3/3] Format Signed-off-by: Pavol Loffay --- pkg/es/config/config.go | 2 +- pkg/es/mocks/Client.go | 18 +++++++++++++++++- pkg/es/mocks/IndexService.go | 18 +++++++++++++++++- pkg/es/mocks/IndicesCreateService.go | 19 +++++++++++++++++-- pkg/es/mocks/IndicesExistsService.go | 15 +++++++++++++++ pkg/es/mocks/MultiSearchService.go | 19 +++++++++++++++++-- pkg/es/mocks/SearchService.go | 19 +++++++++++++++++-- pkg/es/mocks/TemplateCreateService.go | 19 +++++++++++++++++-- plugin/storage/es/options.go | 4 ++-- .../integration/token_propagation_test.go | 7 ++++--- 10 files changed, 124 insertions(+), 16 deletions(-) diff --git a/pkg/es/config/config.go b/pkg/es/config/config.go index 4b556101187..ee0c5a842ef 100644 --- a/pkg/es/config/config.go +++ b/pkg/es/config/config.go @@ -63,7 +63,7 @@ type Configuration struct { TLS TLSConfig UseReadWriteAliases bool CreateIndexTemplates bool - Version uint + Version uint } // TLSConfig describes the configuration properties to connect tls enabled ElasticSearch cluster diff --git a/pkg/es/mocks/Client.go b/pkg/es/mocks/Client.go index e3ae0233005..1717a8c39f9 100644 --- a/pkg/es/mocks/Client.go +++ b/pkg/es/mocks/Client.go @@ -1,10 +1,26 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. +// Copyright (c) 2019 The Jaeger Authors. +// +// 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 mocks import ( - es "github.com/jaegertracing/jaeger/pkg/es" mock "github.com/stretchr/testify/mock" + + es "github.com/jaegertracing/jaeger/pkg/es" ) // Client is an autogenerated mock type for the Client type diff --git a/pkg/es/mocks/IndexService.go b/pkg/es/mocks/IndexService.go index 526a8ee1294..369babcff31 100644 --- a/pkg/es/mocks/IndexService.go +++ b/pkg/es/mocks/IndexService.go @@ -1,10 +1,26 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. +// Copyright (c) 2019 The Jaeger Authors. +// +// 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 mocks import ( - es "github.com/jaegertracing/jaeger/pkg/es" mock "github.com/stretchr/testify/mock" + + es "github.com/jaegertracing/jaeger/pkg/es" ) // IndexService is an autogenerated mock type for the IndexService type diff --git a/pkg/es/mocks/IndicesCreateService.go b/pkg/es/mocks/IndicesCreateService.go index 3f5d3a16b24..2e84e521493 100644 --- a/pkg/es/mocks/IndicesCreateService.go +++ b/pkg/es/mocks/IndicesCreateService.go @@ -1,14 +1,29 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. +// Copyright (c) 2019 The Jaeger Authors. +// +// 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 mocks import ( context "context" - es "github.com/jaegertracing/jaeger/pkg/es" elastic "github.com/olivere/elastic" - mock "github.com/stretchr/testify/mock" + + es "github.com/jaegertracing/jaeger/pkg/es" ) // IndicesCreateService is an autogenerated mock type for the IndicesCreateService type diff --git a/pkg/es/mocks/IndicesExistsService.go b/pkg/es/mocks/IndicesExistsService.go index f6b53a6f354..4d190064703 100644 --- a/pkg/es/mocks/IndicesExistsService.go +++ b/pkg/es/mocks/IndicesExistsService.go @@ -1,5 +1,20 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. +// Copyright (c) 2019 The Jaeger Authors. +// +// 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 mocks import ( diff --git a/pkg/es/mocks/MultiSearchService.go b/pkg/es/mocks/MultiSearchService.go index 06351c0efb7..cb90f157882 100644 --- a/pkg/es/mocks/MultiSearchService.go +++ b/pkg/es/mocks/MultiSearchService.go @@ -1,14 +1,29 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. +// Copyright (c) 2019 The Jaeger Authors. +// +// 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 mocks import ( context "context" - es "github.com/jaegertracing/jaeger/pkg/es" elastic "github.com/olivere/elastic" - mock "github.com/stretchr/testify/mock" + + es "github.com/jaegertracing/jaeger/pkg/es" ) // MultiSearchService is an autogenerated mock type for the MultiSearchService type diff --git a/pkg/es/mocks/SearchService.go b/pkg/es/mocks/SearchService.go index 56904550b19..42d4a618b16 100644 --- a/pkg/es/mocks/SearchService.go +++ b/pkg/es/mocks/SearchService.go @@ -1,14 +1,29 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. +// Copyright (c) 2019 The Jaeger Authors. +// +// 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 mocks import ( context "context" - es "github.com/jaegertracing/jaeger/pkg/es" elastic "github.com/olivere/elastic" - mock "github.com/stretchr/testify/mock" + + es "github.com/jaegertracing/jaeger/pkg/es" ) // SearchService is an autogenerated mock type for the SearchService type diff --git a/pkg/es/mocks/TemplateCreateService.go b/pkg/es/mocks/TemplateCreateService.go index 8437f943103..eb739f3b8ad 100644 --- a/pkg/es/mocks/TemplateCreateService.go +++ b/pkg/es/mocks/TemplateCreateService.go @@ -1,14 +1,29 @@ // Code generated by mockery v1.0.0. DO NOT EDIT. +// Copyright (c) 2019 The Jaeger Authors. +// +// 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 mocks import ( context "context" - es "github.com/jaegertracing/jaeger/pkg/es" elastic "github.com/olivere/elastic" - mock "github.com/stretchr/testify/mock" + + es "github.com/jaegertracing/jaeger/pkg/es" ) // TemplateCreateService is an autogenerated mock type for the TemplateCreateService type diff --git a/plugin/storage/es/options.go b/plugin/storage/es/options.go index 2aca7954660..9b6b52c32e6 100644 --- a/plugin/storage/es/options.go +++ b/plugin/storage/es/options.go @@ -97,7 +97,7 @@ func NewOptions(primaryNamespace string, otherNamespaces ...string) *Options { TagDotReplacement: "@", Enabled: true, CreateIndexTemplates: true, - Version: 0, + Version: 0, }, servers: "http://127.0.0.1:9200", namespace: primaryNamespace, @@ -226,7 +226,7 @@ func addFlags(flagSet *flag.FlagSet, nsConfig *namespaceConfig) { flagSet.Uint( nsConfig.namespace+suffixVersion, 0, - "The major Elasticsearch version. The not specified value enables auto-detection from Elasticsearch API.") + "The major Elasticsearch version. If not specified, the value will be auto-detected from Elasticsearch.") if nsConfig.namespace == archiveNamespace { flagSet.Bool( nsConfig.namespace+suffixEnabled, diff --git a/plugin/storage/integration/token_propagation_test.go b/plugin/storage/integration/token_propagation_test.go index c3b7dd965d0..de6ddaa7141 100644 --- a/plugin/storage/integration/token_propagation_test.go +++ b/plugin/storage/integration/token_propagation_test.go @@ -19,12 +19,13 @@ package integration import ( "context" "encoding/json" - "github.com/olivere/elastic" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "net/http" "strings" "testing" + + "github.com/olivere/elastic" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) const bearerToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsIm5hbWUiOiJKb2huIERvZSIsImlhdCI"