diff --git a/.mockery.header.txt b/.mockery.header.txt new file mode 100644 index 00000000000..e3e63ca7816 --- /dev/null +++ b/.mockery.header.txt @@ -0,0 +1,4 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. diff --git a/.mockery.yaml b/.mockery.yaml index 9e7210dc1c1..9f46e45ae22 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -4,17 +4,66 @@ outpkg: "mocks" dir: "{{.InterfaceDir}}/mocks/" mockname: "{{.InterfaceName}}" filename: "{{.InterfaceName}}.go" +boilerplate-file: .mockery.header.txt packages: + github.com/jaegertracing/jaeger/cmd/collector/app/sanitizer/cache: + interfaces: + ServiceAliasMappingExternalSource: + ServiceAliasMappingStorage: + github.com/jaegertracing/jaeger/cmd/ingester/app/consumer: + interfaces: + Message: + github.com/jaegertracing/jaeger/cmd/ingester/app/processor: + interfaces: + SpanProcessor: + github.com/jaegertracing/jaeger/crossdock/services: + interfaces: + AgentService: + QueryService: + github.com/jaegertracing/jaeger/pkg/cassandra: + config: + unroll-variadic: false + interfaces: + Iterator: + Query: + Session: + github.com/jaegertracing/jaeger/pkg/distributedlock: + config: + all: true github.com/jaegertracing/jaeger/pkg/es: config: all: true - github.com/jaegertracing/jaeger/storage/spanstore: + github.com/jaegertracing/jaeger/pkg/es/client: config: all: true - github.com/jaegertracing/jaeger/proto-gen/storage_v1: + github.com/jaegertracing/jaeger/pkg/kafka/consumer: + interfaces: + Consumer: + github.com/jaegertracing/jaeger/plugin/sampling/leaderelection: config: all: true - github.com/jaegertracing/jaeger/pkg/es/client: + github.com/jaegertracing/jaeger/plugin/storage/grpc: + interfaces: + PluginCapabilities: + github.com/jaegertracing/jaeger/plugin/storage/kafka: + interfaces: + Marshaller: + Unmarshaller: + github.com/jaegertracing/jaeger/proto-gen/storage_v1: + config: + all: true + github.com/jaegertracing/jaeger/storage: + config: + all: true + github.com/jaegertracing/jaeger/storage/dependencystore: + interfaces: + Reader: + github.com/jaegertracing/jaeger/storage/metricsstore: + config: + all: true + github.com/jaegertracing/jaeger/storage/samplingstore: + config: + all: true + github.com/jaegertracing/jaeger/storage/spanstore: config: all: true - diff --git a/cmd/collector/app/sanitizer/cache/mocks/ServiceAliasMappingExternalSource.go b/cmd/collector/app/sanitizer/cache/mocks/ServiceAliasMappingExternalSource.go index a62a84c8b74..65c6e1775fb 100644 --- a/cmd/collector/app/sanitizer/cache/mocks/ServiceAliasMappingExternalSource.go +++ b/cmd/collector/app/sanitizer/cache/mocks/ServiceAliasMappingExternalSource.go @@ -1,17 +1,9 @@ -// Copyright (c) 2019 The Jaeger Authors. -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks @@ -26,7 +18,15 @@ type ServiceAliasMappingExternalSource struct { func (_m *ServiceAliasMappingExternalSource) Load() (map[string]string, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Load") + } + var r0 map[string]string + var r1 error + if rf, ok := ret.Get(0).(func() (map[string]string, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() map[string]string); ok { r0 = rf() } else { @@ -35,7 +35,6 @@ func (_m *ServiceAliasMappingExternalSource) Load() (map[string]string, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -44,3 +43,17 @@ func (_m *ServiceAliasMappingExternalSource) Load() (map[string]string, error) { return r0, r1 } + +// NewServiceAliasMappingExternalSource creates a new instance of ServiceAliasMappingExternalSource. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewServiceAliasMappingExternalSource(t interface { + mock.TestingT + Cleanup(func()) +}) *ServiceAliasMappingExternalSource { + mock := &ServiceAliasMappingExternalSource{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/cmd/collector/app/sanitizer/cache/mocks/ServiceAliasMappingStorage.go b/cmd/collector/app/sanitizer/cache/mocks/ServiceAliasMappingStorage.go index 8a0bc425dc1..9b110c75be3 100644 --- a/cmd/collector/app/sanitizer/cache/mocks/ServiceAliasMappingStorage.go +++ b/cmd/collector/app/sanitizer/cache/mocks/ServiceAliasMappingStorage.go @@ -1,17 +1,9 @@ -// Copyright (c) 2019 The Jaeger Authors. -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks @@ -26,7 +18,15 @@ type ServiceAliasMappingStorage struct { func (_m *ServiceAliasMappingStorage) Load() (map[string]string, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Load") + } + var r0 map[string]string + var r1 error + if rf, ok := ret.Get(0).(func() (map[string]string, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() map[string]string); ok { r0 = rf() } else { @@ -35,7 +35,6 @@ func (_m *ServiceAliasMappingStorage) Load() (map[string]string, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -49,6 +48,10 @@ func (_m *ServiceAliasMappingStorage) Load() (map[string]string, error) { func (_m *ServiceAliasMappingStorage) Save(data map[string]string) error { ret := _m.Called(data) + if len(ret) == 0 { + panic("no return value specified for Save") + } + var r0 error if rf, ok := ret.Get(0).(func(map[string]string) error); ok { r0 = rf(data) @@ -58,3 +61,17 @@ func (_m *ServiceAliasMappingStorage) Save(data map[string]string) error { return r0 } + +// NewServiceAliasMappingStorage creates a new instance of ServiceAliasMappingStorage. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewServiceAliasMappingStorage(t interface { + mock.TestingT + Cleanup(func()) +}) *ServiceAliasMappingStorage { + mock := &ServiceAliasMappingStorage{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/cmd/ingester/app/consumer/consumer_test.go b/cmd/ingester/app/consumer/consumer_test.go index 8c9d5a82f22..c8364bae6bc 100644 --- a/cmd/ingester/app/consumer/consumer_test.go +++ b/cmd/ingester/app/consumer/consumer_test.go @@ -29,11 +29,11 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" - kmocks "github.com/jaegertracing/jaeger/cmd/ingester/app/consumer/mocks" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor" pmocks "github.com/jaegertracing/jaeger/cmd/ingester/app/processor/mocks" "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/kafka/consumer" + kmocks "github.com/jaegertracing/jaeger/pkg/kafka/consumer/mocks" "github.com/jaegertracing/jaeger/pkg/metrics" ) @@ -146,7 +146,7 @@ func TestSaramaConsumerWrapper_start_Messages(t *testing.T) { partitionConsumer: &partitionConsumerWrapper{ topic: topic, partition: partition, - PartitionConsumer: &kmocks.PartitionConsumer{}, + PartitionConsumer: &smocks.PartitionConsumer{}, }, }, } diff --git a/cmd/ingester/app/consumer/mocks/Message.go b/cmd/ingester/app/consumer/mocks/Message.go index 5e72c95da95..ab6b77fd72f 100644 --- a/cmd/ingester/app/consumer/mocks/Message.go +++ b/cmd/ingester/app/consumer/mocks/Message.go @@ -1,16 +1,9 @@ -// Copyright (c) 2018 The Jaeger Authors. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks @@ -25,6 +18,10 @@ type Message struct { func (_m *Message) Key() []byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Key") + } + var r0 []byte if rf, ok := ret.Get(0).(func() []byte); ok { r0 = rf() @@ -41,6 +38,10 @@ func (_m *Message) Key() []byte { func (_m *Message) Offset() int64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Offset") + } + var r0 int64 if rf, ok := ret.Get(0).(func() int64); ok { r0 = rf() @@ -55,6 +56,10 @@ func (_m *Message) Offset() int64 { func (_m *Message) Partition() int32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Partition") + } + var r0 int32 if rf, ok := ret.Get(0).(func() int32); ok { r0 = rf() @@ -69,6 +74,10 @@ func (_m *Message) Partition() int32 { func (_m *Message) Topic() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Topic") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -83,6 +92,10 @@ func (_m *Message) Topic() string { func (_m *Message) Value() []byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Value") + } + var r0 []byte if rf, ok := ret.Get(0).(func() []byte); ok { r0 = rf() @@ -94,3 +107,17 @@ func (_m *Message) Value() []byte { return r0 } + +// NewMessage creates a new instance of Message. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMessage(t interface { + mock.TestingT + Cleanup(func()) +}) *Message { + mock := &Message{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/cmd/ingester/app/consumer/mocks/PartitionConsumer.go b/cmd/ingester/app/consumer/mocks/PartitionConsumer.go deleted file mode 100644 index 85dd7b95788..00000000000 --- a/cmd/ingester/app/consumer/mocks/PartitionConsumer.go +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) 2018 The Jaeger Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mocks - -import ( - sarama "github.com/Shopify/sarama" - mock "github.com/stretchr/testify/mock" -) - -// PartitionConsumer is an autogenerated mock type for the PartitionConsumer type -type PartitionConsumer struct { - mock.Mock -} - -// AsyncClose provides a mock function with given fields: -func (_m *PartitionConsumer) AsyncClose() { - _m.Called() -} - -// Close provides a mock function with given fields: -func (_m *PartitionConsumer) Close() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Errors provides a mock function with given fields: -func (_m *PartitionConsumer) Errors() <-chan *sarama.ConsumerError { - ret := _m.Called() - - var r0 <-chan *sarama.ConsumerError - if rf, ok := ret.Get(0).(func() <-chan *sarama.ConsumerError); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(<-chan *sarama.ConsumerError) - } - } - - return r0 -} - -// HighWaterMarkOffset provides a mock function with given fields: -func (_m *PartitionConsumer) HighWaterMarkOffset() int64 { - ret := _m.Called() - - var r0 int64 - if rf, ok := ret.Get(0).(func() int64); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(int64) - } - - return r0 -} - -// Messages provides a mock function with given fields: -func (_m *PartitionConsumer) Messages() <-chan *sarama.ConsumerMessage { - ret := _m.Called() - - var r0 <-chan *sarama.ConsumerMessage - if rf, ok := ret.Get(0).(func() <-chan *sarama.ConsumerMessage); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(<-chan *sarama.ConsumerMessage) - } - } - - return r0 -} - -// Partition provides a mock function with given fields: -func (_m *PartitionConsumer) Partition() int32 { - ret := _m.Called() - - var r0 int32 - if rf, ok := ret.Get(0).(func() int32); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(int32) - } - - return r0 -} - -// Topic provides a mock function with given fields: -func (_m *PartitionConsumer) Topic() string { - ret := _m.Called() - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// NB (yurishkuro): Added the following functions manually as Makefile doesn't show how to auto-gen it. - -// Pause mocked. -func (_m *PartitionConsumer) Pause() { - _m.Called() -} - -// Resume mocked. -func (_m *PartitionConsumer) Resume() { - _m.Called() -} - -// IsPaused mocked. -func (_m *PartitionConsumer) IsPaused() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} diff --git a/cmd/ingester/app/consumer/processor_factory_test.go b/cmd/ingester/app/consumer/processor_factory_test.go index 6fd944bc07e..86db77f3ef2 100644 --- a/cmd/ingester/app/consumer/processor_factory_test.go +++ b/cmd/ingester/app/consumer/processor_factory_test.go @@ -23,8 +23,9 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" - kmocks "github.com/jaegertracing/jaeger/cmd/ingester/app/consumer/mocks" + cmocks "github.com/jaegertracing/jaeger/cmd/ingester/app/consumer/mocks" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor/mocks" + kmocks "github.com/jaegertracing/jaeger/pkg/kafka/consumer/mocks" "github.com/jaegertracing/jaeger/pkg/metrics" ) @@ -56,7 +57,7 @@ func Test_new(t *testing.T) { processor := pf.new(topic, partition, offset) defer processor.Close() - msg := &kmocks.Message{} + msg := &cmocks.Message{} msg.On("Offset").Return(offset + 1) processor.Process(msg) diff --git a/cmd/ingester/app/processor/mocks/SpanProcessor.go b/cmd/ingester/app/processor/mocks/SpanProcessor.go index 83c086ed687..2bf8031fe9a 100644 --- a/cmd/ingester/app/processor/mocks/SpanProcessor.go +++ b/cmd/ingester/app/processor/mocks/SpanProcessor.go @@ -1,23 +1,16 @@ -// Code generated by mockery v1.0.0 - -// Copyright (c) 2018 The Jaeger Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks -import mock "github.com/stretchr/testify/mock" -import processor "github.com/jaegertracing/jaeger/cmd/ingester/app/processor" +import ( + processor "github.com/jaegertracing/jaeger/cmd/ingester/app/processor" + mock "github.com/stretchr/testify/mock" +) // SpanProcessor is an autogenerated mock type for the SpanProcessor type type SpanProcessor struct { @@ -28,6 +21,10 @@ type SpanProcessor struct { func (_m *SpanProcessor) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -42,6 +39,10 @@ func (_m *SpanProcessor) Close() error { func (_m *SpanProcessor) Process(input processor.Message) error { ret := _m.Called(input) + if len(ret) == 0 { + panic("no return value specified for Process") + } + var r0 error if rf, ok := ret.Get(0).(func(processor.Message) error); ok { r0 = rf(input) @@ -51,3 +52,17 @@ func (_m *SpanProcessor) Process(input processor.Message) error { return r0 } + +// NewSpanProcessor creates a new instance of SpanProcessor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSpanProcessor(t interface { + mock.TestingT + Cleanup(func()) +}) *SpanProcessor { + mock := &SpanProcessor{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/cmd/ingester/app/processor/span_processor_test.go b/cmd/ingester/app/processor/span_processor_test.go index 40b433a36c9..894e6923fb3 100644 --- a/cmd/ingester/app/processor/span_processor_test.go +++ b/cmd/ingester/app/processor/span_processor_test.go @@ -25,7 +25,7 @@ import ( cmocks "github.com/jaegertracing/jaeger/cmd/ingester/app/consumer/mocks" "github.com/jaegertracing/jaeger/model" - umocks "github.com/jaegertracing/jaeger/pkg/kafka/mocks" + umocks "github.com/jaegertracing/jaeger/plugin/storage/kafka/mocks" smocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks" ) diff --git a/cmd/query/app/grpc_handler_test.go b/cmd/query/app/grpc_handler_test.go index a54874141e8..2d66e45b63f 100644 --- a/cmd/query/app/grpc_handler_test.go +++ b/cmd/query/app/grpc_handler_test.go @@ -522,8 +522,11 @@ 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() - server.depReader.On("GetDependencies", endTs.Add(time.Duration(-1)*defaultDependencyLookbackDuration), defaultDependencyLookbackDuration). - Return(expectedDependencies, nil).Times(1) + server.depReader.On("GetDependencies", + mock.Anything, // context.Context + endTs.Add(time.Duration(-1)*defaultDependencyLookbackDuration), + defaultDependencyLookbackDuration, + ).Return(expectedDependencies, nil).Times(1) res, err := client.GetDependencies(context.Background(), &api_v2.GetDependenciesRequest{ StartTime: endTs.Add(time.Duration(-1) * defaultDependencyLookbackDuration), @@ -537,8 +540,11 @@ 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", endTs.Add(time.Duration(-1)*defaultDependencyLookbackDuration), defaultDependencyLookbackDuration). - Return(nil, errStorageGRPC).Times(1) + server.depReader.On( + "GetDependencies", + mock.Anything, // context.Context + endTs.Add(time.Duration(-1)*defaultDependencyLookbackDuration), + defaultDependencyLookbackDuration).Return(nil, errStorageGRPC).Times(1) _, err := client.GetDependencies(context.Background(), &api_v2.GetDependenciesRequest{ StartTime: endTs.Add(time.Duration(-1) * defaultDependencyLookbackDuration), diff --git a/cmd/query/app/handler_deps_test.go b/cmd/query/app/handler_deps_test.go index 50394e4c429..182e149f94d 100644 --- a/cmd/query/app/handler_deps_test.go +++ b/cmd/query/app/handler_deps_test.go @@ -21,6 +21,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/jaegertracing/jaeger/model" @@ -313,7 +314,11 @@ func TestGetDependenciesSuccess(t *testing.T) { defer ts.server.Close() expectedDependencies := []model.DependencyLink{{Parent: "killer", Child: "queen", CallCount: 12}} endTs := time.Unix(0, 1476374248550*millisToNanosMultiplier) - ts.dependencyReader.On("GetDependencies", endTs, defaultDependencyLookbackDuration).Return(expectedDependencies, nil).Times(1) + ts.dependencyReader.On("GetDependencies", + mock.Anything, // context + endTs, + defaultDependencyLookbackDuration, + ).Return(expectedDependencies, nil).Times(1) var response structuredResponse err := getJSON(ts.server.URL+"/api/dependencies?endTs=1476374248550&service=queen", &response) diff --git a/cmd/query/app/querysvc/query_service_test.go b/cmd/query/app/querysvc/query_service_test.go index b20ae18dae6..9363b82e555 100644 --- a/cmd/query/app/querysvc/query_service_test.go +++ b/cmd/query/app/querysvc/query_service_test.go @@ -280,7 +280,11 @@ func TestGetDependencies(t *testing.T) { }, } endTs := time.Unix(0, 1476374248550*millisToNanosMultiplier) - tqs.depsReader.On("GetDependencies", endTs, defaultDependencyLookbackDuration).Return(expectedDependencies, nil).Times(1) + tqs.depsReader.On( + "GetDependencies", + mock.Anything, // context.Context + endTs, + defaultDependencyLookbackDuration).Return(expectedDependencies, nil).Times(1) actualDependencies, err := tqs.queryService.GetDependencies(context.Background(), time.Unix(0, 1476374248550*millisToNanosMultiplier), defaultDependencyLookbackDuration) require.NoError(t, err) diff --git a/cmd/remote-storage/app/server_test.go b/cmd/remote-storage/app/server_test.go index ae8c65adfb3..29324de7d05 100644 --- a/cmd/remote-storage/app/server_test.go +++ b/cmd/remote-storage/app/server_test.go @@ -145,7 +145,12 @@ func TestCreateGRPCHandler(t *testing.T) { require.Error(t, err) assert.Contains(t, err.Error(), "writer error") - storageMocks.depReader.On("GetDependencies", mock.Anything, mock.Anything).Return(nil, errors.New("deps error")) + storageMocks.depReader.On( + "GetDependencies", + mock.Anything, // context + mock.Anything, // time + mock.Anything, // lookback + ).Return(nil, errors.New("deps error")) _, err = h.GetDependencies(context.Background(), &storage_v1.GetDependenciesRequest{}) require.Error(t, err) assert.Contains(t, err.Error(), "deps error") diff --git a/crossdock/services/mocks/AgentService.go b/crossdock/services/mocks/AgentService.go index 538446fb6e8..e035f7ca44b 100644 --- a/crossdock/services/mocks/AgentService.go +++ b/crossdock/services/mocks/AgentService.go @@ -1,23 +1,13 @@ -// Copyright (c) 2019 The Jaeger Authors. -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks -import ( - "github.com/stretchr/testify/mock" -) +import mock "github.com/stretchr/testify/mock" // AgentService is an autogenerated mock type for the AgentService type type AgentService struct { @@ -28,14 +18,21 @@ type AgentService struct { func (_m *AgentService) GetSamplingRate(service string, operation string) (float64, error) { ret := _m.Called(service, operation) + if len(ret) == 0 { + panic("no return value specified for GetSamplingRate") + } + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(string, string) (float64, error)); ok { + return rf(service, operation) + } if rf, ok := ret.Get(0).(func(string, string) float64); ok { r0 = rf(service, operation) } else { r0 = ret.Get(0).(float64) } - var r1 error if rf, ok := ret.Get(1).(func(string, string) error); ok { r1 = rf(service, operation) } else { @@ -44,3 +41,17 @@ func (_m *AgentService) GetSamplingRate(service string, operation string) (float return r0, r1 } + +// NewAgentService creates a new instance of AgentService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewAgentService(t interface { + mock.TestingT + Cleanup(func()) +}) *AgentService { + mock := &AgentService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/crossdock/services/mocks/QueryService.go b/crossdock/services/mocks/QueryService.go index 009948bef4c..31d54be48a5 100644 --- a/crossdock/services/mocks/QueryService.go +++ b/crossdock/services/mocks/QueryService.go @@ -1,24 +1,15 @@ -// Copyright (c) 2019 The Jaeger Authors. -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks import ( - "github.com/stretchr/testify/mock" - - ui "github.com/jaegertracing/jaeger/model/json" + json "github.com/jaegertracing/jaeger/model/json" + mock "github.com/stretchr/testify/mock" ) // QueryService is an autogenerated mock type for the QueryService type @@ -27,19 +18,26 @@ type QueryService struct { } // GetTraces provides a mock function with given fields: serviceName, operation, tags -func (_m *QueryService) GetTraces(serviceName string, operation string, tags map[string]string) ([]*ui.Trace, error) { +func (_m *QueryService) GetTraces(serviceName string, operation string, tags map[string]string) ([]*json.Trace, error) { ret := _m.Called(serviceName, operation, tags) - var r0 []*ui.Trace - if rf, ok := ret.Get(0).(func(string, string, map[string]string) []*ui.Trace); ok { + if len(ret) == 0 { + panic("no return value specified for GetTraces") + } + + var r0 []*json.Trace + var r1 error + if rf, ok := ret.Get(0).(func(string, string, map[string]string) ([]*json.Trace, error)); ok { + return rf(serviceName, operation, tags) + } + if rf, ok := ret.Get(0).(func(string, string, map[string]string) []*json.Trace); ok { r0 = rf(serviceName, operation, tags) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*ui.Trace) + r0 = ret.Get(0).([]*json.Trace) } } - var r1 error if rf, ok := ret.Get(1).(func(string, string, map[string]string) error); ok { r1 = rf(serviceName, operation, tags) } else { @@ -48,3 +46,17 @@ func (_m *QueryService) GetTraces(serviceName string, operation string, tags map return r0, r1 } + +// NewQueryService creates a new instance of QueryService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewQueryService(t interface { + mock.TestingT + Cleanup(func()) +}) *QueryService { + mock := &QueryService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/cassandra/mocks/Iterator.go b/pkg/cassandra/mocks/Iterator.go index 2335f7a5fd4..b06dcc36915 100644 --- a/pkg/cassandra/mocks/Iterator.go +++ b/pkg/cassandra/mocks/Iterator.go @@ -1,21 +1,12 @@ -// Copyright (c) 2019 The Jaeger Authors. -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks -import cassandra "github.com/jaegertracing/jaeger/pkg/cassandra" import mock "github.com/stretchr/testify/mock" // Iterator is an autogenerated mock type for the Iterator type @@ -27,6 +18,10 @@ type Iterator struct { func (_m *Iterator) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -41,6 +36,10 @@ func (_m *Iterator) Close() error { func (_m *Iterator) Scan(dest ...interface{}) bool { ret := _m.Called(dest) + if len(ret) == 0 { + panic("no return value specified for Scan") + } + var r0 bool if rf, ok := ret.Get(0).(func(...interface{}) bool); ok { r0 = rf(dest...) @@ -51,4 +50,16 @@ func (_m *Iterator) Scan(dest ...interface{}) bool { return r0 } -var _ cassandra.Iterator = (*Iterator)(nil) +// NewIterator creates a new instance of Iterator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewIterator(t interface { + mock.TestingT + Cleanup(func()) +}) *Iterator { + mock := &Iterator{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/cassandra/mocks/Query.go b/pkg/cassandra/mocks/Query.go index 89221d1acd8..cc095615162 100644 --- a/pkg/cassandra/mocks/Query.go +++ b/pkg/cassandra/mocks/Query.go @@ -1,22 +1,16 @@ -// Copyright (c) 2019 The Jaeger Authors. -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks -import cassandra "github.com/jaegertracing/jaeger/pkg/cassandra" -import mock "github.com/stretchr/testify/mock" +import ( + cassandra "github.com/jaegertracing/jaeger/pkg/cassandra" + mock "github.com/stretchr/testify/mock" +) // Query is an autogenerated mock type for the Query type type Query struct { @@ -27,6 +21,10 @@ type Query struct { func (_m *Query) Bind(v ...interface{}) cassandra.Query { ret := _m.Called(v) + if len(ret) == 0 { + panic("no return value specified for Bind") + } + var r0 cassandra.Query if rf, ok := ret.Get(0).(func(...interface{}) cassandra.Query); ok { r0 = rf(v...) @@ -43,25 +41,13 @@ func (_m *Query) Bind(v ...interface{}) cassandra.Query { func (_m *Query) Consistency(level cassandra.Consistency) cassandra.Query { ret := _m.Called(level) - var r0 cassandra.Query - if rf, ok := ret.Get(0).(func(cassandra.Consistency) cassandra.Query); ok { - r0 = rf(level) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(cassandra.Query) - } + if len(ret) == 0 { + panic("no return value specified for Consistency") } - return r0 -} - -// PageSize provides a mock function with given fields: n -func (_m *Query) PageSize(n int) cassandra.Query { - ret := _m.Called(n) - var r0 cassandra.Query - if rf, ok := ret.Get(0).(func(int) cassandra.Query); ok { - r0 = rf(n) + if rf, ok := ret.Get(0).(func(cassandra.Consistency) cassandra.Query); ok { + r0 = rf(level) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(cassandra.Query) @@ -75,6 +61,10 @@ func (_m *Query) PageSize(n int) cassandra.Query { func (_m *Query) Exec() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Exec") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -89,6 +79,10 @@ func (_m *Query) Exec() error { func (_m *Query) Iter() cassandra.Iterator { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Iter") + } + var r0 cassandra.Iterator if rf, ok := ret.Get(0).(func() cassandra.Iterator); ok { r0 = rf() @@ -101,15 +95,21 @@ func (_m *Query) Iter() cassandra.Iterator { return r0 } -// String provides a mock function with given fields: -func (_m *Query) String() string { - ret := _m.Called() +// PageSize provides a mock function with given fields: _a0 +func (_m *Query) PageSize(_a0 int) cassandra.Query { + ret := _m.Called(_a0) - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() + if len(ret) == 0 { + panic("no return value specified for PageSize") + } + + var r0 cassandra.Query + if rf, ok := ret.Get(0).(func(int) cassandra.Query); ok { + r0 = rf(_a0) } else { - r0 = ret.Get(0).(string) + if ret.Get(0) != nil { + r0 = ret.Get(0).(cassandra.Query) + } } return r0 @@ -119,14 +119,21 @@ func (_m *Query) String() string { func (_m *Query) ScanCAS(dest ...interface{}) (bool, error) { ret := _m.Called(dest) + if len(ret) == 0 { + panic("no return value specified for ScanCAS") + } + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(...interface{}) (bool, error)); ok { + return rf(dest...) + } if rf, ok := ret.Get(0).(func(...interface{}) bool); ok { r0 = rf(dest...) } else { r0 = ret.Get(0).(bool) } - var r1 error if rf, ok := ret.Get(1).(func(...interface{}) error); ok { r1 = rf(dest...) } else { @@ -136,4 +143,34 @@ func (_m *Query) ScanCAS(dest ...interface{}) (bool, error) { return r0, r1 } -var _ cassandra.Query = (*Query)(nil) +// String provides a mock function with given fields: +func (_m *Query) String() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for String") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// NewQuery creates a new instance of Query. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewQuery(t interface { + mock.TestingT + Cleanup(func()) +}) *Query { + mock := &Query{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/cassandra/mocks/Session.go b/pkg/cassandra/mocks/Session.go index c7e62d625e7..c56886a284d 100644 --- a/pkg/cassandra/mocks/Session.go +++ b/pkg/cassandra/mocks/Session.go @@ -1,22 +1,16 @@ -// Copyright (c) 2019 The Jaeger Authors. -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks -import cassandra "github.com/jaegertracing/jaeger/pkg/cassandra" -import mock "github.com/stretchr/testify/mock" +import ( + cassandra "github.com/jaegertracing/jaeger/pkg/cassandra" + mock "github.com/stretchr/testify/mock" +) // Session is an autogenerated mock type for the Session type type Session struct { @@ -32,6 +26,10 @@ func (_m *Session) Close() { func (_m *Session) Query(stmt string, values ...interface{}) cassandra.Query { ret := _m.Called(stmt, values) + if len(ret) == 0 { + panic("no return value specified for Query") + } + var r0 cassandra.Query if rf, ok := ret.Get(0).(func(string, ...interface{}) cassandra.Query); ok { r0 = rf(stmt, values...) @@ -44,4 +42,16 @@ func (_m *Session) Query(stmt string, values ...interface{}) cassandra.Query { return r0 } -var _ cassandra.Session = (*Session)(nil) +// NewSession creates a new instance of Session. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSession(t interface { + mock.TestingT + Cleanup(func()) +}) *Session { + mock := &Session{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/distributedlock/mocks/Lock.go b/pkg/distributedlock/mocks/Lock.go index eca8b097408..46a5b6241a7 100644 --- a/pkg/distributedlock/mocks/Lock.go +++ b/pkg/distributedlock/mocks/Lock.go @@ -1,41 +1,42 @@ -// Copyright (c) 2019 The Jaeger Authors. -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks import ( - "time" + time "time" - "github.com/stretchr/testify/mock" + mock "github.com/stretchr/testify/mock" ) +// Lock is an autogenerated mock type for the Lock type type Lock struct { mock.Mock } +// Acquire provides a mock function with given fields: resource, ttl func (_m *Lock) Acquire(resource string, ttl time.Duration) (bool, error) { ret := _m.Called(resource, ttl) + if len(ret) == 0 { + panic("no return value specified for Acquire") + } + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(string, time.Duration) (bool, error)); ok { + return rf(resource, ttl) + } if rf, ok := ret.Get(0).(func(string, time.Duration) bool); ok { r0 = rf(resource, ttl) } else { r0 = ret.Get(0).(bool) } - var r1 error if rf, ok := ret.Get(1).(func(string, time.Duration) error); ok { r1 = rf(resource, ttl) } else { @@ -45,17 +46,25 @@ func (_m *Lock) Acquire(resource string, ttl time.Duration) (bool, error) { return r0, r1 } +// Forfeit provides a mock function with given fields: resource func (_m *Lock) Forfeit(resource string) (bool, error) { ret := _m.Called(resource) + if len(ret) == 0 { + panic("no return value specified for Forfeit") + } + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(string) (bool, error)); ok { + return rf(resource) + } if rf, ok := ret.Get(0).(func(string) bool); ok { r0 = rf(resource) } else { r0 = ret.Get(0).(bool) } - var r1 error if rf, ok := ret.Get(1).(func(string) error); ok { r1 = rf(resource) } else { @@ -64,3 +73,17 @@ func (_m *Lock) Forfeit(resource string) (bool, error) { return r0, r1 } + +// NewLock creates a new instance of Lock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewLock(t interface { + mock.TestingT + Cleanup(func()) +}) *Lock { + mock := &Lock{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/es/client/mocks/ClusterAPI.go b/pkg/es/client/mocks/ClusterAPI.go index 8aee9d9bd36..d45d4ff4608 100644 --- a/pkg/es/client/mocks/ClusterAPI.go +++ b/pkg/es/client/mocks/ClusterAPI.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/client/mocks/IndexAPI.go b/pkg/es/client/mocks/IndexAPI.go index 5845ad17800..4f0bfce58a0 100644 --- a/pkg/es/client/mocks/IndexAPI.go +++ b/pkg/es/client/mocks/IndexAPI.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/client/mocks/IndexManagementLifecycleAPI.go b/pkg/es/client/mocks/IndexManagementLifecycleAPI.go index 69058b5b84c..7745f2e6ca9 100644 --- a/pkg/es/client/mocks/IndexManagementLifecycleAPI.go +++ b/pkg/es/client/mocks/IndexManagementLifecycleAPI.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/mocks/Client.go b/pkg/es/mocks/Client.go index 6e5b183cf74..1462937b7df 100644 --- a/pkg/es/mocks/Client.go +++ b/pkg/es/mocks/Client.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/mocks/IndexService.go b/pkg/es/mocks/IndexService.go index 65a51de263f..f27762e2486 100644 --- a/pkg/es/mocks/IndexService.go +++ b/pkg/es/mocks/IndexService.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/mocks/IndicesCreateService.go b/pkg/es/mocks/IndicesCreateService.go index 54437da7878..908da599dad 100644 --- a/pkg/es/mocks/IndicesCreateService.go +++ b/pkg/es/mocks/IndicesCreateService.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/mocks/IndicesDeleteService.go b/pkg/es/mocks/IndicesDeleteService.go index caaefff9eb3..3e5608b80e9 100644 --- a/pkg/es/mocks/IndicesDeleteService.go +++ b/pkg/es/mocks/IndicesDeleteService.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/mocks/IndicesExistsService.go b/pkg/es/mocks/IndicesExistsService.go index d49168a6358..e44af5c3cf2 100644 --- a/pkg/es/mocks/IndicesExistsService.go +++ b/pkg/es/mocks/IndicesExistsService.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/mocks/MultiSearchService.go b/pkg/es/mocks/MultiSearchService.go index b3c9dfaf849..349c0f76324 100644 --- a/pkg/es/mocks/MultiSearchService.go +++ b/pkg/es/mocks/MultiSearchService.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/mocks/SearchService.go b/pkg/es/mocks/SearchService.go index af544050c52..cf01f949330 100644 --- a/pkg/es/mocks/SearchService.go +++ b/pkg/es/mocks/SearchService.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/mocks/TemplateApplier.go b/pkg/es/mocks/TemplateApplier.go index 303bd8155fa..eede962f82d 100644 --- a/pkg/es/mocks/TemplateApplier.go +++ b/pkg/es/mocks/TemplateApplier.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/mocks/TemplateBuilder.go b/pkg/es/mocks/TemplateBuilder.go index 11a297e6ce2..d6284a03e97 100644 --- a/pkg/es/mocks/TemplateBuilder.go +++ b/pkg/es/mocks/TemplateBuilder.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/pkg/es/mocks/TemplateCreateService.go b/pkg/es/mocks/TemplateCreateService.go index 53706fc635d..865987879d3 100644 --- a/pkg/es/mocks/TemplateCreateService.go +++ b/pkg/es/mocks/TemplateCreateService.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/cmd/ingester/app/consumer/mocks/Consumer.go b/pkg/kafka/consumer/mocks/Consumer.go similarity index 55% rename from cmd/ingester/app/consumer/mocks/Consumer.go rename to pkg/kafka/consumer/mocks/Consumer.go index a40cf181b81..0754d073495 100644 --- a/cmd/ingester/app/consumer/mocks/Consumer.go +++ b/pkg/kafka/consumer/mocks/Consumer.go @@ -1,24 +1,17 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -// Copyright (c) 2018 The Jaeger Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks -import cluster "github.com/bsm/sarama-cluster" +import ( + cluster "github.com/bsm/sarama-cluster" -import mock "github.com/stretchr/testify/mock" + mock "github.com/stretchr/testify/mock" +) // Consumer is an autogenerated mock type for the Consumer type type Consumer struct { @@ -29,6 +22,10 @@ type Consumer struct { func (_m *Consumer) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -48,6 +45,10 @@ func (_m *Consumer) MarkPartitionOffset(topic string, partition int32, offset in func (_m *Consumer) Partitions() <-chan cluster.PartitionConsumer { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Partitions") + } + var r0 <-chan cluster.PartitionConsumer if rf, ok := ret.Get(0).(func() <-chan cluster.PartitionConsumer); ok { r0 = rf() @@ -59,3 +60,17 @@ func (_m *Consumer) Partitions() <-chan cluster.PartitionConsumer { return r0 } + +// NewConsumer creates a new instance of Consumer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewConsumer(t interface { + mock.TestingT + Cleanup(func()) +}) *Consumer { + mock := &Consumer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/kafka/mocks/Marshaller.go b/pkg/kafka/mocks/Marshaller.go deleted file mode 100644 index b4b8f1ed68e..00000000000 --- a/pkg/kafka/mocks/Marshaller.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -// Copyright (c) 2018 The Jaeger Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mocks - -import mock "github.com/stretchr/testify/mock" -import model "github.com/jaegertracing/jaeger/model" - -// Marshaller is an autogenerated mock type for the Marshaller type -type Marshaller struct { - mock.Mock -} - -// marshal provides a mock function with given fields: _a0 -func (_m *Marshaller) Marshal(_a0 *model.Span) ([]byte, error) { - ret := _m.Called(_a0) - - var r0 []byte - if rf, ok := ret.Get(0).(func(*model.Span) []byte); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(*model.Span) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/pkg/kafka/mocks/Unmarshaller.go b/pkg/kafka/mocks/Unmarshaller.go deleted file mode 100644 index e879bed9399..00000000000 --- a/pkg/kafka/mocks/Unmarshaller.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -// Copyright (c) 2018 The Jaeger Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mocks - -import mock "github.com/stretchr/testify/mock" -import model "github.com/jaegertracing/jaeger/model" - -// Unmarshaller is an autogenerated mock type for the Unmarshaller type -type Unmarshaller struct { - mock.Mock -} - -// Unmarshal provides a mock function with given fields: _a0 -func (_m *Unmarshaller) Unmarshal(_a0 []byte) (*model.Span, error) { - ret := _m.Called(_a0) - - var r0 *model.Span - if rf, ok := ret.Get(0).(func([]byte) *model.Span); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.Span) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]byte) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/plugin/pkg/distributedlock/cassandra/lock_test.go b/plugin/pkg/distributedlock/cassandra/lock_test.go index 36833148c54..16629d344ae 100644 --- a/plugin/pkg/distributedlock/cassandra/lock_test.go +++ b/plugin/pkg/distributedlock/cassandra/lock_test.go @@ -79,24 +79,24 @@ func TestExtendLease(t *testing.T) { t.Run(testCase.caption, func(t *testing.T) { withCQLLock(func(s *cqlLockTest) { query := &mocks.Query{} - query.On("ScanCAS", matchEverything()).Return(testCase.applied, testCase.errScan) + query.On("ScanCAS", mock.Anything).Return(testCase.applied, testCase.errScan) - var args []any - captureArgs := mock.MatchedBy(func(v []any) bool { - args = v - return true - }) - - s.session.On("Query", mock.AnythingOfType("string"), captureArgs).Return(query) + s.session.On( + "Query", + mock.AnythingOfType("string"), + []any{ + 60, + localhost, + samplingLock, + localhost, + }, + ).Return(query) err := s.lock.extendLease(samplingLock, time.Second*60) if testCase.expectedErrMsg == "" { require.NoError(t, err) } else { require.EqualError(t, err, testCase.expectedErrMsg) } - - expectedArgs := []any{60, localhost, samplingLock, localhost} - assert.Equal(t, expectedArgs, args) }) }) } @@ -159,25 +159,29 @@ func TestAcquire(t *testing.T) { testCase := tc // capture loop var t.Run(testCase.caption, func(t *testing.T) { withCQLLock(func(s *cqlLockTest) { - firstQuery := &mocks.Query{} - secondQuery := &mocks.Query{} - - scanMatcher := func() any { - scanFunc := func(args []any) bool { + assignPtr := func(vals ...string) any { + return mock.MatchedBy(func(args []any) bool { + if len(args) != len(vals) { + return false + } for i, arg := range args { - if ptr, ok := arg.(*string); ok { - *ptr = testCase.retVals[i] + ptr, ok := arg.(*string) + if !ok { + return false } + *ptr = vals[i] } return true - } - return mock.MatchedBy(scanFunc) + }) } - firstQuery.On("ScanCAS", scanMatcher()).Return(testCase.insertLockApplied, testCase.errScan) - secondQuery.On("ScanCAS", matchEverything()).Return(testCase.updateLockApplied, nil) + firstQuery := &mocks.Query{} + firstQuery.On("ScanCAS", assignPtr(testCase.retVals...)). + Return(testCase.insertLockApplied, testCase.errScan) + secondQuery := &mocks.Query{} + secondQuery.On("ScanCAS", mock.Anything).Return(testCase.updateLockApplied, nil) - s.session.On("Query", stringMatcher("INSERT INTO leases"), matchEverything()).Return(firstQuery) - s.session.On("Query", stringMatcher("UPDATE leases"), matchEverything()).Return(secondQuery) + s.session.On("Query", stringMatcher("INSERT INTO leases"), mock.Anything).Return(firstQuery) + s.session.On("Query", stringMatcher("UPDATE leases"), mock.Anything).Return(secondQuery) acquired, err := s.lock.Acquire(samplingLock, 0) if testCase.expectedErrMsg == "" { require.NoError(t, err) @@ -226,15 +230,9 @@ func TestForfeit(t *testing.T) { t.Run(testCase.caption, func(t *testing.T) { withCQLLock(func(s *cqlLockTest) { query := &mocks.Query{} - query.On("ScanCAS", matchEverything()).Return(testCase.applied, testCase.errScan) + query.On("ScanCAS", mock.Anything).Return(testCase.applied, testCase.errScan) - var args []any - captureArgs := mock.MatchedBy(func(v []any) bool { - args = v - return true - }) - - s.session.On("Query", mock.AnythingOfType("string"), captureArgs).Return(query) + s.session.On("Query", mock.AnythingOfType("string"), []any{samplingLock, localhost}).Return(query) applied, err := s.lock.Forfeit(samplingLock) if testCase.expectedErrMsg == "" { require.NoError(t, err) @@ -242,27 +240,11 @@ func TestForfeit(t *testing.T) { require.EqualError(t, err, testCase.expectedErrMsg) } assert.Equal(t, testCase.applied, applied) - - assert.Len(t, args, 2) - if d, ok := args[0].(string); ok { - assert.Equal(t, samplingLock, d) - } else { - assert.Fail(t, "expecting first arg as string", "received: %+v", args) - } - if d, ok := args[1].(string); ok { - assert.Equal(t, localhost, d) - } else { - assert.Fail(t, "expecting second arg as string", "received: %+v", args) - } }) }) } } -func matchEverything() any { - return mock.MatchedBy(func(_ []any) bool { return true }) -} - // stringMatcher can match a string argument when it contains a specific substring q func stringMatcher(q string) any { matchFunc := func(s string) bool { diff --git a/plugin/sampling/leaderelection/mocks/ElectionParticipant.go b/plugin/sampling/leaderelection/mocks/ElectionParticipant.go index 53ed8b6eac6..a78df33b1b4 100644 --- a/plugin/sampling/leaderelection/mocks/ElectionParticipant.go +++ b/plugin/sampling/leaderelection/mocks/ElectionParticipant.go @@ -1,53 +1,63 @@ -// Copyright (c) 2018 The Jaeger Authors. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks -import "github.com/stretchr/testify/mock" +import mock "github.com/stretchr/testify/mock" +// ElectionParticipant is an autogenerated mock type for the ElectionParticipant type type ElectionParticipant struct { mock.Mock } -func (_m *ElectionParticipant) IsLeader() bool { +// Close provides a mock function with given fields: +func (_m *ElectionParticipant) Close() error { ret := _m.Called() - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { + if len(ret) == 0 { + panic("no return value specified for Close") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() } else { - r0 = ret.Get(0).(bool) + r0 = ret.Error(0) } return r0 } -func (_m *ElectionParticipant) Start() error { + +// IsLeader provides a mock function with given fields: +func (_m *ElectionParticipant) IsLeader() bool { ret := _m.Called() - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { + if len(ret) == 0 { + panic("no return value specified for IsLeader") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() } else { - r0 = ret.Error(0) + r0 = ret.Get(0).(bool) } return r0 } -func (_m *ElectionParticipant) Close() error { +// Start provides a mock function with given fields: +func (_m *ElectionParticipant) Start() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Start") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -57,3 +67,17 @@ func (_m *ElectionParticipant) Close() error { return r0 } + +// NewElectionParticipant creates a new instance of ElectionParticipant. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewElectionParticipant(t interface { + mock.TestingT + Cleanup(func()) +}) *ElectionParticipant { + mock := &ElectionParticipant{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/plugin/storage/cassandra/spanstore/operation_names_test.go b/plugin/storage/cassandra/spanstore/operation_names_test.go index 913e0fee87a..f757cc4358d 100644 --- a/plugin/storage/cassandra/spanstore/operation_names_test.go +++ b/plugin/storage/cassandra/spanstore/operation_names_test.go @@ -155,27 +155,46 @@ func TestOperationNamesStorageGetServices(t *testing.T) { name string schemaVersion schemaVersion expErr error + expRes []spanstore.Operation }{ - {name: "test old schema without error", schemaVersion: previousVersion, expErr: nil}, + { + name: "test old schema without error", + schemaVersion: previousVersion, + expRes: []spanstore.Operation{{Name: "foo"}}, + }, + { + name: "test new schema without error", + schemaVersion: latestVersion, + expRes: []spanstore.Operation{{SpanKind: "foo", Name: "bar"}}, + }, {name: "test old schema with scan error", schemaVersion: previousVersion, expErr: scanError}, - {name: "test new schema without error", schemaVersion: latestVersion, expErr: nil}, {name: "test new schema with scan error", schemaVersion: latestVersion, expErr: scanError}, } { t.Run(test.name, func(t *testing.T) { withOperationNamesStorage(0, test.schemaVersion, func(s *operationNameStorageTest) { - var matched bool - matchOnce := mock.MatchedBy(func(_ []any) bool { - if matched { - return false - } - matched = true - return true - }) - matchEverything := mock.MatchedBy(func(_ []any) bool { return true }) + assignPtr := func(vals ...string) any { + return mock.MatchedBy(func(args []any) bool { + if len(args) != len(vals) { + return false + } + for i, arg := range args { + ptr, ok := arg.(*string) + if !ok { + return false + } + *ptr = vals[i] + } + return true + }) + } iter := &mocks.Iterator{} - iter.On("Scan", matchOnce).Return(true) - iter.On("Scan", matchEverything).Return(false) // false to stop the loop + if test.schemaVersion == previousVersion { + iter.On("Scan", assignPtr("foo")).Return(true).Once() + } else { + iter.On("Scan", assignPtr("foo", "bar")).Return(true).Once() + } + iter.On("Scan", mock.Anything).Return(false) // false to stop the loop iter.On("Close").Return(test.expErr) query := &mocks.Query{} @@ -187,9 +206,7 @@ func TestOperationNamesStorageGetServices(t *testing.T) { }) if test.expErr == nil { require.NoError(t, err) - // expect one empty operation result - // because mock iter.Scan(&placeholder) does not write to `placeholder` - assert.Equal(t, []spanstore.Operation{{}}, services) + assert.Equal(t, test.expRes, services) } else { require.EqualError( t, diff --git a/plugin/storage/grpc/shared/grpc_handler_test.go b/plugin/storage/grpc/shared/grpc_handler_test.go index 23d40c4534f..20eb4ca7eb7 100644 --- a/plugin/storage/grpc/shared/grpc_handler_test.go +++ b/plugin/storage/grpc/shared/grpc_handler_test.go @@ -272,7 +272,7 @@ func TestGRPCServerGetDependencies(t *testing.T) { Child: "child", }, } - r.impl.depsReader.On("GetDependencies", end, lookback). + r.impl.depsReader.On("GetDependencies", mock.Anything, end, lookback). Return(deps, nil) s, err := r.server.GetDependencies(context.Background(), &storage_v1.GetDependenciesRequest{ diff --git a/plugin/storage/kafka/mocks/Marshaller.go b/plugin/storage/kafka/mocks/Marshaller.go new file mode 100644 index 00000000000..6dcfb031277 --- /dev/null +++ b/plugin/storage/kafka/mocks/Marshaller.go @@ -0,0 +1,62 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + model "github.com/jaegertracing/jaeger/model" + mock "github.com/stretchr/testify/mock" +) + +// Marshaller is an autogenerated mock type for the Marshaller type +type Marshaller struct { + mock.Mock +} + +// Marshal provides a mock function with given fields: _a0 +func (_m *Marshaller) Marshal(_a0 *model.Span) ([]byte, error) { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for Marshal") + } + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func(*model.Span) ([]byte, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(*model.Span) []byte); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func(*model.Span) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewMarshaller creates a new instance of Marshaller. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMarshaller(t interface { + mock.TestingT + Cleanup(func()) +}) *Marshaller { + mock := &Marshaller{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/plugin/storage/kafka/mocks/Unmarshaller.go b/plugin/storage/kafka/mocks/Unmarshaller.go new file mode 100644 index 00000000000..95949bef3ee --- /dev/null +++ b/plugin/storage/kafka/mocks/Unmarshaller.go @@ -0,0 +1,62 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + model "github.com/jaegertracing/jaeger/model" + mock "github.com/stretchr/testify/mock" +) + +// Unmarshaller is an autogenerated mock type for the Unmarshaller type +type Unmarshaller struct { + mock.Mock +} + +// Unmarshal provides a mock function with given fields: _a0 +func (_m *Unmarshaller) Unmarshal(_a0 []byte) (*model.Span, error) { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for Unmarshal") + } + + var r0 *model.Span + var r1 error + if rf, ok := ret.Get(0).(func([]byte) (*model.Span, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func([]byte) *model.Span); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.Span) + } + } + + if rf, ok := ret.Get(1).(func([]byte) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewUnmarshaller creates a new instance of Unmarshaller. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUnmarshaller(t interface { + mock.TestingT + Cleanup(func()) +}) *Unmarshaller { + mock := &Unmarshaller{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/plugin/storage/kafka/writer_test.go b/plugin/storage/kafka/writer_test.go index 0b10ce7533b..14ab9ea15f2 100644 --- a/plugin/storage/kafka/writer_test.go +++ b/plugin/storage/kafka/writer_test.go @@ -28,7 +28,7 @@ import ( "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" - "github.com/jaegertracing/jaeger/pkg/kafka/mocks" + "github.com/jaegertracing/jaeger/plugin/storage/kafka/mocks" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginClient.go b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginClient.go index 2dab013089b..ca4cbd4cfcb 100644 --- a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginClient.go +++ b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginServer.go b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginServer.go index 5650162d4a8..8b8800e9f73 100644 --- a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginServer.go +++ b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceClient.go b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceClient.go index b161d35d44b..bfae9ab49d2 100644 --- a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceClient.go +++ b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceServer.go b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceServer.go index acfbb6193a5..6b47c7d66de 100644 --- a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceServer.go +++ b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginClient.go b/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginClient.go index 81c415b22b4..8e3271a94a8 100644 --- a/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginClient.go +++ b/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginServer.go b/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginServer.go index fa332b0e265..bf69f71d2ad 100644 --- a/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginServer.go +++ b/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/DependenciesReaderPluginClient.go b/proto-gen/storage_v1/mocks/DependenciesReaderPluginClient.go index 9f20c03b202..7cefb3e5d3a 100644 --- a/proto-gen/storage_v1/mocks/DependenciesReaderPluginClient.go +++ b/proto-gen/storage_v1/mocks/DependenciesReaderPluginClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/DependenciesReaderPluginServer.go b/proto-gen/storage_v1/mocks/DependenciesReaderPluginServer.go index 7f374cf33f1..1b94064e5f0 100644 --- a/proto-gen/storage_v1/mocks/DependenciesReaderPluginServer.go +++ b/proto-gen/storage_v1/mocks/DependenciesReaderPluginServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/PluginCapabilitiesClient.go b/proto-gen/storage_v1/mocks/PluginCapabilitiesClient.go index 61d3839be26..1b10266a3bb 100644 --- a/proto-gen/storage_v1/mocks/PluginCapabilitiesClient.go +++ b/proto-gen/storage_v1/mocks/PluginCapabilitiesClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/PluginCapabilitiesServer.go b/proto-gen/storage_v1/mocks/PluginCapabilitiesServer.go index 506309f82f0..8fad2bc5617 100644 --- a/proto-gen/storage_v1/mocks/PluginCapabilitiesServer.go +++ b/proto-gen/storage_v1/mocks/PluginCapabilitiesServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/SpanReaderPluginClient.go b/proto-gen/storage_v1/mocks/SpanReaderPluginClient.go index 64b6fea2e46..01454f78b8a 100644 --- a/proto-gen/storage_v1/mocks/SpanReaderPluginClient.go +++ b/proto-gen/storage_v1/mocks/SpanReaderPluginClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/SpanReaderPluginServer.go b/proto-gen/storage_v1/mocks/SpanReaderPluginServer.go index 2e6ebfed7ae..fc81ad9a093 100644 --- a/proto-gen/storage_v1/mocks/SpanReaderPluginServer.go +++ b/proto-gen/storage_v1/mocks/SpanReaderPluginServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/SpanReaderPlugin_FindTracesClient.go b/proto-gen/storage_v1/mocks/SpanReaderPlugin_FindTracesClient.go index b50328a1ae9..1c0e967ce37 100644 --- a/proto-gen/storage_v1/mocks/SpanReaderPlugin_FindTracesClient.go +++ b/proto-gen/storage_v1/mocks/SpanReaderPlugin_FindTracesClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/SpanReaderPlugin_FindTracesServer.go b/proto-gen/storage_v1/mocks/SpanReaderPlugin_FindTracesServer.go index 0a88808e0bd..f956f544f2d 100644 --- a/proto-gen/storage_v1/mocks/SpanReaderPlugin_FindTracesServer.go +++ b/proto-gen/storage_v1/mocks/SpanReaderPlugin_FindTracesServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/SpanReaderPlugin_GetTraceClient.go b/proto-gen/storage_v1/mocks/SpanReaderPlugin_GetTraceClient.go index 063efc6eecb..e17b0f2d579 100644 --- a/proto-gen/storage_v1/mocks/SpanReaderPlugin_GetTraceClient.go +++ b/proto-gen/storage_v1/mocks/SpanReaderPlugin_GetTraceClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/SpanReaderPlugin_GetTraceServer.go b/proto-gen/storage_v1/mocks/SpanReaderPlugin_GetTraceServer.go index 44309a59be2..df8ea6dc07e 100644 --- a/proto-gen/storage_v1/mocks/SpanReaderPlugin_GetTraceServer.go +++ b/proto-gen/storage_v1/mocks/SpanReaderPlugin_GetTraceServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/SpanWriterPluginClient.go b/proto-gen/storage_v1/mocks/SpanWriterPluginClient.go index 7e7bdea0e7a..64b7950db7d 100644 --- a/proto-gen/storage_v1/mocks/SpanWriterPluginClient.go +++ b/proto-gen/storage_v1/mocks/SpanWriterPluginClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/SpanWriterPluginServer.go b/proto-gen/storage_v1/mocks/SpanWriterPluginServer.go index 42d17aba5be..fcaf559fd43 100644 --- a/proto-gen/storage_v1/mocks/SpanWriterPluginServer.go +++ b/proto-gen/storage_v1/mocks/SpanWriterPluginServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/StreamingSpanWriterPluginClient.go b/proto-gen/storage_v1/mocks/StreamingSpanWriterPluginClient.go index a783927eb3e..78ec15772e4 100644 --- a/proto-gen/storage_v1/mocks/StreamingSpanWriterPluginClient.go +++ b/proto-gen/storage_v1/mocks/StreamingSpanWriterPluginClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/StreamingSpanWriterPluginServer.go b/proto-gen/storage_v1/mocks/StreamingSpanWriterPluginServer.go index 6768e3cad35..061587deecf 100644 --- a/proto-gen/storage_v1/mocks/StreamingSpanWriterPluginServer.go +++ b/proto-gen/storage_v1/mocks/StreamingSpanWriterPluginServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/StreamingSpanWriterPlugin_WriteSpanStreamClient.go b/proto-gen/storage_v1/mocks/StreamingSpanWriterPlugin_WriteSpanStreamClient.go index 563fd4dfeed..32fea096b60 100644 --- a/proto-gen/storage_v1/mocks/StreamingSpanWriterPlugin_WriteSpanStreamClient.go +++ b/proto-gen/storage_v1/mocks/StreamingSpanWriterPlugin_WriteSpanStreamClient.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/proto-gen/storage_v1/mocks/StreamingSpanWriterPlugin_WriteSpanStreamServer.go b/proto-gen/storage_v1/mocks/StreamingSpanWriterPlugin_WriteSpanStreamServer.go index 1d5003d0fa8..a89e12c5049 100644 --- a/proto-gen/storage_v1/mocks/StreamingSpanWriterPlugin_WriteSpanStreamServer.go +++ b/proto-gen/storage_v1/mocks/StreamingSpanWriterPlugin_WriteSpanStreamServer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/storage/dependencystore/mocks/Reader.go b/storage/dependencystore/mocks/Reader.go index a289fc0d213..887f848d689 100644 --- a/storage/dependencystore/mocks/Reader.go +++ b/storage/dependencystore/mocks/Reader.go @@ -1,28 +1,20 @@ -// Copyright (c) 2019 The Jaeger Authors. -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks import ( - "context" - "time" + context "context" - "github.com/stretchr/testify/mock" + mock "github.com/stretchr/testify/mock" - "github.com/jaegertracing/jaeger/model" - "github.com/jaegertracing/jaeger/storage/dependencystore" + model "github.com/jaegertracing/jaeger/model" + + time "time" ) // Reader is an autogenerated mock type for the Reader type @@ -30,11 +22,19 @@ type Reader struct { mock.Mock } -// GetDependencies provides a mock function with given fields: endTs, lookback +// GetDependencies provides a mock function with given fields: ctx, endTs, lookback func (_m *Reader) GetDependencies(ctx context.Context, endTs time.Time, lookback time.Duration) ([]model.DependencyLink, error) { - ret := _m.Called(endTs, lookback) + ret := _m.Called(ctx, endTs, lookback) + + if len(ret) == 0 { + panic("no return value specified for GetDependencies") + } var r0 []model.DependencyLink + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, time.Time, time.Duration) ([]model.DependencyLink, error)); ok { + return rf(ctx, endTs, lookback) + } if rf, ok := ret.Get(0).(func(context.Context, time.Time, time.Duration) []model.DependencyLink); ok { r0 = rf(ctx, endTs, lookback) } else { @@ -43,7 +43,6 @@ func (_m *Reader) GetDependencies(ctx context.Context, endTs time.Time, lookback } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, time.Time, time.Duration) error); ok { r1 = rf(ctx, endTs, lookback) } else { @@ -53,4 +52,16 @@ func (_m *Reader) GetDependencies(ctx context.Context, endTs time.Time, lookback return r0, r1 } -var _ dependencystore.Reader = (*Reader)(nil) +// NewReader creates a new instance of Reader. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewReader(t interface { + mock.TestingT + Cleanup(func()) +}) *Reader { + mock := &Reader{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/storage/metricsstore/mocks/Reader.go b/storage/metricsstore/mocks/Reader.go index 0814af842c0..aa920d53c3c 100644 --- a/storage/metricsstore/mocks/Reader.go +++ b/storage/metricsstore/mocks/Reader.go @@ -1,29 +1,21 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -// Copyright (c) 2021 The Jaeger Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks import ( context "context" - time "time" - - mock "github.com/stretchr/testify/mock" metrics "github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics" metricsstore "github.com/jaegertracing/jaeger/storage/metricsstore" + + mock "github.com/stretchr/testify/mock" + + time "time" ) // Reader is an autogenerated mock type for the Reader type @@ -35,7 +27,15 @@ type Reader struct { func (_m *Reader) GetCallRates(ctx context.Context, params *metricsstore.CallRateQueryParameters) (*metrics.MetricFamily, error) { ret := _m.Called(ctx, params) + if len(ret) == 0 { + panic("no return value specified for GetCallRates") + } + var r0 *metrics.MetricFamily + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.CallRateQueryParameters) (*metrics.MetricFamily, error)); ok { + return rf(ctx, params) + } if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.CallRateQueryParameters) *metrics.MetricFamily); ok { r0 = rf(ctx, params) } else { @@ -44,7 +44,6 @@ func (_m *Reader) GetCallRates(ctx context.Context, params *metricsstore.CallRat } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *metricsstore.CallRateQueryParameters) error); ok { r1 = rf(ctx, params) } else { @@ -58,7 +57,15 @@ func (_m *Reader) GetCallRates(ctx context.Context, params *metricsstore.CallRat func (_m *Reader) GetErrorRates(ctx context.Context, params *metricsstore.ErrorRateQueryParameters) (*metrics.MetricFamily, error) { ret := _m.Called(ctx, params) + if len(ret) == 0 { + panic("no return value specified for GetErrorRates") + } + var r0 *metrics.MetricFamily + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.ErrorRateQueryParameters) (*metrics.MetricFamily, error)); ok { + return rf(ctx, params) + } if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.ErrorRateQueryParameters) *metrics.MetricFamily); ok { r0 = rf(ctx, params) } else { @@ -67,7 +74,6 @@ func (_m *Reader) GetErrorRates(ctx context.Context, params *metricsstore.ErrorR } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *metricsstore.ErrorRateQueryParameters) error); ok { r1 = rf(ctx, params) } else { @@ -81,7 +87,15 @@ func (_m *Reader) GetErrorRates(ctx context.Context, params *metricsstore.ErrorR func (_m *Reader) GetLatencies(ctx context.Context, params *metricsstore.LatenciesQueryParameters) (*metrics.MetricFamily, error) { ret := _m.Called(ctx, params) + if len(ret) == 0 { + panic("no return value specified for GetLatencies") + } + var r0 *metrics.MetricFamily + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.LatenciesQueryParameters) (*metrics.MetricFamily, error)); ok { + return rf(ctx, params) + } if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.LatenciesQueryParameters) *metrics.MetricFamily); ok { r0 = rf(ctx, params) } else { @@ -90,7 +104,6 @@ func (_m *Reader) GetLatencies(ctx context.Context, params *metricsstore.Latenci } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *metricsstore.LatenciesQueryParameters) error); ok { r1 = rf(ctx, params) } else { @@ -104,14 +117,21 @@ func (_m *Reader) GetLatencies(ctx context.Context, params *metricsstore.Latenci func (_m *Reader) GetMinStepDuration(ctx context.Context, params *metricsstore.MinStepDurationQueryParameters) (time.Duration, error) { ret := _m.Called(ctx, params) + if len(ret) == 0 { + panic("no return value specified for GetMinStepDuration") + } + var r0 time.Duration + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.MinStepDurationQueryParameters) (time.Duration, error)); ok { + return rf(ctx, params) + } if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.MinStepDurationQueryParameters) time.Duration); ok { r0 = rf(ctx, params) } else { r0 = ret.Get(0).(time.Duration) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *metricsstore.MinStepDurationQueryParameters) error); ok { r1 = rf(ctx, params) } else { @@ -120,3 +140,17 @@ func (_m *Reader) GetMinStepDuration(ctx context.Context, params *metricsstore.M return r0, r1 } + +// NewReader creates a new instance of Reader. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewReader(t interface { + mock.TestingT + Cleanup(func()) +}) *Reader { + mock := &Reader{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/storage/mocks/ArchiveFactory.go b/storage/mocks/ArchiveFactory.go index d0139b3cc75..6030697602b 100644 --- a/storage/mocks/ArchiveFactory.go +++ b/storage/mocks/ArchiveFactory.go @@ -1,22 +1,16 @@ -// Copyright (c) 2018 The Jaeger Authors. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks -import mock "github.com/stretchr/testify/mock" -import spanstore "github.com/jaegertracing/jaeger/storage/spanstore" -import storage "github.com/jaegertracing/jaeger/storage" +import ( + spanstore "github.com/jaegertracing/jaeger/storage/spanstore" + mock "github.com/stretchr/testify/mock" +) // ArchiveFactory is an autogenerated mock type for the ArchiveFactory type type ArchiveFactory struct { @@ -27,7 +21,15 @@ type ArchiveFactory struct { func (_m *ArchiveFactory) CreateArchiveSpanReader() (spanstore.Reader, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CreateArchiveSpanReader") + } + var r0 spanstore.Reader + var r1 error + if rf, ok := ret.Get(0).(func() (spanstore.Reader, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() spanstore.Reader); ok { r0 = rf() } else { @@ -36,7 +38,6 @@ func (_m *ArchiveFactory) CreateArchiveSpanReader() (spanstore.Reader, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -50,7 +51,15 @@ func (_m *ArchiveFactory) CreateArchiveSpanReader() (spanstore.Reader, error) { func (_m *ArchiveFactory) CreateArchiveSpanWriter() (spanstore.Writer, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CreateArchiveSpanWriter") + } + var r0 spanstore.Writer + var r1 error + if rf, ok := ret.Get(0).(func() (spanstore.Writer, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() spanstore.Writer); ok { r0 = rf() } else { @@ -59,7 +68,6 @@ func (_m *ArchiveFactory) CreateArchiveSpanWriter() (spanstore.Writer, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -69,4 +77,16 @@ func (_m *ArchiveFactory) CreateArchiveSpanWriter() (spanstore.Writer, error) { return r0, r1 } -var _ storage.ArchiveFactory = (*ArchiveFactory)(nil) +// NewArchiveFactory creates a new instance of ArchiveFactory. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewArchiveFactory(t interface { + mock.TestingT + Cleanup(func()) +}) *ArchiveFactory { + mock := &ArchiveFactory{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/storage/mocks/Factory.go b/storage/mocks/Factory.go index 8f2c713ec1e..90d14de5334 100644 --- a/storage/mocks/Factory.go +++ b/storage/mocks/Factory.go @@ -1,27 +1,21 @@ -// Copyright (c) 2018 The Jaeger Authors. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks import ( - mock "github.com/stretchr/testify/mock" - zap "go.uber.org/zap" - metrics "github.com/jaegertracing/jaeger/pkg/metrics" - storage "github.com/jaegertracing/jaeger/storage" dependencystore "github.com/jaegertracing/jaeger/storage/dependencystore" + + mock "github.com/stretchr/testify/mock" + spanstore "github.com/jaegertracing/jaeger/storage/spanstore" + + zap "go.uber.org/zap" ) // Factory is an autogenerated mock type for the Factory type @@ -33,7 +27,15 @@ type Factory struct { func (_m *Factory) CreateDependencyReader() (dependencystore.Reader, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CreateDependencyReader") + } + var r0 dependencystore.Reader + var r1 error + if rf, ok := ret.Get(0).(func() (dependencystore.Reader, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() dependencystore.Reader); ok { r0 = rf() } else { @@ -42,7 +44,6 @@ func (_m *Factory) CreateDependencyReader() (dependencystore.Reader, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -56,7 +57,15 @@ func (_m *Factory) CreateDependencyReader() (dependencystore.Reader, error) { func (_m *Factory) CreateSpanReader() (spanstore.Reader, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CreateSpanReader") + } + var r0 spanstore.Reader + var r1 error + if rf, ok := ret.Get(0).(func() (spanstore.Reader, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() spanstore.Reader); ok { r0 = rf() } else { @@ -65,7 +74,6 @@ func (_m *Factory) CreateSpanReader() (spanstore.Reader, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -79,7 +87,15 @@ func (_m *Factory) CreateSpanReader() (spanstore.Reader, error) { func (_m *Factory) CreateSpanWriter() (spanstore.Writer, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CreateSpanWriter") + } + var r0 spanstore.Writer + var r1 error + if rf, ok := ret.Get(0).(func() (spanstore.Writer, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() spanstore.Writer); ok { r0 = rf() } else { @@ -88,7 +104,6 @@ func (_m *Factory) CreateSpanWriter() (spanstore.Writer, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -102,6 +117,10 @@ func (_m *Factory) CreateSpanWriter() (spanstore.Writer, error) { func (_m *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error { ret := _m.Called(metricsFactory, logger) + if len(ret) == 0 { + panic("no return value specified for Initialize") + } + var r0 error if rf, ok := ret.Get(0).(func(metrics.Factory, *zap.Logger) error); ok { r0 = rf(metricsFactory, logger) @@ -112,4 +131,16 @@ func (_m *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger return r0 } -var _ storage.Factory = (*Factory)(nil) +// NewFactory creates a new instance of Factory. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFactory(t interface { + mock.TestingT + Cleanup(func()) +}) *Factory { + mock := &Factory{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/storage/mocks/MetricsFactory.go b/storage/mocks/MetricsFactory.go index 2a0c3bee555..4d5d5823450 100644 --- a/storage/mocks/MetricsFactory.go +++ b/storage/mocks/MetricsFactory.go @@ -1,26 +1,17 @@ -// Copyright (c) 2021 The Jaeger Authors. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks import ( + metricsstore "github.com/jaegertracing/jaeger/storage/metricsstore" mock "github.com/stretchr/testify/mock" - zap "go.uber.org/zap" - metricsstore "github.com/jaegertracing/jaeger/storage/metricsstore" + zap "go.uber.org/zap" ) // MetricsFactory is an autogenerated mock type for the MetricsFactory type @@ -32,7 +23,15 @@ type MetricsFactory struct { func (_m *MetricsFactory) CreateMetricsReader() (metricsstore.Reader, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CreateMetricsReader") + } + var r0 metricsstore.Reader + var r1 error + if rf, ok := ret.Get(0).(func() (metricsstore.Reader, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() metricsstore.Reader); ok { r0 = rf() } else { @@ -41,7 +40,6 @@ func (_m *MetricsFactory) CreateMetricsReader() (metricsstore.Reader, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -55,6 +53,10 @@ func (_m *MetricsFactory) CreateMetricsReader() (metricsstore.Reader, error) { func (_m *MetricsFactory) Initialize(logger *zap.Logger) error { ret := _m.Called(logger) + if len(ret) == 0 { + panic("no return value specified for Initialize") + } + var r0 error if rf, ok := ret.Get(0).(func(*zap.Logger) error); ok { r0 = rf(logger) @@ -64,3 +66,17 @@ func (_m *MetricsFactory) Initialize(logger *zap.Logger) error { return r0 } + +// NewMetricsFactory creates a new instance of MetricsFactory. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMetricsFactory(t interface { + mock.TestingT + Cleanup(func()) +}) *MetricsFactory { + mock := &MetricsFactory{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/storage/mocks/Purger.go b/storage/mocks/Purger.go new file mode 100644 index 00000000000..1ee41d39863 --- /dev/null +++ b/storage/mocks/Purger.go @@ -0,0 +1,51 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// Purger is an autogenerated mock type for the Purger type +type Purger struct { + mock.Mock +} + +// Purge provides a mock function with given fields: _a0 +func (_m *Purger) Purge(_a0 context.Context) error { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for Purge") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewPurger creates a new instance of Purger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewPurger(t interface { + mock.TestingT + Cleanup(func()) +}) *Purger { + mock := &Purger{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/storage/mocks/SamplingStoreFactory.go b/storage/mocks/SamplingStoreFactory.go new file mode 100644 index 00000000000..89cc1771d45 --- /dev/null +++ b/storage/mocks/SamplingStoreFactory.go @@ -0,0 +1,94 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + distributedlock "github.com/jaegertracing/jaeger/pkg/distributedlock" + mock "github.com/stretchr/testify/mock" + + samplingstore "github.com/jaegertracing/jaeger/storage/samplingstore" +) + +// SamplingStoreFactory is an autogenerated mock type for the SamplingStoreFactory type +type SamplingStoreFactory struct { + mock.Mock +} + +// CreateLock provides a mock function with given fields: +func (_m *SamplingStoreFactory) CreateLock() (distributedlock.Lock, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for CreateLock") + } + + var r0 distributedlock.Lock + var r1 error + if rf, ok := ret.Get(0).(func() (distributedlock.Lock, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() distributedlock.Lock); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(distributedlock.Lock) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateSamplingStore provides a mock function with given fields: maxBuckets +func (_m *SamplingStoreFactory) CreateSamplingStore(maxBuckets int) (samplingstore.Store, error) { + ret := _m.Called(maxBuckets) + + if len(ret) == 0 { + panic("no return value specified for CreateSamplingStore") + } + + var r0 samplingstore.Store + var r1 error + if rf, ok := ret.Get(0).(func(int) (samplingstore.Store, error)); ok { + return rf(maxBuckets) + } + if rf, ok := ret.Get(0).(func(int) samplingstore.Store); ok { + r0 = rf(maxBuckets) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(samplingstore.Store) + } + } + + if rf, ok := ret.Get(1).(func(int) error); ok { + r1 = rf(maxBuckets) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewSamplingStoreFactory creates a new instance of SamplingStoreFactory. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSamplingStoreFactory(t interface { + mock.TestingT + Cleanup(func()) +}) *SamplingStoreFactory { + mock := &SamplingStoreFactory{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/storage/samplingstore/mocks/Store.go b/storage/samplingstore/mocks/Store.go index ddfa6692c7f..99f3c5be5e5 100644 --- a/storage/samplingstore/mocks/Store.go +++ b/storage/samplingstore/mocks/Store.go @@ -1,60 +1,67 @@ -// Copyright (c) 2019 The Jaeger Authors. -// Copyright (c) 2017 Uber Technologies, Inc. +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Run 'make generate-mocks' to regenerate. + +// Code generated by mockery. DO NOT EDIT. package mocks import ( - "time" + model "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/model" + mock "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/mock" - - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/model" + time "time" ) +// Store is an autogenerated mock type for the Store type type Store struct { mock.Mock } -func (_m *Store) InsertThroughput(throughput []*model.Throughput) error { - ret := _m.Called(throughput) +// GetLatestProbabilities provides a mock function with given fields: +func (_m *Store) GetLatestProbabilities() (model.ServiceOperationProbabilities, error) { + ret := _m.Called() - var r0 error - if rf, ok := ret.Get(0).(func([]*model.Throughput) error); ok { - r0 = rf(throughput) - } else { - r0 = ret.Error(0) + if len(ret) == 0 { + panic("no return value specified for GetLatestProbabilities") } - return r0 -} -func (_m *Store) InsertProbabilitiesAndQPS(hostname string, probabilities model.ServiceOperationProbabilities, qps model.ServiceOperationQPS) error { - ret := _m.Called(hostname, probabilities, qps) + var r0 model.ServiceOperationProbabilities + var r1 error + if rf, ok := ret.Get(0).(func() (model.ServiceOperationProbabilities, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() model.ServiceOperationProbabilities); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(model.ServiceOperationProbabilities) + } + } - var r0 error - if rf, ok := ret.Get(0).(func(string, model.ServiceOperationProbabilities, model.ServiceOperationQPS) error); ok { - r0 = rf(hostname, probabilities, qps) + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() } else { - r0 = ret.Error(0) + r1 = ret.Error(1) } - return r0 + return r0, r1 } + +// GetThroughput provides a mock function with given fields: start, end func (_m *Store) GetThroughput(start time.Time, end time.Time) ([]*model.Throughput, error) { ret := _m.Called(start, end) + if len(ret) == 0 { + panic("no return value specified for GetThroughput") + } + var r0 []*model.Throughput + var r1 error + if rf, ok := ret.Get(0).(func(time.Time, time.Time) ([]*model.Throughput, error)); ok { + return rf(start, end) + } if rf, ok := ret.Get(0).(func(time.Time, time.Time) []*model.Throughput); ok { r0 = rf(start, end) } else { @@ -63,7 +70,6 @@ func (_m *Store) GetThroughput(start time.Time, end time.Time) ([]*model.Through } } - var r1 error if rf, ok := ret.Get(1).(func(time.Time, time.Time) error); ok { r1 = rf(start, end) } else { @@ -72,22 +78,53 @@ func (_m *Store) GetThroughput(start time.Time, end time.Time) ([]*model.Through return r0, r1 } -func (_m *Store) GetLatestProbabilities() (model.ServiceOperationProbabilities, error) { - ret := _m.Called() - var r0 model.ServiceOperationProbabilities - if rf, ok := ret.Get(0).(func() model.ServiceOperationProbabilities); ok { - r0 = rf() +// InsertProbabilitiesAndQPS provides a mock function with given fields: hostname, probabilities, qps +func (_m *Store) InsertProbabilitiesAndQPS(hostname string, probabilities model.ServiceOperationProbabilities, qps model.ServiceOperationQPS) error { + ret := _m.Called(hostname, probabilities, qps) + + if len(ret) == 0 { + panic("no return value specified for InsertProbabilitiesAndQPS") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, model.ServiceOperationProbabilities, model.ServiceOperationQPS) error); ok { + r0 = rf(hostname, probabilities, qps) } else { - r0 = ret.Get(0).(model.ServiceOperationProbabilities) + r0 = ret.Error(0) } - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() + return r0 +} + +// InsertThroughput provides a mock function with given fields: throughput +func (_m *Store) InsertThroughput(throughput []*model.Throughput) error { + ret := _m.Called(throughput) + + if len(ret) == 0 { + panic("no return value specified for InsertThroughput") + } + + var r0 error + if rf, ok := ret.Get(0).(func([]*model.Throughput) error); ok { + r0 = rf(throughput) } else { - r1 = ret.Error(1) + r0 = ret.Error(0) } - return r0, r1 + return r0 +} + +// NewStore creates a new instance of Store. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewStore(t interface { + mock.TestingT + Cleanup(func()) +}) *Store { + mock := &Store{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock } diff --git a/storage/spanstore/mocks/Reader.go b/storage/spanstore/mocks/Reader.go index 73d3630c7b2..d48658937c3 100644 --- a/storage/spanstore/mocks/Reader.go +++ b/storage/spanstore/mocks/Reader.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks diff --git a/storage/spanstore/mocks/Writer.go b/storage/spanstore/mocks/Writer.go index 10a34477345..7c7bad80b66 100644 --- a/storage/spanstore/mocks/Writer.go +++ b/storage/spanstore/mocks/Writer.go @@ -1,3 +1,8 @@ +// Copyright (c) The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 +// +// Run 'make generate-mocks' to regenerate. + // Code generated by mockery. DO NOT EDIT. package mocks