This commit is contained in:
barnett 2018-11-19 14:16:37 +08:00
commit e81095334b
14 changed files with 5739 additions and 899 deletions

3632
db/dao/dao_mock.go Normal file

File diff suppressed because it is too large Load Diff

721
db/db_mock.go Normal file
View File

@ -0,0 +1,721 @@
// Automatically generated by MockGen. DO NOT EDIT!
// Source: db.go
package db
import (
"github.com/goodrain/rainbond/db/dao"
"github.com/jinzhu/gorm"
"github.com/rafrombrc/gomock/gomock"
)
// Mock of Manager interface
type MockManager struct {
ctrl *gomock.Controller
recorder *_MockManagerRecorder
}
// Recorder for MockManager (not exported)
type _MockManagerRecorder struct {
mock *MockManager
}
func NewMockManager(ctrl *gomock.Controller) *MockManager {
mock := &MockManager{ctrl: ctrl}
mock.recorder = &_MockManagerRecorder{mock}
return mock
}
func (_m *MockManager) EXPECT() *_MockManagerRecorder {
return _m.recorder
}
func (_m *MockManager) CloseManager() error {
ret := _m.ctrl.Call(_m, "CloseManager")
ret0, _ := ret[0].(error)
return ret0
}
func (_mr *_MockManagerRecorder) CloseManager() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "CloseManager")
}
func (_m *MockManager) Begin() *gorm.DB {
ret := _m.ctrl.Call(_m, "Begin")
ret0, _ := ret[0].(*gorm.DB)
return ret0
}
func (_mr *_MockManagerRecorder) Begin() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "Begin")
}
func (_m *MockManager) LicenseDao() dao.LicenseDao {
ret := _m.ctrl.Call(_m, "LicenseDao")
ret0, _ := ret[0].(dao.LicenseDao)
return ret0
}
func (_mr *_MockManagerRecorder) LicenseDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "LicenseDao")
}
func (_m *MockManager) AppDao() dao.AppDao {
ret := _m.ctrl.Call(_m, "AppDao")
ret0, _ := ret[0].(dao.AppDao)
return ret0
}
func (_mr *_MockManagerRecorder) AppDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "AppDao")
}
func (_m *MockManager) TenantDao() dao.TenantDao {
ret := _m.ctrl.Call(_m, "TenantDao")
ret0, _ := ret[0].(dao.TenantDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantDao")
}
func (_m *MockManager) TenantDaoTransactions(db *gorm.DB) dao.TenantDao {
ret := _m.ctrl.Call(_m, "TenantDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantDaoTransactions", arg0)
}
func (_m *MockManager) EventLogDao() dao.EventLogDao {
ret := _m.ctrl.Call(_m, "EventLogDao")
ret0, _ := ret[0].(dao.EventLogDao)
return ret0
}
func (_mr *_MockManagerRecorder) EventLogDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "EventLogDao")
}
func (_m *MockManager) EventLogDaoTransactions(_param0 *gorm.DB) dao.EventLogDao {
ret := _m.ctrl.Call(_m, "EventLogDaoTransactions", _param0)
ret0, _ := ret[0].(dao.EventLogDao)
return ret0
}
func (_mr *_MockManagerRecorder) EventLogDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "EventLogDaoTransactions", arg0)
}
func (_m *MockManager) TenantServiceDao() dao.TenantServiceDao {
ret := _m.ctrl.Call(_m, "TenantServiceDao")
ret0, _ := ret[0].(dao.TenantServiceDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceDao")
}
func (_m *MockManager) TenantServiceDeleteDao() dao.TenantServiceDeleteDao {
ret := _m.ctrl.Call(_m, "TenantServiceDeleteDao")
ret0, _ := ret[0].(dao.TenantServiceDeleteDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceDeleteDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceDeleteDao")
}
func (_m *MockManager) TenantServiceDaoTransactions(db *gorm.DB) dao.TenantServiceDao {
ret := _m.ctrl.Call(_m, "TenantServiceDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantServiceDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceDaoTransactions", arg0)
}
func (_m *MockManager) TenantServiceDeleteDaoTransactions(db *gorm.DB) dao.TenantServiceDeleteDao {
ret := _m.ctrl.Call(_m, "TenantServiceDeleteDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantServiceDeleteDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceDeleteDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceDeleteDaoTransactions", arg0)
}
func (_m *MockManager) TenantServicesPortDao() dao.TenantServicesPortDao {
ret := _m.ctrl.Call(_m, "TenantServicesPortDao")
ret0, _ := ret[0].(dao.TenantServicesPortDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServicesPortDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServicesPortDao")
}
func (_m *MockManager) TenantServicesPortDaoTransactions(_param0 *gorm.DB) dao.TenantServicesPortDao {
ret := _m.ctrl.Call(_m, "TenantServicesPortDaoTransactions", _param0)
ret0, _ := ret[0].(dao.TenantServicesPortDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServicesPortDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServicesPortDaoTransactions", arg0)
}
func (_m *MockManager) TenantServiceRelationDao() dao.TenantServiceRelationDao {
ret := _m.ctrl.Call(_m, "TenantServiceRelationDao")
ret0, _ := ret[0].(dao.TenantServiceRelationDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceRelationDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceRelationDao")
}
func (_m *MockManager) TenantServiceRelationDaoTransactions(_param0 *gorm.DB) dao.TenantServiceRelationDao {
ret := _m.ctrl.Call(_m, "TenantServiceRelationDaoTransactions", _param0)
ret0, _ := ret[0].(dao.TenantServiceRelationDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceRelationDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceRelationDaoTransactions", arg0)
}
func (_m *MockManager) TenantServiceEnvVarDao() dao.TenantServiceEnvVarDao {
ret := _m.ctrl.Call(_m, "TenantServiceEnvVarDao")
ret0, _ := ret[0].(dao.TenantServiceEnvVarDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceEnvVarDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceEnvVarDao")
}
func (_m *MockManager) TenantServiceEnvVarDaoTransactions(_param0 *gorm.DB) dao.TenantServiceEnvVarDao {
ret := _m.ctrl.Call(_m, "TenantServiceEnvVarDaoTransactions", _param0)
ret0, _ := ret[0].(dao.TenantServiceEnvVarDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceEnvVarDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceEnvVarDaoTransactions", arg0)
}
func (_m *MockManager) TenantServiceMountRelationDao() dao.TenantServiceMountRelationDao {
ret := _m.ctrl.Call(_m, "TenantServiceMountRelationDao")
ret0, _ := ret[0].(dao.TenantServiceMountRelationDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceMountRelationDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceMountRelationDao")
}
func (_m *MockManager) TenantServiceMountRelationDaoTransactions(db *gorm.DB) dao.TenantServiceMountRelationDao {
ret := _m.ctrl.Call(_m, "TenantServiceMountRelationDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantServiceMountRelationDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceMountRelationDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceMountRelationDaoTransactions", arg0)
}
func (_m *MockManager) TenantServiceVolumeDao() dao.TenantServiceVolumeDao {
ret := _m.ctrl.Call(_m, "TenantServiceVolumeDao")
ret0, _ := ret[0].(dao.TenantServiceVolumeDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceVolumeDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceVolumeDao")
}
func (_m *MockManager) TenantServiceVolumeDaoTransactions(_param0 *gorm.DB) dao.TenantServiceVolumeDao {
ret := _m.ctrl.Call(_m, "TenantServiceVolumeDaoTransactions", _param0)
ret0, _ := ret[0].(dao.TenantServiceVolumeDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceVolumeDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceVolumeDaoTransactions", arg0)
}
func (_m *MockManager) K8sServiceDao() dao.K8sServiceDao {
ret := _m.ctrl.Call(_m, "K8sServiceDao")
ret0, _ := ret[0].(dao.K8sServiceDao)
return ret0
}
func (_mr *_MockManagerRecorder) K8sServiceDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "K8sServiceDao")
}
func (_m *MockManager) K8sServiceDaoTransactions(_param0 *gorm.DB) dao.K8sServiceDao {
ret := _m.ctrl.Call(_m, "K8sServiceDaoTransactions", _param0)
ret0, _ := ret[0].(dao.K8sServiceDao)
return ret0
}
func (_mr *_MockManagerRecorder) K8sServiceDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "K8sServiceDaoTransactions", arg0)
}
func (_m *MockManager) K8sDeployReplicationDao() dao.K8sDeployReplicationDao {
ret := _m.ctrl.Call(_m, "K8sDeployReplicationDao")
ret0, _ := ret[0].(dao.K8sDeployReplicationDao)
return ret0
}
func (_mr *_MockManagerRecorder) K8sDeployReplicationDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "K8sDeployReplicationDao")
}
func (_m *MockManager) K8sPodDao() dao.K8sPodDao {
ret := _m.ctrl.Call(_m, "K8sPodDao")
ret0, _ := ret[0].(dao.K8sPodDao)
return ret0
}
func (_mr *_MockManagerRecorder) K8sPodDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "K8sPodDao")
}
func (_m *MockManager) K8sPodDaoTransactions(_param0 *gorm.DB) dao.K8sPodDao {
ret := _m.ctrl.Call(_m, "K8sPodDaoTransactions", _param0)
ret0, _ := ret[0].(dao.K8sPodDao)
return ret0
}
func (_mr *_MockManagerRecorder) K8sPodDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "K8sPodDaoTransactions", arg0)
}
func (_m *MockManager) ServiceProbeDao() dao.ServiceProbeDao {
ret := _m.ctrl.Call(_m, "ServiceProbeDao")
ret0, _ := ret[0].(dao.ServiceProbeDao)
return ret0
}
func (_mr *_MockManagerRecorder) ServiceProbeDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "ServiceProbeDao")
}
func (_m *MockManager) ServiceProbeDaoTransactions(_param0 *gorm.DB) dao.ServiceProbeDao {
ret := _m.ctrl.Call(_m, "ServiceProbeDaoTransactions", _param0)
ret0, _ := ret[0].(dao.ServiceProbeDao)
return ret0
}
func (_mr *_MockManagerRecorder) ServiceProbeDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "ServiceProbeDaoTransactions", arg0)
}
func (_m *MockManager) TenantServiceLBMappingPortDao() dao.TenantServiceLBMappingPortDao {
ret := _m.ctrl.Call(_m, "TenantServiceLBMappingPortDao")
ret0, _ := ret[0].(dao.TenantServiceLBMappingPortDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceLBMappingPortDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceLBMappingPortDao")
}
func (_m *MockManager) TenantServiceLBMappingPortDaoTransactions(_param0 *gorm.DB) dao.TenantServiceLBMappingPortDao {
ret := _m.ctrl.Call(_m, "TenantServiceLBMappingPortDaoTransactions", _param0)
ret0, _ := ret[0].(dao.TenantServiceLBMappingPortDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceLBMappingPortDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceLBMappingPortDaoTransactions", arg0)
}
func (_m *MockManager) TenantServiceLabelDao() dao.TenantServiceLabelDao {
ret := _m.ctrl.Call(_m, "TenantServiceLabelDao")
ret0, _ := ret[0].(dao.TenantServiceLabelDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceLabelDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceLabelDao")
}
func (_m *MockManager) TenantServiceLabelDaoTransactions(db *gorm.DB) dao.TenantServiceLabelDao {
ret := _m.ctrl.Call(_m, "TenantServiceLabelDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantServiceLabelDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceLabelDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceLabelDaoTransactions", arg0)
}
func (_m *MockManager) TenantServiceStatusDao() dao.ServiceStatusDao {
ret := _m.ctrl.Call(_m, "TenantServiceStatusDao")
ret0, _ := ret[0].(dao.ServiceStatusDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceStatusDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceStatusDao")
}
func (_m *MockManager) TenantServiceStatusDaoTransactions(db *gorm.DB) dao.ServiceStatusDao {
ret := _m.ctrl.Call(_m, "TenantServiceStatusDaoTransactions", db)
ret0, _ := ret[0].(dao.ServiceStatusDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServiceStatusDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServiceStatusDaoTransactions", arg0)
}
func (_m *MockManager) LocalSchedulerDao() dao.LocalSchedulerDao {
ret := _m.ctrl.Call(_m, "LocalSchedulerDao")
ret0, _ := ret[0].(dao.LocalSchedulerDao)
return ret0
}
func (_mr *_MockManagerRecorder) LocalSchedulerDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "LocalSchedulerDao")
}
func (_m *MockManager) TenantPluginDaoTransactions(db *gorm.DB) dao.TenantPluginDao {
ret := _m.ctrl.Call(_m, "TenantPluginDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantPluginDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantPluginDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantPluginDaoTransactions", arg0)
}
func (_m *MockManager) TenantPluginDao() dao.TenantPluginDao {
ret := _m.ctrl.Call(_m, "TenantPluginDao")
ret0, _ := ret[0].(dao.TenantPluginDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantPluginDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantPluginDao")
}
func (_m *MockManager) TenantPluginDefaultENVDaoTransactions(db *gorm.DB) dao.TenantPluginDefaultENVDao {
ret := _m.ctrl.Call(_m, "TenantPluginDefaultENVDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantPluginDefaultENVDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantPluginDefaultENVDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantPluginDefaultENVDaoTransactions", arg0)
}
func (_m *MockManager) TenantPluginDefaultENVDao() dao.TenantPluginDefaultENVDao {
ret := _m.ctrl.Call(_m, "TenantPluginDefaultENVDao")
ret0, _ := ret[0].(dao.TenantPluginDefaultENVDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantPluginDefaultENVDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantPluginDefaultENVDao")
}
func (_m *MockManager) TenantPluginBuildVersionDao() dao.TenantPluginBuildVersionDao {
ret := _m.ctrl.Call(_m, "TenantPluginBuildVersionDao")
ret0, _ := ret[0].(dao.TenantPluginBuildVersionDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantPluginBuildVersionDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantPluginBuildVersionDao")
}
func (_m *MockManager) TenantPluginBuildVersionDaoTransactions(db *gorm.DB) dao.TenantPluginBuildVersionDao {
ret := _m.ctrl.Call(_m, "TenantPluginBuildVersionDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantPluginBuildVersionDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantPluginBuildVersionDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantPluginBuildVersionDaoTransactions", arg0)
}
func (_m *MockManager) TenantPluginVersionENVDao() dao.TenantPluginVersionEnvDao {
ret := _m.ctrl.Call(_m, "TenantPluginVersionENVDao")
ret0, _ := ret[0].(dao.TenantPluginVersionEnvDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantPluginVersionENVDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantPluginVersionENVDao")
}
func (_m *MockManager) TenantPluginVersionENVDaoTransactions(db *gorm.DB) dao.TenantPluginVersionEnvDao {
ret := _m.ctrl.Call(_m, "TenantPluginVersionENVDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantPluginVersionEnvDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantPluginVersionENVDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantPluginVersionENVDaoTransactions", arg0)
}
func (_m *MockManager) TenantServicePluginRelationDao() dao.TenantServicePluginRelationDao {
ret := _m.ctrl.Call(_m, "TenantServicePluginRelationDao")
ret0, _ := ret[0].(dao.TenantServicePluginRelationDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServicePluginRelationDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServicePluginRelationDao")
}
func (_m *MockManager) TenantServicePluginRelationDaoTransactions(db *gorm.DB) dao.TenantServicePluginRelationDao {
ret := _m.ctrl.Call(_m, "TenantServicePluginRelationDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantServicePluginRelationDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServicePluginRelationDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServicePluginRelationDaoTransactions", arg0)
}
func (_m *MockManager) TenantServicesStreamPluginPortDao() dao.TenantServicesStreamPluginPortDao {
ret := _m.ctrl.Call(_m, "TenantServicesStreamPluginPortDao")
ret0, _ := ret[0].(dao.TenantServicesStreamPluginPortDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServicesStreamPluginPortDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServicesStreamPluginPortDao")
}
func (_m *MockManager) TenantServicesStreamPluginPortDaoTransactions(db *gorm.DB) dao.TenantServicesStreamPluginPortDao {
ret := _m.ctrl.Call(_m, "TenantServicesStreamPluginPortDaoTransactions", db)
ret0, _ := ret[0].(dao.TenantServicesStreamPluginPortDao)
return ret0
}
func (_mr *_MockManagerRecorder) TenantServicesStreamPluginPortDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TenantServicesStreamPluginPortDaoTransactions", arg0)
}
func (_m *MockManager) CodeCheckResultDao() dao.CodeCheckResultDao {
ret := _m.ctrl.Call(_m, "CodeCheckResultDao")
ret0, _ := ret[0].(dao.CodeCheckResultDao)
return ret0
}
func (_mr *_MockManagerRecorder) CodeCheckResultDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "CodeCheckResultDao")
}
func (_m *MockManager) CodeCheckResultDaoTransactions(db *gorm.DB) dao.CodeCheckResultDao {
ret := _m.ctrl.Call(_m, "CodeCheckResultDaoTransactions", db)
ret0, _ := ret[0].(dao.CodeCheckResultDao)
return ret0
}
func (_mr *_MockManagerRecorder) CodeCheckResultDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "CodeCheckResultDaoTransactions", arg0)
}
func (_m *MockManager) AppPublishDao() dao.AppPublishDao {
ret := _m.ctrl.Call(_m, "AppPublishDao")
ret0, _ := ret[0].(dao.AppPublishDao)
return ret0
}
func (_mr *_MockManagerRecorder) AppPublishDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "AppPublishDao")
}
func (_m *MockManager) AppPublishDaoTransactions(db *gorm.DB) dao.AppPublishDao {
ret := _m.ctrl.Call(_m, "AppPublishDaoTransactions", db)
ret0, _ := ret[0].(dao.AppPublishDao)
return ret0
}
func (_mr *_MockManagerRecorder) AppPublishDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "AppPublishDaoTransactions", arg0)
}
func (_m *MockManager) ServiceEventDao() dao.EventDao {
ret := _m.ctrl.Call(_m, "ServiceEventDao")
ret0, _ := ret[0].(dao.EventDao)
return ret0
}
func (_mr *_MockManagerRecorder) ServiceEventDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "ServiceEventDao")
}
func (_m *MockManager) ServiceEventDaoTransactions(db *gorm.DB) dao.EventDao {
ret := _m.ctrl.Call(_m, "ServiceEventDaoTransactions", db)
ret0, _ := ret[0].(dao.EventDao)
return ret0
}
func (_mr *_MockManagerRecorder) ServiceEventDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "ServiceEventDaoTransactions", arg0)
}
func (_m *MockManager) VersionInfoDao() dao.VersionInfoDao {
ret := _m.ctrl.Call(_m, "VersionInfoDao")
ret0, _ := ret[0].(dao.VersionInfoDao)
return ret0
}
func (_mr *_MockManagerRecorder) VersionInfoDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "VersionInfoDao")
}
func (_m *MockManager) VersionInfoDaoTransactions(db *gorm.DB) dao.VersionInfoDao {
ret := _m.ctrl.Call(_m, "VersionInfoDaoTransactions", db)
ret0, _ := ret[0].(dao.VersionInfoDao)
return ret0
}
func (_mr *_MockManagerRecorder) VersionInfoDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "VersionInfoDaoTransactions", arg0)
}
func (_m *MockManager) RegionUserInfoDao() dao.RegionUserInfoDao {
ret := _m.ctrl.Call(_m, "RegionUserInfoDao")
ret0, _ := ret[0].(dao.RegionUserInfoDao)
return ret0
}
func (_mr *_MockManagerRecorder) RegionUserInfoDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "RegionUserInfoDao")
}
func (_m *MockManager) RegionUserInfoDaoTransactions(db *gorm.DB) dao.RegionUserInfoDao {
ret := _m.ctrl.Call(_m, "RegionUserInfoDaoTransactions", db)
ret0, _ := ret[0].(dao.RegionUserInfoDao)
return ret0
}
func (_mr *_MockManagerRecorder) RegionUserInfoDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "RegionUserInfoDaoTransactions", arg0)
}
func (_m *MockManager) RegionAPIClassDao() dao.RegionAPIClassDao {
ret := _m.ctrl.Call(_m, "RegionAPIClassDao")
ret0, _ := ret[0].(dao.RegionAPIClassDao)
return ret0
}
func (_mr *_MockManagerRecorder) RegionAPIClassDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "RegionAPIClassDao")
}
func (_m *MockManager) RegionAPIClassDaoTransactions(db *gorm.DB) dao.RegionAPIClassDao {
ret := _m.ctrl.Call(_m, "RegionAPIClassDaoTransactions", db)
ret0, _ := ret[0].(dao.RegionAPIClassDao)
return ret0
}
func (_mr *_MockManagerRecorder) RegionAPIClassDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "RegionAPIClassDaoTransactions", arg0)
}
func (_m *MockManager) RegionProcotolsDao() dao.RegionProcotolsDao {
ret := _m.ctrl.Call(_m, "RegionProcotolsDao")
ret0, _ := ret[0].(dao.RegionProcotolsDao)
return ret0
}
func (_mr *_MockManagerRecorder) RegionProcotolsDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "RegionProcotolsDao")
}
func (_m *MockManager) RegionProcotolsDaoTransactions(db *gorm.DB) dao.RegionProcotolsDao {
ret := _m.ctrl.Call(_m, "RegionProcotolsDaoTransactions", db)
ret0, _ := ret[0].(dao.RegionProcotolsDao)
return ret0
}
func (_mr *_MockManagerRecorder) RegionProcotolsDaoTransactions(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "RegionProcotolsDaoTransactions", arg0)
}
func (_m *MockManager) NotificationEventDao() dao.NotificationEventDao {
ret := _m.ctrl.Call(_m, "NotificationEventDao")
ret0, _ := ret[0].(dao.NotificationEventDao)
return ret0
}
func (_mr *_MockManagerRecorder) NotificationEventDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "NotificationEventDao")
}
func (_m *MockManager) AppBackupDao() dao.AppBackupDao {
ret := _m.ctrl.Call(_m, "AppBackupDao")
ret0, _ := ret[0].(dao.AppBackupDao)
return ret0
}
func (_mr *_MockManagerRecorder) AppBackupDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "AppBackupDao")
}
func (_m *MockManager) ServiceSourceDao() dao.ServiceSourceDao {
ret := _m.ctrl.Call(_m, "ServiceSourceDao")
ret0, _ := ret[0].(dao.ServiceSourceDao)
return ret0
}
func (_mr *_MockManagerRecorder) ServiceSourceDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "ServiceSourceDao")
}
func (_m *MockManager) CertificateDao() dao.CertificateDao {
ret := _m.ctrl.Call(_m, "CertificateDao")
ret0, _ := ret[0].(dao.CertificateDao)
return ret0
}
func (_mr *_MockManagerRecorder) CertificateDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "CertificateDao")
}
func (_m *MockManager) RuleExtensionDao() dao.RuleExtensionDao {
ret := _m.ctrl.Call(_m, "RuleExtensionDao")
ret0, _ := ret[0].(dao.RuleExtensionDao)
return ret0
}
func (_mr *_MockManagerRecorder) RuleExtensionDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "RuleExtensionDao")
}
func (_m *MockManager) HttpRuleDao() dao.HttpRuleDao {
ret := _m.ctrl.Call(_m, "HttpRuleDao")
ret0, _ := ret[0].(dao.HttpRuleDao)
return ret0
}
func (_mr *_MockManagerRecorder) HttpRuleDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "HttpRuleDao")
}
func (_m *MockManager) StreamRuleDao() dao.StreamRuleDao {
ret := _m.ctrl.Call(_m, "StreamRuleDao")
ret0, _ := ret[0].(dao.StreamRuleDao)
return ret0
}
func (_mr *_MockManagerRecorder) StreamRuleDao() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "StreamRuleDao")
}

