Documentation ¶
Overview ¶
This file is used for the 'Schedular'
This file is used for the 'Schedular'
NOTE: this file is used for the 'Schedular' TODO: all 'sync' mode now
Index ¶
- Constants
- func ExecSH(scripts string, dir string) ([]byte, error)
- func GetDirFiles(base_dir string, dir string) (files []string)
- func MD5(data string) (val string)
- func PreparePath(cachename string, filename string) (dir string)
- func ReadCaseFromTar(tarURL string) (content string)
- func ReadTar(tarURL string, fileURL string, suffix string) (content string)
- func ReceiveFile(w http.ResponseWriter, r *http.Request, cacheURL string) (realURL string, params map[string]string)
- func Render(w http.ResponseWriter, httpStatus int, ret HttpRet)
- func RenderError(w http.ResponseWriter, err error)
- func RenderErrorf(w http.ResponseWriter, msg string)
- func RenderOK(w http.ResponseWriter, msg string, data interface{})
- func TarDir(caseDir string) (tarURL string)
- func TarFileList(filelist []string, caseDir string, objectName string) (tarURL string, found bool)
- func UntarFile(filename string, cacheURL string)
- type DB
- func (db *DB) Add(collect DBCollectName, val DBInterface) (string, error)
- func (db *DB) CollectExist(collect DBCollectName) error
- func (db *DB) GenerateID(collect DBCollectName, val string) string
- func (db *DB) Get(collect DBCollectName, id string) (DBInterface, error)
- func (db *DB) Lookup(collect DBCollectName, query DBQuery) (ids []string)
- func (db *DB) RegistCollect(collect DBCollectName) error
- func (db *DB) Remove(collect DBCollectName, id string) error
- func (db *DB) Update(collect DBCollectName, id string, val DBInterface) error
- type DBCollectName
- type DBInterface
- type DBQuery
- type HttpRet
- type Resource
- type ResourceClass
- type ResourceCommon
- type ResourceStatus
- type RetStatus
- type Scheduler
- type TestAction
- type TestActionCommand
- type TestCase
- func (tc *TestCase) GetBundleContent() string
- func (tc *TestCase) GetBundleName() string
- func (tc *TestCase) GetBundleTarURL() string
- func (tc *TestCase) GetBundleURL() string
- func (tc *TestCase) GetID() string
- func (tc *TestCase) GetRepoID() string
- func (tc *TestCase) GetReportContent() string
- func (tc *TestCase) GetReportStatus() (hasReport bool, caseUpdated bool, err error)
- func (tc *TestCase) IsValid() error
- func (tc *TestCase) MatchStatus(status string) bool
- func (tc *TestCase) SetBundleName(bundle string)
- func (tc *TestCase) SetBundleURL(bundle string)
- func (tc *TestCase) SetID(id string)
- func (tc *TestCase) SetRepoID(id string)
- func (tc TestCase) String() string
- type TestCasePub
- type TestCaseRepo
- func (repo *TestCaseRepo) GetCase(groupAndName string) (tc TestCase, err error)
- func (repo *TestCaseRepo) GetCases() []TestCase
- func (repo *TestCaseRepo) GetID() string
- func (repo *TestCaseRepo) IsValid() error
- func (repo *TestCaseRepo) Modify(newRepo TestCaseRepo)
- func (repo *TestCaseRepo) Purge() error
- func (repo *TestCaseRepo) Refresh() bool
- func (repo *TestCaseRepo) SetCacheDir(CacheDir string)
- func (repo *TestCaseRepo) SetID(id string)
- func (repo TestCaseRepo) String() string
- type TestCaseRepoPub
- type TestCommand
- type TestStatus
- type TestTask
- func (task *TestTask) Apply() error
- func (task *TestTask) Collect() error
- func (task *TestTask) Command(action TestAction) (err error)
- func (task *TestTask) Deploy() error
- func (task *TestTask) Destroy() error
- func (task *TestTask) GetID() string
- func (task *TestTask) GetSchedulerID() string
- func (task *TestTask) Loop() (needContinue error)
- func (task *TestTask) Run() error
- func (task *TestTask) SetID(id string)
- func (task *TestTask) SetSchedulerID(id string)
- func (task TestTask) String() string
- type TestUnit
- func (t *TestUnit) Apply() error
- func (t *TestUnit) Collect() error
- func (t *TestUnit) Deploy() error
- func (t *TestUnit) Destroy() error
- func (t *TestUnit) GetBundleURL() string
- func (t *TestUnit) GetID() string
- func (t *TestUnit) GetResourceID() string
- func (t *TestUnit) GetSchedulerID() string
- func (t *TestUnit) GetStatus() TestStatus
- func (t *TestUnit) Run() error
- func (t *TestUnit) SetBundleURL(url string)
- func (t *TestUnit) SetID(id string)
- func (t *TestUnit) SetResourceID(id string)
- func (t *TestUnit) SetSchedulerID(id string)
- func (t *TestUnit) SetStatus(s TestStatus)
- func (t TestUnit) String() string
- func (t *TestUnit) UnmarshalJSON(data []byte) error
Constants ¶
const ( TestCaseConfigFile = "case.json" TestCaseSourceDir = "source" TestCaseCollectDir = "collect" TestCaseReportFile = "report.md" )
const ( DBCase DBCollectName = "case" DBRepo = "repo" DBResource = "resource" //testing task: for frontend users DBTask = "task" //scheduler: for backend servers DBScheduler = "scheduler" //scheduler unit DBUnit = "unit" )
const ( TestStatusInit TestStatus = "init" TestStatusAllocating = "allocating" TestStatusAllocated = "allocated" TestStatusAllocateFailed = "allocate failed" TestStatusDeploying = "deploying" TestStatusDeployed = "deployed" TestStatusDeployFailed = "deploy failed" TestStatusRunning = "running" TestStatusRun = "run" TestStatusRunFailed = "run failed" TestStatusCollecting = "collecting" TestStatusCollected = "collect" TestStatusCollectFailed = "collect failed" TestStatusDestroying = "destroying" TestStatusFinish = "finish" TestStatusDestroyFailed = "destroy failed" )
Warning: this is not the test case status, this is the test status, which is runtime
const ( TestActionAction TestAction = "action" TestActionID = "id" TestActionApply = "apply" TestActionDeploy = "deploy" TestActionRun = "run" TestActionCollect = "collect" TestActionDestroy = "destroy" )
const SchedulerCacheDir = "/tmp/.test_schedular_cache"
const SchedulerDefaultPrio = 100
const SchedulerPriority = "Priority"
const TestCaseCache string = "/tmp/.testcase_cache/"
Variables ¶
This section is empty.
Functions ¶
func GetDirFiles ¶
func PreparePath ¶
When filename is null, we just want to prepare a pure directory
func ReadCaseFromTar ¶
func ReceiveFile ¶
func RenderError ¶
func RenderError(w http.ResponseWriter, err error)
func RenderErrorf ¶
func RenderErrorf(w http.ResponseWriter, msg string)
func RenderOK ¶
func RenderOK(w http.ResponseWriter, msg string, data interface{})
func TarFileList ¶
file name filelist is like this: './source/file'
Types ¶
type DB ¶
type DB struct {
OCTDB map[DBCollectName](map[string]DBInterface)
}
func GetDefaultDB ¶
func GetDefaultDB() DB
func (*DB) Add ¶
func (db *DB) Add(collect DBCollectName, val DBInterface) (string, error)
func (*DB) CollectExist ¶
func (db *DB) CollectExist(collect DBCollectName) error
func (*DB) GenerateID ¶
func (db *DB) GenerateID(collect DBCollectName, val string) string
The case, repo, resource should be consistent The task could always be different
func (*DB) Get ¶
func (db *DB) Get(collect DBCollectName, id string) (DBInterface, error)
func (*DB) RegistCollect ¶
func (db *DB) RegistCollect(collect DBCollectName) error
func (*DB) Update ¶
func (db *DB) Update(collect DBCollectName, id string, val DBInterface) error
If id exist,s modify it; if id does not exist, add it.
type DBCollectName ¶
type DBCollectName string
type DBInterface ¶
type DBInterface interface {
String() string
}
type HttpRet ¶
func SendCommand ¶
type Resource ¶
type Resource struct { ResourceCommon ID string URL string //0 means no limit MaxJobs int TestUnitIDs []string Status ResourceStatus }
This is record in the testing cluster
func ResourceFromString ¶
func (*Resource) IsQualify ¶
func (res *Resource) IsQualify(req ResourceCommon) bool
type ResourceClass ¶
type ResourceClass string
const ( ResourceOS ResourceClass = "os" ResourceContainer = "container" )
type ResourceCommon ¶
type ResourceCommon struct { Class ResourceClass Distribution string //ResName is used in 'container', for example: ubuntu/busybox ResName string Version string Arch string CPU int64 Memory int64 }
Common is the request from the user
type ResourceStatus ¶
type ResourceStatus string
const ( ResourceStatusFree ResourceStatus = "free" ResourceStatusLocked = "locked" )
type Scheduler ¶
func SchedulerFromString ¶
func SchedulerNew ¶
func (*Scheduler) Command ¶
func (s *Scheduler) Command(action TestAction) (err error)
func (*Scheduler) GetStatus ¶
func (s *Scheduler) GetStatus() TestStatus
type TestAction ¶
type TestAction string
func TestActionFromString ¶
func TestActionFromString(val string) (TestAction, error)
type TestActionCommand ¶
Used for tranfer between scheduler and octd/containerpool
func ActionCommandFromString ¶
func ActionCommandFromString(val string) (t TestActionCommand, err error)
func (TestActionCommand) String ¶
func (t TestActionCommand) String() string
type TestCase ¶
type TestCase struct { TestCasePub //This is not necessary, but since the developer names the bundle, //just don't want to miss it BundleName string /* the dir */ BundleURL string }
func CaseFromBundle ¶
func CaseFromString ¶
func CaseFromTar ¶
If bundleURL is nil, untar the bundle in the same dir
func (*TestCase) GetBundleContent ¶
func (*TestCase) GetBundleName ¶
func (*TestCase) GetBundleTarURL ¶
If cacheURL is nil, tar the bundle in the same dir
func (*TestCase) GetBundleURL ¶
func (*TestCase) GetReportContent ¶
func (*TestCase) GetReportStatus ¶
func (*TestCase) MatchStatus ¶
func (*TestCase) SetBundleName ¶
func (*TestCase) SetBundleURL ¶
type TestCasePub ¶
type TestCaseRepo ¶
type TestCaseRepo struct { TestCaseRepoPub //used to get the repo data, default to : /tmp/tcserver_cache/ CacheDir string Cases []TestCase //The id is not public since it should be set in the implementation Timestamp int64 }
func RepoFromString ¶
func RepoFromString(val string) (tcr TestCaseRepo, err error)
func (*TestCaseRepo) GetCase ¶
func (repo *TestCaseRepo) GetCase(groupAndName string) (tc TestCase, err error)
func (*TestCaseRepo) GetCases ¶
func (repo *TestCaseRepo) GetCases() []TestCase
func (*TestCaseRepo) GetID ¶
func (repo *TestCaseRepo) GetID() string
func (*TestCaseRepo) IsValid ¶
func (repo *TestCaseRepo) IsValid() error
func (*TestCaseRepo) Modify ¶
func (repo *TestCaseRepo) Modify(newRepo TestCaseRepo)
func (*TestCaseRepo) Purge ¶
func (repo *TestCaseRepo) Purge() error
func (*TestCaseRepo) Refresh ¶
func (repo *TestCaseRepo) Refresh() bool
func (*TestCaseRepo) SetCacheDir ¶
func (repo *TestCaseRepo) SetCacheDir(CacheDir string)
func (*TestCaseRepo) SetID ¶
func (repo *TestCaseRepo) SetID(id string)
func (TestCaseRepo) String ¶
func (repo TestCaseRepo) String() string
type TestCaseRepoPub ¶
type TestCaseRepoPub struct { //set in runtime implementation ID string //Name is the short name of URL, make the repo management easier Name string URL string CaseFolder string //Type is the method to discover and get the repos. 'git' as a default Type string //We can disable a repo Enable bool Groups []string }
type TestCommand ¶
type TestStatus ¶
type TestStatus string
type TestTask ¶
type TestTask struct { ID string PostURL string //a tar.gz file BundleURL string Status TestStatus Priority int //Return from the scheduler SchedulerID string //Used in octd, keep track of the unit name Name string }
func TaskFromString ¶
func TestTaskNew ¶
func (*TestTask) Command ¶
func (task *TestTask) Command(action TestAction) (err error)
func (*TestTask) Deploy ¶
Donnot need to send files now, since it will be done by the Apply function
func (*TestTask) GetSchedulerID ¶
func (*TestTask) SetSchedulerID ¶
type TestUnit ¶
type TestUnit struct { ResourceCommon //Suggest to name the unit, easier to write/maintain, must be different Name string //deploy files: script/data Commands TestCommand //FIXME: I don't want to use Children.. // Children []TestUnit ReportURL string Status TestStatus //the id of the scheduler SchedulerID string //runtime ID, used to keep track of the relevant hostTest/container ResourceID string //TODO: use the test bundle URL, but should put files into a smaller piece BundleURL string // contains filtered or unexported fields }
func UnitFromString ¶
func (*TestUnit) GetBundleURL ¶
func (*TestUnit) GetResourceID ¶
func (*TestUnit) GetSchedulerID ¶
func (*TestUnit) GetStatus ¶
func (t *TestUnit) GetStatus() TestStatus
func (*TestUnit) SetBundleURL ¶
func (*TestUnit) SetResourceID ¶
func (*TestUnit) SetSchedulerID ¶
func (*TestUnit) SetStatus ¶
func (t *TestUnit) SetStatus(s TestStatus)