Skip to content

Commit

Permalink
Fix ES Integration Test
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Jan 18, 2025
1 parent 43b7604 commit 7c4c43e
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions plugin/storage/integration/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ type ESStorageIntegration struct {
client *elastic.Client
v8Client *elasticsearch8.Client

factory *es.Factory
factory *es.Factory
archiveFactory *es.Factory
}

func (s *ESStorageIntegration) getVersion() (uint, error) {
Expand Down Expand Up @@ -102,23 +103,10 @@ func (s *ESStorageIntegration) esCleanUp(t *testing.T) {
require.NoError(t, s.factory.Purge(context.Background()))
}

func (*ESStorageIntegration) initializeESFactory(t *testing.T, allTagsAsFields bool) *es.Factory {
func (*ESStorageIntegration) initializeESFactory(t *testing.T, args []string, factoryInit func() *es.Factory) *es.Factory {
logger := zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller()))
f := es.NewFactory()
f := factoryInit()
v, command := config.Viperize(f.AddFlags)
args := []string{
fmt.Sprintf("--es.num-shards=%v", 5),
fmt.Sprintf("--es.num-replicas=%v", 1),
fmt.Sprintf("--es.index-prefix=%v", indexPrefix),
fmt.Sprintf("--es.use-ilm=%v", false),
fmt.Sprintf("--es.service-cache-ttl=%v", 1*time.Second),
fmt.Sprintf("--es.tags-as-fields.all=%v", allTagsAsFields),
fmt.Sprintf("--es.bulk.actions=%v", 1),
fmt.Sprintf("--es.bulk.flush-interval=%v", time.Nanosecond),
"--es-archive.enabled=true",
fmt.Sprintf("--es-archive.tags-as-fields.all=%v", allTagsAsFields),
fmt.Sprintf("--es-archive.index-prefix=%v", indexPrefix),
}
require.NoError(t, command.ParseFlags(args))
f.InitFromViper(v, logger)
require.NoError(t, f.Initialize(metrics.NullFactory, logger))
Expand All @@ -130,18 +118,33 @@ func (*ESStorageIntegration) initializeESFactory(t *testing.T, allTagsAsFields b
}

func (s *ESStorageIntegration) initSpanstore(t *testing.T, allTagsAsFields bool) {
f := s.initializeESFactory(t, allTagsAsFields)
f := s.initializeESFactory(t, []string{
fmt.Sprintf("--es.num-shards=%v", 5),
fmt.Sprintf("--es.num-replicas=%v", 1),
fmt.Sprintf("--es.index-prefix=%v", indexPrefix),
fmt.Sprintf("--es.use-ilm=%v", false),
fmt.Sprintf("--es.service-cache-ttl=%v", 1*time.Second),
fmt.Sprintf("--es.tags-as-fields.all=%v", allTagsAsFields),
fmt.Sprintf("--es.bulk.actions=%v", 1),
fmt.Sprintf("--es.bulk.flush-interval=%v", time.Nanosecond),
"--es-archive.enabled=true",
}, es.NewFactory)
af := s.initializeESFactory(t, []string{
fmt.Sprintf("--es-archive.tags-as-fields.all=%v", allTagsAsFields),
fmt.Sprintf("--es-archive.index-prefix=%v", indexPrefix),
}, es.NewArchiveFactory)
s.factory = f
s.archiveFactory = af
var err error
spanWriter, err := f.CreateSpanWriter()
require.NoError(t, err)
s.TraceWriter = v1adapter.NewTraceWriter(spanWriter)
spanReader, err := f.CreateSpanReader()
require.NoError(t, err)
s.TraceReader = v1adapter.NewTraceReader(spanReader)
s.ArchiveSpanReader, err = f.CreateArchiveSpanReader()
s.ArchiveSpanReader, err = af.CreateSpanReader()
require.NoError(t, err)
s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter()
s.ArchiveSpanWriter, err = af.CreateSpanWriter()
require.NoError(t, err)

dependencyReader, err := f.CreateDependencyReader()
Expand Down

0 comments on commit 7c4c43e

Please sign in to comment.