View File

@ -1,84 +0,0 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package dao
import (
"github.com/goodrain/rainbond/db/model"
"github.com/jinzhu/gorm"
"time"
)
type MockHttpRuleDaoImpl struct {
}
func (h *MockHttpRuleDaoImpl) AddModel(model.Interface) error {
return nil
}
func (h *MockHttpRuleDaoImpl) UpdateModel(model.Interface) error {
return nil
}
// GetHttpRuleByServiceIDAndContainerPort gets a HttpRule based on serviceID and containerPort
func (h *MockHttpRuleDaoImpl) GetHttpRuleByServiceIDAndContainerPort(serviceID string,
containerPort int) (*model.HttpRule, error) {
createTime, _ := time.Parse(time.RFC3339, "2018-11-18T10:24:43Z")
httpRule := &model.HttpRule{
Model: model.Model{
ID: 1,
CreatedAt: createTime,
},
ServiceID: serviceID,
ContainerPort: containerPort,
Domain: "dummy-domain",
Path: "/",
LoadBalancerType: model.RoundRobinLBType,
}
return httpRule, nil
}
type MockStreamRuleDaoTmpl struct {
DB *gorm.DB
}
func (s *MockStreamRuleDaoTmpl) AddModel(model.Interface) error {
return nil
}
func (s *MockStreamRuleDaoTmpl) UpdateModel(model.Interface) error {
return nil
}
// GetStreamRuleByServiceIDAndContainerPort gets a StreamRule based on serviceID and containerPort
func (s *MockStreamRuleDaoTmpl) GetStreamRuleByServiceIDAndContainerPort(serviceID string,
containerPort int) (*model.StreamRule, error) {
//createTime, _ := time.Parse(time.RFC3339, "2018-11-18T10:24:43Z")
//streamRule := &model.StreamRule{
// Model: model.Model{
// ID: 3,
// CreatedAt: createTime,
// },
// ServiceID: serviceID,
// ContainerPort: containerPort,
// IP: "127.0.0.1",
//}
return nil, nil
}

