Skip to content

Commit

Permalink
Fix Tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Dec 6, 2024
1 parent bcdc86d commit 55d3d19
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
21 changes: 14 additions & 7 deletions cmd/query/app/grpc_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ import (
"github.com/jaegertracing/jaeger/plugin/metricstore/disabled"
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
"github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics"
depsmocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks"
"github.com/jaegertracing/jaeger/storage/metricstore"
metricsmocks "github.com/jaegertracing/jaeger/storage/metricstore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
"github.com/jaegertracing/jaeger/storage_v2/depstore"
depsmocks "github.com/jaegertracing/jaeger/storage_v2/depstore/mocks"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

Expand Down Expand Up @@ -511,10 +512,13 @@ func TestGetDependenciesSuccessGRPC(t *testing.T) {
withServerAndClient(t, func(server *grpcServer, client *grpcClient) {
expectedDependencies := []model.DependencyLink{{Parent: "killer", Child: "queen", CallCount: 12}}
endTs := time.Now().UTC()
expectedEndTs := endTs.Add(time.Duration(-1) * defaultDependencyLookbackDuration)
server.depReader.On("GetDependencies",
mock.Anything, // context.Context
endTs.Add(time.Duration(-1)*defaultDependencyLookbackDuration),
defaultDependencyLookbackDuration,
depstore.QueryParameters{
StartTime: expectedEndTs.Add(-defaultDependencyLookbackDuration),
EndTime: expectedEndTs,
},
).Return(expectedDependencies, nil).Times(1)

res, err := client.GetDependencies(context.Background(), &api_v2.GetDependenciesRequest{
Expand All @@ -529,11 +533,14 @@ func TestGetDependenciesSuccessGRPC(t *testing.T) {
func TestGetDependenciesFailureGRPC(t *testing.T) {
withServerAndClient(t, func(server *grpcServer, client *grpcClient) {
endTs := time.Now().UTC()
server.depReader.On(
"GetDependencies",
expectedEndTs := endTs.Add(time.Duration(-1) * defaultDependencyLookbackDuration)
server.depReader.On("GetDependencies",
mock.Anything, // context.Context
endTs.Add(time.Duration(-1)*defaultDependencyLookbackDuration),
defaultDependencyLookbackDuration).Return(nil, errStorageGRPC).Times(1)
depstore.QueryParameters{
StartTime: expectedEndTs.Add(-defaultDependencyLookbackDuration),
EndTime: expectedEndTs,
},
).Return(nil, errStorageGRPC).Times(1)

_, err := client.GetDependencies(context.Background(), &api_v2.GetDependenciesRequest{
StartTime: endTs.Add(time.Duration(-1) * defaultDependencyLookbackDuration),
Expand Down
14 changes: 10 additions & 4 deletions cmd/query/app/handler_deps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/jaegertracing/jaeger/model"
ui "github.com/jaegertracing/jaeger/model/json"
"github.com/jaegertracing/jaeger/storage_v2/depstore"
)

func TestDeduplicateDependencies(t *testing.T) {
Expand Down Expand Up @@ -304,8 +305,10 @@ func TestGetDependenciesSuccess(t *testing.T) {
endTs := time.Unix(0, 1476374248550*millisToNanosMultiplier)
ts.dependencyReader.On("GetDependencies",
mock.Anything, // context
endTs,
defaultDependencyLookbackDuration,
depstore.QueryParameters{
StartTime: endTs.Add(-defaultDependencyLookbackDuration),
EndTime: endTs,
},
).Return(expectedDependencies, nil).Times(1)

var response structuredResponse
Expand All @@ -324,8 +327,11 @@ func TestGetDependenciesCassandraFailure(t *testing.T) {
endTs := time.Unix(0, 1476374248550*millisToNanosMultiplier)
ts.dependencyReader.On("GetDependencies",
mock.Anything, // context
endTs,
defaultDependencyLookbackDuration).Return(nil, errStorage).Times(1)
depstore.QueryParameters{
StartTime: endTs.Add(-defaultDependencyLookbackDuration),
EndTime: endTs,
},
).Return(nil, errStorage).Times(1)

var response structuredResponse
err := getJSON(ts.server.URL+"/api/dependencies?endTs=1476374248550&service=testing", &response)
Expand Down

0 comments on commit 55d3d19

Please sign in to comment.