@@ -20,18 +20,18 @@ import (
20
20
)
21
21
22
22
func TestGetRedisKey (t * testing.T ) {
23
- assert .Equal (t , "RESULTS_SUMMARY -1" , getRedisKey (shared.TestRun {
23
+ assert .Equal (t , "RESULTS_SUMMARY_v2 -1" , getSummaryFileRedisKey (shared.TestRun {
24
24
ID : 1 ,
25
25
}))
26
26
}
27
27
28
- func TestLoadOldSummaries_success (t * testing.T ) {
28
+ func TestLoadSummaries_success (t * testing.T ) {
29
29
mockCtrl := gomock .NewController (t )
30
30
defer mockCtrl .Finish ()
31
31
32
32
urls := []string {
33
- "https://example.com/1-summary .json.gz" ,
34
- "https://example.com/2-summary .json.gz" ,
33
+ "https://example.com/1-summary_v2 .json.gz" ,
34
+ "https://example.com/2-summary_v2 .json.gz" ,
35
35
}
36
36
testRuns := []shared.TestRun {
37
37
{
@@ -44,64 +44,8 @@ func TestLoadOldSummaries_success(t *testing.T) {
44
44
},
45
45
}
46
46
keys := []string {
47
- getRedisKey (testRuns [0 ]),
48
- getRedisKey (testRuns [1 ]),
49
- }
50
-
51
- cachedStore := sharedtest .NewMockCachedStore (mockCtrl )
52
- sh := unstructuredSearchHandler {queryHandler {dataSource : cachedStore }}
53
- summaryBytes := [][]byte {
54
- []byte (`{"/a/b/c":[1,2]}` ),
55
- []byte (`{"/x/y/z":[3,4]}` ),
56
- }
57
- summaries := []summary {
58
- {
59
- oldFormat : map [string ][]int {"/a/b/c" : {1 , 2 }},
60
- newFormat : map [string ]SummaryResult {"/a/b/c" : {Status : "" , Counts : []int (nil )}},
61
- },
62
- {
63
- oldFormat : map [string ][]int {"/x/y/z" : {3 , 4 }},
64
- newFormat : map [string ]SummaryResult {"/x/y/z" : {Status : "" , Counts : []int (nil )}},
65
- },
66
- }
67
-
68
- bindCopySlice := func (i int ) func (_ , _ , _ interface {}) {
69
- return func (cid , sid , iv interface {}) {
70
- ptr := iv .(* []byte )
71
- * ptr = summaryBytes [i ]
72
- }
73
- }
74
- for i , key := range keys {
75
- cachedStore .EXPECT ().Get (key , urls [i ], gomock .Any ()).Do (bindCopySlice (i )).Return (nil )
76
- }
77
-
78
- ss , err := sh .loadSummaries (testRuns )
79
- assert .Nil (t , err )
80
- assert .Equal (t , summaries [0 ], ss [0 ])
81
- assert .Equal (t , summaries [1 ], ss [1 ])
82
- }
83
-
84
- func TestLoadNewSummaries_success (t * testing.T ) {
85
- mockCtrl := gomock .NewController (t )
86
- defer mockCtrl .Finish ()
87
-
88
- urls := []string {
89
- "https://example.com/1-summary.json.gz" ,
90
- "https://example.com/2-summary.json.gz" ,
91
- }
92
- testRuns := []shared.TestRun {
93
- {
94
- ID : 1 ,
95
- ResultsURL : urls [0 ],
96
- },
97
- {
98
- ID : 2 ,
99
- ResultsURL : urls [1 ],
100
- },
101
- }
102
- keys := []string {
103
- getRedisKey (testRuns [0 ]),
104
- getRedisKey (testRuns [1 ]),
47
+ getSummaryFileRedisKey (testRuns [0 ]),
48
+ getSummaryFileRedisKey (testRuns [1 ]),
105
49
}
106
50
107
51
cachedStore := sharedtest .NewMockCachedStore (mockCtrl )
@@ -111,14 +55,8 @@ func TestLoadNewSummaries_success(t *testing.T) {
111
55
[]byte (`{"/x/y/z":{"s":"E","c":[3,4]}}` ),
112
56
}
113
57
summaries := []summary {
114
- {
115
- oldFormat : nil ,
116
- newFormat : map [string ]SummaryResult {"/a/b/c" : {Status : "O" , Counts : []int {1 , 2 }}},
117
- },
118
- {
119
- oldFormat : nil ,
120
- newFormat : map [string ]SummaryResult {"/x/y/z" : {Status : "E" , Counts : []int {3 , 4 }}},
121
- },
58
+ map [string ]SummaryResult {"/a/b/c" : {Status : "O" , Counts : []int {1 , 2 }}},
59
+ map [string ]SummaryResult {"/x/y/z" : {Status : "E" , Counts : []int {3 , 4 }}},
122
60
}
123
61
124
62
bindCopySlice := func (i int ) func (_ , _ , _ interface {}) {
@@ -142,8 +80,8 @@ func TestLoadSummaries_fail(t *testing.T) {
142
80
defer mockCtrl .Finish ()
143
81
144
82
urls := []string {
145
- "https://example.com/1-summary .json.gz" ,
146
- "https://example.com/2-summary .json.gz" ,
83
+ "https://example.com/1-summary_v2 .json.gz" ,
84
+ "https://example.com/2-summary_v2 .json.gz" ,
147
85
}
148
86
testRuns := []shared.TestRun {
149
87
{
@@ -156,14 +94,14 @@ func TestLoadSummaries_fail(t *testing.T) {
156
94
},
157
95
}
158
96
keys := []string {
159
- getRedisKey (testRuns [0 ]),
160
- getRedisKey (testRuns [1 ]),
97
+ getSummaryFileRedisKey (testRuns [0 ]),
98
+ getSummaryFileRedisKey (testRuns [1 ]),
161
99
}
162
100
163
101
cachedStore := sharedtest .NewMockCachedStore (mockCtrl )
164
102
sh := unstructuredSearchHandler {queryHandler {dataSource : cachedStore }}
165
103
summaryBytes := [][]byte {
166
- []byte (`{"/a/b/c":[1,2]}` ),
104
+ []byte (`{"/a/b/c":{"s":"O","c": [1,2]} }` ),
167
105
}
168
106
169
107
storeMiss := errors .New ("No such summary file" )
@@ -177,6 +115,19 @@ func TestLoadSummaries_fail(t *testing.T) {
177
115
assert .Contains (t , err .Error (), storeMiss .Error ())
178
116
}
179
117
118
+ func TestSummaryIsValid_v1 (t * testing.T ) {
119
+ qh := queryHandler {}
120
+ // Summaries without the "_v2" suffix should not be used.
121
+ url := "https://example.com/invalid-summary.json.gz"
122
+ assert .False (t , qh .summaryIsValid (url ))
123
+ }
124
+
125
+ func TestSummaryIsValid_v2 (t * testing.T ) {
126
+ qh := queryHandler {}
127
+ url := "https://example.com/valid-summary_v2.json.gz"
128
+ assert .True (t , qh .summaryIsValid (url ))
129
+ }
130
+
180
131
func TestGetRunsAndFilters_default (t * testing.T ) {
181
132
mockCtrl := gomock .NewController (t )
182
133
defer mockCtrl .Finish ()
@@ -190,8 +141,8 @@ func TestGetRunsAndFilters_default(t *testing.T) {
190
141
191
142
runIDs := []int64 {1 , 2 }
192
143
urls := []string {
193
- "https://example.com/1-summary .json.gz" ,
194
- "https://example.com/2-summary .json.gz" ,
144
+ "https://example.com/1-summary_v2 .json.gz" ,
145
+ "https://example.com/2-summary_v2 .json.gz" ,
195
146
}
196
147
chrome , _ := shared .ParseProductSpec ("chrome" )
197
148
edge , _ := shared .ParseProductSpec ("edge" )
@@ -240,8 +191,8 @@ func TestGetRunsAndFilters_specificRunIDs(t *testing.T) {
240
191
241
192
runIDs := []int64 {1 , 2 }
242
193
urls := []string {
243
- "https://example.com/1-summary .json.gz" ,
244
- "https://example.com/2-summary .json.gz" ,
194
+ "https://example.com/1-summary_v2 .json.gz" ,
195
+ "https://example.com/2-summary_v2 .json.gz" ,
245
196
}
246
197
chrome , _ := shared .ParseProductSpec ("chrome" )
247
198
edge , _ := shared .ParseProductSpec ("edge" )
0 commit comments