View File

@ -1,305 +0,0 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package dao
import (
"github.com/goodrain/rainbond/db/model"
"github.com/jinzhu/gorm"
"time"
)
//TenantDaoImpl 租户信息管理
type MockTenantDaoImpl struct {
}
//AddModel 添加租户
func (t *MockTenantDaoImpl) AddModel(mo model.Interface) error {
return nil
}
//UpdateModel 更新租户
func (t *MockTenantDaoImpl) UpdateModel(mo model.Interface) error {
return nil
}
//GetTenantByUUID 获取租户
func (t *MockTenantDaoImpl) GetTenantByUUID(uuid string) (*model.Tenants, error) {
createTime, _ := time.Parse(time.RFC3339, "2018-10-18T10:24:43Z")
tenant := &model.Tenants{
Model: model.Model{
ID: 1,
CreatedAt: createTime,
},
Name: "0enb7gyx",
UUID: "e8539a9c33fd418db11cce26d2bca431",
EID: "214ec4d212582eb36a84cc180aad2783",
}
return tenant, nil
}
//GetTenantByUUIDIsExist 获取租户
func (t *MockTenantDaoImpl) GetTenantByUUIDIsExist(uuid string) bool {
return false
}
//GetTenantIDByName 获取租户
func (t *MockTenantDaoImpl) GetTenantIDByName(name string) (*model.Tenants, error) {
return nil, nil
}
//GetALLTenants GetALLTenants
func (t *MockTenantDaoImpl) GetALLTenants() ([]*model.Tenants, error) {
return nil, nil
}
//GetTenantsByEid
func (t *MockTenantDaoImpl) GetTenantByEid(eid string) ([]*model.Tenants, error) {
return nil, nil
}
//GetTenantIDsByNames get tenant ids by names
func (t *MockTenantDaoImpl) GetTenantIDsByNames(names []string) (re []string, err error) {
return
}
//GetALLTenants GetALLTenants
func (t *MockTenantDaoImpl) GetPagedTenants(offset, len int) ([]*model.Tenants, error) {
return nil, nil
}
//TenantServicesDaoImpl 租户应用dao
type MockTenantServicesDaoImpl struct {
DB *gorm.DB
}
//GetAllServices 获取全部应用信息的资源相关信息
func (t *MockTenantServicesDaoImpl) GetAllServices() ([]*model.TenantServices, error) {
return nil, nil
}
func (t *MockTenantServicesDaoImpl) GetAllServicesID() ([]*model.TenantServices, error) {
return nil, nil
}
//AddModel 添加租户应用
func (t *MockTenantServicesDaoImpl) AddModel(mo model.Interface) error {
return nil
}
//UpdateModel 更新租户应用
func (t *MockTenantServicesDaoImpl) UpdateModel(mo model.Interface) error {
return nil
}
//GetServiceByID 获取服务通过服务id
func (t *MockTenantServicesDaoImpl) GetServiceByID(serviceID string) (*model.TenantServices, error) {
createTime, _ := time.Parse(time.RFC3339, "2018-10-22T14:14:12Z")
updateTime, _ := time.Parse(time.RFC3339, "2018-10-22T14:14:12Z")
services := &model.TenantServices{
Model: model.Model{
ID: 1,
CreatedAt: createTime,
},
TenantID: "e8539a9c33fd418db11cce26d2bca431",
ServiceID: "43eaae441859eda35b02075d37d83589",
ServiceKey: "application",
ServiceAlias: "grd83589",
Comment: "application info",
ServiceVersion: "latest",
ImageName: "goodrain.me/runner:latest",
ContainerCPU: 20,
ContainerMemory: 128,
ContainerCMD: "start_web",
VolumePath: "vol43eaae4418",
ExtendMethod: "stateless",
Replicas: 1,
DeployVersion: "20181022200709",
Category: "application",
CurStatus: "undeploy",
Status: 0,
ServiceType: "application",
Namespace: "goodrain",
VolumeType: "shared",
PortType: "multi_outer",
UpdateTime: updateTime,
ServiceOrigin: "assistant",
CodeFrom: "gitlab_demo",
Domain: "0enb7gyx",
}
return services, nil
}
//GetServiceByID 获取服务通过服务别名
func (t *MockTenantServicesDaoImpl) GetServiceByServiceAlias(serviceAlias string) (*model.TenantServices, error) {
return nil, nil
}
//GetServiceMemoryByTenantIDs get service memory by tenant ids
func (t *MockTenantServicesDaoImpl) GetServiceMemoryByTenantIDs(tenantIDs []string, runningServiceIDs []string) (map[string]map[string]interface{}, error) {
return nil, nil
}
//GetServiceMemoryByServiceIDs get service memory by service ids
func (t *MockTenantServicesDaoImpl) GetServiceMemoryByServiceIDs(serviceIDs []string) (map[string]map[string]interface{}, error) {
return nil, nil
}
//GetPagedTenantService GetPagedTenantResource
func (t *MockTenantServicesDaoImpl) GetPagedTenantService(offset, length int, serviceIDs []string) ([]map[string]interface{}, int, error) {
return nil, 0, nil
}
//GetServiceAliasByIDs 获取应用别名
func (t *MockTenantServicesDaoImpl) GetServiceAliasByIDs(uids []string) ([]*model.TenantServices, error) {
return nil, nil
}
//GetServiceByIDs get some service by service ids
func (t *MockTenantServicesDaoImpl) GetServiceByIDs(uids []string) ([]*model.TenantServices, error) {
return nil, nil
}
//GetServiceByTenantIDAndServiceAlias 根据租户名和服务名
func (t *MockTenantServicesDaoImpl) GetServiceByTenantIDAndServiceAlias(tenantID, serviceName string) (*model.TenantServices, error) {
return nil, nil
}
//GetServicesByTenantID GetServicesByTenantID
func (t *MockTenantServicesDaoImpl) GetServicesByTenantID(tenantID string) ([]*model.TenantServices, error) {
return nil, nil
}
//GetServicesByTenantIDs GetServicesByTenantIDs
func (t *MockTenantServicesDaoImpl) GetServicesByTenantIDs(tenantIDs []string) ([]*model.TenantServices, error) {
return nil, nil
}
//GetServicesAllInfoByTenantID GetServicesAllInfoByTenantID
func (t *MockTenantServicesDaoImpl) GetServicesAllInfoByTenantID(tenantID string) ([]*model.TenantServices, error) {
return nil, nil
}
//SetTenantServiceStatus SetTenantServiceStatus
func (t *MockTenantServicesDaoImpl) SetTenantServiceStatus(serviceID, status string) error {
return nil
}
//DeleteServiceByServiceID DeleteServiceByServiceID
func (t *MockTenantServicesDaoImpl) DeleteServiceByServiceID(serviceID string) error {
return nil
}
//TenantServicesPortDaoImpl 租户应用端口操作
type MockTenantServicesPortDaoImpl struct {
}
//AddModel 添加应用端口
func (t *MockTenantServicesPortDaoImpl) AddModel(mo model.Interface) error {
return nil
}
//UpdateModel 更新租户
func (t *MockTenantServicesPortDaoImpl) UpdateModel(mo model.Interface) error {
return nil
}
//DeleteModel 删除端口
func (t *MockTenantServicesPortDaoImpl) DeleteModel(serviceID string, args ...interface{}) error {
return nil
}
//GetPortsByServiceID 通过服务获取port
func (t *MockTenantServicesPortDaoImpl) GetPortsByServiceID(serviceID string) ([]*model.TenantServicesPort, error) {
var ports []*model.TenantServicesPort
createTime, _ := time.Parse(time.RFC3339, "2018-10-22T14:14:12Z")
port := &model.TenantServicesPort{
Model: model.Model{
ID: 2,
CreatedAt: createTime,
},
TenantID: "e8539a9c33fd418db11cce26d2bca431",
ServiceID: "43eaae441859eda35b02075d37d83589",
ContainerPort: 5000,
MappingPort: 5000,
Protocol: "http",
PortAlias: "GRD835895000",
IsInnerService: false,
IsOuterService: true,
}
ports = append(ports, port)
return ports, nil
return nil, nil
}
//GetOuterPorts 获取对外端口
func (t *MockTenantServicesPortDaoImpl) GetOuterPorts(serviceID string) ([]*model.TenantServicesPort, error) {
var ports []*model.TenantServicesPort
createTime, _ := time.Parse(time.RFC3339, "2018-10-22T14:14:12Z")
port := &model.TenantServicesPort{
Model: model.Model{
ID: 2,
CreatedAt: createTime,
},
TenantID: "e8539a9c33fd418db11cce26d2bca431",
ServiceID: "43eaae441859eda35b02075d37d83589",
ContainerPort: 5000,
MappingPort: 5000,
Protocol: "http",
PortAlias: "GRD835895000",
IsInnerService: false,
IsOuterService: true,
}
ports = append(ports, port)
return ports, nil
}
//GetInnerPorts 获取对内端口
func (t *MockTenantServicesPortDaoImpl) GetInnerPorts(serviceID string) ([]*model.TenantServicesPort, error) {
return nil, nil
}
//GetPort get port
func (t *MockTenantServicesPortDaoImpl) GetPort(serviceID string, port int) (*model.TenantServicesPort, error) {
return nil, nil
}
//DELPortsByServiceID DELPortsByServiceID
func (t *MockTenantServicesPortDaoImpl) DELPortsByServiceID(serviceID string) error {
return nil
}

