Exemplo n.º 1
0
func (task *AddTaskVars) GetInsertQueryAndBinds() (string, []interface{}, error) {
	if task.ChromiumRev == "" ||
		task.SkiaRev == "" ||
		task.ChromiumRevTs == "" {
		return "", nil, fmt.Errorf("Invalid parameters")
	}
	// Example timestamp format: "Wed Jul 15 13:42:19 2015"
	var chromiumRevTs string
	if parsedTs, err := time.Parse(time.ANSIC, task.ChromiumRevTs); err != nil {
		// ChromiumRevTs is likely already in the expected format.
		chromiumRevTs = task.ChromiumRevTs
	} else {
		chromiumRevTs = parsedTs.UTC().Format("20060102150405")
	}
	if err := ctfeutil.CheckLengths([]ctfeutil.LengthCheck{
		{"chromium_rev", task.ChromiumRev, 100},
		{"skia_rev", task.SkiaRev, 100},
	}); err != nil {
		return "", nil, err
	}
	return fmt.Sprintf("INSERT INTO %s (username,chromium_rev,chromium_rev_ts,skia_rev,ts_added,repeat_after_days) VALUES (?,?,?,?,?,?);",
			db.TABLE_CHROMIUM_BUILD_TASKS),
		[]interface{}{
			task.Username,
			task.ChromiumRev,
			chromiumRevTs,
			task.SkiaRev,
			task.TsAdded,
			task.RepeatAfterDays,
		},
		nil
}
Exemplo n.º 2
0
func (task *AddTaskVars) GetInsertQueryAndBinds() (string, []interface{}, error) {
	if task.PageSets == "" ||
		task.ChromiumBuild.ChromiumRev == "" ||
		task.ChromiumBuild.SkiaRev == "" ||
		task.Description == "" {
		return "", nil, fmt.Errorf("Invalid parameters")
	}
	if err := chromium_builds.Validate(task.ChromiumBuild); err != nil {
		return "", nil, err
	}
	if err := ctfeutil.CheckLengths([]ctfeutil.LengthCheck{
		{"page_sets", task.PageSets, 100},
		{"desc", task.Description, 255},
	}); err != nil {
		return "", nil, err
	}
	return fmt.Sprintf("INSERT INTO %s (username,page_sets,chromium_rev,skia_rev,description,ts_added, repeat_after_days) VALUES (?,?,?,?,?,?,?);",
			db.TABLE_CAPTURE_SKPS_TASKS),
		[]interface{}{
			task.Username,
			task.PageSets,
			task.ChromiumBuild.ChromiumRev,
			task.ChromiumBuild.SkiaRev,
			task.Description,
			task.TsAdded,
			task.RepeatAfterDays,
		},
		nil
}
Exemplo n.º 3
0
func (task *AddTaskVars) GetInsertQueryAndBinds() (string, []interface{}, error) {
	if task.SkpRepository.PageSets == "" ||
		task.SkpRepository.ChromiumRev == "" ||
		task.SkpRepository.SkiaRev == "" ||
		task.LuaScript == "" ||
		task.Description == "" {
		return "", nil, fmt.Errorf("Invalid parameters")
	}
	if err := capture_skps.Validate(task.SkpRepository); err != nil {
		return "", nil, err
	}
	if err := ctfeutil.CheckLengths([]ctfeutil.LengthCheck{
		{"lua_script", task.LuaScript, db.TEXT_MAX_LENGTH},
		{"lua_aggregator_script", task.LuaAggregatorScript, db.TEXT_MAX_LENGTH},
		{"description", task.Description, 255},
	}); err != nil {
		return "", nil, err
	}
	return fmt.Sprintf("INSERT INTO %s (username,page_sets,chromium_rev,skia_rev,lua_script,lua_aggregator_script,description,ts_added,repeat_after_days) VALUES (?,?,?,?,?,?,?,?,?);",
			db.TABLE_LUA_SCRIPT_TASKS),
		[]interface{}{
			task.Username,
			task.SkpRepository.PageSets,
			task.SkpRepository.ChromiumRev,
			task.SkpRepository.SkiaRev,
			task.LuaScript,
			task.LuaAggregatorScript,
			task.Description,
			task.TsAdded,
			task.RepeatAfterDays,
		},
		nil
}
Exemplo n.º 4
0
func (task *AddTaskVars) GetInsertQueryAndBinds() (string, []interface{}, error) {
	if task.Benchmark == "" ||
		task.Platform == "" ||
		task.PageSets == "" ||
		task.RepeatRuns == "" ||
		task.RunInParallel == "" ||
		task.Description == "" {
		return "", nil, fmt.Errorf("Invalid parameters")
	}
	if err := ctfeutil.CheckLengths([]ctfeutil.LengthCheck{
		{"benchmark", task.Benchmark, 100},
		{"platform", task.Platform, 100},
		{"page_sets", task.PageSets, 100},
		{"benchmark_args", task.BenchmarkArgs, 255},
		{"browser_args_nopatch", task.BrowserArgsNoPatch, 255},
		{"browser_args_withpatch", task.BrowserArgsWithPatch, 255},
		{"desc", task.Description, 255},
		{"chromium_patch", task.ChromiumPatch, db.LONG_TEXT_MAX_LENGTH},
		{"blink_patch", task.BlinkPatch, db.LONG_TEXT_MAX_LENGTH},
		{"skia_patch", task.SkiaPatch, db.LONG_TEXT_MAX_LENGTH},
		{"benchmark_patch", task.BenchmarkPatch, db.LONG_TEXT_MAX_LENGTH},
	}); err != nil {
		return "", nil, err
	}
	runInParallel := 0
	if task.RunInParallel == "True" {
		runInParallel = 1
	}
	return fmt.Sprintf("INSERT INTO %s (username,benchmark,platform,page_sets,repeat_runs,run_in_parallel, benchmark_args,browser_args_nopatch,browser_args_withpatch,description,chromium_patch,blink_patch,skia_patch,benchmark_patch,ts_added,repeat_after_days) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);",
			db.TABLE_CHROMIUM_PERF_TASKS),
		[]interface{}{
			task.Username,
			task.Benchmark,
			task.Platform,
			task.PageSets,
			task.RepeatRuns,
			runInParallel,
			task.BenchmarkArgs,
			task.BrowserArgsNoPatch,
			task.BrowserArgsWithPatch,
			task.Description,
			task.ChromiumPatch,
			task.BlinkPatch,
			task.SkiaPatch,
			task.BenchmarkPatch,
			task.TsAdded,
			task.RepeatAfterDays,
		},
		nil
}
Exemplo n.º 5
0
func (task *AddRecreatePageSetsTaskVars) GetInsertQueryAndBinds() (string, []interface{}, error) {
	if task.PageSets == "" {
		return "", nil, fmt.Errorf("Invalid parameters")
	}
	if err := ctfeutil.CheckLengths([]ctfeutil.LengthCheck{{"page_sets", task.PageSets, 100}}); err != nil {
		return "", nil, err
	}
	return fmt.Sprintf("INSERT INTO %s (username,page_sets,ts_added,repeat_after_days) VALUES (?,?,?,?);",
			db.TABLE_RECREATE_PAGE_SETS_TASKS),
		[]interface{}{
			task.Username,
			task.PageSets,
			task.TsAdded,
			task.RepeatAfterDays,
		},
		nil
}
Exemplo n.º 6
0
func (task *UpdateVars) GetUpdateExtraClausesAndBinds() ([]string, []interface{}, error) {
	if err := ctfeutil.CheckLengths([]ctfeutil.LengthCheck{
		{"ScriptOutput", task.ScriptOutput.String, 255},
		{"AggregatedOutput", task.AggregatedOutput.String, 255},
	}); err != nil {
		return nil, nil, err
	}
	clauses := []string{}
	args := []interface{}{}
	if task.ScriptOutput.Valid {
		clauses = append(clauses, "script_output = ?")
		args = append(args, task.ScriptOutput.String)
	}
	if task.AggregatedOutput.Valid {
		clauses = append(clauses, "aggregated_output = ?")
		args = append(args, task.AggregatedOutput.String)
	}
	return clauses, args, nil
}
Exemplo n.º 7
0
func (task *UpdateVars) GetUpdateExtraClausesAndBinds() ([]string, []interface{}, error) {
	if err := ctfeutil.CheckLengths([]ctfeutil.LengthCheck{
		{"NoPatchRawOutput", task.NoPatchRawOutput.String, 255},
		{"WithPatchRawOutput", task.WithPatchRawOutput.String, 255},
		{"Results", task.Results.String, 255},
	}); err != nil {
		return nil, nil, err
	}
	clauses := []string{}
	args := []interface{}{}
	if task.Results.Valid {
		clauses = append(clauses, "results = ?")
		args = append(args, task.Results.String)
	}
	if task.NoPatchRawOutput.Valid {
		clauses = append(clauses, "nopatch_raw_output = ?")
		args = append(args, task.NoPatchRawOutput.String)
	}
	if task.WithPatchRawOutput.Valid {
		clauses = append(clauses, "withpatch_raw_output = ?")
		args = append(args, task.WithPatchRawOutput.String)
	}
	return clauses, args, nil
}
Exemplo n.º 8
0
func (task *AddRecreateWebpageArchivesTaskVars) GetInsertQueryAndBinds() (string, []interface{}, error) {
	if task.PageSets == "" ||
		task.ChromiumBuild.ChromiumRev == "" ||
		task.ChromiumBuild.SkiaRev == "" {
		return "", nil, fmt.Errorf("Invalid parameters")
	}
	if err := chromium_builds.Validate(task.ChromiumBuild); err != nil {
		return "", nil, err
	}
	if err := ctfeutil.CheckLengths([]ctfeutil.LengthCheck{{"page_sets", task.PageSets, 100}}); err != nil {
		return "", nil, err
	}
	return fmt.Sprintf("INSERT INTO %s (username,page_sets,chromium_rev,skia_rev,ts_added,repeat_after_days) VALUES (?,?,?,?,?,?);",
			db.TABLE_RECREATE_WEBPAGE_ARCHIVES_TASKS),
		[]interface{}{
			task.Username,
			task.PageSets,
			task.ChromiumBuild.ChromiumRev,
			task.ChromiumBuild.SkiaRev,
			task.TsAdded,
			task.RepeatAfterDays,
		},
		nil
}