Skip to content

Commit

Permalink
Upgrade storage integration test to tracestore archive reader and writer
Browse files Browse the repository at this point in the history
Signed-off-by: Emmanuel Emonueje Ebenezer <[email protected]>
  • Loading branch information
ekefan committed Jan 6, 2025
1 parent b1153a0 commit 2ca2f23
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
5 changes: 1 addition & 4 deletions plugin/storage/integration/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ func (s *CassandraStorageIntegration) initializeCassandra(t *testing.T) {
spanReader, err := f.CreateSpanReader()
require.NoError(t, err)
s.TraceReader = v1adapter.NewTraceReader(spanReader)
s.ArchiveSpanReader, err = f.CreateArchiveSpanReader()
require.NoError(t, err)
s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter()
require.NoError(t, err)
s.ArchiveTraceReader, s.ArchiveTraceWriter = v1adapter.InitializeArchiveStorage(s.factory, zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())))
s.SamplingStore, err = f.CreateSamplingStore(0)
require.NoError(t, err)
s.initializeDependencyReaderAndWriter(t, f)
Expand Down
4 changes: 1 addition & 3 deletions plugin/storage/integration/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ func (s *ESStorageIntegration) initSpanstore(t *testing.T, allTagsAsFields bool)
spanReader, err := f.CreateSpanReader()
require.NoError(t, err)
s.TraceReader = v1adapter.NewTraceReader(spanReader)
s.ArchiveSpanReader, err = f.CreateArchiveSpanReader()
require.NoError(t, err)
s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter()
s.ArchiveTraceReader, s.ArchiveTraceWriter = v1adapter.InitializeArchiveStorage(s.factory, zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())))
require.NoError(t, err)

s.DependencyReader, err = f.CreateDependencyReader()
Expand Down
5 changes: 1 addition & 4 deletions plugin/storage/integration/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ func (s *GRPCStorageIntegrationTestSuite) initialize(t *testing.T) {
spanReader, err := f.CreateSpanReader()
require.NoError(t, err)
s.TraceReader = v1adapter.NewTraceReader(spanReader)
s.ArchiveSpanReader, err = f.CreateArchiveSpanReader()
require.NoError(t, err)
s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter()
require.NoError(t, err)
s.ArchiveTraceReader, s.ArchiveTraceWriter = v1adapter.InitializeArchiveStorage(s.factory, zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())))

// TODO DependencyWriter is not implemented in grpc store

Expand Down
27 changes: 17 additions & 10 deletions plugin/storage/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/storage/dependencystore"
"github.com/jaegertracing/jaeger/storage/samplingstore"
"github.com/jaegertracing/jaeger/storage/spanstore"
"github.com/jaegertracing/jaeger/storage_v2/tracestore"
"github.com/jaegertracing/jaeger/storage_v2/v1adapter"
)
Expand All @@ -45,8 +44,8 @@ var fixtures embed.FS
type StorageIntegration struct {
TraceWriter tracestore.Writer
TraceReader tracestore.Reader
ArchiveSpanReader spanstore.Reader
ArchiveSpanWriter spanstore.Writer
ArchiveTraceReader tracestore.Reader
ArchiveTraceWriter tracestore.Writer
DependencyWriter dependencystore.Writer
DependencyReader dependencystore.Reader
SamplingStore samplingstore.Store
Expand Down Expand Up @@ -189,25 +188,33 @@ func (s *StorageIntegration) testArchiveTrace(t *testing.T) {
}
defer s.cleanUp(t)
tID := model.NewTraceID(uint64(11), uint64(22))
expected := &model.Span{
expectedSpan := &model.Span{
OperationName: "archive_span",
StartTime: time.Now().Add(-time.Hour * 72 * 5).Truncate(time.Microsecond),
TraceID: tID,
SpanID: model.NewSpanID(55),
References: []model.SpanRef{},
Process: model.NewProcess("archived_service", model.KeyValues{}),
}
expectedTrace := &model.Trace{
Spans: []*model.Span{
expectedSpan,
},
}
require.NoError(t, s.ArchiveTraceWriter.WriteTraces(context.Background(), v1adapter.V1TraceToOtelTrace(expectedTrace)))

require.NoError(t, s.ArchiveSpanWriter.WriteSpan(context.Background(), expected))

var actual *model.Trace
var actualTrace *model.Trace
found := s.waitForCondition(t, func(_ *testing.T) bool {
var err error
actual, err = s.ArchiveSpanReader.GetTrace(context.Background(), spanstore.GetTraceParameters{TraceID: tID})
return err == nil && len(actual.Spans) == 1
iterTraces := s.ArchiveTraceReader.GetTraces(context.Background(), tracestore.GetTraceParams{TraceID: tID.ToOTELTraceID()})
traces, err := v1adapter.V1TracesFromSeq2(iterTraces)
if len(traces) > 0 {
actualTrace = traces[0]
}
return err == nil && len(actualTrace.Spans) == 1
})
require.True(t, found)
CompareTraces(t, &model.Trace{Spans: []*model.Span{expected}}, actual)
CompareTraces(t, expectedTrace, actualTrace)
}

func (s *StorageIntegration) testGetLargeSpan(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions plugin/storage/integration/memstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func (s *MemStorageIntegrationTestSuite) initialize(_ *testing.T) {
s.SamplingStore = memory.NewSamplingStore(2)
s.TraceReader = v1adapter.NewTraceReader(store)
s.TraceWriter = v1adapter.NewTraceWriter(store)
s.ArchiveSpanReader = archiveStore
s.ArchiveSpanWriter = archiveStore
s.ArchiveTraceReader = v1adapter.NewTraceReader(archiveStore)
s.ArchiveTraceWriter = v1adapter.NewTraceWriter(archiveStore)

// TODO DependencyWriter is not implemented in memory store

Expand Down

0 comments on commit 2ca2f23

Please sign in to comment.