View File

@ -1,369 +0,0 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package mysql
import (
"github.com/goodrain/rainbond/db/dao"
mysqldao "github.com/goodrain/rainbond/db/mysql/dao"
"github.com/jinzhu/gorm"
)
//Manager db manager
type MockManager struct {
}
func (m *MockManager) CloseManager() error {
return nil
}
//Begin begin a transaction
func (m *MockManager) Begin() *gorm.DB {
return nil
}
//LicenseDao LicenseDao
func (m *MockManager) LicenseDao() dao.LicenseDao {
return nil
}
//EventLogDao EventLogDao
func (m *MockManager) EventLogDao() dao.EventLogDao {
return nil
}
//EventLogDaoTransactions EventLogDao
func (m *MockManager) EventLogDaoTransactions(db *gorm.DB) dao.EventLogDao {
return nil
}
//TenantDao 租户数据
func (m *MockManager) TenantDao() dao.TenantDao {
return &mysqldao.MockTenantDaoImpl{}
}
//TenantDaoTransactions 租户数据,带操作事务
func (m *MockManager) TenantDaoTransactions(db *gorm.DB) dao.TenantDao {
return nil
}
//TenantServiceDao TenantServiceDao
func (m *MockManager) TenantServiceDao() dao.TenantServiceDao {
return &mysqldao.MockTenantServicesDaoImpl{}
}
//TenantServiceDaoTransactions TenantServiceDaoTransactions
func (m *MockManager) TenantServiceDaoTransactions(db *gorm.DB) dao.TenantServiceDao {
return nil
}
//TenantServiceDeleteDao TenantServiceDeleteDao
func (m *MockManager) TenantServiceDeleteDao() dao.TenantServiceDeleteDao {
return nil
}
//TenantServiceDeleteDaoTransactions TenantServiceDeleteDaoTransactions
func (m *MockManager) TenantServiceDeleteDaoTransactions(db *gorm.DB) dao.TenantServiceDeleteDao {
return nil
}
//TenantServicesPortDao TenantServicesPortDao
func (m *MockManager) TenantServicesPortDao() dao.TenantServicesPortDao {
return &mysqldao.MockTenantServicesPortDaoImpl{}
}
//TenantServicesPortDaoTransactions TenantServicesPortDaoTransactions
func (m *MockManager) TenantServicesPortDaoTransactions(db *gorm.DB) dao.TenantServicesPortDao {
return nil
}
//TenantServiceRelationDao TenantServiceRelationDao
func (m *MockManager) TenantServiceRelationDao() dao.TenantServiceRelationDao {
return nil
}
//TenantServiceRelationDaoTransactions TenantServiceRelationDaoTransactions
func (m *MockManager) TenantServiceRelationDaoTransactions(db *gorm.DB) dao.TenantServiceRelationDao {
return nil
}
//TenantServiceEnvVarDao TenantServiceEnvVarDao
func (m *MockManager) TenantServiceEnvVarDao() dao.TenantServiceEnvVarDao {
return nil
}
//TenantServiceEnvVarDaoTransactions TenantServiceEnvVarDaoTransactions
func (m *MockManager) TenantServiceEnvVarDaoTransactions(db *gorm.DB) dao.TenantServiceEnvVarDao {
return nil
}
//TenantServiceMountRelationDao TenantServiceMountRelationDao
func (m *MockManager) TenantServiceMountRelationDao() dao.TenantServiceMountRelationDao {
return nil
}
//TenantServiceMountRelationDaoTransactions TenantServiceMountRelationDaoTransactions
func (m *MockManager) TenantServiceMountRelationDaoTransactions(db *gorm.DB) dao.TenantServiceMountRelationDao {
return nil
}
//TenantServiceVolumeDao TenantServiceVolumeDao
func (m *MockManager) TenantServiceVolumeDao() dao.TenantServiceVolumeDao {
return nil
}
//TenantServiceVolumeDaoTransactions TenantServiceVolumeDaoTransactions
func (m *MockManager) TenantServiceVolumeDaoTransactions(db *gorm.DB) dao.TenantServiceVolumeDao {
return nil
}
//TenantServiceLabelDao TenantServiceLabelDao
func (m *MockManager) TenantServiceLabelDao() dao.TenantServiceLabelDao {
return nil
}
//TenantServiceLabelDaoTransactions TenantServiceLabelDaoTransactions
func (m *MockManager) TenantServiceLabelDaoTransactions(db *gorm.DB) dao.TenantServiceLabelDao {
return nil
}
//K8sServiceDao K8sServiceDao
func (m *MockManager) K8sServiceDao() dao.K8sServiceDao {
return nil
}
//K8sServiceDaoTransactions K8sServiceDaoTransactions
func (m *MockManager) K8sServiceDaoTransactions(db *gorm.DB) dao.K8sServiceDao {
return nil
}
//K8sDeployReplicationDao K8sDeployReplicationDao
func (m *MockManager) K8sDeployReplicationDao() dao.K8sDeployReplicationDao {
return nil
}
//K8sPodDao K8sPodDao
func (m *MockManager) K8sPodDao() dao.K8sPodDao {
return nil
}
//K8sPodDaoTransactions K8sPodDaoTransactions
func (m *MockManager) K8sPodDaoTransactions(db *gorm.DB) dao.K8sPodDao {
return nil
}
//ServiceProbeDao ServiceProbeDao
func (m *MockManager) ServiceProbeDao() dao.ServiceProbeDao {
return nil
}
//ServiceProbeDaoTransactions ServiceProbeDaoTransactions
func (m *MockManager) ServiceProbeDaoTransactions(db *gorm.DB) dao.ServiceProbeDao {
return nil
}
//TenantServiceLBMappingPortDao TenantServiceLBMappingPortDao
func (m *MockManager) TenantServiceLBMappingPortDao() dao.TenantServiceLBMappingPortDao {
return nil
}
//TenantServiceLBMappingPortDaoTransactions TenantServiceLBMappingPortDaoTransactions
func (m *MockManager) TenantServiceLBMappingPortDaoTransactions(db *gorm.DB) dao.TenantServiceLBMappingPortDao {
return nil
}
//TenantServiceStatusDao TenantServiceStatusDao
func (m *MockManager) TenantServiceStatusDao() dao.ServiceStatusDao {
return nil
}
//TenantServiceStatusDaoTransactions TenantServiceStatusDaoTransactions
func (m *MockManager) TenantServiceStatusDaoTransactions(db *gorm.DB) dao.ServiceStatusDao {
return nil
}
//TenantPluginDao TenantPluginDao
func (m *MockManager) TenantPluginDao() dao.TenantPluginDao {
return nil
}
//TenantPluginDaoTransactions TenantPluginDaoTransactions
func (m *MockManager) TenantPluginDaoTransactions(db *gorm.DB) dao.TenantPluginDao {
return nil
}
//TenantPluginBuildVersionDao TenantPluginBuildVersionDao
func (m *MockManager) TenantPluginBuildVersionDao() dao.TenantPluginBuildVersionDao {
return nil
}
//TenantPluginBuildVersionDaoTransactions TenantPluginBuildVersionDaoTransactions
func (m *MockManager) TenantPluginBuildVersionDaoTransactions(db *gorm.DB) dao.TenantPluginBuildVersionDao {
return nil
}
//TenantPluginDefaultENVDao TenantPluginDefaultENVDao
func (m *MockManager) TenantPluginDefaultENVDao() dao.TenantPluginDefaultENVDao {
return nil
}
//TenantPluginDefaultENVDaoTransactions TenantPluginDefaultENVDaoTransactions
func (m *MockManager) TenantPluginDefaultENVDaoTransactions(db *gorm.DB) dao.TenantPluginDefaultENVDao {
return nil
}
//TenantPluginVersionENVDao TenantPluginVersionENVDao
func (m *MockManager) TenantPluginVersionENVDao() dao.TenantPluginVersionEnvDao {
return nil
}
//TenantPluginVersionENVDaoTransactions TenantPluginVersionENVDaoTransactions
func (m *MockManager) TenantPluginVersionENVDaoTransactions(db *gorm.DB) dao.TenantPluginVersionEnvDao {
return nil
}
//TenantServicePluginRelationDao TenantServicePluginRelationDao
func (m *MockManager) TenantServicePluginRelationDao() dao.TenantServicePluginRelationDao {
return nil
}
//TenantServicePluginRelationDaoTransactions TenantServicePluginRelationDaoTransactions
func (m *MockManager) TenantServicePluginRelationDaoTransactions(db *gorm.DB) dao.TenantServicePluginRelationDao {
return nil
}
//TenantServicesStreamPluginPortDao TenantServicesStreamPluginPortDao
func (m *MockManager) TenantServicesStreamPluginPortDao() dao.TenantServicesStreamPluginPortDao {
return nil
}
//TenantServicesStreamPluginPortDaoTransactions TenantServicesStreamPluginPortDaoTransactions
func (m *MockManager) TenantServicesStreamPluginPortDaoTransactions(db *gorm.DB) dao.TenantServicesStreamPluginPortDao {
return nil
}
//CodeCheckResultDao CodeCheckResultDao
func (m *MockManager) CodeCheckResultDao() dao.CodeCheckResultDao {
return nil
}
//CodeCheckResultDaoTransactions CodeCheckResultDaoTransactions
func (m *MockManager) CodeCheckResultDaoTransactions(db *gorm.DB) dao.CodeCheckResultDao {
return nil
}
//AppPublishDao AppPublishDao
func (m *MockManager) AppPublishDao() dao.AppPublishDao {
return nil
}
//AppPublishDaoTransactions AppPublishDaoTransactions
func (m *MockManager) AppPublishDaoTransactions(db *gorm.DB) dao.AppPublishDao {
return nil
}
//ServiceEventDao TenantServicePluginRelationDao
func (m *MockManager) ServiceEventDao() dao.EventDao {
return nil
}
//ServiceEventDaoTransactions TenantServicePluginRelationDaoTransactions
func (m *MockManager) ServiceEventDaoTransactions(db *gorm.DB) dao.EventDao {
return nil
}
//VersionInfoDao VersionInfoDao
func (m *MockManager) VersionInfoDao() dao.VersionInfoDao {
return nil
}
//VersionInfoDaoTransactions VersionInfoDaoTransactions
func (m *MockManager) VersionInfoDaoTransactions(db *gorm.DB) dao.VersionInfoDao {
return nil
}
//LocalSchedulerDao 本地调度信息
func (m *MockManager) LocalSchedulerDao() dao.LocalSchedulerDao {
return nil
}
//RegionUserInfoDao RegionUserInfoDao
func (m *MockManager) RegionUserInfoDao() dao.RegionUserInfoDao {
return nil
}
//RegionUserInfoDaoTransactions RegionUserInfoDaoTransactions
func (m *MockManager) RegionUserInfoDaoTransactions(db *gorm.DB) dao.RegionUserInfoDao {
return nil
}
//RegionAPIClassDao RegionAPIClassDao
func (m *MockManager) RegionAPIClassDao() dao.RegionAPIClassDao {
return nil
}
//RegionAPIClassDaoTransactions RegionAPIClassDaoTransactions
func (m *MockManager) RegionAPIClassDaoTransactions(db *gorm.DB) dao.RegionAPIClassDao {
return nil
}
//RegionProcotolsDao RegionProcotolsDao
func (m *MockManager) RegionProcotolsDao() dao.RegionProcotolsDao {
return nil
}
//RegionProcotolsDaoTransactions RegionProcotolsDao
func (m *MockManager) RegionProcotolsDaoTransactions(db *gorm.DB) dao.RegionProcotolsDao {
return nil
}
//NotificationEventDao NotificationEventDao
func (m *MockManager) NotificationEventDao() dao.NotificationEventDao {
return nil
}
//AppDao app export and import info
func (m *MockManager) AppDao() dao.AppDao {
return nil
}
//AppBackupDao group app backup info
func (m *MockManager) AppBackupDao() dao.AppBackupDao {
return nil
}
//ServiceSourceDao service source db impl
func (m *MockManager) ServiceSourceDao() dao.ServiceSourceDao {
return nil
}
func (m *MockManager) CertificateDao() dao.CertificateDao {
return nil
}
func (m *MockManager) RuleExtensionDao() dao.RuleExtensionDao {
return nil
}
func (m *MockManager) HttpRuleDao() dao.HttpRuleDao {
return &mysqldao.MockHttpRuleDaoImpl{}
}
func (m *MockManager) StreamRuleDao() dao.StreamRuleDao {
return &mysqldao.MockStreamRuleDaoTmpl{}
}

