* refactor: Move job cleanup to separate controller and fix history write - Created JobCleanupController in apps/provisioning/pkg/controller - Separated cleanup logic from ConcurrentJobDriver - Fixed bug where expired jobs were not written to history - Added comprehensive tests with 93.8% coverage - Removed cleanup interval parameter from ConcurrentJobDriver - Cleanup now properly follows Complete + WriteJob pattern Fixes expired jobs being lost instead of archived * refactor: Update lease renewal interval to use jobExpiry variable - Changed the lease renewal interval in the GetPostStartHooks method to utilize the jobExpiry variable for improved clarity and maintainability. * Format code * Fix Unix milliseconds * fix: correct Unix timestamp assertions and remove duplicate test expectations - Changed Unix() to UnixMilli() for correct millisecond timestamp validation - Removed duplicate store.AssertExpectations(t) calls throughout tests
145 lines
4.4 KiB
Go
145 lines
4.4 KiB
Go
// Code generated by mockery v2.53.4. DO NOT EDIT.
|
|
|
|
package jobs
|
|
|
|
import (
|
|
context "context"
|
|
|
|
loki "github.com/grafana/grafana/apps/provisioning/pkg/loki"
|
|
mock "github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
// MockLokiClient is an autogenerated mock type for the LokiClient type
|
|
type MockLokiClient struct {
|
|
mock.Mock
|
|
}
|
|
|
|
type MockLokiClient_Expecter struct {
|
|
mock *mock.Mock
|
|
}
|
|
|
|
func (_m *MockLokiClient) EXPECT() *MockLokiClient_Expecter {
|
|
return &MockLokiClient_Expecter{mock: &_m.Mock}
|
|
}
|
|
|
|
// Push provides a mock function with given fields: _a0, _a1
|
|
func (_m *MockLokiClient) Push(_a0 context.Context, _a1 []loki.Stream) error {
|
|
ret := _m.Called(_a0, _a1)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Push")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, []loki.Stream) error); ok {
|
|
r0 = rf(_a0, _a1)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// MockLokiClient_Push_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Push'
|
|
type MockLokiClient_Push_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// Push is a helper method to define mock.On call
|
|
// - _a0 context.Context
|
|
// - _a1 []loki.Stream
|
|
func (_e *MockLokiClient_Expecter) Push(_a0 interface{}, _a1 interface{}) *MockLokiClient_Push_Call {
|
|
return &MockLokiClient_Push_Call{Call: _e.mock.On("Push", _a0, _a1)}
|
|
}
|
|
|
|
func (_c *MockLokiClient_Push_Call) Run(run func(_a0 context.Context, _a1 []loki.Stream)) *MockLokiClient_Push_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run(args[0].(context.Context), args[1].([]loki.Stream))
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockLokiClient_Push_Call) Return(_a0 error) *MockLokiClient_Push_Call {
|
|
_c.Call.Return(_a0)
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockLokiClient_Push_Call) RunAndReturn(run func(context.Context, []loki.Stream) error) *MockLokiClient_Push_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// RangeQuery provides a mock function with given fields: ctx, logQL, start, end, limit
|
|
func (_m *MockLokiClient) RangeQuery(ctx context.Context, logQL string, start int64, end int64, limit int64) (loki.QueryRes, error) {
|
|
ret := _m.Called(ctx, logQL, start, end, limit)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for RangeQuery")
|
|
}
|
|
|
|
var r0 loki.QueryRes
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, string, int64, int64, int64) (loki.QueryRes, error)); ok {
|
|
return rf(ctx, logQL, start, end, limit)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context, string, int64, int64, int64) loki.QueryRes); ok {
|
|
r0 = rf(ctx, logQL, start, end, limit)
|
|
} else {
|
|
r0 = ret.Get(0).(loki.QueryRes)
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context, string, int64, int64, int64) error); ok {
|
|
r1 = rf(ctx, logQL, start, end, limit)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// MockLokiClient_RangeQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RangeQuery'
|
|
type MockLokiClient_RangeQuery_Call struct {
|
|
*mock.Call
|
|
}
|
|
|
|
// RangeQuery is a helper method to define mock.On call
|
|
// - ctx context.Context
|
|
// - logQL string
|
|
// - start int64
|
|
// - end int64
|
|
// - limit int64
|
|
func (_e *MockLokiClient_Expecter) RangeQuery(ctx interface{}, logQL interface{}, start interface{}, end interface{}, limit interface{}) *MockLokiClient_RangeQuery_Call {
|
|
return &MockLokiClient_RangeQuery_Call{Call: _e.mock.On("RangeQuery", ctx, logQL, start, end, limit)}
|
|
}
|
|
|
|
func (_c *MockLokiClient_RangeQuery_Call) Run(run func(ctx context.Context, logQL string, start int64, end int64, limit int64)) *MockLokiClient_RangeQuery_Call {
|
|
_c.Call.Run(func(args mock.Arguments) {
|
|
run(args[0].(context.Context), args[1].(string), args[2].(int64), args[3].(int64), args[4].(int64))
|
|
})
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockLokiClient_RangeQuery_Call) Return(_a0 loki.QueryRes, _a1 error) *MockLokiClient_RangeQuery_Call {
|
|
_c.Call.Return(_a0, _a1)
|
|
return _c
|
|
}
|
|
|
|
func (_c *MockLokiClient_RangeQuery_Call) RunAndReturn(run func(context.Context, string, int64, int64, int64) (loki.QueryRes, error)) *MockLokiClient_RangeQuery_Call {
|
|
_c.Call.Return(run)
|
|
return _c
|
|
}
|
|
|
|
// NewMockLokiClient creates a new instance of MockLokiClient. 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 NewMockLokiClient(t interface {
|
|
mock.TestingT
|
|
Cleanup(func())
|
|
}) *MockLokiClient {
|
|
mock := &MockLokiClient{}
|
|
mock.Mock.Test(t)
|
|
|
|
t.Cleanup(func() { mock.AssertExpectations(t) })
|
|
|
|
return mock
|
|
}
|