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

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 }
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 %s, which appears after %s\n", c.Hash, i, time.Unix(c.CommitTime, 0), time.Unix(oldestTS, 0))
41 }
42 if c.CommitTime < lastTS {
43 return fmt.Errorf("Commits out of order: Commit (%s) %d timestamp is %s, which appears before (%s) %s\n", c.Hash, i, time.Unix(c.CommitT ime, 0), lastHash, time.Unix(lastTS, 0))
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 length 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 fmt.Println("Tile range:", tile.Commits[0].CommitTime, t ile.Commits[len(tile.Commits)-1].CommitTime)
82 fmt.Println("Tile range:", time.Unix(tile.Commits[0].Com mitTime, 0), time.Unix(tile.Commits[len(tile.Commits)-1].CommitTime, 0))
83 }
84 // Validate the git hashes in the tile.
85 err = validateTile(tile, oldestTS)
86 oldestTS = tile.Commits[0].CommitTime
87 if err != nil {
88 fmt.Printf("Failed to validate tile %d scale 0: %s\n", i ndex, err)
89 isValid = false
90 break
91 }
92 if index > 0 && index != tile.TileIndex {
93 fmt.Printf("Tile index inconsistent: index %d != tile.Ti leIndex %d\n", index, tile.TileIndex)
94 isValid = false
95 break
96 }
97 if tile.Scale != 0 {
98 fmt.Printf("Tile scale isn't 0: tile.Scale %d\n", tile.S cale)
99 isValid = false
100 break
101 }
102 if tile.TileIndex > 0 {
103 index = tile.TileIndex - 1
104 } else {
105 break
106 }
107 }
108
109 return isValid
110 }
111
112 func main() {
113 flag.Parse()
114 valid := true
115 for _, name := range config.ALL_DATASET_NAMES {
116 fmt.Printf("Validating dataset: %s\n", string(name))
117 store := filetilestore.NewFileTileStore(*tileDir, string(name))
118 valid = valid && validateDataset(store)
119 }
120 if !valid {
121 log.Fatal("FAILED Validation.")
122 }
123 }
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