255
vendor/github.com/rafrombrc/gomock/gomock/call.go generated vendored Normal file
View File

@ -0,0 +1,255 @@
// Copyright 2010 Google Inc.
//
// 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 gomock
import (
"fmt"
"reflect"
"strings"
)
const NoLimit = 1e8 // close enough to infinity
// Call represents an expected call to a mock.
type Call struct {
t TestReporter // for triggering test failures on invalid call setup
receiver interface{} // the receiver of the method call
method string // the name of the method
args []Matcher // the args
rets []interface{} // the return values (if any)
preReqs []*Call // prerequisite calls
// Expectations
minCalls, maxCalls int
numCalls int // actual number made
// Actions
doFunc reflect.Value
setArgs map[int]reflect.Value
}
func (c *Call) AnyTimes() *Call {
c.minCalls, c.maxCalls = 0, NoLimit
return c
}
// Do declares the action to run when the call is matched.
// It takes an interface{} argument to support n-arity functions.
func (c *Call) Do(f interface{}) *Call {
// TODO: Check arity and types here, rather than dying badly elsewhere.
c.doFunc = reflect.ValueOf(f)
return c
}
func (c *Call) Return(rets ...interface{}) *Call {
mt := c.methodType()
if len(rets) != mt.NumOut() {
c.t.Fatalf("wrong number of arguments to Return for %T.%v: got %d, want %d",
c.receiver, c.method, len(rets), mt.NumOut())
}
for i, ret := range rets {
if got, want := reflect.TypeOf(ret), mt.Out(i); got == want {
// Identical types; nothing to do.
} else if got == nil {
// Nil needs special handling.
switch want.Kind() {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
// ok
default:
c.t.Fatalf("argument %d to Return for %T.%v is nil, but %v is not nillable",
i, c.receiver, c.method, want)
}
} else if got.AssignableTo(want) {
// Assignable type relation. Make the assignment now so that the generated code
// can return the values with a type assertion.
v := reflect.New(want).Elem()
v.Set(reflect.ValueOf(ret))
rets[i] = v.Interface()
} else {
c.t.Fatalf("wrong type of argument %d to Return for %T.%v: %v is not assignable to %v",
i, c.receiver, c.method, got, want)
}
}
c.rets = rets
return c
}
func (c *Call) Times(n int) *Call {
c.minCalls, c.maxCalls = n, n
return c
}
// WithinTimes specifies an acceptable range for the number of calls.
func (c *Call) WithinTimes(min, max int) *Call {
c.minCalls, c.maxCalls = min, max
return c
}
// SetArg declares an action that will set the nth argument's value,
// indirected through a pointer.
func (c *Call) SetArg(n int, value interface{}) *Call {
if c.setArgs == nil {
c.setArgs = make(map[int]reflect.Value)
}
mt := c.methodType()
// TODO: This will break on variadic methods.
// We will need to check those at invocation time.
if n < 0 || n >= mt.NumIn() {
c.t.Fatalf("SetArg(%d, ...) called for a method with %d args", n, mt.NumIn())
}
// Permit setting argument through an interface.
// In the interface case, we don't (nay, can't) check the type here.
at := mt.In(n)
switch at.Kind() {
case reflect.Ptr:
dt := at.Elem()
if vt := reflect.TypeOf(value); !vt.AssignableTo(dt) {
c.t.Fatalf("SetArg(%d, ...) argument is a %v, not assignable to %v", n, vt, dt)
}
case reflect.Interface:
// nothing to do
default:
c.t.Fatalf("SetArg(%d, ...) referring to argument of non-pointer non-interface type %v", n, at)
}
c.setArgs[n] = reflect.ValueOf(value)
return c
}
// isPreReq returns true if other is a direct or indirect prerequisite to c.
func (c *Call) isPreReq(other *Call) bool {
for _, preReq := range c.preReqs {
if other == preReq || preReq.isPreReq(other) {
return true
}
}
return false
}
// After declares that the call may only match after preReq has been exhausted.
func (c *Call) After(preReq *Call) *Call {
if preReq.isPreReq(c) {
msg := fmt.Sprintf(
"Loop in call order: %v is a prerequisite to %v (possibly indirectly).",
c, preReq,
)
panic(msg)
}
c.preReqs = append(c.preReqs, preReq)
return c
}
// Returns true iff the minimum number of calls have been made.
func (c *Call) satisfied() bool {
return c.numCalls >= c.minCalls
}
// Returns true iff the maximum number of calls have been made.
func (c *Call) exhausted() bool {
return c.numCalls >= c.maxCalls
}
func (c *Call) String() string {
args := make([]string, len(c.args))
for i, arg := range c.args {
args[i] = arg.String()
}
arguments := strings.Join(args, ", ")
return fmt.Sprintf("%T.%v(%s)", c.receiver, c.method, arguments)
}
// Tests if the given call matches the expected call.
func (c *Call) matches(args []interface{}) bool {
if len(args) != len(c.args) {
return false
}
for i, m := range c.args {
if !m.Matches(args[i]) {
return false
}
}
// Check that all prerequisite calls have been satisfied.
for _, preReqCall := range c.preReqs {
if !preReqCall.satisfied() {
return false
}
}
return true
}
// dropPrereqs tells the expected Call to not re-check prerequite calls any
// longer, and to return its current set.
func (c *Call) dropPrereqs() (preReqs []*Call) {
preReqs = c.preReqs
c.preReqs = nil
return
}
func (c *Call) call(args []interface{}) (rets []interface{}, action func()) {
c.numCalls++
// Actions
if c.doFunc.IsValid() {
doArgs := make([]reflect.Value, len(args))
ft := c.doFunc.Type()
for i := 0; i < ft.NumIn(); i++ {
if args[i] != nil {
doArgs[i] = reflect.ValueOf(args[i])
} else {
// Use the zero value for the arg.
doArgs[i] = reflect.Zero(ft.In(i))
}
}
action = func() { c.doFunc.Call(doArgs) }
}
for n, v := range c.setArgs {
reflect.ValueOf(args[n]).Elem().Set(v)
}
rets = c.rets
if rets == nil {
// Synthesize the zero value for each of the return args' types.
mt := c.methodType()
rets = make([]interface{}, mt.NumOut())
for i := 0; i < mt.NumOut(); i++ {
rets[i] = reflect.Zero(mt.Out(i)).Interface()
}
}
return
}
func (c *Call) methodType() reflect.Type {
recv := reflect.ValueOf(c.receiver)
for i := 0; i < recv.Type().NumMethod(); i++ {
if recv.Type().Method(i).Name == c.method {
return recv.Method(i).Type()
}
}
panic(fmt.Sprintf("gomock: failed finding method %s on %T", c.method, c.receiver))
}
// InOrder declares that the given calls should occur in order.
func InOrder(calls ...*Call) {
for i := 1; i < len(calls); i++ {
calls[i].After(calls[i-1])
}
}

76
vendor/github.com/rafrombrc/gomock/gomock/callset.go generated vendored Normal file
View File

@ -0,0 +1,76 @@
// Copyright 2011 Google Inc.
//
// 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 gomock
// callSet represents a set of expected calls, indexed by receiver and method
// name.
type callSet map[interface{}]map[string][]*Call
// Add adds a new expected call.
func (cs callSet) Add(call *Call) {
methodMap, ok := cs[call.receiver]
if !ok {
methodMap = make(map[string][]*Call)
cs[call.receiver] = methodMap
}
methodMap[call.method] = append(methodMap[call.method], call)
}
// Remove removes an expected call.
func (cs callSet) Remove(call *Call) {
methodMap, ok := cs[call.receiver]
if !ok {
return
}
sl := methodMap[call.method]
for i, c := range sl {
if c == call {
// quick removal; we don't need to maintain call order
if len(sl) > 1 {
sl[i] = sl[len(sl)-1]
}
methodMap[call.method] = sl[:len(sl)-1]
break
}
}
}
// FindMatch searches for a matching call. Returns nil if no call matched.
func (cs callSet) FindMatch(receiver interface{}, method string, args []interface{}) *Call {
methodMap, ok := cs[receiver]
if !ok {
return nil
}
calls, ok := methodMap[method]
if !ok {
return nil
}
// Search through the unordered set of calls expected on a method on a
// receiver.
for _, call := range calls {
// A call should not normally still be here if exhausted,
// but it can happen if, for instance, .Times(0) was used.
// Pretend the call doesn't match.
if call.exhausted() {
continue
}
if call.matches(args) {
return call
}
}
return nil
}

173
vendor/github.com/rafrombrc/gomock/gomock/controller.go generated vendored Normal file
View File

@ -0,0 +1,173 @@
// Copyright 2010 Google Inc.
//
// 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.
// GoMock - a mock framework for Go.
//
// Standard usage:
// (1) Define an interface that you wish to mock.
// type MyInterface interface {
// SomeMethod(x int64, y string)
// }
// (2) Use mockgen to generate a mock from the interface.
// (3) Use the mock in a test:
// func TestMyThing(t *testing.T) {
// mockCtrl := gomock.NewController(t)
// defer mockCtrl.Finish()
//
// mockObj := something.NewMockMyInterface(mockCtrl)
// mockObj.EXPECT().SomeMethod(4, "blah")
// // pass mockObj to a real object and play with it.
// }
//
// By default, expected calls are not enforced to run in any particular order.
// Call order dependency can be enforced by use of InOrder and/or Call.After.
// Call.After can create more varied call order dependencies, but InOrder is
// often more convenient.
//
// The following examples create equivalent call order dependencies.
//
// Example of using Call.After to chain expected call order:
//
// firstCall := mockObj.EXPECT().SomeMethod(1, "first")
// secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall)
// mockObj.EXPECT().SomeMethod(3, "third").After(secondCall)
//
// Example of using InOrder to declare expected call order:
//
// gomock.InOrder(
// mockObj.EXPECT().SomeMethod(1, "first"),
// mockObj.EXPECT().SomeMethod(2, "second"),
// mockObj.EXPECT().SomeMethod(3, "third"),
// )
//
// TODO:
// - Handle different argument/return types (e.g. ..., chan, map, interface).
package gomock
import (
"runtime/debug"
"sync"
)
// A TestReporter is something that can be used to report test failures.
// It is satisfied by the standard library's *testing.T.
type TestReporter interface {
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
}
// A Controller represents the top-level control of a mock ecosystem.
// It defines the scope and lifetime of mock objects, as well as their expectations.
// It is safe to call Controller's methods from multiple goroutines.
type Controller struct {
mu sync.Mutex
t TestReporter
expectedCalls callSet
}
func NewController(t TestReporter) *Controller {
return &Controller{
t: t,
expectedCalls: make(callSet),
}
}
func (ctrl *Controller) RecordCall(receiver interface{}, method string, args ...interface{}) *Call {
// TODO: check arity, types.
margs := make([]Matcher, len(args))
for i, arg := range args {
if m, ok := arg.(Matcher); ok {
margs[i] = m
} else if arg == nil {
// Handle nil specially so that passing a nil interface value
// will match the typed nils of concrete args.
margs[i] = Nil()
} else {
margs[i] = Eq(arg)
}
}
ctrl.mu.Lock()
defer ctrl.mu.Unlock()
call := &Call{t: ctrl.t, receiver: receiver, method: method, args: margs, minCalls: 1, maxCalls: 1}
ctrl.expectedCalls.Add(call)
return call
}
func (ctrl *Controller) Call(receiver interface{}, method string, args ...interface{}) []interface{} {
ctrl.mu.Lock()
defer ctrl.mu.Unlock()
expected := ctrl.expectedCalls.FindMatch(receiver, method, args)
if expected == nil {
stack := debug.Stack()
ctrl.t.Fatalf("Missing EXPECT() for invoked function: %T.%v(%v)\n%s\n",
receiver, method, args, string(stack))
}
// Two things happen here:
// * the matching call no longer needs to check prerequite calls,
// * and the prerequite calls are no longer expected, so remove them.
preReqCalls := expected.dropPrereqs()
for _, preReqCall := range preReqCalls {
ctrl.expectedCalls.Remove(preReqCall)
}
rets, action := expected.call(args)
if expected.exhausted() {
ctrl.expectedCalls.Remove(expected)
}
// Don't hold the lock while doing the call's action (if any)
// so that actions may execute concurrently.
// We use the deferred Unlock to capture any panics that happen above;
// here we add a deferred Lock to balance it.
ctrl.mu.Unlock()
defer ctrl.mu.Lock()
if action != nil {
action()
}
return rets
}
func (ctrl *Controller) Finish() {
ctrl.mu.Lock()
defer ctrl.mu.Unlock()
// If we're currently panicking, probably because this is a deferred call,
// pass through the panic.
if err := recover(); err != nil {
panic(err)
}
// Check that all remaining expected calls are satisfied.
failures := false
for _, methodMap := range ctrl.expectedCalls {
for _, calls := range methodMap {
for _, call := range calls {
if !call.satisfied() {
ctrl.t.Errorf("missing call(s) to %v\n%s\n", call,
string(debug.Stack()))
failures = true
}
}
}
}
if failures {
ctrl.t.Fatalf("aborting test due to missing call(s)")
}
}

