Skip to content

Commit e60b2df

Browse files
authored
Fix paths in mockery config (#7045)
## Which problem is this PR solving? - When we did a recent move of a bunch of packages to internal/ the mocks were moved manually instead of being re-generated via mockery and the paths in the mockery config were not updated. The mockery run would log warnings, but unfortunately not fail. ## Description of the changes - Fix the paths to eliminate most warnings (the remaining one is deprecation notice) - Change Makefile target to first remove all mocks/*.go files to ensure generated code is not stale - Regenerate some affected mocks - Remove AgentService from crossdock (doesn't exist anymore) and fix the tests - We had a mock for `crossdock.T` stored and never regenerated. Moved it from under mocks/ into `t_mock_test.go`. ## How was this change tested? - CI --------- Signed-off-by: Yuri Shkuro <[email protected]>
1 parent 23cf4c0 commit e60b2df

17 files changed

+126
-124
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ resource.syso
5151
.gocache
5252
test-results.json
5353
.metrics/
54+
.mockery.log

.mockery.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@ packages:
2424
SpanProcessor:
2525
github.com/jaegertracing/jaeger/crossdock/services:
2626
interfaces:
27-
AgentService:
27+
CollectorService:
2828
QueryService:
29-
github.com/jaegertracing/jaeger/pkg/cassandra:
29+
github.com/jaegertracing/jaeger/internal/storage/cassandra:
3030
config:
3131
unroll-variadic: false
3232
interfaces:
3333
Iterator:
3434
Query:
3535
Session:
36-
github.com/jaegertracing/jaeger/pkg/distributedlock:
36+
github.com/jaegertracing/jaeger/internal/distributedlock:
3737
config:
3838
all: true
39-
github.com/jaegertracing/jaeger/pkg/es:
39+
github.com/jaegertracing/jaeger/internal/storage/elasticsearch:
4040
config:
4141
all: true
42-
github.com/jaegertracing/jaeger/pkg/es/client:
42+
github.com/jaegertracing/jaeger/internal/storage/elasticsearch/client:
4343
config:
4444
all: true
45-
github.com/jaegertracing/jaeger/pkg/kafka/consumer:
45+
github.com/jaegertracing/jaeger/internal/storage/kafka/consumer:
4646
interfaces:
4747
Consumer:
48-
github.com/jaegertracing/jaeger/plugin/sampling/leaderelection:
48+
github.com/jaegertracing/jaeger/internal/leaderelection:
4949
config:
5050
all: true
5151
github.com/jaegertracing/jaeger/internal/storage/v1/grpc/shared:
@@ -83,4 +83,3 @@ packages:
8383
interfaces:
8484
CoreSpanReader:
8585
CoreSpanWriter:
86-

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ init-submodules:
218218
MOCKERY_FLAGS := --all --disable-version-string
219219
.PHONY: generate-mocks
220220
generate-mocks: $(MOCKERY)
221-
$(MOCKERY)
221+
find . -path '*/mocks/*' -name '*.go' -type f -delete
222+
$(MOCKERY) | tee .mockery.log
222223

223224
.PHONY: certs
224225
certs:
File renamed without changes.

crossdock/services/mocks/AgentService.go renamed to crossdock/services/mocks/CollectorService.go

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crossdock/services/mocks/T.go renamed to crossdock/services/t_mock_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
// Copyright (c) 2017 Uber Technologies, Inc.
33
// SPDX-License-Identifier: Apache-2.0
44

5-
package mocks
5+
package services
66

77
import (
88
"github.com/crossdock/crossdock-go"
99
"github.com/stretchr/testify/mock"
1010
)
1111

12-
// T is an autogenerated mock type for the T type
13-
type T struct {
12+
// TMock is an autogenerated mock type for the crossdock.T type.
13+
// Correction: it used to be auto-generated, but now is't fixed.
14+
type TMock struct {
1415
mock.Mock
1516
}
1617

1718
// Behavior provides a mock function with given fields:
18-
func (_m *T) Behavior() string {
19+
func (_m *TMock) Behavior() string {
1920
ret := _m.Called()
2021

2122
var r0 string
@@ -29,7 +30,7 @@ func (_m *T) Behavior() string {
2930
}
3031

3132
// Param provides a mock function with given fields: key
32-
func (_m *T) Param(key string) string {
33+
func (_m *TMock) Param(key string) string {
3334
ret := _m.Called(key)
3435

3536
var r0 string
@@ -43,36 +44,36 @@ func (_m *T) Param(key string) string {
4344
}
4445

4546
// Tag provides a mock function with given fields: key, value
46-
func (_m *T) Tag(key string, value string) {
47+
func (_m *TMock) Tag(key string, value string) {
4748
_m.Called(key, value)
4849
}
4950

5051
// Errorf provides a mock function with given fields: format, args
51-
func (_m *T) Errorf(format string, args ...interface{}) {
52+
func (_m *TMock) Errorf(format string, args ...any) {
5253
_m.Called(format, args)
5354
}
5455

5556
// Skipf provides a mock function with given fields: format, args
56-
func (_m *T) Skipf(format string, args ...interface{}) {
57+
func (_m *TMock) Skipf(format string, args ...any) {
5758
_m.Called(format, args)
5859
}
5960

6061
// Successf provides a mock function with given fields: format, args
61-
func (_m *T) Successf(format string, args ...interface{}) {
62+
func (_m *TMock) Successf(format string, args ...any) {
6263
_m.Called(format, args)
6364
}
6465

6566
// Fatalf provides a mock function with given fields: format, args
66-
func (_m *T) Fatalf(format string, args ...interface{}) {
67+
func (_m *TMock) Fatalf(format string, args ...any) {
6768
_m.Called(format, args)
6869
}
6970

7071
// FailNow provides a mock function with given fields:
71-
func (_m *T) FailNow() {
72+
func (_m *TMock) FailNow() {
7273
_m.Called()
7374
}
7475

7576
// Put provides a mock function with given fields: status, output
76-
func (_m *T) Put(status crossdock.Status, output string) {
77+
func (_m *TMock) Put(status crossdock.Status, output string) {
7778
_m.Called(status, output)
7879
}

crossdock/services/tracehandler_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func TestAdaptiveSamplingTestInternal(t *testing.T) {
416416
for i, test := range tests {
417417
t.Run(strconv.Itoa(i), func(t *testing.T) {
418418
query := &mocks.QueryService{}
419-
agent := &mocks.AgentService{}
419+
agent := &mocks.CollectorService{}
420420

421421
handler := &TraceHandler{
422422
agent: agent,
@@ -450,8 +450,8 @@ func TestAdaptiveSamplingTestInternal(t *testing.T) {
450450

451451
func TestEndToEndTest(t *testing.T) {
452452
query := &mocks.QueryService{}
453-
agent := &mocks.AgentService{}
454-
cT := &mocks.T{}
453+
agent := &mocks.CollectorService{}
454+
cT := &TMock{}
455455
handler := NewTraceHandler(query, agent, zap.NewNop())
456456
handler.getTracesSleepDuration = time.Millisecond
457457

@@ -489,8 +489,8 @@ func TestAdaptiveSamplingTest(t *testing.T) {
489489
defer server.Close()
490490

491491
query := &mocks.QueryService{}
492-
agent := &mocks.AgentService{}
493-
cT := &mocks.T{}
492+
agent := &mocks.CollectorService{}
493+
cT := &TMock{}
494494
handler := &TraceHandler{
495495
agent: agent,
496496
query: query,
@@ -528,7 +528,7 @@ func TestAdaptiveSamplingTest(t *testing.T) {
528528
},
529529
}
530530

531-
agent = &mocks.AgentService{}
531+
agent = &mocks.CollectorService{}
532532
handler.agent = agent
533533
agent.On("GetSamplingRate", "go", mock.AnythingOfType("string")).Return(0.222, nil)
534534
// The query service returns an adaptive sampled trace

internal/storage/cassandra/mocks/Query.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/storage/cassandra/mocks/Session.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)