Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'opensearch' as a supported value for SPAN_STORAGE_TYPE #3255

Merged
merged 2 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/es-index-cleaner/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
es-index-cleaner-*-*
1 change: 1 addition & 0 deletions plugin/storage/es/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
esmapping-generator-*-*
12 changes: 7 additions & 5 deletions plugin/storage/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ import (

const (
cassandraStorageType = "cassandra"
opensearchStorageType = "opensearch"
elasticsearchStorageType = "elasticsearch"
memoryStorageType = "memory"
kafkaStorageType = "kafka"
grpcPluginStorageType = "grpc-plugin"
badgerStorageType = "badger"
downsamplingRatio = "downsampling.ratio"
downsamplingHashSalt = "downsampling.hashsalt"
spanStorageType = "span-storage-type"

downsamplingRatio = "downsampling.ratio"
downsamplingHashSalt = "downsampling.hashsalt"
spanStorageType = "span-storage-type"

// defaultDownsamplingRatio is the default downsampling ratio.
defaultDownsamplingRatio = 1.0
Expand All @@ -55,7 +57,7 @@ const (
)

// AllStorageTypes defines all available storage backends
var AllStorageTypes = []string{cassandraStorageType, elasticsearchStorageType, memoryStorageType, kafkaStorageType, badgerStorageType, grpcPluginStorageType}
var AllStorageTypes = []string{cassandraStorageType, opensearchStorageType, elasticsearchStorageType, memoryStorageType, kafkaStorageType, badgerStorageType, grpcPluginStorageType}

// Factory implements storage.Factory interface as a meta-factory for storage components.
type Factory struct {
Expand Down Expand Up @@ -90,7 +92,7 @@ func (f *Factory) getFactoryOfType(factoryType string) (storage.Factory, error)
switch factoryType {
case cassandraStorageType:
return cassandra.NewFactory(), nil
case elasticsearchStorageType:
case elasticsearchStorageType, opensearchStorageType:
return es.NewFactory(), nil
case memoryStorageType:
return memory.NewFactory(), nil
Expand Down
1 change: 1 addition & 0 deletions plugin/storage/factory_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type FactoryConfig struct {
// FactoryConfigFromEnvAndCLI reads the desired types of storage backends from SPAN_STORAGE_TYPE and
// DEPENDENCY_STORAGE_TYPE environment variables. Allowed values:
// * `cassandra` - built-in
// * `opensearch` - built-in
// * `elasticsearch` - built-in
// * `memory` - built-in
// * `kafka` - built-in
Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/integration/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func healthCheck() error {
}

func testElasticsearchStorage(t *testing.T, allTagsAsFields, archive bool) {
if os.Getenv("STORAGE") != "elasticsearch" {
if os.Getenv("STORAGE") != "elasticsearch" && os.Getenv("STORAGE") != "opensearch" {
t.Skip("Integration test against ElasticSearch skipped; set STORAGE env var to elasticsearch to run this")
}
if err := healthCheck(); err != nil {
Expand Down
13 changes: 8 additions & 5 deletions scripts/es-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ setup_opensearch() {
}

setup_query() {
local distro=$1
local os=$(go env GOOS)
local arch=$(go env GOARCH)
local params=(
--es.tls.enabled=false
--es.version=7
--es.server-urls=http://127.0.0.1:9200
--query.bearer-token-propagation=true
)
SPAN_STORAGE_TYPE=elasticsearch ./cmd/query/query-linux-${arch} ${params[@]}
SPAN_STORAGE_TYPE=${distro} ./cmd/query/query-${os}-${arch} ${params[@]}
}

teardown_es() {
Expand All @@ -68,7 +70,7 @@ teardown_query() {

build_query() {
make build-crossdock-ui-placeholder
GOOS=linux make build-query
make build-query
}

run_integration_test() {
Expand All @@ -83,16 +85,17 @@ run_integration_test() {
echo "Unknown distribution $distro. Valid options are opensearch or elasticsearch"
usage
fi
STORAGE=elasticsearch make storage-integration-test
STORAGE=${distro} make storage-integration-test
make index-cleaner-integration-test
make index-rollover-integration-test
teardown_es ${cid}
}

run_token_propagation_test() {
local distro=$1
build_query
make test-compile-es-scripts
setup_query &
setup_query ${distro} &
local pid=$!
make token-propagation-integration-test
teardown_query ${pid}
Expand All @@ -104,7 +107,7 @@ main() {
echo "Executing integration test for $1 $2"
run_integration_test "$1" "$2"
echo "Executing token propagation test"
run_token_propagation_test
run_token_propagation_test "$1"
}

main "$@"