View File

@ -0,0 +1,416 @@
// Copyright 2011 Google Inc.
//
// 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 gomock_test
import (
"fmt"
"reflect"
"testing"
"github.com/rafrombrc/gomock/gomock"
)
type ErrorReporter struct {
t *testing.T
log []string
failed bool
fatalToken struct{}
}
func NewErrorReporter(t *testing.T) *ErrorReporter {
return &ErrorReporter{t: t}
}
func (e *ErrorReporter) reportLog() {
for _, entry := range e.log {
e.t.Log(entry)
}
}
func (e *ErrorReporter) assertPass(msg string) {
if e.failed {
e.t.Errorf("Expected pass, but got failure(s): %s", msg)
e.reportLog()
}
}
func (e *ErrorReporter) assertFail(msg string) {
if !e.failed {
e.t.Error("Expected failure, but got pass: %s", msg)
}
}
// Use to check that code triggers a fatal test failure.
func (e *ErrorReporter) assertFatal(fn func()) {
defer func() {
err := recover()
if err == nil {
var actual string
if e.failed {
actual = "non-fatal failure"
} else {
actual = "pass"
}
e.t.Error("Expected fatal failure, but got a", actual)
} else if token, ok := err.(*struct{}); ok && token == &e.fatalToken {
// This is okay - the panic is from Fatalf().
return
} else {
// Some other panic.
panic(err)
}
}()
fn()
}
// recoverUnexpectedFatal can be used as a deferred call in test cases to
// recover from and display a call to ErrorReporter.Fatalf().
func (e *ErrorReporter) recoverUnexpectedFatal() {
err := recover()
if err == nil {
// No panic.
} else if token, ok := err.(*struct{}); ok && token == &e.fatalToken {
// Unexpected fatal error happened.
e.t.Error("Got unexpected fatal error(s). All errors up to this point:")
e.reportLog()
return
} else {
// Some other panic.
panic(err)
}
}
func (e *ErrorReporter) Logf(format string, args ...interface{}) {
e.log = append(e.log, fmt.Sprintf(format, args...))
}
func (e *ErrorReporter) Errorf(format string, args ...interface{}) {
e.Logf(format, args...)
e.failed = true
}
func (e *ErrorReporter) Fatalf(format string, args ...interface{}) {
e.Logf(format, args...)
e.failed = true
panic(&e.fatalToken)
}
// A type purely for use as a receiver in testing the Controller.
type Subject struct{}
func (s *Subject) FooMethod(arg string) int {
return 0
}
func (s *Subject) BarMethod(arg string) int {
return 0
}
func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
if !reflect.DeepEqual(expected, actual) {
t.Error("Expected %+v, but got %+v", expected, actual)
}
}
func createFixtures(t *testing.T) (reporter *ErrorReporter, ctrl *gomock.Controller) {
// reporter acts as a testing.T-like object that we pass to the
// Controller. We use it to test that the mock considered tests
// successful or failed.
reporter = NewErrorReporter(t)
ctrl = gomock.NewController(reporter)
return
}
func TestNoCalls(t *testing.T) {
reporter, ctrl := createFixtures(t)
ctrl.Finish()
reporter.assertPass("No calls expected or made.")
}
func TestExpectedMethodCall(t *testing.T) {
reporter, ctrl := createFixtures(t)
subject := new(Subject)
ctrl.RecordCall(subject, "FooMethod", "argument")
ctrl.Call(subject, "FooMethod", "argument")
ctrl.Finish()
reporter.assertPass("Expected method call made.")
}
func TestUnexpectedMethodCall(t *testing.T) {
reporter, ctrl := createFixtures(t)
subject := new(Subject)
reporter.assertFatal(func() {
ctrl.Call(subject, "FooMethod", "argument")
})
ctrl.Finish()
}
func TestRepeatedCall(t *testing.T) {
reporter, ctrl := createFixtures(t)
subject := new(Subject)
ctrl.RecordCall(subject, "FooMethod", "argument").Times(3)
ctrl.Call(subject, "FooMethod", "argument")
ctrl.Call(subject, "FooMethod", "argument")
ctrl.Call(subject, "FooMethod", "argument")
reporter.assertPass("After expected repeated method calls.")
reporter.assertFatal(func() {
ctrl.Call(subject, "FooMethod", "argument")
})
ctrl.Finish()
reporter.assertFail("After calling one too many times.")
}
func TestUnexpectedArgCount(t *testing.T) {
reporter, ctrl := createFixtures(t)
defer reporter.recoverUnexpectedFatal()
subject := new(Subject)
ctrl.RecordCall(subject, "FooMethod", "argument")
reporter.assertFatal(func() {
// This call is made with the wrong number of arguments...
ctrl.Call(subject, "FooMethod", "argument", "extra_argument")
})
reporter.assertFatal(func() {
// ... so is this.
ctrl.Call(subject, "FooMethod")
})
reporter.assertFatal(func() {
// The expected call wasn't made.
ctrl.Finish()
})
}
func TestWithinTimes(t *testing.T) {
rep, ctrl := createFixtures(t)
s := new(Subject)
ctrl.RecordCall(s, "FooMethod", "arg").WithinTimes(3, 5)
ctrl.Call(s, "FooMethod", "arg")
ctrl.Call(s, "FooMethod", "arg")
ctrl.Call(s, "FooMethod", "arg")
rep.assertPass("After minimum number of method calls.")
ctrl.Call(s, "FooMethod", "arg")
ctrl.Call(s, "FooMethod", "arg")
rep.assertPass("After maximum number of method calls.")
rep.assertFatal(func() {
ctrl.Call(s, "FooMethod", "argument")
})
ctrl.Finish()
rep.assertFail("After exceeding maximum method calls.")
}
func TestAnyTimes(t *testing.T) {
reporter, ctrl := createFixtures(t)
subject := new(Subject)
ctrl.RecordCall(subject, "FooMethod", "argument").AnyTimes()
for i := 0; i < 100; i++ {
ctrl.Call(subject, "FooMethod", "argument")
}
reporter.assertPass("After 100 method calls.")
ctrl.Finish()
}
func TestDo(t *testing.T) {
_, ctrl := createFixtures(t)
subject := new(Subject)
doCalled := false
var argument string
ctrl.RecordCall(subject, "FooMethod", "argument").Do(
func(arg string) {
doCalled = true
argument = arg
})
if doCalled {
t.Error("Do() callback called too early.")
}
ctrl.Call(subject, "FooMethod", "argument")
if !doCalled {
t.Error("Do() callback not called.")
}
if "argument" != argument {
t.Error("Do callback received wrong argument.")
}
ctrl.Finish()
}
func TestReturn(t *testing.T) {
_, ctrl := createFixtures(t)
subject := new(Subject)
// Unspecified return should produce "zero" result.
ctrl.RecordCall(subject, "FooMethod", "zero")
ctrl.RecordCall(subject, "FooMethod", "five").Return(5)
assertEqual(
t,
[]interface{}{0},
ctrl.Call(subject, "FooMethod", "zero"))
assertEqual(
t,
[]interface{}{5},
ctrl.Call(subject, "FooMethod", "five"))
ctrl.Finish()
}
func TestUnorderedCalls(t *testing.T) {
reporter, ctrl := createFixtures(t)
defer reporter.recoverUnexpectedFatal()
subjectTwo := new(Subject)
subjectOne := new(Subject)
ctrl.RecordCall(subjectOne, "FooMethod", "1")
ctrl.RecordCall(subjectOne, "BarMethod", "2")
ctrl.RecordCall(subjectTwo, "FooMethod", "3")
ctrl.RecordCall(subjectTwo, "BarMethod", "4")
// Make the calls in a different order, which should be fine.
ctrl.Call(subjectOne, "BarMethod", "2")
ctrl.Call(subjectTwo, "FooMethod", "3")
ctrl.Call(subjectTwo, "BarMethod", "4")
ctrl.Call(subjectOne, "FooMethod", "1")
reporter.assertPass("After making all calls in different order")
ctrl.Finish()
reporter.assertPass("After finish")
}
func commonTestOrderedCalls(t *testing.T) (reporter *ErrorReporter, ctrl *gomock.Controller, subjectOne, subjectTwo *Subject) {
reporter, ctrl = createFixtures(t)
subjectOne = new(Subject)
subjectTwo = new(Subject)
gomock.InOrder(
ctrl.RecordCall(subjectOne, "FooMethod", "1").AnyTimes(),
ctrl.RecordCall(subjectTwo, "FooMethod", "2"),
ctrl.RecordCall(subjectTwo, "BarMethod", "3"),
)
return
}
func TestOrderedCallsCorrect(t *testing.T) {
reporter, ctrl, subjectOne, subjectTwo := commonTestOrderedCalls(t)
ctrl.Call(subjectOne, "FooMethod", "1")
ctrl.Call(subjectTwo, "FooMethod", "2")
ctrl.Call(subjectTwo, "BarMethod", "3")
ctrl.Finish()
reporter.assertPass("After finish")
}
func TestOrderedCallsInCorrect(t *testing.T) {
reporter, ctrl, subjectOne, subjectTwo := commonTestOrderedCalls(t)
ctrl.Call(subjectOne, "FooMethod", "1")
reporter.assertFatal(func() {
ctrl.Call(subjectTwo, "BarMethod", "3")
})
}
// Test that calls that are prerequites to other calls but have maxCalls >
// minCalls are removed from the expected call set.
func TestOrderedCallsWithPreReqMaxUnbounded(t *testing.T) {
reporter, ctrl, subjectOne, subjectTwo := commonTestOrderedCalls(t)
// Initially we should be able to call FooMethod("1") as many times as we
// want.
ctrl.Call(subjectOne, "FooMethod", "1")
ctrl.Call(subjectOne, "FooMethod", "1")
// But calling something that has it as a prerequite should remove it from
// the expected call set. This allows tests to ensure that FooMethod("1") is
// *not* called after FooMethod("2").
ctrl.Call(subjectTwo, "FooMethod", "2")
// Therefore this call should fail:
reporter.assertFatal(func() {
ctrl.Call(subjectOne, "FooMethod", "1")
})
}
func TestCallAfterLoopPanic(t *testing.T) {
_, ctrl := createFixtures(t)
subject := new(Subject)
firstCall := ctrl.RecordCall(subject, "Foo", "1")
secondCall := ctrl.RecordCall(subject, "Foo", "2")
thirdCall := ctrl.RecordCall(subject, "Foo", "3")
gomock.InOrder(firstCall, secondCall, thirdCall)
defer func() {
err := recover()
if err == nil {
t.Error("Call.After creation of dependency loop did not panic.")
}
}()
// This should panic due to dependency loop.
firstCall.After(thirdCall)
}
func TestPanicOverridesExpectationChecks(t *testing.T) {
ctrl := gomock.NewController(t)
reporter := NewErrorReporter(t)
reporter.assertFatal(func() {
ctrl.RecordCall(new(Subject), "FooMethod", "1")
defer ctrl.Finish()
reporter.Fatalf("Intentional panic")
})
}
func TestSetArgWithBadType(t *testing.T) {
rep, ctrl := createFixtures(t)
defer ctrl.Finish()
s := new(Subject)
// This should catch a type error:
rep.assertFatal(func() {
ctrl.RecordCall(s, "FooMethod", "1").SetArg(0, "blah")
})
ctrl.Call(s, "FooMethod", "1")
}
func TestTimes0(t *testing.T) {
rep, ctrl := createFixtures(t)
defer ctrl.Finish()
s := new(Subject)
ctrl.RecordCall(s, "FooMethod", "arg").Times(0)
rep.assertFatal(func() {
ctrl.Call(s, "FooMethod", "arg")
})
}

