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

Side by Side Diff: perf/server/src/tiletool/main.go

Issue 388273002: Add a command line tool for validating the tileStore. (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « perf/server/Makefile ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // tiletool is a command line application to validate a tile store.
2 package main
3
4 import (
5 "flag"
6 "fmt"
7 "log"
8 "time"
9 )
10
11 import (
12 "config"
13 "filetilestore"
14 "types"
15 )
16
17 // flags
18 var (
19 tileDir = flag.String("tile_dir", "/tmp/tileStore", "What directory t o look for tiles in.")
20 verbose = flag.Bool("verbose", false, "Verbose.")
21 echoHashes = flag.Bool("echo_hashes", false, "Echo Git hashes during val idation.")
22 )
23
24 // validateTile validates a tile by confirming that all the commits are in
25 // ascending order.
26 //
27 // Also checks that none of the commits overlap with the following tile by
28 // making sure each commit appears before oldestTS.
29 func validateTile(tile *types.Tile, oldestTS int64) error {
30 var lastTS int64 = 0
31 lastHash := ""
32 if *verbose {
33 fmt.Println("Number of Commits:", len(tile.Commits))
34 }
kelvinly 2014/07/14 15:23:30 Would it make sense to also make sure the tileId a
jcgregorio 2014/07/14 15:30:29 Done.
35 for i, c := range tile.Commits {
36 if *echoHashes {
37 fmt.Println("Hash:", c.Hash, c.CommitTime)
38 }
39 if c.CommitTime > oldestTS {
40 fmt.Printf("ERROR: Tiles out of order: Commit (%s) %d ti mestamp is %d, which appears after %d\n", c.Hash, i, c.CommitTime, oldestTS)
41 }
42 if c.CommitTime < lastTS {
43 return fmt.Errorf("Commits out of order: Commit (%s) %d timestamp is %d, which appears before (%s) %d\n", c.Hash, i, c.CommitTime, lastH ash, lastTS)
44 }
45 lastTS = c.CommitTime
46 lastHash = c.Hash
47 }
48
49 if *verbose {
50 fmt.Println("Number of traces:", len(tile.Traces))
51 }
52
53 // Make sure each Trace is the right length.
54 numCommits := len(tile.Commits)
55 for _, trace := range tile.Traces {
56 if len(trace.Values) != numCommits {
57 return fmt.Errorf("Trace lenght incorrect: Num Commits % d != Values in trace %d for Key %s", numCommits, len(trace.Values), trace.Key)
58 }
59 }
60
61 return nil
62 }
63
64 // validateDataset validates all the tiles stored in a TileStore.
65 func validateDataset(store types.TileStore) bool {
66 index := -1
67 isValid := true
68 // If tilebuilding were instantaneous this might cause a false negative, but
69 // it's not.
70 oldestTS := time.Now().Unix()
71
72 for {
73 tile, err := store.Get(0, index)
74 if err != nil {
75 fmt.Printf("Failed to Get(0, %d): %s\n", index, err)
76 isValid = false
77 break
78 }
79 if *verbose {
80 fmt.Println("TileIndex:", tile.TileIndex)
81 }
82 // Validate the git hashes in the tile.
83 err = validateTile(tile, oldestTS)
84 oldestTS = tile.Commits[0].CommitTime
85 if err != nil {
86 fmt.Printf("Failed to validate tile %d scale 0: %s\n", i ndex, err)
87 isValid = false
88 break
89 }
90 if tile.TileIndex > 0 {
91 index = tile.TileIndex - 1
92 } else {
93 break
94 }
95 }
96
97 return isValid
98 }
99
100 func main() {
101 flag.Parse()
102 valid := true
103 for _, name := range config.ALL_DATASET_NAMES {
104 fmt.Printf("Validating dataset: %s\n", string(name))
105 store := filetilestore.NewFileTileStore(*tileDir, string(name))
106 valid = valid && validateDataset(store)
107 }
108 if !valid {
109 log.Fatal("FAILED Validation.")
110 }
111 }
OLDNEW
« no previous file with comments | « perf/server/Makefile ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698