Skip to content

Commit

Permalink
Fix Unit Tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Nov 16, 2024
1 parent 1ad1d59 commit a1e030a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 10 deletions.
4 changes: 3 additions & 1 deletion cmd/anonymizer/app/query/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
dependencyStoreMocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

var (
Expand Down Expand Up @@ -55,11 +56,12 @@ type testServer struct {

func newTestServer(t *testing.T) *testServer {
spanReader := &spanstoremocks.Reader{}
traceReader := factoryadapter.NewTraceReader(spanReader)
metricsReader, err := disabled.NewMetricsReader()
require.NoError(t, err)

q := querysvc.NewQueryService(
spanReader,
traceReader,
&dependencyStoreMocks.Reader{},
querysvc.QueryServiceOptions{},
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/query/app/apiv3/grpc_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
dependencyStoreMocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

var (
Expand Down Expand Up @@ -57,7 +58,7 @@ func newTestServerClient(t *testing.T) *testServerClient {
}

q := querysvc.NewQueryService(
tsc.reader,
factoryadapter.NewTraceReader(tsc.reader),
&dependencyStoreMocks.Reader{},
querysvc.QueryServiceOptions{},
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/query/app/apiv3/http_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
dependencyStoreMocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

func setupHTTPGatewayNoServer(
Expand All @@ -35,7 +36,7 @@ func setupHTTPGatewayNoServer(
reader: &spanstoremocks.Reader{},
}

q := querysvc.NewQueryService(gw.reader,
q := querysvc.NewQueryService(factoryadapter.NewTraceReader(gw.reader),
&dependencyStoreMocks.Reader{},
querysvc.QueryServiceOptions{},
)
Expand Down
5 changes: 3 additions & 2 deletions cmd/query/app/grpc_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
metricsmocks "github.com/jaegertracing/jaeger/storage/metricsstore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

var (
Expand Down Expand Up @@ -901,7 +902,7 @@ func initializeTenantedTestServerGRPCWithOptions(t *testing.T, tm *tenancy.Manag
require.NoError(t, err)

q := querysvc.NewQueryService(
spanReader,
factoryadapter.NewTraceReader(spanReader),
dependencyReader,
querysvc.QueryServiceOptions{
ArchiveSpanReader: archiveSpanReader,
Expand Down Expand Up @@ -1165,7 +1166,7 @@ func TestNewGRPCHandlerWithEmptyOptions(t *testing.T) {
require.NoError(t, err)

q := querysvc.NewQueryService(
&spanstoremocks.Reader{},
factoryadapter.NewTraceReader(&spanstoremocks.Reader{}),
&depsmocks.Reader{},
querysvc.QueryServiceOptions{})

Expand Down
7 changes: 5 additions & 2 deletions cmd/query/app/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
metricsmocks "github.com/jaegertracing/jaeger/storage/metricsstore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

const millisToNanosMultiplier = int64(time.Millisecond / time.Nanosecond)
Expand Down Expand Up @@ -119,7 +120,8 @@ func initializeTestServerWithOptions(
options = append(options, HandlerOptions.Logger(zaptest.NewLogger(t)))
readStorage := &spanstoremocks.Reader{}
dependencyStorage := &depsmocks.Reader{}
qs := querysvc.NewQueryService(readStorage, dependencyStorage, queryOptions)
traceReader := factoryadapter.NewTraceReader(readStorage)
qs := querysvc.NewQueryService(traceReader, dependencyStorage, queryOptions)
r := NewRouter()
apiHandler := NewAPIHandler(qs, options...)
apiHandler.RegisterRoutes(r)
Expand Down Expand Up @@ -198,8 +200,9 @@ func TestLogOnServerError(t *testing.T) {
zapCore, logs := observer.New(zap.InfoLevel)
logger := zap.New(zapCore)
readStorage := &spanstoremocks.Reader{}
traceReader := factoryadapter.NewTraceReader(readStorage)
dependencyStorage := &depsmocks.Reader{}
qs := querysvc.NewQueryService(readStorage, dependencyStorage, querysvc.QueryServiceOptions{})
qs := querysvc.NewQueryService(traceReader, dependencyStorage, querysvc.QueryServiceOptions{})
h := NewAPIHandler(qs, HandlerOptions.Logger(logger))
e := errors.New("test error")
h.handleError(&httptest.ResponseRecorder{}, e, http.StatusInternalServerError)
Expand Down
4 changes: 3 additions & 1 deletion cmd/query/app/querysvc/query_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
depsmocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

const millisToNanosMultiplier = int64(time.Millisecond / time.Nanosecond)
Expand Down Expand Up @@ -87,6 +88,7 @@ func withAdjuster() testOption {

func initializeTestService(optionAppliers ...testOption) *testQueryService {
readStorage := &spanstoremocks.Reader{}
traceReader := factoryadapter.NewTraceReader(readStorage)
dependencyStorage := &depsmocks.Reader{}

options := QueryServiceOptions{}
Expand All @@ -100,7 +102,7 @@ func initializeTestService(optionAppliers ...testOption) *testQueryService {
optApplier(&tqs, &options)
}

tqs.queryService = NewQueryService(readStorage, dependencyStorage, options)
tqs.queryService = NewQueryService(traceReader, dependencyStorage, options)
return &tqs
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/query/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
depsmocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

var testCertKeyLocation = "../../../pkg/config/tlscfg/testdata"
Expand Down Expand Up @@ -331,10 +332,11 @@ type fakeQueryService struct {

func makeQuerySvc() *fakeQueryService {
spanReader := &spanstoremocks.Reader{}
traceReader := factoryadapter.NewTraceReader(spanReader)
dependencyReader := &depsmocks.Reader{}
expectedServices := []string{"test"}
spanReader.On("GetServices", mock.AnythingOfType("*context.valueCtx")).Return(expectedServices, nil)
qs := querysvc.NewQueryService(spanReader, dependencyReader, querysvc.QueryServiceOptions{})
qs := querysvc.NewQueryService(traceReader, dependencyReader, querysvc.QueryServiceOptions{})
return &fakeQueryService{
qs: qs,
spanReader: spanReader,
Expand Down
4 changes: 3 additions & 1 deletion cmd/query/app/token_propagation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/plugin/storage/es"
"github.com/jaegertracing/jaeger/ports"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

const (
Expand Down Expand Up @@ -83,8 +84,9 @@ func runQueryService(t *testing.T, esURL string) *Server {

spanReader, err := f.CreateSpanReader()
require.NoError(t, err)
traceReader := factoryadapter.NewTraceReader(spanReader)

querySvc := querysvc.NewQueryService(spanReader, nil, querysvc.QueryServiceOptions{})
querySvc := querysvc.NewQueryService(traceReader, nil, querysvc.QueryServiceOptions{})
telset := telemetery.Setting{
Logger: flagsSvc.Logger,
TracerProvider: jtracer.NoOp().OTEL,
Expand Down

0 comments on commit a1e030a

Please sign in to comment.