97
vendor/github.com/rafrombrc/gomock/gomock/matchers.go generated vendored Normal file
View File

@ -0,0 +1,97 @@
// Copyright 2010 Google Inc.
//
// 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 gomock
import (
"fmt"
"reflect"
)
// A Matcher is a representation of a class of values.
// It is used to represent the valid or expected arguments to a mocked method.
type Matcher interface {
// Matches returns whether y is a match.
Matches(x interface{}) bool
// String describes what the matcher matches.
String() string
}
type anyMatcher struct{}
func (anyMatcher) Matches(x interface{}) bool {
return true
}
func (anyMatcher) String() string {
return "is anything"
}
type eqMatcher struct {
x interface{}
}
func (e eqMatcher) Matches(x interface{}) bool {
return reflect.DeepEqual(e.x, x)
}
func (e eqMatcher) String() string {
return fmt.Sprintf("is equal to %v", e.x)
}
type nilMatcher struct{}
func (nilMatcher) Matches(x interface{}) bool {
if x == nil {
return true
}
v := reflect.ValueOf(x)
switch v.Kind() {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map,
reflect.Ptr, reflect.Slice:
return v.IsNil()
}
return false
}
func (nilMatcher) String() string {
return "is nil"
}
type notMatcher struct {
m Matcher
}
func (n notMatcher) Matches(x interface{}) bool {
return !n.m.Matches(x)
}
func (n notMatcher) String() string {
// TODO: Improve this if we add a NotString method to the Matcher interface.
return "not(" + n.m.String() + ")"
}
// Constructors
func Any() Matcher { return anyMatcher{} }
func Eq(x interface{}) Matcher { return eqMatcher{x} }
func Nil() Matcher { return nilMatcher{} }
func Not(x interface{}) Matcher {
if m, ok := x.(Matcher); ok {
return notMatcher{m}
}
return notMatcher{Eq(x)}
}

View File

@ -0,0 +1,70 @@
// Copyright 2010 Google Inc.
//
// 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 gomock_test
import (
"errors"
"testing"
"github.com/rafrombrc/gomock/gomock"
mock_matcher "github.com/rafrombrc/gomock/gomock/mock_matcher"
)
func TestMatchers(t *testing.T) {
type e interface{}
type testCase struct {
matcher gomock.Matcher
yes, no []e
}
tests := []testCase{
testCase{gomock.Any(), []e{3, nil, "foo"}, nil},
testCase{gomock.Eq(4), []e{4}, []e{3, "blah", nil, int64(4)}},
testCase{gomock.Nil(),
[]e{nil, (error)(nil), (chan bool)(nil), (*int)(nil)},
[]e{"", 0, make(chan bool), errors.New("err"), new(int)}},
testCase{gomock.Not(gomock.Eq(4)), []e{3, "blah", nil, int64(4)}, []e{4}},
}
for i, test := range tests {
for _, x := range test.yes {
if !test.matcher.Matches(x) {
t.Errorf(`test %d: "%v %s" should be true.`, i, x, test.matcher)
}
}
for _, x := range test.no {
if test.matcher.Matches(x) {
t.Errorf(`test %d: "%v %s" should be false.`, i, x, test.matcher)
}
}
}
}
// A more thorough test of notMatcher
func TestNotMatcher(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockMatcher := mock_matcher.NewMockMatcher(ctrl)
notMatcher := gomock.Not(mockMatcher)
mockMatcher.EXPECT().Matches(4).Return(true)
if match := notMatcher.Matches(4); match {
t.Errorf("notMatcher should not match 4")
}
mockMatcher.EXPECT().Matches(5).Return(false)
if match := notMatcher.Matches(5); !match {
t.Errorf("notMatcher should match 5")
}
}

View File

@ -0,0 +1,49 @@
// Automatically generated by MockGen. DO NOT EDIT!
// Source: github.com/rafrombrc/gomock/gomock (interfaces: Matcher)
package mock_gomock
import (
gomock "github.com/rafrombrc/gomock/gomock"
)
// Mock of Matcher interface
type MockMatcher struct {
ctrl *gomock.Controller
recorder *_MockMatcherRecorder
}
// Recorder for MockMatcher (not exported)
type _MockMatcherRecorder struct {
mock *MockMatcher
}
func NewMockMatcher(ctrl *gomock.Controller) *MockMatcher {
mock := &MockMatcher{ctrl: ctrl}
mock.recorder = &_MockMatcherRecorder{mock}
return mock
}
func (_m *MockMatcher) EXPECT() *_MockMatcherRecorder {
return _m.recorder
}
func (_m *MockMatcher) Matches(_param0 interface{}) bool {
ret := _m.ctrl.Call(_m, "Matches", _param0)
ret0, _ := ret[0].(bool)
return ret0
}
func (_mr *_MockMatcherRecorder) Matches(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "Matches", arg0)
}
func (_m *MockMatcher) String() string {
ret := _m.ctrl.Call(_m, "String")
ret0, _ := ret[0].(string)
return ret0
}
func (_mr *_MockMatcherRecorder) String() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "String")
}

View File

@ -194,104 +194,19 @@ func (a AppServiceBuild) ApplyRules(port *model.TenantServicesPort, service *cor
var secret *corev1.Secret
// http
if httpRule != nil {
domain := strings.Replace(httpRule.Domain, " ", "", -1)
if domain == "" {
domain = createDefaultDomain(a.tenant.Name, a.service.ServiceAlias, port.ContainerPort)
ing, sec, err := a.applyHttpRule(httpRule, port, service)
if err != nil {
return nil, nil, err
}
path := strings.Replace(httpRule.Path, " ", "", -1)
if path == "" {
path = "/"
}
ing := extensions.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: genIngName("l7", service.Name, path),
Namespace: a.tenant.UUID,
},
Spec: extensions.IngressSpec{
Rules: []extensions.IngressRule{
{
Host: domain,
IngressRuleValue: extensions.IngressRuleValue{
HTTP: &extensions.HTTPIngressRuleValue{
Paths: []extensions.HTTPIngressPath{
{
Path: path,
Backend: extensions.IngressBackend{
ServiceName: service.Name,
ServicePort: intstr.FromInt(port.ContainerPort),
},
},
},
},
},
},
},
},
}
annos := make(map[string]string)
// load balancer type
annos[parser.GetAnnotationWithPrefix("load-balancer-type")] = string(httpRule.LoadBalancerType)
// header
if httpRule.Header != "" {
annos[parser.GetAnnotationWithPrefix("header")] = httpRule.Header
}
// cookie
if httpRule.Cookie != "" {
annos[parser.GetAnnotationWithPrefix("cookie")] = httpRule.Cookie
}
// certificate
if httpRule.CertificateID != "" {
cert, err := a.dbmanager.CertificateDao().GetCertificateByID(httpRule.CertificateID)
if err != nil {
return nil, nil, fmt.Errorf("Cant not get certificate by id(%s): %v", httpRule.CertificateID, err)
}
// create secret
secret = &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: cert.CertificateName,
Namespace: a.tenant.UUID,
},
Data: map[string][]byte{
"tls.crt": []byte(cert.Certificate),
"tls.key": []byte(cert.PrivateKey),
},
Type: corev1.SecretTypeOpaque,
}
ing.Spec.TLS = []extensions.IngressTLS{
{
Hosts: []string{domain},
SecretName: secret.Name,
},
}
}
// rule extension
if httpRule.RuleExtensionID != "" {
re, err := a.dbmanager.RuleExtensionDao().GetRuleExtensionByID(httpRule.RuleExtensionID)
if err != nil {
logrus.Warnf("Error occurred while getting RuleExtension "+
"by RuleExtensionID(%s): %v", httpRule.RuleExtensionID, err)
} else {
switch re.Value {
case model.HttpToHttpsRVT:
annos[parser.GetAnnotationWithPrefix("force-ssl-redirect")] = "true"
case model.HttpAndHttpsRVT:
annos[parser.GetAnnotationWithPrefix("http-and-https")] = "true"
default:
logrus.Warnf("Unexpected RuleExtension Value: %s", re.Value)
}
}
}
ing.SetAnnotations(annos)
ingresses = append(ingresses, &ing)
ingresses = append(ingresses, ing)
secret = sec
}
// stream
if streamRule != nil {
mappingPort, err := a.dbmanager.TenantServiceLBMappingPortDao().CreateTenantServiceLBMappingPort(
a.serviceID, port.ContainerPort)
ing, err := applyStreamRule(streamRule, port, service, string(mappingPort.Port), a.tenant.UUID)
ing, err := applyStreamRule(streamRule, service, string(mappingPort.Port), a.tenant.UUID)
if err != nil {
return nil, nil, err
}
@ -301,10 +216,109 @@ func (a AppServiceBuild) ApplyRules(port *model.TenantServicesPort, service *cor
return ingresses, secret, nil
}
// applyStreamRule applies stream rule into ingress
func (a *AppServiceBuild) applyHttpRule(rule *model.HttpRule, port *model.TenantServicesPort,
service *corev1.Service) (ing *extensions.Ingress, sec *corev1.Secret, err error) {
if err != nil {
return nil, nil, err
}
domain := strings.Replace(rule.Domain, " ", "", -1)
if domain == "" {
domain = createDefaultDomain(a.tenant.Name, a.service.ServiceAlias, port.ContainerPort)
}
path := strings.Replace(rule.Path, " ", "", -1)
if path == "" {
path = "/"
}
ing = &extensions.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: genIngName("l7", service.Name, path),
Namespace: a.tenant.UUID,
},
Spec: extensions.IngressSpec{
Rules: []extensions.IngressRule{
{
Host: domain,
IngressRuleValue: extensions.IngressRuleValue{
HTTP: &extensions.HTTPIngressRuleValue{
Paths: []extensions.HTTPIngressPath{
{
Path: path,
Backend: extensions.IngressBackend{
ServiceName: service.Name,
ServicePort: intstr.FromInt(port.ContainerPort),
},
},
},
},
},
},
},
},
}
annos := make(map[string]string)
// load balancer type
annos[parser.GetAnnotationWithPrefix("load-balancer-type")] = string(rule.LoadBalancerType)
// header
if rule.Header != "" {
annos[parser.GetAnnotationWithPrefix("header")] = rule.Header
}
// cookie
if rule.Cookie != "" {
annos[parser.GetAnnotationWithPrefix("cookie")] = rule.Cookie
}
// certificate
if rule.CertificateID != "" {
cert, err := a.dbmanager.CertificateDao().GetCertificateByID(rule.CertificateID)
if err != nil {
return nil, nil, fmt.Errorf("Cant not get certificate by id(%s): %v", rule.CertificateID, err)
}
// create secret
sec = &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: cert.CertificateName,
Namespace: a.tenant.UUID,
},
Data: map[string][]byte{
"tls.crt": []byte(cert.Certificate),
"tls.key": []byte(cert.PrivateKey),
},
Type: corev1.SecretTypeOpaque,
}
ing.Spec.TLS = []extensions.IngressTLS{
{
Hosts: []string{domain},
SecretName: sec.Name,
},
}
}
// rule extension
if rule.RuleExtensionID != "" {
re, err := a.dbmanager.RuleExtensionDao().GetRuleExtensionByID(rule.RuleExtensionID)
if err != nil {
logrus.Warnf("Error occurred while getting RuleExtension "+
"by RuleExtensionID(%s): %v", rule.RuleExtensionID, err)
} else {
switch re.Value {
case model.HttpToHttpsRVT:
annos[parser.GetAnnotationWithPrefix("force-ssl-redirect")] = "true"
case model.HttpAndHttpsRVT:
annos[parser.GetAnnotationWithPrefix("http-and-https")] = "true"
default:
logrus.Warnf("Unexpected RuleExtension Value: %s", re.Value)
}
}
}
ing.SetAnnotations(annos)
return ing, sec, nil
}
// applyStreamRule applies stream rule into ingress
func applyStreamRule(
streamRule *model.StreamRule,
port *model.TenantServicesPort,
rule *model.StreamRule,
service *corev1.Service,
mappingPort string,
namespace string) (ing *extensions.Ingress, err error) {
@ -321,11 +335,11 @@ func applyStreamRule(
},
}
annos := make(map[string]string)
annos[parser.GetAnnotationWithPrefix("load-balancer-type")] = string(streamRule.LoadBalancerType)
annos[parser.GetAnnotationWithPrefix("load-balancer-type")] = string(rule.LoadBalancerType)
annos[parser.GetAnnotationWithPrefix("l4-enable")] = "true"
annos[parser.GetAnnotationWithPrefix("l4-host")] = streamRule.IP
annos[parser.GetAnnotationWithPrefix("l4-host")] = rule.IP
if err != nil {
return nil, err
return nil, err
}
annos[parser.GetAnnotationWithPrefix("l4-port")] = mappingPort
ing.SetAnnotations(annos)

