diff --git a/_mocks/opencsg.com/csghub-server/builder/deploy/mock_Deployer.go b/_mocks/opencsg.com/csghub-server/builder/deploy/mock_Deployer.go index 2f067af4..954cb181 100644 --- a/_mocks/opencsg.com/csghub-server/builder/deploy/mock_Deployer.go +++ b/_mocks/opencsg.com/csghub-server/builder/deploy/mock_Deployer.go @@ -84,6 +84,53 @@ func (_c *MockDeployer_CheckResourceAvailable_Call) RunAndReturn(run func(contex return _c } +// DeleteEvaluation provides a mock function with given fields: ctx, req +func (_m *MockDeployer) DeleteEvaluation(ctx context.Context, req types.ArgoWorkFlowDeleteReq) error { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for DeleteEvaluation") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, types.ArgoWorkFlowDeleteReq) error); ok { + r0 = rf(ctx, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDeployer_DeleteEvaluation_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteEvaluation' +type MockDeployer_DeleteEvaluation_Call struct { + *mock.Call +} + +// DeleteEvaluation is a helper method to define mock.On call +// - ctx context.Context +// - req types.ArgoWorkFlowDeleteReq +func (_e *MockDeployer_Expecter) DeleteEvaluation(ctx interface{}, req interface{}) *MockDeployer_DeleteEvaluation_Call { + return &MockDeployer_DeleteEvaluation_Call{Call: _e.mock.On("DeleteEvaluation", ctx, req)} +} + +func (_c *MockDeployer_DeleteEvaluation_Call) Run(run func(ctx context.Context, req types.ArgoWorkFlowDeleteReq)) *MockDeployer_DeleteEvaluation_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.ArgoWorkFlowDeleteReq)) + }) + return _c +} + +func (_c *MockDeployer_DeleteEvaluation_Call) Return(_a0 error) *MockDeployer_DeleteEvaluation_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDeployer_DeleteEvaluation_Call) RunAndReturn(run func(context.Context, types.ArgoWorkFlowDeleteReq) error) *MockDeployer_DeleteEvaluation_Call { + _c.Call.Return(run) + return _c +} + // Deploy provides a mock function with given fields: ctx, dr func (_m *MockDeployer) Deploy(ctx context.Context, dr types.DeployRepo) (int64, error) { ret := _m.Called(ctx, dr) @@ -257,6 +304,65 @@ func (_c *MockDeployer_GetClusterById_Call) RunAndReturn(run func(context.Contex return _c } +// GetEvaluation provides a mock function with given fields: ctx, req +func (_m *MockDeployer) GetEvaluation(ctx context.Context, req types.EvaluationGetReq) (*types.ArgoWorkFlowRes, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for GetEvaluation") + } + + var r0 *types.ArgoWorkFlowRes + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.EvaluationGetReq) (*types.ArgoWorkFlowRes, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, types.EvaluationGetReq) *types.ArgoWorkFlowRes); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.ArgoWorkFlowRes) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, types.EvaluationGetReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDeployer_GetEvaluation_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetEvaluation' +type MockDeployer_GetEvaluation_Call struct { + *mock.Call +} + +// GetEvaluation is a helper method to define mock.On call +// - ctx context.Context +// - req types.EvaluationGetReq +func (_e *MockDeployer_Expecter) GetEvaluation(ctx interface{}, req interface{}) *MockDeployer_GetEvaluation_Call { + return &MockDeployer_GetEvaluation_Call{Call: _e.mock.On("GetEvaluation", ctx, req)} +} + +func (_c *MockDeployer_GetEvaluation_Call) Run(run func(ctx context.Context, req types.EvaluationGetReq)) *MockDeployer_GetEvaluation_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.EvaluationGetReq)) + }) + return _c +} + +func (_c *MockDeployer_GetEvaluation_Call) Return(_a0 *types.ArgoWorkFlowRes, _a1 error) *MockDeployer_GetEvaluation_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDeployer_GetEvaluation_Call) RunAndReturn(run func(context.Context, types.EvaluationGetReq) (*types.ArgoWorkFlowRes, error)) *MockDeployer_GetEvaluation_Call { + _c.Call.Return(run) + return _c +} + // GetReplica provides a mock function with given fields: ctx, dr func (_m *MockDeployer) GetReplica(ctx context.Context, dr types.DeployRepo) (int, int, []types.Instance, error) { ret := _m.Called(ctx, dr) @@ -447,6 +553,67 @@ func (_c *MockDeployer_ListCluster_Call) RunAndReturn(run func(context.Context) return _c } +// ListEvaluations provides a mock function with given fields: _a0, _a1, _a2, _a3 +func (_m *MockDeployer) ListEvaluations(_a0 context.Context, _a1 string, _a2 int, _a3 int) (*types.ArgoWorkFlowListRes, error) { + ret := _m.Called(_a0, _a1, _a2, _a3) + + if len(ret) == 0 { + panic("no return value specified for ListEvaluations") + } + + var r0 *types.ArgoWorkFlowListRes + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, int, int) (*types.ArgoWorkFlowListRes, error)); ok { + return rf(_a0, _a1, _a2, _a3) + } + if rf, ok := ret.Get(0).(func(context.Context, string, int, int) *types.ArgoWorkFlowListRes); ok { + r0 = rf(_a0, _a1, _a2, _a3) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.ArgoWorkFlowListRes) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, int, int) error); ok { + r1 = rf(_a0, _a1, _a2, _a3) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDeployer_ListEvaluations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListEvaluations' +type MockDeployer_ListEvaluations_Call struct { + *mock.Call +} + +// ListEvaluations is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 string +// - _a2 int +// - _a3 int +func (_e *MockDeployer_Expecter) ListEvaluations(_a0 interface{}, _a1 interface{}, _a2 interface{}, _a3 interface{}) *MockDeployer_ListEvaluations_Call { + return &MockDeployer_ListEvaluations_Call{Call: _e.mock.On("ListEvaluations", _a0, _a1, _a2, _a3)} +} + +func (_c *MockDeployer_ListEvaluations_Call) Run(run func(_a0 context.Context, _a1 string, _a2 int, _a3 int)) *MockDeployer_ListEvaluations_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(int), args[3].(int)) + }) + return _c +} + +func (_c *MockDeployer_ListEvaluations_Call) Return(_a0 *types.ArgoWorkFlowListRes, _a1 error) *MockDeployer_ListEvaluations_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDeployer_ListEvaluations_Call) RunAndReturn(run func(context.Context, string, int, int) (*types.ArgoWorkFlowListRes, error)) *MockDeployer_ListEvaluations_Call { + _c.Call.Return(run) + return _c +} + // Logs provides a mock function with given fields: ctx, dr func (_m *MockDeployer) Logs(ctx context.Context, dr types.DeployRepo) (*deploy.MultiLogReader, error) { ret := _m.Called(ctx, dr) @@ -721,6 +888,65 @@ func (_c *MockDeployer_Stop_Call) RunAndReturn(run func(context.Context, types.D return _c } +// SubmitEvaluation provides a mock function with given fields: ctx, req +func (_m *MockDeployer) SubmitEvaluation(ctx context.Context, req types.EvaluationReq) (*types.ArgoWorkFlowRes, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for SubmitEvaluation") + } + + var r0 *types.ArgoWorkFlowRes + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.EvaluationReq) (*types.ArgoWorkFlowRes, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, types.EvaluationReq) *types.ArgoWorkFlowRes); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.ArgoWorkFlowRes) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, types.EvaluationReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDeployer_SubmitEvaluation_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubmitEvaluation' +type MockDeployer_SubmitEvaluation_Call struct { + *mock.Call +} + +// SubmitEvaluation is a helper method to define mock.On call +// - ctx context.Context +// - req types.EvaluationReq +func (_e *MockDeployer_Expecter) SubmitEvaluation(ctx interface{}, req interface{}) *MockDeployer_SubmitEvaluation_Call { + return &MockDeployer_SubmitEvaluation_Call{Call: _e.mock.On("SubmitEvaluation", ctx, req)} +} + +func (_c *MockDeployer_SubmitEvaluation_Call) Run(run func(ctx context.Context, req types.EvaluationReq)) *MockDeployer_SubmitEvaluation_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.EvaluationReq)) + }) + return _c +} + +func (_c *MockDeployer_SubmitEvaluation_Call) Return(_a0 *types.ArgoWorkFlowRes, _a1 error) *MockDeployer_SubmitEvaluation_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDeployer_SubmitEvaluation_Call) RunAndReturn(run func(context.Context, types.EvaluationReq) (*types.ArgoWorkFlowRes, error)) *MockDeployer_SubmitEvaluation_Call { + _c.Call.Return(run) + return _c +} + // UpdateCluster provides a mock function with given fields: ctx, data func (_m *MockDeployer) UpdateCluster(ctx context.Context, data types.ClusterRequest) (*types.UpdateClusterResponse, error) { ret := _m.Called(ctx, data) diff --git a/_mocks/opencsg.com/csghub-server/builder/store/database/mock_ArgoWorkFlowStore.go b/_mocks/opencsg.com/csghub-server/builder/store/database/mock_ArgoWorkFlowStore.go new file mode 100644 index 00000000..a392d894 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/builder/store/database/mock_ArgoWorkFlowStore.go @@ -0,0 +1,384 @@ +// Code generated by mockery v2.49.1. DO NOT EDIT. + +package database + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + database "opencsg.com/csghub-server/builder/store/database" +) + +// MockArgoWorkFlowStore is an autogenerated mock type for the ArgoWorkFlowStore type +type MockArgoWorkFlowStore struct { + mock.Mock +} + +type MockArgoWorkFlowStore_Expecter struct { + mock *mock.Mock +} + +func (_m *MockArgoWorkFlowStore) EXPECT() *MockArgoWorkFlowStore_Expecter { + return &MockArgoWorkFlowStore_Expecter{mock: &_m.Mock} +} + +// CreateWorkFlow provides a mock function with given fields: ctx, workFlow +func (_m *MockArgoWorkFlowStore) CreateWorkFlow(ctx context.Context, workFlow database.ArgoWorkflow) (*database.ArgoWorkflow, error) { + ret := _m.Called(ctx, workFlow) + + if len(ret) == 0 { + panic("no return value specified for CreateWorkFlow") + } + + var r0 *database.ArgoWorkflow + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, database.ArgoWorkflow) (*database.ArgoWorkflow, error)); ok { + return rf(ctx, workFlow) + } + if rf, ok := ret.Get(0).(func(context.Context, database.ArgoWorkflow) *database.ArgoWorkflow); ok { + r0 = rf(ctx, workFlow) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.ArgoWorkflow) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, database.ArgoWorkflow) error); ok { + r1 = rf(ctx, workFlow) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockArgoWorkFlowStore_CreateWorkFlow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateWorkFlow' +type MockArgoWorkFlowStore_CreateWorkFlow_Call struct { + *mock.Call +} + +// CreateWorkFlow is a helper method to define mock.On call +// - ctx context.Context +// - workFlow database.ArgoWorkflow +func (_e *MockArgoWorkFlowStore_Expecter) CreateWorkFlow(ctx interface{}, workFlow interface{}) *MockArgoWorkFlowStore_CreateWorkFlow_Call { + return &MockArgoWorkFlowStore_CreateWorkFlow_Call{Call: _e.mock.On("CreateWorkFlow", ctx, workFlow)} +} + +func (_c *MockArgoWorkFlowStore_CreateWorkFlow_Call) Run(run func(ctx context.Context, workFlow database.ArgoWorkflow)) *MockArgoWorkFlowStore_CreateWorkFlow_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(database.ArgoWorkflow)) + }) + return _c +} + +func (_c *MockArgoWorkFlowStore_CreateWorkFlow_Call) Return(_a0 *database.ArgoWorkflow, _a1 error) *MockArgoWorkFlowStore_CreateWorkFlow_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockArgoWorkFlowStore_CreateWorkFlow_Call) RunAndReturn(run func(context.Context, database.ArgoWorkflow) (*database.ArgoWorkflow, error)) *MockArgoWorkFlowStore_CreateWorkFlow_Call { + _c.Call.Return(run) + return _c +} + +// DeleteWorkFlow provides a mock function with given fields: ctx, id +func (_m *MockArgoWorkFlowStore) DeleteWorkFlow(ctx context.Context, id int64) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for DeleteWorkFlow") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockArgoWorkFlowStore_DeleteWorkFlow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteWorkFlow' +type MockArgoWorkFlowStore_DeleteWorkFlow_Call struct { + *mock.Call +} + +// DeleteWorkFlow is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockArgoWorkFlowStore_Expecter) DeleteWorkFlow(ctx interface{}, id interface{}) *MockArgoWorkFlowStore_DeleteWorkFlow_Call { + return &MockArgoWorkFlowStore_DeleteWorkFlow_Call{Call: _e.mock.On("DeleteWorkFlow", ctx, id)} +} + +func (_c *MockArgoWorkFlowStore_DeleteWorkFlow_Call) Run(run func(ctx context.Context, id int64)) *MockArgoWorkFlowStore_DeleteWorkFlow_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockArgoWorkFlowStore_DeleteWorkFlow_Call) Return(_a0 error) *MockArgoWorkFlowStore_DeleteWorkFlow_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockArgoWorkFlowStore_DeleteWorkFlow_Call) RunAndReturn(run func(context.Context, int64) error) *MockArgoWorkFlowStore_DeleteWorkFlow_Call { + _c.Call.Return(run) + return _c +} + +// FindByID provides a mock function with given fields: ctx, id +func (_m *MockArgoWorkFlowStore) FindByID(ctx context.Context, id int64) (database.ArgoWorkflow, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for FindByID") + } + + var r0 database.ArgoWorkflow + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (database.ArgoWorkflow, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) database.ArgoWorkflow); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Get(0).(database.ArgoWorkflow) + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockArgoWorkFlowStore_FindByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindByID' +type MockArgoWorkFlowStore_FindByID_Call struct { + *mock.Call +} + +// FindByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockArgoWorkFlowStore_Expecter) FindByID(ctx interface{}, id interface{}) *MockArgoWorkFlowStore_FindByID_Call { + return &MockArgoWorkFlowStore_FindByID_Call{Call: _e.mock.On("FindByID", ctx, id)} +} + +func (_c *MockArgoWorkFlowStore_FindByID_Call) Run(run func(ctx context.Context, id int64)) *MockArgoWorkFlowStore_FindByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockArgoWorkFlowStore_FindByID_Call) Return(WorkFlow database.ArgoWorkflow, err error) *MockArgoWorkFlowStore_FindByID_Call { + _c.Call.Return(WorkFlow, err) + return _c +} + +func (_c *MockArgoWorkFlowStore_FindByID_Call) RunAndReturn(run func(context.Context, int64) (database.ArgoWorkflow, error)) *MockArgoWorkFlowStore_FindByID_Call { + _c.Call.Return(run) + return _c +} + +// FindByTaskID provides a mock function with given fields: ctx, id +func (_m *MockArgoWorkFlowStore) FindByTaskID(ctx context.Context, id string) (database.ArgoWorkflow, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for FindByTaskID") + } + + var r0 database.ArgoWorkflow + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (database.ArgoWorkflow, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, string) database.ArgoWorkflow); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Get(0).(database.ArgoWorkflow) + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockArgoWorkFlowStore_FindByTaskID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindByTaskID' +type MockArgoWorkFlowStore_FindByTaskID_Call struct { + *mock.Call +} + +// FindByTaskID is a helper method to define mock.On call +// - ctx context.Context +// - id string +func (_e *MockArgoWorkFlowStore_Expecter) FindByTaskID(ctx interface{}, id interface{}) *MockArgoWorkFlowStore_FindByTaskID_Call { + return &MockArgoWorkFlowStore_FindByTaskID_Call{Call: _e.mock.On("FindByTaskID", ctx, id)} +} + +func (_c *MockArgoWorkFlowStore_FindByTaskID_Call) Run(run func(ctx context.Context, id string)) *MockArgoWorkFlowStore_FindByTaskID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockArgoWorkFlowStore_FindByTaskID_Call) Return(WorkFlow database.ArgoWorkflow, err error) *MockArgoWorkFlowStore_FindByTaskID_Call { + _c.Call.Return(WorkFlow, err) + return _c +} + +func (_c *MockArgoWorkFlowStore_FindByTaskID_Call) RunAndReturn(run func(context.Context, string) (database.ArgoWorkflow, error)) *MockArgoWorkFlowStore_FindByTaskID_Call { + _c.Call.Return(run) + return _c +} + +// FindByUsername provides a mock function with given fields: ctx, username, per, page +func (_m *MockArgoWorkFlowStore) FindByUsername(ctx context.Context, username string, per int, page int) ([]database.ArgoWorkflow, int, error) { + ret := _m.Called(ctx, username, per, page) + + if len(ret) == 0 { + panic("no return value specified for FindByUsername") + } + + var r0 []database.ArgoWorkflow + var r1 int + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, int, int) ([]database.ArgoWorkflow, int, error)); ok { + return rf(ctx, username, per, page) + } + if rf, ok := ret.Get(0).(func(context.Context, string, int, int) []database.ArgoWorkflow); ok { + r0 = rf(ctx, username, per, page) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]database.ArgoWorkflow) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, int, int) int); ok { + r1 = rf(ctx, username, per, page) + } else { + r1 = ret.Get(1).(int) + } + + if rf, ok := ret.Get(2).(func(context.Context, string, int, int) error); ok { + r2 = rf(ctx, username, per, page) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockArgoWorkFlowStore_FindByUsername_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindByUsername' +type MockArgoWorkFlowStore_FindByUsername_Call struct { + *mock.Call +} + +// FindByUsername is a helper method to define mock.On call +// - ctx context.Context +// - username string +// - per int +// - page int +func (_e *MockArgoWorkFlowStore_Expecter) FindByUsername(ctx interface{}, username interface{}, per interface{}, page interface{}) *MockArgoWorkFlowStore_FindByUsername_Call { + return &MockArgoWorkFlowStore_FindByUsername_Call{Call: _e.mock.On("FindByUsername", ctx, username, per, page)} +} + +func (_c *MockArgoWorkFlowStore_FindByUsername_Call) Run(run func(ctx context.Context, username string, per int, page int)) *MockArgoWorkFlowStore_FindByUsername_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(int), args[3].(int)) + }) + return _c +} + +func (_c *MockArgoWorkFlowStore_FindByUsername_Call) Return(WorkFlows []database.ArgoWorkflow, total int, err error) *MockArgoWorkFlowStore_FindByUsername_Call { + _c.Call.Return(WorkFlows, total, err) + return _c +} + +func (_c *MockArgoWorkFlowStore_FindByUsername_Call) RunAndReturn(run func(context.Context, string, int, int) ([]database.ArgoWorkflow, int, error)) *MockArgoWorkFlowStore_FindByUsername_Call { + _c.Call.Return(run) + return _c +} + +// UpdateWorkFlow provides a mock function with given fields: ctx, workFlow +func (_m *MockArgoWorkFlowStore) UpdateWorkFlow(ctx context.Context, workFlow database.ArgoWorkflow) (*database.ArgoWorkflow, error) { + ret := _m.Called(ctx, workFlow) + + if len(ret) == 0 { + panic("no return value specified for UpdateWorkFlow") + } + + var r0 *database.ArgoWorkflow + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, database.ArgoWorkflow) (*database.ArgoWorkflow, error)); ok { + return rf(ctx, workFlow) + } + if rf, ok := ret.Get(0).(func(context.Context, database.ArgoWorkflow) *database.ArgoWorkflow); ok { + r0 = rf(ctx, workFlow) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.ArgoWorkflow) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, database.ArgoWorkflow) error); ok { + r1 = rf(ctx, workFlow) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockArgoWorkFlowStore_UpdateWorkFlow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateWorkFlow' +type MockArgoWorkFlowStore_UpdateWorkFlow_Call struct { + *mock.Call +} + +// UpdateWorkFlow is a helper method to define mock.On call +// - ctx context.Context +// - workFlow database.ArgoWorkflow +func (_e *MockArgoWorkFlowStore_Expecter) UpdateWorkFlow(ctx interface{}, workFlow interface{}) *MockArgoWorkFlowStore_UpdateWorkFlow_Call { + return &MockArgoWorkFlowStore_UpdateWorkFlow_Call{Call: _e.mock.On("UpdateWorkFlow", ctx, workFlow)} +} + +func (_c *MockArgoWorkFlowStore_UpdateWorkFlow_Call) Run(run func(ctx context.Context, workFlow database.ArgoWorkflow)) *MockArgoWorkFlowStore_UpdateWorkFlow_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(database.ArgoWorkflow)) + }) + return _c +} + +func (_c *MockArgoWorkFlowStore_UpdateWorkFlow_Call) Return(_a0 *database.ArgoWorkflow, _a1 error) *MockArgoWorkFlowStore_UpdateWorkFlow_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockArgoWorkFlowStore_UpdateWorkFlow_Call) RunAndReturn(run func(context.Context, database.ArgoWorkflow) (*database.ArgoWorkflow, error)) *MockArgoWorkFlowStore_UpdateWorkFlow_Call { + _c.Call.Return(run) + return _c +} + +// NewMockArgoWorkFlowStore creates a new instance of MockArgoWorkFlowStore. 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 NewMockArgoWorkFlowStore(t interface { + mock.TestingT + Cleanup(func()) +}) *MockArgoWorkFlowStore { + mock := &MockArgoWorkFlowStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/builder/store/database/mock_TagRuleStore.go b/_mocks/opencsg.com/csghub-server/builder/store/database/mock_TagRuleStore.go new file mode 100644 index 00000000..a149c0c0 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/builder/store/database/mock_TagRuleStore.go @@ -0,0 +1,99 @@ +// Code generated by mockery v2.49.1. DO NOT EDIT. + +package database + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + database "opencsg.com/csghub-server/builder/store/database" +) + +// MockTagRuleStore is an autogenerated mock type for the TagRuleStore type +type MockTagRuleStore struct { + mock.Mock +} + +type MockTagRuleStore_Expecter struct { + mock *mock.Mock +} + +func (_m *MockTagRuleStore) EXPECT() *MockTagRuleStore_Expecter { + return &MockTagRuleStore_Expecter{mock: &_m.Mock} +} + +// FindByRepo provides a mock function with given fields: ctx, category, namespace, repoName, repoType +func (_m *MockTagRuleStore) FindByRepo(ctx context.Context, category string, namespace string, repoName string, repoType string) (*database.TagRule, error) { + ret := _m.Called(ctx, category, namespace, repoName, repoType) + + if len(ret) == 0 { + panic("no return value specified for FindByRepo") + } + + var r0 *database.TagRule + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) (*database.TagRule, error)); ok { + return rf(ctx, category, namespace, repoName, repoType) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) *database.TagRule); ok { + r0 = rf(ctx, category, namespace, repoName, repoType) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.TagRule) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, string) error); ok { + r1 = rf(ctx, category, namespace, repoName, repoType) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockTagRuleStore_FindByRepo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindByRepo' +type MockTagRuleStore_FindByRepo_Call struct { + *mock.Call +} + +// FindByRepo is a helper method to define mock.On call +// - ctx context.Context +// - category string +// - namespace string +// - repoName string +// - repoType string +func (_e *MockTagRuleStore_Expecter) FindByRepo(ctx interface{}, category interface{}, namespace interface{}, repoName interface{}, repoType interface{}) *MockTagRuleStore_FindByRepo_Call { + return &MockTagRuleStore_FindByRepo_Call{Call: _e.mock.On("FindByRepo", ctx, category, namespace, repoName, repoType)} +} + +func (_c *MockTagRuleStore_FindByRepo_Call) Run(run func(ctx context.Context, category string, namespace string, repoName string, repoType string)) *MockTagRuleStore_FindByRepo_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string), args[4].(string)) + }) + return _c +} + +func (_c *MockTagRuleStore_FindByRepo_Call) Return(_a0 *database.TagRule, _a1 error) *MockTagRuleStore_FindByRepo_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockTagRuleStore_FindByRepo_Call) RunAndReturn(run func(context.Context, string, string, string, string) (*database.TagRule, error)) *MockTagRuleStore_FindByRepo_Call { + _c.Call.Return(run) + return _c +} + +// NewMockTagRuleStore creates a new instance of MockTagRuleStore. 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 NewMockTagRuleStore(t interface { + mock.TestingT + Cleanup(func()) +}) *MockTagRuleStore { + mock := &MockTagRuleStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/builder/store/database/mock_TagStore.go b/_mocks/opencsg.com/csghub-server/builder/store/database/mock_TagStore.go index 862b878d..f2638d83 100644 --- a/_mocks/opencsg.com/csghub-server/builder/store/database/mock_TagStore.go +++ b/_mocks/opencsg.com/csghub-server/builder/store/database/mock_TagStore.go @@ -900,6 +900,67 @@ func (_c *MockTagStore_FindOrCreate_Call) RunAndReturn(run func(context.Context, return _c } +// FindTag provides a mock function with given fields: ctx, name, scope, category +func (_m *MockTagStore) FindTag(ctx context.Context, name string, scope string, category string) (*database.Tag, error) { + ret := _m.Called(ctx, name, scope, category) + + if len(ret) == 0 { + panic("no return value specified for FindTag") + } + + var r0 *database.Tag + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*database.Tag, error)); ok { + return rf(ctx, name, scope, category) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *database.Tag); ok { + r0 = rf(ctx, name, scope, category) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.Tag) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, name, scope, category) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockTagStore_FindTag_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindTag' +type MockTagStore_FindTag_Call struct { + *mock.Call +} + +// FindTag is a helper method to define mock.On call +// - ctx context.Context +// - name string +// - scope string +// - category string +func (_e *MockTagStore_Expecter) FindTag(ctx interface{}, name interface{}, scope interface{}, category interface{}) *MockTagStore_FindTag_Call { + return &MockTagStore_FindTag_Call{Call: _e.mock.On("FindTag", ctx, name, scope, category)} +} + +func (_c *MockTagStore_FindTag_Call) Run(run func(ctx context.Context, name string, scope string, category string)) *MockTagStore_FindTag_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockTagStore_FindTag_Call) Return(_a0 *database.Tag, _a1 error) *MockTagStore_FindTag_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockTagStore_FindTag_Call) RunAndReturn(run func(context.Context, string, string, string) (*database.Tag, error)) *MockTagStore_FindTag_Call { + _c.Call.Return(run) + return _c +} + // GetTagsByScopeAndCategories provides a mock function with given fields: ctx, scope, categories func (_m *MockTagStore) GetTagsByScopeAndCategories(ctx context.Context, scope database.TagScope, categories []string) ([]*database.Tag, error) { ret := _m.Called(ctx, scope, categories) diff --git a/_mocks/opencsg.com/csghub-server/component/mock_TagComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_TagComponent.go index 76b73284..af076cd7 100644 --- a/_mocks/opencsg.com/csghub-server/component/mock_TagComponent.go +++ b/_mocks/opencsg.com/csghub-server/component/mock_TagComponent.go @@ -82,6 +82,66 @@ func (_c *MockTagComponent_AllTags_Call) RunAndReturn(run func(context.Context) return _c } +// AllTagsByScopeAndCategory provides a mock function with given fields: ctx, scope, category +func (_m *MockTagComponent) AllTagsByScopeAndCategory(ctx context.Context, scope string, category string) ([]*database.Tag, error) { + ret := _m.Called(ctx, scope, category) + + if len(ret) == 0 { + panic("no return value specified for AllTagsByScopeAndCategory") + } + + var r0 []*database.Tag + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) ([]*database.Tag, error)); ok { + return rf(ctx, scope, category) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) []*database.Tag); ok { + r0 = rf(ctx, scope, category) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*database.Tag) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, scope, category) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockTagComponent_AllTagsByScopeAndCategory_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllTagsByScopeAndCategory' +type MockTagComponent_AllTagsByScopeAndCategory_Call struct { + *mock.Call +} + +// AllTagsByScopeAndCategory is a helper method to define mock.On call +// - ctx context.Context +// - scope string +// - category string +func (_e *MockTagComponent_Expecter) AllTagsByScopeAndCategory(ctx interface{}, scope interface{}, category interface{}) *MockTagComponent_AllTagsByScopeAndCategory_Call { + return &MockTagComponent_AllTagsByScopeAndCategory_Call{Call: _e.mock.On("AllTagsByScopeAndCategory", ctx, scope, category)} +} + +func (_c *MockTagComponent_AllTagsByScopeAndCategory_Call) Run(run func(ctx context.Context, scope string, category string)) *MockTagComponent_AllTagsByScopeAndCategory_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockTagComponent_AllTagsByScopeAndCategory_Call) Return(_a0 []*database.Tag, _a1 error) *MockTagComponent_AllTagsByScopeAndCategory_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockTagComponent_AllTagsByScopeAndCategory_Call) RunAndReturn(run func(context.Context, string, string) ([]*database.Tag, error)) *MockTagComponent_AllTagsByScopeAndCategory_Call { + _c.Call.Return(run) + return _c +} + // ClearMetaTags provides a mock function with given fields: ctx, repoType, namespace, name func (_m *MockTagComponent) ClearMetaTags(ctx context.Context, repoType types.RepositoryType, namespace string, name string) error { ret := _m.Called(ctx, repoType, namespace, name) diff --git a/cmd/csghub-server/cmd/start/server.go b/cmd/csghub-server/cmd/start/server.go index 1f3cf55b..e66787af 100644 --- a/cmd/csghub-server/cmd/start/server.go +++ b/cmd/csghub-server/cmd/start/server.go @@ -67,6 +67,7 @@ var serverCmd = &cobra.Command{ if err != nil { return fmt.Errorf("fail to initialize message queue, %w", err) } + s3Internal := len(cfg.S3.InternalEndpoint) > 0 err = deploy.Init(common.DeployConfig{ ImageBuilderURL: cfg.Space.BuilderEndpoint, ImageRunnerURL: cfg.Space.RunnerEndpoint, @@ -76,6 +77,7 @@ var serverCmd = &cobra.Command{ ModelDeployTimeoutInMin: cfg.Model.DeployTimeoutInMin, ModelDownloadEndpoint: cfg.Model.DownloadEndpoint, PublicRootDomain: cfg.Space.PublicRootDomain, + S3Internal: s3Internal, IsMasterHost: cfg.IsMasterHost, }) if err != nil { diff --git a/common/config/config.go b/common/config/config.go index e631e2d5..7d85a642 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -16,11 +16,8 @@ type Config struct { EnableSwagger bool `env:"STARHUB_SERVER_ENABLE_SWAGGER, default=false"` APIToken string `env:"STARHUB_SERVER_API_TOKEN, default=0c11e6e4f2054444374ba3f0b70de4145935a7312289d404814cd5907c6aa93cc65cd35dbf94e04c13a3dedbf51f1694de84240c8acb7238b54a2c3ac8e87c59"` // enable if you want to acess csghub through https, especially for space rproxy - EnableHTTPS bool `env:"STARHUB_SERVER_ENABLE_HTTPS, default=false"` - //the api key to call lbs service, like tencent map or gaode map - LBSServiceKey string `env:"STARHUB_SERVER_LBS_SERVICE_KEY, default=123456"` - //the cdn domain for different city - CityToCdnDomain map[string]string `env:"STARHUB_SERVER_CITY_TO_CDN_DOMAIN, default="` + EnableHTTPS bool `env:"STARHUB_SERVER_ENABLE_HTTPS, default=false"` + DocsHost string `env:"STARHUB_SERVER_SERVER_DOCS_HOST, default=http://localhost:6636"` //the master host IsMasterHost bool `env:"STARHUB_SERVER_IS_MASTER_HOST, default=true"` diff --git a/common/tests/stores.go b/common/tests/stores.go index 46380274..9a548bec 100644 --- a/common/tests/stores.go +++ b/common/tests/stores.go @@ -42,13 +42,13 @@ func NewMockStores(t interface { mock.TestingT }) *MockStores { return &MockStores{ - User: mockdb.NewMockUserStore(t), - UserLikes: mockdb.NewMockUserLikesStore(t), - Repo: mockdb.NewMockRepoStore(t), - RepoRelation: mockdb.NewMockRepoRelationsStore(t), - Model: mockdb.NewMockModelStore(t), - SpaceResource: mockdb.NewMockSpaceResourceStore(t), - Tag: mockdb.NewMockTagStore(t), + User: mockdb.NewMockUserStore(t), + UserLikes: mockdb.NewMockUserLikesStore(t), + Repo: mockdb.NewMockRepoStore(t), + RepoRelation: mockdb.NewMockRepoRelationsStore(t), + Model: mockdb.NewMockModelStore(t), + SpaceResource: mockdb.NewMockSpaceResourceStore(t), + //Tag: mockdb.NewMockTagStore(t), Dataset: mockdb.NewMockDatasetStore(t), PromptConversation: mockdb.NewMockPromptConversationStore(t), PromptPrefix: mockdb.NewMockPromptPrefixStore(t), diff --git a/component/evaluation_test.go b/component/evaluation_test.go index 83cafb22..a1620f14 100644 --- a/component/evaluation_test.go +++ b/component/evaluation_test.go @@ -3,7 +3,6 @@ package component import ( "context" "encoding/json" - "strconv" "testing" "github.com/stretchr/testify/require" @@ -125,23 +124,12 @@ func TestEvaluationComponent_CreateEvaluation(t *testing.T) { ID: 1, FrameImage: "lm-evaluation-harness:0.4.6", }, nil) - ac.EXPECT().QueryBalanceByUserIDInternal(ctx, "test").Return(&database.AccountUser{ - Balance: 123.4, - }, nil) resource, err := json.Marshal(req2.Hardware) require.Nil(t, err) stores.SpaceResourceMock().EXPECT().FindByID(ctx, int64(1)).Return(&database.SpaceResource{ ID: 1, Resources: string(resource), }, nil) - ac.EXPECT().QueryPricesBySKUType("", types.AcctPriceListReq{ - SkuType: types.SKUCSGHub, - SkuKind: strconv.Itoa(int(types.SKUPayAsYouGo)), - ResourceID: strconv.FormatInt(int64(1), 10), - }).Return(&database.PriceResp{ - Total: 100, - Prices: []database.AccountPrice{{SkuPrice: 10}}, - }, nil) deployerMock.EXPECT().SubmitEvaluation(ctx, req2).Return(&types.ArgoWorkFlowRes{ ID: 1, TaskName: "test", diff --git a/component/model_test.go b/component/model_test.go index f90bc1d5..3cea82d9 100644 --- a/component/model_test.go +++ b/component/model_test.go @@ -580,9 +580,9 @@ func TestModelComponent_SetRuntimeFrameworkModes(t *testing.T) { }, nil, ) rftags := []*database.Tag{{Name: "t1"}, {Name: "t2"}} - mc.mocks.stores.TagMock().EXPECT().GetTagsByScopeAndCategories( - ctx, database.TagScope("model"), []string{"runtime_framework", "resource"}, - ).Return(rftags, nil) + // mc.mocks.stores.TagMock().EXPECT().GetTagsByScopeAndCategories( + // ctx, database.TagScope("model"), []string{"runtime_framework", "resource"}, + // ).Return(rftags, nil) mc.mocks.stores.RepoRuntimeFrameworkMock().EXPECT().GetByIDsAndType( ctx, int64(1), int64(1), 1, diff --git a/component/user.go b/component/user.go index 16a8aab2..86cc31e9 100644 --- a/component/user.go +++ b/component/user.go @@ -88,8 +88,12 @@ type userComponentImpl struct { spaceStore database.SpaceStore namespaceStore database.NamespaceStore gitServer gitserver.GitServer + spaceComponent SpaceComponent + repoComponent RepoComponent + deployer deploy.Deployer userLikeStore database.UserLikesStore repoStore database.RepoStore + deploy database.DeployTaskStore collectionStore database.CollectionStore accountingComponent AccountingComponent // srs database.SpaceResourceStore