From 1d77c5f0af636cf2261f76a02ac32574c235ac27 Mon Sep 17 00:00:00 2001 From: Manik Mehta Date: Sat, 18 Jan 2025 06:27:35 +0530 Subject: [PATCH] [storage]Upgraded integration tests to use Dependency Writer of storage_v2 (#6559) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Which problem is this PR solving? Fixes a part of: #6366 ## Description of the changes - Upgared the integration tests ## How was this change tested? - e2e tests ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` Signed-off-by: Manik2708 Co-authored-by: Yuri Shkuro --- plugin/storage/integration/cassandra_test.go | 9 ++++----- .../storage/integration/elasticsearch_test.go | 2 +- plugin/storage/integration/integration.go | 3 +-- storage_v2/depstore/writer.go | 15 +++++++++++++++ storage_v2/v1adapter/tracewriter.go | 17 +++++++++++++++++ 5 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 storage_v2/depstore/writer.go diff --git a/plugin/storage/integration/cassandra_test.go b/plugin/storage/integration/cassandra_test.go index 59f26b46d00..161a695cc03 100644 --- a/plugin/storage/integration/cassandra_test.go +++ b/plugin/storage/integration/cassandra_test.go @@ -89,17 +89,16 @@ func (s *CassandraStorageIntegration) initializeCassandra(t *testing.T) { } func (s *CassandraStorageIntegration) initializeDependencyReaderAndWriter(t *testing.T, f *cassandra.Factory) { - var ( - err error - ok bool - ) + var err error dependencyReader, err := f.CreateDependencyReader() require.NoError(t, err) s.DependencyReader = v1adapter.NewDependencyReader(dependencyReader) // TODO: Update this when the factory interface has CreateDependencyWriter - if s.DependencyWriter, ok = dependencyReader.(dependencystore.Writer); !ok { + if dependencyWriter, ok := dependencyReader.(dependencystore.Writer); !ok { t.Log("DependencyWriter not implemented ") + } else { + s.DependencyWriter = v1adapter.NewDependencyWriter(dependencyWriter) } } diff --git a/plugin/storage/integration/elasticsearch_test.go b/plugin/storage/integration/elasticsearch_test.go index 8e5c3b8abf3..c7e5618b14e 100644 --- a/plugin/storage/integration/elasticsearch_test.go +++ b/plugin/storage/integration/elasticsearch_test.go @@ -148,7 +148,7 @@ func (s *ESStorageIntegration) initSpanstore(t *testing.T, allTagsAsFields bool) require.NoError(t, err) s.DependencyReader = v1adapter.NewDependencyReader(dependencyReader) - s.DependencyWriter = dependencyReader.(dependencystore.Writer) + s.DependencyWriter = v1adapter.NewDependencyWriter(dependencyReader.(dependencystore.Writer)) s.SamplingStore, err = f.CreateSamplingStore(1) require.NoError(t, err) diff --git a/plugin/storage/integration/integration.go b/plugin/storage/integration/integration.go index d5998ac806f..05c6e5465e5 100644 --- a/plugin/storage/integration/integration.go +++ b/plugin/storage/integration/integration.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/require" "github.com/jaegertracing/jaeger/model" - "github.com/jaegertracing/jaeger/storage/dependencystore" "github.com/jaegertracing/jaeger/storage/samplingstore" samplemodel "github.com/jaegertracing/jaeger/storage/samplingstore/model" "github.com/jaegertracing/jaeger/storage/spanstore" @@ -48,7 +47,7 @@ type StorageIntegration struct { TraceReader tracestore.Reader ArchiveSpanReader spanstore.Reader ArchiveSpanWriter spanstore.Writer - DependencyWriter dependencystore.Writer + DependencyWriter depstore.Writer DependencyReader depstore.Reader SamplingStore samplingstore.Store Fixtures []*QueryFixtures diff --git a/storage_v2/depstore/writer.go b/storage_v2/depstore/writer.go new file mode 100644 index 00000000000..914a6a11c5b --- /dev/null +++ b/storage_v2/depstore/writer.go @@ -0,0 +1,15 @@ +// Copyright (c) 2025 The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 + +package depstore + +import ( + "time" + + "github.com/jaegertracing/jaeger/model" +) + +// Writer write the dependencies into the storage +type Writer interface { + WriteDependencies(ts time.Time, dependencies []model.DependencyLink) error +} diff --git a/storage_v2/v1adapter/tracewriter.go b/storage_v2/v1adapter/tracewriter.go index 4c9c6f75281..7b84b9e5832 100644 --- a/storage_v2/v1adapter/tracewriter.go +++ b/storage_v2/v1adapter/tracewriter.go @@ -6,9 +6,12 @@ package v1adapter import ( "context" "errors" + "time" "go.opentelemetry.io/collector/pdata/ptrace" + "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/storage/dependencystore" "github.com/jaegertracing/jaeger/storage/spanstore" "github.com/jaegertracing/jaeger/storage_v2/tracestore" ) @@ -47,3 +50,17 @@ func (t *TraceWriter) WriteTraces(ctx context.Context, td ptrace.Traces) error { } return errors.Join(errs...) } + +type DependencyWriter struct { + writer dependencystore.Writer +} + +func NewDependencyWriter(writer dependencystore.Writer) *DependencyWriter { + return &DependencyWriter{ + writer: writer, + } +} + +func (dw *DependencyWriter) WriteDependencies(ts time.Time, dependencies []model.DependencyLink) error { + return dw.writer.WriteDependencies(ts, dependencies) +}