Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(773)

Unified Diff: ct/go/util/util.go

Issue 1990873002: Use swarming in create_pagesets CT task (Closed) Base URL: https://skia.googlesource.com/buildbot@ct-3-swarming-timeouts
Patch Set: Remove TODOs Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ct/go/util/util.go
diff --git a/ct/go/util/util.go b/ct/go/util/util.go
index e69499571e5931fd2e1900fa47f49b38c967c093..4fe5e885e89d7e9bc204289066f7cb69cd1d0944 100644
--- a/ct/go/util/util.go
+++ b/ct/go/util/util.go
@@ -16,6 +16,7 @@ import (
"time"
"go.skia.org/infra/go/exec"
+ "go.skia.org/infra/go/swarming"
"go.skia.org/infra/go/util"
"github.com/skia-dev/glog"
@@ -390,3 +391,48 @@ func ValidateSKPs(pathToSkps string) error {
return nil
}
+
+// GetStartRange returns the range worker should start processing at based on its num and how many
+// artifacts it is allowed to process.
+func GetStartRange(workerNum, artifactsPerWorker int) int {
+ return ((workerNum - 1) * artifactsPerWorker) + 1
+}
+
+// ArchiveTriggerCollectSwarmingTasks is a convenience function for CT scripts to call to
+// batch archive isolates, trigger swarming tasks, collect the triggered swarming tasks.
+func ArchiveTriggerCollectSwarmingTask(s *swarming.SwarmingClient, taskNames, genJSONs []string, hardTimeout, ioTimeout time.Duration) error {
dogben 2016/05/18 17:38:26 Seems that taskNames is only used to verify tasksT
rmistry 2016/05/19 12:59:50 Keeping the taskNames check because of all the new
dogben 2016/05/19 14:27:22 I don't understand.
rmistry 2016/05/19 14:42:19 Done.
+ // Batcharchive the tasks.
+ tasksToHashes, err := s.BatchArchiveTargets(genJSONs, BATCHARCHIVE_TIMEOUT)
+ if err != nil {
+ return fmt.Errorf("Could not batch archive targets: %s", err)
+ }
+ if len(taskNames) != len(tasksToHashes) {
+ return fmt.Errorf("len(taskNames) was %d and len(tasksToHashes) was %d", len(taskNames), len(tasksToHashes))
+ }
+ // Trigger swarming using the isolate hashes.
+ dimensions := map[string]string{"pool": SWARMING_POOL}
+ tasks, err := s.TriggerSwarmingTasks(tasksToHashes, dimensions, swarming.RECOMMENDED_PRIORITY, swarming.RECOMMENDED_EXPIRATION, hardTimeout, ioTimeout, false)
+ if err != nil {
+ return fmt.Errorf("Could not trigger swarming task: %s", err)
+ }
+ // Collect all tasks and log the ones that fail.
+ for _, task := range tasks {
+ if _, _, err := task.Collect(s); err != nil {
+ glog.Errorf("task %s failed: %s", task.Title, err)
+ continue
+ }
+ }
+ return nil
+}
+
+// GetPathToPyFiles returns the location of CT's python scripts.
+func GetPathToPyFiles(runOnSwarming bool) string {
+ var pathToPyFiles string
dogben 2016/05/18 17:38:26 nit: just return rather than assigning to pathToPy
rmistry 2016/05/19 12:59:50 Done.
+ if runOnSwarming {
+ pathToPyFiles = filepath.Join(filepath.Dir(filepath.Dir(os.Args[0])), "src", "go.skia.org", "infra", "ct", "py")
+ } else {
+ _, currentFile, _, _ := runtime.Caller(0)
+ pathToPyFiles = filepath.Join(filepath.Dir(filepath.Dir(filepath.Dir(currentFile))), "py")
+ }
+ return pathToPyFiles
+}

Powered by Google App Engine
This is Rietveld 408576698