Esempio n. 1
0
//Get job result
func (this *JobController) GetJobResult() {
	jid := this.GetString("jobid")

	resultPath := path.Join(config.GetSharePath(), jid)
	ex, err := comm.FileExists(resultPath)
	if !ex || err != nil {
		log.Println(err)
		return
	}

	zipPath := path.Join(config.GetSharePath(), jid+".zip")
	ex, err = comm.FileExists(zipPath)
	if err != nil {
		log.Println(err)
		return
	}
	if !ex {
		err := comm.Zipit(resultPath, zipPath)
		if err != nil {
			log.Println(err)
			return
		}
	}
	name := jid + ".zip"
	this.Ctx.Output.Download(zipPath, name)
}
Esempio n. 2
0
func (this *JobController) DeleteJob() {
	this.Ctx.Output.SetStatus(200)
	id := this.Ctx.Input.Param(":id")
	if master.IsFinished(id) {
		models.DeleteJobSketchInDB(id)
		models.DeleteJobInDB(id)
		resultPath := path.Join(config.GetSharePath(), id)
		err := os.RemoveAll(resultPath)
		if err != nil {
			log.Println(err)
		}
		resultPath = path.Join(config.GetSharePath(), id+".zip")
		err = os.Remove(resultPath)
		if err != nil {
			log.Println(err)
		}
	}
}
Esempio n. 3
0
func moveTestFile(job *models.Job, control *JobController) error {
	if job.JobInfo.FrameKind == framework.FRAME_MONKEY {
		//move file to share path
		dist := path.Join(config.GetSharePath(), job.JobId)
		err := os.Mkdir(dist, os.ModePerm)
		if err != nil {
			return err
		}
		dist = path.Join(dist, comm.APPNAME)
		err = control.SaveToFile("file", dist)

		if err != nil {
			return err
		}
		//update framework info
		monkey := job.JobInfo.Frame.(framework.MonkeyFrame)
		monkey.AppPath = dist
		job.JobInfo.Frame = monkey
	} else if job.JobInfo.FrameKind == framework.FRAME_ROBOT {
		//move file to share path
		dist := path.Join(config.GetSharePath(), job.JobId)
		err := os.Mkdir(dist, os.ModePerm)
		if err != nil {
			return err
		}
		distApp := path.Join(dist, comm.APPNAME)
		err = control.SaveToFile("app", distApp)
		if err != nil {
			return err
		}
		distTest := path.Join(dist, comm.TESTNAME)
		err = control.SaveToFile("test", distTest)
		if err != nil {
			return err
		}
		//update framework info
		robotium := job.JobInfo.Frame.(framework.RobotFrame)
		robotium.AppPath = distApp
		robotium.TestPath = distTest
		job.JobInfo.Frame = robotium
	}
	return nil
}