View File

@ -20,69 +20,34 @@ package conversion
import (
"fmt"
"github.com/goodrain/rainbond/db"
"github.com/goodrain/rainbond/db/dao"
"github.com/goodrain/rainbond/db/model"
"github.com/goodrain/rainbond/db/mysql"
"github.com/goodrain/rainbond/gateway/annotations/parser"
"github.com/goodrain/rainbond/worker/appm/types/v1"
"github.com/rafrombrc/gomock/gomock"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"strconv"
"testing"
"time"
)
func TestAppServiceBuild_ApplyRules(t *testing.T) {
dbmanager := &mysql.MockManager{}
serviceID := "43eaae441859eda35b02075d37d83589"
replicationType := v1.TypeDeployment
build, err := AppServiceBuilder(serviceID, string(replicationType), dbmanager)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
ports, _ := build.dbmanager.TenantServicesPortDao().GetOuterPorts(serviceID)
mockService := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "default-svc",
Namespace: build.tenant.UUID,
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Name: "service-port",
Port: 30000,
TargetPort: intstr.FromInt(10000),
},
},
Selector: map[string]string{
"tier": "default",
},
},
}
ingresses, secret, err := build.ApplyRules(ports[0], mockService)
fmt.Println(ingresses)
fmt.Println(secret)
}
func TestAppServiceBuild_ApplyStreamRule(t *testing.T) {
func TestApplyStreamRule(t *testing.T) {
testCase := map[string]string{
"namespace": "e8539a9c33fd418db11cce26d2bca431",
parser.GetAnnotationWithPrefix("l4-enable"): "true",
parser.GetAnnotationWithPrefix("l4-host"): "127.0.0.1",
parser.GetAnnotationWithPrefix("l4-port"): "32145",
"serviceName": "default-svc",
"servicePort": "5000",
"containerPort": "10000",
}
serviceID := "43eaae441859eda35b02075d37d83589"
servicePort, err := strconv.Atoi(testCase["servicePort"])
containerPort, err := strconv.Atoi(testCase["containerPort"])
if err != nil {
t.Errorf("Can not convert %s(string) to int: %v", testCase["servicePort"], err)
t.Errorf("Can not convert %s(string) to int: %v", testCase["containerPort"], err)
}
port := &model.TenantServicesPort{
TenantID: testCase["namespace"],
@ -103,7 +68,7 @@ func TestAppServiceBuild_ApplyStreamRule(t *testing.T) {
Ports: []corev1.ServicePort{
{
Name: "service-port",
Port: int32(servicePort),
Port: int32(containerPort),
TargetPort: intstr.Parse(testCase["containerPort"]),
},
},
@ -126,7 +91,7 @@ func TestAppServiceBuild_ApplyStreamRule(t *testing.T) {
LoadBalancerType: model.RoundRobinLBType,
}
ing, err := applyStreamRule(streamRule, port, service,
ing, err := applyStreamRule(streamRule, service,
testCase[parser.GetAnnotationWithPrefix("l4-port")], testCase["namespace"])
if err != nil {
t.Errorf("Unexpected error occurred while applying stream rule: %v", err)
@ -160,10 +125,140 @@ func TestAppServiceBuild_ApplyStreamRule(t *testing.T) {
t.Errorf("Expected %s for ServiceName but returned %s", testCase["serviceName"],
ing.Spec.Backend.ServiceName)
}
if fmt.Sprintf("%v", ing.Spec.Backend.ServicePort.IntVal) != testCase["servicePort"] {
t.Errorf("Expected %s for ServicePort but returned %v", testCase["servicePort"],
if ing.Spec.Backend.ServicePort.IntVal != int32(containerPort) {
t.Errorf("Expected %v for ServicePort but returned %v", containerPort,
ing.Spec.Backend.ServicePort)
}
fmt.Sprintln(ing)
}
func TestAppServiceBuild_ApplyHttpRule(t *testing.T) {
testCase := map[string]string{
"namespace": "e8539a9c33fd418db11cce26d2bca431",
"domain": "www.goodrain.com",
"path": "/dummy-path",
"serviceName": "dummy-service-name",
"servicePort": "10000",
}
ctrl := gomock.NewController(t)
defer ctrl.Finish()
dbmanager := db.NewMockManager(ctrl)
serviceID := "43eaae441859eda35b02075d37d83589"
containerPort, err := strconv.Atoi(testCase["servicePort"])
if err != nil {
t.Errorf("Can't convert %s(string) to int", testCase["servicePort"])
}
serviceDao := dao.NewMockTenantServiceDao(ctrl)
updateTime, _ := time.Parse(time.RFC3339, "2018-10-22T14:14:12Z")
services := &model.TenantServices{
TenantID: testCase["namespace"],
ServiceID: serviceID,
ServiceKey: "application",
ServiceAlias: "grd83589",
Comment: "application info",
ServiceVersion: "latest",
ImageName: "goodrain.me/runner:latest",
ContainerCPU: 20,
ContainerMemory: 128,
ContainerCMD: "start_web",
VolumePath: "vol43eaae4418",
ExtendMethod: "stateless",
Replicas: 1,
DeployVersion: "20181022200709",
Category: "application",
CurStatus: "undeploy",
Status: 0,
ServiceType: "application",
Namespace: "goodrain",
VolumeType: "shared",
PortType: "multi_outer",
UpdateTime: updateTime,
ServiceOrigin: "assistant",
CodeFrom: "gitlab_demo",
Domain: "0enb7gyx",
}
serviceDao.EXPECT().GetServiceByID(serviceID).Return(services, nil)
dbmanager.EXPECT().TenantServiceDao().Return(serviceDao)
tenantDao := dao.NewMockTenantDao(ctrl)
tenant := &model.Tenants{
Name: "0enb7gyx",
UUID: testCase["namespace"],
EID: "214ec4d212582eb36a84cc180aad2783",
}
tenantDao.EXPECT().GetTenantByUUID(services.TenantID).Return(tenant, nil)
dbmanager.EXPECT().TenantDao().Return(tenantDao)
replicationType := v1.TypeDeployment
build, err := AppServiceBuilder(serviceID, string(replicationType), dbmanager)
if err != nil {
t.Errorf("Unexpected occurred while creating AppServiceBuild: %v", err)
}
httpRule := &model.HttpRule{
ServiceID: serviceID,
ContainerPort: containerPort,
Domain: testCase["domain"],
Path: testCase["path"],
LoadBalancerType: model.RoundRobinLBType,
}
port := &model.TenantServicesPort{
TenantID: tenant.UUID,
ServiceID: serviceID,
ContainerPort: containerPort,
MappingPort:containerPort,
Protocol: "http",
IsInnerService: false,
IsOuterService: true,
}
service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: testCase["serviceName"],
Namespace: build.tenant.UUID,
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Name: "service-port",
Port: int32(containerPort),
TargetPort: intstr.FromInt(containerPort),
},
},
Selector: map[string]string{
"tier": "default",
},
},
}
ing, sec, err := build.applyHttpRule(httpRule, port, service)
if err != nil {
t.Errorf("Unexpected error occurred whiling applying http rule: %v", err)
}
if sec != nil {
t.Errorf("Expected nil for sec, but returned %v", sec)
}
if ing.ObjectMeta.Namespace != testCase["namespace"] {
t.Errorf("Expected %s for namespace, but returned %s", testCase["namespace"], ing.ObjectMeta.Namespace)
}
if ing.Spec.Rules[0].Host != testCase["domain"] {
t.Errorf("Expected %s for host, but returned %s", testCase["domain"], ing.Spec.Rules[0].Host)
}
if ing.Spec.Rules[0].IngressRuleValue.HTTP.Paths[0].Path != testCase["path"] {
t.Errorf("Expected %s for path, but returned %s", testCase["path"], ing.Spec.Rules[0].IngressRuleValue.HTTP.Paths[0].Path)
}
if ing.Spec.Rules[0].IngressRuleValue.HTTP.Paths[0].Backend.ServiceName != testCase["serviceName"] {
t.Errorf("Expected %s for serviceName, but returned %s", testCase["serviceName"],
ing.Spec.Rules[0].IngressRuleValue.HTTP.Paths[0].Backend.ServiceName)
}
if fmt.Sprintf("%v", ing.Spec.Rules[0].IngressRuleValue.HTTP.Paths[0].Backend.ServicePort.IntVal) != testCase["servicePort"] {
t.Errorf("Expected %s for servicePort, but returned %s", testCase["servicePort"],
fmt.Sprintf("%v", ing.Spec.Rules[0].IngressRuleValue.HTTP.Paths[0].Backend.ServicePort.IntVal))
}
}