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

Side by Side Diff: ct/go/worker_scripts/run_lua/main.go

Issue 1991943002: Use swarming in run_lua CT task (Closed) Base URL: https://skia.googlesource.com/buildbot@ct-6-capture_skps
Patch Set: Use new method in util.go 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 unified diff | Download patch
OLDNEW
1 // Application that runs lua scripts over the specified SKP repository. 1 // Application that runs lua scripts over the specified SKP repository.
2 package main 2 package main
3 3
4 import ( 4 import (
5 "flag" 5 "flag"
6 "fmt"
7 "io" 6 "io"
8 "os" 7 "os"
8 "path"
9 "path/filepath" 9 "path/filepath"
10 "strconv"
10 "time" 11 "time"
11 12
12 "github.com/skia-dev/glog" 13 "github.com/skia-dev/glog"
13 14
14 "go.skia.org/infra/ct/go/util" 15 "go.skia.org/infra/ct/go/util"
15 "go.skia.org/infra/ct/go/worker_scripts/worker_common" 16 "go.skia.org/infra/ct/go/worker_scripts/worker_common"
16 "go.skia.org/infra/go/common" 17 "go.skia.org/infra/go/common"
17 skutil "go.skia.org/infra/go/util" 18 skutil "go.skia.org/infra/go/util"
18 ) 19 )
19 20
20 var ( 21 var (
21 » workerNum = flag.Int("worker_num", 1, "The number of this CT worker. It will be in the {1..100} range.") 22 » startRange = flag.Int("start_range", 1, "The number this worker will run lua scripts from.")
23 » num = flag.Int("num", 100, "The total number of SKPs to run on starting from the start_range.")
22 pagesetType = flag.String("pageset_type", util.PAGESET_TYPE_MOBILE_10k , "The type of pagesets to create from the Alexa CSV list. Eg: 10k, Mobile10k, A ll.") 24 pagesetType = flag.String("pageset_type", util.PAGESET_TYPE_MOBILE_10k , "The type of pagesets to create from the Alexa CSV list. Eg: 10k, Mobile10k, A ll.")
23 chromiumBuild = flag.String("chromium_build", "", "The chromium build th at was used to create the SKPs we would like to run lua scripts against.") 25 chromiumBuild = flag.String("chromium_build", "", "The chromium build th at was used to create the SKPs we would like to run lua scripts against.")
24 runID = flag.String("run_id", "", "The unique run id (typically requester + timestamp).") 26 runID = flag.String("run_id", "", "The unique run id (typically requester + timestamp).")
25 ) 27 )
26 28
27 func main() { 29 func main() {
28 defer common.LogPanic() 30 defer common.LogPanic()
29 worker_common.Init() 31 worker_common.Init()
30 defer util.TimeTrack(time.Now(), "Running Lua Scripts") 32 defer util.TimeTrack(time.Now(), "Running Lua Scripts")
31 defer glog.Flush() 33 defer glog.Flush()
32 34
33 if *chromiumBuild == "" { 35 if *chromiumBuild == "" {
34 glog.Error("Must specify --chromium_build") 36 glog.Error("Must specify --chromium_build")
35 return 37 return
36 } 38 }
37 if *runID == "" { 39 if *runID == "" {
38 glog.Error("Must specify --run_id") 40 glog.Error("Must specify --run_id")
39 return 41 return
40 } 42 }
41 43
42 // Create the task file so that the master knows this worker is still bu sy.
43 skutil.LogErr(util.CreateTaskFile(util.ACTIVITY_RUNNING_LUA_SCRIPTS))
44 defer util.DeleteTaskFile(util.ACTIVITY_RUNNING_LUA_SCRIPTS)
45
46 // Sync Skia tree. 44 // Sync Skia tree.
47 skutil.LogErr(util.SyncDir(util.SkiaTreeDir)) 45 skutil.LogErr(util.SyncDir(util.SkiaTreeDir))
48 46
49 // Build tools. 47 // Build tools.
50 skutil.LogErr(util.BuildSkiaTools()) 48 skutil.LogErr(util.BuildSkiaTools())
51 49
52 // Instantiate GsUtil object. 50 // Instantiate GsUtil object.
53 gs, err := util.NewGsUtil(nil) 51 gs, err := util.NewGsUtil(nil)
54 if err != nil { 52 if err != nil {
55 glog.Error(err) 53 glog.Error(err)
56 return 54 return
57 } 55 }
58 56
59 // Download SKPs if they do not exist locally. 57 // Download SKPs if they do not exist locally.
60 » if err := gs.DownloadWorkerArtifacts(util.SKPS_DIR_NAME, filepath.Join(* pagesetType, *chromiumBuild), *workerNum); err != nil { 58 » localSkpsDir := filepath.Join(util.SkpsDir, *pagesetType, *chromiumBuild )
59 » if _, err := gs.DownloadSwarmingArtifacts(localSkpsDir, util.SKPS_DIR_NA ME, path.Join(*pagesetType, *chromiumBuild), *startRange, *num); err != nil {
61 glog.Error(err) 60 glog.Error(err)
62 return 61 return
63 } 62 }
64 » localSkpsDir := filepath.Join(util.SkpsDir, *pagesetType, *chromiumBuild ) 63 » defer skutil.RemoveAll(localSkpsDir)
65 64
66 // Download the lua script for this run from Google storage. 65 // Download the lua script for this run from Google storage.
67 luaScriptName := *runID + ".lua" 66 luaScriptName := *runID + ".lua"
68 luaScriptLocalPath := filepath.Join(os.TempDir(), luaScriptName) 67 luaScriptLocalPath := filepath.Join(os.TempDir(), luaScriptName)
69 remoteDir := filepath.Join(util.LuaRunsDir, *runID) 68 remoteDir := filepath.Join(util.LuaRunsDir, *runID)
70 luaScriptRemotePath := filepath.Join(remoteDir, "scripts", luaScriptName ) 69 luaScriptRemotePath := filepath.Join(remoteDir, "scripts", luaScriptName )
71 respBody, err := gs.GetRemoteFileContents(luaScriptRemotePath) 70 respBody, err := gs.GetRemoteFileContents(luaScriptRemotePath)
72 if err != nil { 71 if err != nil {
73 glog.Errorf("Could not fetch %s: %s", luaScriptRemotePath, err) 72 glog.Errorf("Could not fetch %s: %s", luaScriptRemotePath, err)
74 return 73 return
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 err = util.ExecuteCmd( 111 err = util.ExecuteCmd(
113 filepath.Join(util.SkiaTreeDir, "out", "Release", util.BINARY_LU A_PICTURES), args, 112 filepath.Join(util.SkiaTreeDir, "out", "Release", util.BINARY_LU A_PICTURES), args,
114 []string{}, util.LUA_PICTURES_TIMEOUT, stdoutFile, stderrFile) 113 []string{}, util.LUA_PICTURES_TIMEOUT, stdoutFile, stderrFile)
115 if err != nil { 114 if err != nil {
116 glog.Error(err) 115 glog.Error(err)
117 return 116 return
118 } 117 }
119 118
120 // Copy stdout and stderr files to Google Storage. 119 // Copy stdout and stderr files to Google Storage.
121 skutil.LogErr( 120 skutil.LogErr(
122 » » gs.UploadFile(stdoutFileName, os.TempDir(), filepath.Join(remote Dir, fmt.Sprintf("slave%d", *workerNum), "outputs"))) 121 » » gs.UploadFile(stdoutFileName, os.TempDir(), filepath.Join(remote Dir, strconv.Itoa(*startRange), "outputs")))
123 skutil.LogErr( 122 skutil.LogErr(
124 » » gs.UploadFile(stderrFileName, os.TempDir(), filepath.Join(remote Dir, fmt.Sprintf("slave%d", *workerNum), "errors"))) 123 » » gs.UploadFile(stderrFileName, os.TempDir(), filepath.Join(remote Dir, strconv.Itoa(*startRange), "errors")))
125 } 124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698