Skip to content

Commit

Permalink
[storage]Upgraded integration tests to use Dependency Writer of stora…
Browse files Browse the repository at this point in the history
…ge_v2 (jaegertracing#6559)

<!--
!! Please DELETE this comment before posting.
We appreciate your contribution to the Jaeger project! 👋🎉
-->

## Which problem is this PR solving?
Fixes a part of: jaegertracing#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 <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
  • Loading branch information
Manik2708 and yurishkuro committed Jan 21, 2025
1 parent db6ee71 commit 1d77c5f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
9 changes: 4 additions & 5 deletions plugin/storage/integration/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

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 @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions plugin/storage/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
15 changes: 15 additions & 0 deletions storage_v2/depstore/writer.go
Original file line number Diff line number Diff line change
@@ -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
}
17 changes: 17 additions & 0 deletions storage_v2/v1adapter/tracewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
}

0 comments on commit 1d77c5f

Please sign in to comment.