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

[WIP] Upgrade storage integration test: Use V2 Archive ReaderWriter #6489

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 4 additions & 2 deletions plugin/storage/integration/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ 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()
archiveSpanReader, err := f.CreateArchiveSpanReader()
require.NoError(t, err)
s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter()
s.ArchiveTraceReader = v1adapter.NewTraceReader(archiveSpanReader)
archiveSpanWriter, err := f.CreateArchiveSpanWriter()
require.NoError(t, err)
s.ArchiveTraceWriter = v1adapter.NewTraceWriter(archiveSpanWriter)
s.SamplingStore, err = f.CreateSamplingStore(0)
require.NoError(t, err)
s.initializeDependencyReaderAndWriter(t, f)
Expand Down
9 changes: 6 additions & 3 deletions plugin/storage/integration/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,24 @@ func (s *ESStorageIntegration) initSpanstore(t *testing.T, allTagsAsFields bool)
f := s.initializeESFactory(t, allTagsAsFields)
s.factory = f
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 = f.CreateArchiveSpanReader()
require.NoError(t, err)
s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter()
s.ArchiveTraceReader = v1adapter.NewTraceReader(s.ArchiveSpanReader)
archiveSpanWriter, err := f.CreateArchiveSpanWriter()
require.NoError(t, err)
s.ArchiveTraceWriter = v1adapter.NewTraceWriter(archiveSpanWriter)

dependencyReader, err := f.CreateDependencyReader()
require.NoError(t, err)
s.DependencyReader = v1adapter.NewDependencyReader(dependencyReader)

s.DependencyWriter = dependencyReader.(dependencystore.Writer)

s.SamplingStore, err = f.CreateSamplingStore(1)
Expand Down
6 changes: 4 additions & 2 deletions plugin/storage/integration/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ 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()
archiveSpanReader, err := f.CreateArchiveSpanReader()
require.NoError(t, err)
s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter()
s.ArchiveTraceReader = v1adapter.NewTraceReader(archiveSpanReader)
archiveSpanWriter, err := f.CreateArchiveSpanWriter()
require.NoError(t, err)
s.ArchiveTraceWriter = v1adapter.NewTraceWriter(archiveSpanWriter)

// TODO DependencyWriter is not implemented in grpc store

Expand Down
42 changes: 27 additions & 15 deletions plugin/storage/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ var fixtures embed.FS
// Some implementations may declare multiple tests, with different settings,
// and RunAll() under different conditions.
type StorageIntegration struct {
TraceWriter tracestore.Writer
TraceReader tracestore.Reader
ArchiveSpanReader spanstore.Reader
ArchiveSpanWriter spanstore.Writer
DependencyWriter dependencystore.Writer
DependencyReader depstore.Reader
SamplingStore samplingstore.Store
Fixtures []*QueryFixtures
TraceWriter tracestore.Writer
TraceReader tracestore.Reader
ArchiveTraceReader tracestore.Reader
ArchiveSpanReader spanstore.Reader
Copy link
Contributor Author

@ekefan ekefan Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the plan is not to get this merged, I just wanted to show you somthing:

the segfaults occured because the ArchiveTraceReader wasn't reading the spans, so `actualTrace1 remained nil, hence the errors when trying to read the spans

but that doesn't occur with the archive span reader...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a tip - if you don't think the PR is ready for merge, you can convert it to a Draft. I would still get a notification of all changes because I subscribe to all, but it won't be saying "Ready for review".

ArchiveTraceWriter tracestore.Writer
DependencyWriter dependencystore.Writer
DependencyReader depstore.Reader
SamplingStore samplingstore.Store
Fixtures []*QueryFixtures

// TODO: remove this after all storage backends return spanKind from GetOperations
GetOperationsMissingSpanKind bool
Expand Down Expand Up @@ -190,25 +191,36 @@ 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]
} else {
actualTrace, err = s.ArchiveSpanReader.GetTrace(context.Background(), spanstore.GetTraceParameters{TraceID: tID})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with span reader, the archive span test(specifically) doesn't fail,
I have had no luck figuring out why it does fail with the archive trace reader,

}

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
Loading