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

Side by Side Diff: golden/go/analysis/analysis_test.go

Issue 884943003: Ignore traces (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Created 5 years, 10 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 | « golden/go/analysis/analysis.go ('k') | golden/go/analysis/status.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package analysis 1 package analysis
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "os" 5 "os"
6 "sort" 6 "sort"
7 "strings" 7 "strings"
8 "testing" 8 "testing"
9 "time" 9 "time"
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 "t4": map[string]types.Label{"d_44": types.POSITIVE}, 76 "t4": map[string]types.Label{"d_44": types.POSITIVE},
77 } 77 }
78 STATUS_OK_2, UNTRIAGED_COUNT_2, NEGATIVE_COUNT_2 := true, 0, 0 78 STATUS_OK_2, UNTRIAGED_COUNT_2, NEGATIVE_COUNT_2 := true, 0, 0
79 79
80 assert.Equal(t, len(digests), len(params)) 80 assert.Equal(t, len(digests), len(params))
81 assert.Equal(t, len(digests[0]), len(commits)) 81 assert.Equal(t, len(digests[0]), len(commits))
82 82
83 diffStore := NewMockDiffStore() 83 diffStore := NewMockDiffStore()
84 expStore := expstorage.NewMemExpectationsStore() 84 expStore := expstorage.NewMemExpectationsStore()
85 tileStore := NewMockTileStore(t, digests, params, commits) 85 tileStore := NewMockTileStore(t, digests, params, commits)
86 ignoreStore := types.NewMemIgnoreStore()
86 timeBetweenPolls := 10 * time.Hour 87 timeBetweenPolls := 10 * time.Hour
87 » a := NewAnalyzer(expStore, tileStore, diffStore, mockUrlGenerator, timeB etweenPolls) 88 » a := NewAnalyzer(expStore, tileStore, diffStore, ignoreStore, mockUrlGen erator, timeBetweenPolls)
88 89
89 allTests, err := a.ListTestDetails(nil) 90 allTests, err := a.ListTestDetails(nil)
90 assert.Nil(t, err) 91 assert.Nil(t, err)
91 92
92 // Poll until ready 93 // Poll until ready
93 for allTests == nil { 94 for allTests == nil {
94 time.Sleep(10 * time.Millisecond) 95 time.Sleep(10 * time.Millisecond)
95 allTests, err = a.ListTestDetails(nil) 96 allTests, err = a.ListTestDetails(nil)
96 assert.Nil(t, err) 97 assert.Nil(t, err)
97 } 98 }
98 assert.NotNil(t, allTests) 99 assert.NotNil(t, allTests)
99 assert.Equal(t, len(params), len(allTests.Tests)) 100 assert.Equal(t, len(params), len(allTests.Tests))
100 101
101 // Make sure the lookup function works correctly. 102 // Make sure the lookup function works correctly.
102 » for _, oneTest := range a.currentTestDetails.Tests { 103 » for _, oneTest := range a.current.TestDetails.Tests {
103 » » found := a.currentTestDetails.lookup(oneTest.Name) 104 » » found := a.current.TestDetails.lookup(oneTest.Name)
104 assert.NotNil(t, found) 105 assert.NotNil(t, found)
105 assert.Equal(t, oneTest, found) 106 assert.Equal(t, oneTest, found)
106 } 107 }
107 108
108 test1, err := a.GetTestDetails("t1", nil) 109 test1, err := a.GetTestDetails("t1", nil)
109 assert.Nil(t, err) 110 assert.Nil(t, err)
110 assert.NotNil(t, test1) 111 assert.NotNil(t, test1)
111 assert.Equal(t, commits, test1.Commits) 112 assert.Equal(t, commits, test1.Commits)
112 assert.Equal(t, 1, len(test1.Tests)) 113 assert.Equal(t, 1, len(test1.Tests))
113 assert.Equal(t, 0, len(test1.Query)) 114 assert.Equal(t, 0, len(test1.Query))
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // Download the testdata and remove the testdata directory at the end. 175 // Download the testdata and remove the testdata directory at the end.
175 err := testutils.DownloadTestDataFile(TEST_DATA_STORAGE_PATH, TEST_DATA_ PATH) 176 err := testutils.DownloadTestDataFile(TEST_DATA_STORAGE_PATH, TEST_DATA_ PATH)
176 assert.Nil(t, err, "Unable to download testdata.") 177 assert.Nil(t, err, "Unable to download testdata.")
177 defer func() { 178 defer func() {
178 os.RemoveAll(TEST_DATA_DIR) 179 os.RemoveAll(TEST_DATA_DIR)
179 }() 180 }()
180 181
181 diffStore := NewMockDiffStore() 182 diffStore := NewMockDiffStore()
182 expStore := expstorage.NewMemExpectationsStore() 183 expStore := expstorage.NewMemExpectationsStore()
183 tileStore := NewMockTileStoreFromJson(t, TEST_DATA_PATH) 184 tileStore := NewMockTileStoreFromJson(t, TEST_DATA_PATH)
185 ignoreStore := types.NewMemIgnoreStore()
184 timeBetweenPolls := 10 * time.Hour 186 timeBetweenPolls := 10 * time.Hour
185 » a := NewAnalyzer(expStore, tileStore, diffStore, mockUrlGenerator, timeB etweenPolls) 187 » a := NewAnalyzer(expStore, tileStore, diffStore, ignoreStore, mockUrlGen erator, timeBetweenPolls)
186 188
187 // Poll until the Analyzer has process the tile. 189 // Poll until the Analyzer has process the tile.
188 var allTests *GUITestDetails 190 var allTests *GUITestDetails
189 allTests, err = a.ListTestDetails(nil) 191 allTests, err = a.ListTestDetails(nil)
190 assert.Nil(t, err) 192 assert.Nil(t, err)
191 for allTests == nil { 193 for allTests == nil {
192 time.Sleep(10 * time.Millisecond) 194 time.Sleep(10 * time.Millisecond)
193 allTests, err = a.ListTestDetails(nil) 195 allTests, err = a.ListTestDetails(nil)
194 assert.Nil(t, err) 196 assert.Nil(t, err)
195 } 197 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 assert.True(t, commitIds[0] < len(oneTest.Commits)) 233 assert.True(t, commitIds[0] < len(oneTest.Commits))
232 assert.True(t, commitIds[0] >= 0) 234 assert.True(t, commitIds[0] >= 0)
233 for i := 1; i < len(commitIds); i++ { 235 for i := 1; i < len(commitIds); i++ {
234 assert.True(t, commitIds[i-1] < commitIds[i], fm t.Sprintf("%d is not smaller than %d", commitIds[i-1], commitIds[i])) 236 assert.True(t, commitIds[i-1] < commitIds[i], fm t.Sprintf("%d is not smaller than %d", commitIds[i-1], commitIds[i]))
235 assert.True(t, commitIds[i] < len(oneTest.Commit s)) 237 assert.True(t, commitIds[i] < len(oneTest.Commit s))
236 assert.True(t, commitIds[i] >= 0) 238 assert.True(t, commitIds[i] >= 0)
237 } 239 }
238 } 240 }
239 241
240 // Go through the current tile and check whether the digests mat ch up. 242 // Go through the current tile and check whether the digests mat ch up.
241 » » for _, trace := range a.currentTile.Traces[testName] { 243 » » for _, trace := range a.current.Tile.Traces[testName] {
242 for idx, digest := range trace.Digests { 244 for idx, digest := range trace.Digests {
243 assert.NotNil(t, commitsBD[digest], fmt.Sprintf( "Did not find digest: %s in \n %v", digest, commitsBD)) 245 assert.NotNil(t, commitsBD[digest], fmt.Sprintf( "Did not find digest: %s in \n %v", digest, commitsBD))
244 assert.NotEqual(t, len(commitsBD[digest]), sort. SearchInts(commitsBD[digest], trace.CommitIds[idx])) 246 assert.NotEqual(t, len(commitsBD[digest]), sort. SearchInts(commitsBD[digest], trace.CommitIds[idx]))
245 } 247 }
246 } 248 }
247 } 249 }
248 250
249 // Get the status. 251 // Get the status.
250 status := a.GetStatus() 252 status := a.GetStatus()
251 253
252 // Query over all corpora. 254 // Query over all corpora.
253 allTests, err = a.ListTestDetails(nil) 255 allTests, err = a.ListTestDetails(nil)
254 assert.Nil(t, err) 256 assert.Nil(t, err)
255 assert.NotNil(t, allTests.AllParams) 257 assert.NotNil(t, allTests.AllParams)
256 258
257 // Query each corpus individually and make sure the results make sense. 259 // Query each corpus individually and make sure the results make sense.
258 testCount := 0 260 testCount := 0
259 testParams := map[string][]string{} 261 testParams := map[string][]string{}
260 for corpus, _ := range status.CorpStatus { 262 for corpus, _ := range status.CorpStatus {
261 q := map[string][]string{"source_type": []string{corpus}} 263 q := map[string][]string{"source_type": []string{corpus}}
262 corpusTests, err := a.ListTestDetails(q) 264 corpusTests, err := a.ListTestDetails(q)
265 q["head"] = []string{"0"}
263 assert.Nil(t, err) 266 assert.Nil(t, err)
264 assert.Equal(t, q, corpusTests.Query) 267 assert.Equal(t, q, corpusTests.Query)
265 assert.NotEqual(t, allTests.AllParams, corpusTests.AllParams) 268 assert.NotEqual(t, allTests.AllParams, corpusTests.AllParams)
266 269
267 testCount += len(corpusTests.Tests) 270 testCount += len(corpusTests.Tests)
268 addParams(testParams, corpusTests.AllParams) 271 addParams(testParams, corpusTests.AllParams)
269 } 272 }
270 assert.Equal(t, len(allTests.Tests), testCount) 273 assert.Equal(t, len(allTests.Tests), testCount)
271 assert.Equal(t, len(allTests.AllParams), len(testParams)) 274 assert.Equal(t, len(allTests.AllParams), len(testParams))
272 for param, values := range allTests.AllParams { 275 for param, values := range allTests.AllParams {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 } 334 }
332 335
333 func (m MockDiffStore) AbsPath(digest []string) map[string]string { 336 func (m MockDiffStore) AbsPath(digest []string) map[string]string {
334 result := map[string]string{} 337 result := map[string]string{}
335 for _, d := range digest { 338 for _, d := range digest {
336 result[d] = "abspath/" + d 339 result[d] = "abspath/" + d
337 } 340 }
338 return result 341 return result
339 } 342 }
340 343
341 func (m MockDiffStore) IgnorableDigests() map[string]bool { 344 func (m MockDiffStore) UnavailableDigests() map[string]bool {
342 return nil 345 return nil
343 } 346 }
344 347
345 func NewMockDiffStore() diff.DiffStore { 348 func NewMockDiffStore() diff.DiffStore {
346 return MockDiffStore{} 349 return MockDiffStore{}
347 } 350 }
348 351
349 // Mock the tilestore for GoldenTraces 352 // Mock the tilestore for GoldenTraces
350 func NewMockTileStore(t *testing.T, digests [][]string, params []map[string]stri ng, commits []*ptypes.Commit) ptypes.TileStore { 353 func NewMockTileStore(t *testing.T, digests [][]string, params []map[string]stri ng, commits []*ptypes.Commit) ptypes.TileStore {
351 // Build the tile from the digests, params and commits. 354 // Build the tile from the digests, params and commits.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 402 }
400 403
401 func (m *MockTileStore) Put(scale, index int, tile *ptypes.Tile) error { 404 func (m *MockTileStore) Put(scale, index int, tile *ptypes.Tile) error {
402 assert.FailNow(m.t, "Should not be called.") 405 assert.FailNow(m.t, "Should not be called.")
403 return nil 406 return nil
404 } 407 }
405 408
406 func (m *MockTileStore) GetModifiable(scale, index int) (*ptypes.Tile, error) { 409 func (m *MockTileStore) GetModifiable(scale, index int) (*ptypes.Tile, error) {
407 return m.Get(scale, index) 410 return m.Get(scale, index)
408 } 411 }
OLDNEW
« no previous file with comments | « golden/go/analysis/analysis.go ('k') | golden/go/analysis/status.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698