Skip to content

Commit c77d72f

Browse files
committed
change legacy to 2010-suite
1 parent 4ab1233 commit c77d72f

11 files changed

Lines changed: 90 additions & 59 deletions

File tree

‎codespeed/fixtures/jruby.json‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎codespeed/fixtures/testdata.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
"fields": {
220220
"name": "float",
221221
"parent": null,
222-
"source": "legacy",
222+
"source": "2010-suite",
223223
"data_type": "U",
224224
"description": "",
225225
"units_title": "Time",
@@ -234,7 +234,7 @@
234234
"fields": {
235235
"name": "int",
236236
"parent": null,
237-
"source": "legacy",
237+
"source": "2010-suite",
238238
"data_type": "U",
239239
"description": "",
240240
"units_title": "Time",

‎codespeed/fixtures/timeline_tests.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
"fields": {
211211
"parent": null,
212212
"name": "float",
213-
"source": "legacy",
213+
"source": "2010-suite",
214214
"default_on_comparison": true,
215215
"units_title": "Time",
216216
"units": "seconds",
@@ -224,7 +224,7 @@
224224
"fields": {
225225
"parent": null,
226226
"name": "int",
227-
"source": "legacy",
227+
"source": "2010-suite",
228228
"default_on_comparison": true,
229229
"units_title": "Time",
230230
"units": "seconds",

‎codespeed/models.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ def __str__(self):
176176

177177
class Benchmark(models.Model):
178178
S_TYPES = (
179-
('legacy', 'Legacy'),
179+
('2010-suite', '2010-suite'),
180180
('pyperformance', 'PyPerformance'),
181181
)
182+
# Former source names, still accepted from uploaders and old permalinks
183+
SOURCE_ALIASES = {'legacy': '2010-suite'}
182184
D_TYPES = (
183185
('U', 'Mean'),
184186
('M', 'Median'),
@@ -189,7 +191,7 @@ class Benchmark(models.Model):
189191
'self', on_delete=models.CASCADE, verbose_name="parent",
190192
help_text="allows to group benchmarks in hierarchies",
191193
null=True, blank=True, default=None)
192-
source = models.CharField(max_length=14, choices=S_TYPES, default='legacy')
194+
source = models.CharField(max_length=14, choices=S_TYPES, default='2010-suite')
193195
data_type = models.CharField(max_length=1, choices=D_TYPES, default='U')
194196
description = models.CharField(max_length=300, blank=True)
195197
units_title = models.CharField(max_length=30, default='Time')
@@ -198,6 +200,10 @@ class Benchmark(models.Model):
198200
default_on_comparison = models.BooleanField(
199201
"Default on comparison page", default=True)
200202

203+
@classmethod
204+
def normalize_source(cls, source):
205+
return cls.SOURCE_ALIASES.get(source, source)
206+
201207
class Meta:
202208
unique_together = (('name', 'source'),)
203209

‎codespeed/results.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ def validate_result(item):
3939
return 'Value for key "' + key + '" empty in request', error
4040

4141
# 'source' is optional: uploaders that predate it (pyperformance on
42-
# speed.python.org) get the 'legacy' default.
43-
if 'source' in item and item['source'] not in dict(Benchmark.S_TYPES):
42+
# speed.python.org) get the '2010-suite' default.
43+
if ('source' in item and
44+
Benchmark.normalize_source(item['source']) not in dict(Benchmark.S_TYPES)):
4445
return 'Invalid source "%s"' % item['source'], error
4546

4647
try:
@@ -73,7 +74,8 @@ def save_result(data, update_repo=True):
7374
branch, created = Branch.objects.get_or_create(name=data["branch"],
7475
project=p)
7576
b, created = Benchmark.objects.get_or_create(
76-
name=data["benchmark"], source=data.get("source", "legacy"))
77+
name=data["benchmark"],
78+
source=Benchmark.normalize_source(data.get("source", "2010-suite")))
7779

7880
if created:
7981
if "description" in data:

‎codespeed/static/js/timeline.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,8 @@ function setValuesOfInputFields(params) {
766766
var benchmark = valueOrDefault(params.ben, defaults.benchmark);
767767
var benchRadio = $("input:radio[name='benchmark']").filter("[value='" + benchmark + "']");
768768
if (benchRadio.length === 0 && benchmark !== "grid" && benchmark !== "show_none") {
769-
// backwards compat: a bare '<name>' permalink defaults to the legacy suite
770-
benchmark = benchmark + ".legacy";
769+
// backwards compat: a bare '<name>' permalink defaults to the 2010-suite
770+
benchmark = benchmark + ".2010-suite";
771771
benchRadio = $("input:radio[name='benchmark']").filter("[value='" + benchmark + "']");
772772
}
773773
benchRadio.prop('checked', true);

‎codespeed/tests/test_models.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def test_changes_table_row_has_bench_source(self):
190190
s1 = self.make_result(15)
191191
rep = self.make_report(s1)
192192
tablelist = rep.get_changes_table(force_save=True)
193-
self.assertEqual(tablelist[0]['rows'][0]['bench_source'], 'legacy')
193+
self.assertEqual(tablelist[0]['rows'][0]['bench_source'], '2010-suite')
194194

195195
def test_multiple_quantities(self):
196196
b1 = self.make_bench('b1', quantity='Space', units='bytes')
@@ -217,7 +217,7 @@ def test_stale_tablecache_is_rebuilt(self):
217217
Report.objects.filter(pk=report.pk).update(_tablecache=json.dumps(cached))
218218

219219
table = Report.objects.get(pk=report.pk).get_changes_table()
220-
self.assertEqual(table[0]['rows'][0]['bench_source'], 'legacy')
220+
self.assertEqual(table[0]['rows'][0]['bench_source'], '2010-suite')
221221
self.assertIn('"bench_source"',
222222
Report.objects.get(pk=report.pk)._tablecache)
223223

‎codespeed/tests/test_views.py‎

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def setUp(self):
3030
'benchmark': 'float',
3131
'environment': 'Dual Core',
3232
'result_value': 456,
33-
'source': 'legacy',
33+
'source': '2010-suite',
3434
}
3535

3636
def test_add_correct_result(self):
@@ -44,7 +44,7 @@ def test_add_correct_result(self):
4444
# Check that the data was correctly saved
4545
e = Environment.objects.get(name='Dual Core')
4646
b = Benchmark.objects.get(name='float')
47-
self.assertEqual(b.source, "legacy")
47+
self.assertEqual(b.source, "2010-suite")
4848
self.assertEqual(b.units, "seconds")
4949
self.assertEqual(b.lessisbetter, True)
5050
p = Project.objects.get(name='MyProject')
@@ -106,7 +106,7 @@ def test_bad_environment(self):
106106
def test_empty_argument(self):
107107
"""Should respond 400 when a POST request has an empty argument"""
108108
for key in self.data:
109-
if key == 'source': # optional, defaults to 'legacy'
109+
if key == 'source': # optional, defaults to '2010-suite'
110110
continue
111111
backup = self.data[key]
112112
self.data[key] = ""
@@ -120,7 +120,7 @@ def test_empty_argument(self):
120120
def test_missing_argument(self):
121121
"""Should respond 400 when a POST request is missing an argument"""
122122
for key in list(self.data):
123-
if key == 'source': # optional, defaults to 'legacy'
123+
if key == 'source': # optional, defaults to '2010-suite'
124124
continue
125125
backup = self.data[key]
126126
del self.data[key]
@@ -196,14 +196,23 @@ def test_source_set_on_new_benchmark(self):
196196
b = Benchmark.objects.get(name='newbench')
197197
self.assertEqual(b.source, 'pyperformance')
198198

199-
def test_source_defaults_to_legacy(self):
200-
"""A payload without a source creates a 'legacy' Benchmark"""
199+
def test_source_defaults_to_2010_suite(self):
200+
"""A payload without a source creates a '2010-suite' Benchmark"""
201201
modified_data = copy.deepcopy(self.data)
202202
del modified_data['source']
203203
response = self.client.post(self.path, modified_data)
204204
self.assertEqual(response.status_code, 202)
205205
b = Benchmark.objects.get(name='float')
206-
self.assertEqual(b.source, 'legacy')
206+
self.assertEqual(b.source, '2010-suite')
207+
208+
def test_former_source_name_is_accepted(self):
209+
"""Uploaders still sending the pre-rename source name are mapped"""
210+
modified_data = copy.deepcopy(self.data)
211+
modified_data['source'] = 'legacy'
212+
response = self.client.post(self.path, modified_data)
213+
self.assertEqual(response.status_code, 202)
214+
b = Benchmark.objects.get(name='float')
215+
self.assertEqual(b.source, '2010-suite')
207216

208217
def test_same_name_different_source_are_distinct(self):
209218
"""The same name in a different suite is a separate Benchmark"""
@@ -212,10 +221,10 @@ def test_same_name_different_source_are_distinct(self):
212221
modified_data['source'] = 'pyperformance'
213222
self.client.post(self.path, modified_data)
214223

215-
legacy = Benchmark.objects.get(name='float', source='legacy')
224+
suite2010 = Benchmark.objects.get(name='float', source='2010-suite')
216225
pyperf = Benchmark.objects.get(name='float', source='pyperformance')
217-
self.assertNotEqual(legacy.pk, pyperf.pk)
218-
self.assertEqual(legacy.results.count(), 1)
226+
self.assertNotEqual(suite2010.pk, pyperf.pk)
227+
self.assertEqual(suite2010.results.count(), 1)
219228
self.assertEqual(pyperf.results.count(), 1)
220229

221230
def test_invalid_source_rejected(self):
@@ -255,31 +264,31 @@ def setUp(self):
255264
'benchmark': 'Richards',
256265
'environment': 'bigdog',
257266
'result_value': 456,
258-
'source': 'legacy'},
267+
'source': '2010-suite'},
259268
{'commitid': '456',
260269
'project': 'pypy',
261270
'branch': 'default',
262271
'executable': 'pypy-c',
263272
'benchmark': 'Richards',
264273
'environment': 'bigdog',
265274
'result_value': 457,
266-
'source': 'legacy'},
275+
'source': '2010-suite'},
267276
{'commitid': '456',
268277
'project': 'pypy',
269278
'branch': 'default',
270279
'executable': 'pypy-c',
271280
'benchmark': 'Richards2',
272281
'environment': 'bigdog',
273282
'result_value': 34,
274-
'source': 'legacy'},
283+
'source': '2010-suite'},
275284
{'commitid': '789',
276285
'project': 'pypy',
277286
'branch': 'default',
278287
'executable': 'pypy-c',
279288
'benchmark': 'Richards',
280289
'environment': 'bigdog',
281290
'result_value': 458,
282-
'source': 'legacy'},
291+
'source': '2010-suite'},
283292
]
284293

285294
def test_get_returns_405(self):
@@ -301,7 +310,7 @@ def test_add_correct_results(self):
301310
# Check that the data was correctly saved
302311
e = Environment.objects.get(name='bigdog')
303312
b = Benchmark.objects.get(name='Richards')
304-
self.assertEqual(b.source, "legacy")
313+
self.assertEqual(b.source, "2010-suite")
305314
self.assertEqual(b.units, "seconds")
306315
self.assertEqual(b.lessisbetter, True)
307316
p = Project.objects.get(name='pypy')
@@ -356,7 +365,7 @@ def test_empty_argument(self):
356365
'''Should return 400 when making a request with an empty argument'''
357366
data = self.data[1]
358367
for key in data:
359-
if key == 'source': # optional, defaults to 'legacy'
368+
if key == 'source': # optional, defaults to '2010-suite'
360369
continue
361370
backup = data[key]
362371
data[key] = ""
@@ -372,7 +381,7 @@ def test_missing_argument(self):
372381
'''Should return 400 when making a request with a missing argument'''
373382
data = self.data[2]
374383
for key in list(data):
375-
if key == 'source': # optional, defaults to 'legacy'
384+
if key == 'source': # optional, defaults to '2010-suite'
376385
continue
377386
backup = data[key]
378387
del data[key]
@@ -523,19 +532,19 @@ def test_no_source_fold_with_one_source(self):
523532
response = self.client.get(reverse('timeline'))
524533
self.assertEqual(response.status_code, 200)
525534
self.assertIsNone(response.context['grid_revisions'])
526-
self.assertNotContains(response, 'class="togglefold">Legacy</a>')
535+
self.assertNotContains(response, 'class="togglefold">2010-suite</a>')
527536
self.assertContains(response, 'grid_revisions: null')
528537

529538
def test_source_fold_with_several_sources(self):
530539
Benchmark.objects.create(name='float', source='pyperformance')
531540
# Suites are rendered folded, except the one of the selected benchmark
532541
response = self.client.get(reverse('timeline'))
533-
self.assertContains(response, 'class="togglefold folded">Legacy</a>')
542+
self.assertContains(response, 'class="togglefold folded">2010-suite</a>')
534543
self.assertContains(
535544
response, 'class="togglefold folded">PyPerformance</a>')
536545
response = self.client.get(
537546
reverse('timeline'), {'ben': 'float.pyperformance'})
538-
self.assertContains(response, 'class="togglefold folded">Legacy</a>')
547+
self.assertContains(response, 'class="togglefold folded">2010-suite</a>')
539548
self.assertContains(response, 'class="togglefold">PyPerformance</a>')
540549

541550
@override_settings(TIMELINE_GRID_REVISIONS=25)
@@ -614,11 +623,18 @@ def test_groups_with_nothing_checked_are_rendered_folded(self):
614623
self.assertContains(
615624
response, 'class="togglefold folded">PyPerformance</a>')
616625

626+
def test_former_source_name_in_ben_param(self):
627+
"""Permalinks from before the rename still say ben=legacy"""
628+
from codespeed.views import _parse_ben_param
629+
Benchmark.objects.create(name='float', source='pyperformance')
630+
self.assertEqual(
631+
{b.source for b in _parse_ben_param('legacy')}, {'2010-suite'})
632+
617633
def test_benchmarks_grouped_by_source_with_several_sources(self):
618634
Benchmark.objects.create(name='float', source='pyperformance')
619635
response = self.client.get(self.path)
620636
self.assertEqual(list(response.context['benchmarks']),
621-
['Legacy', 'PyPerformance'])
637+
['2010-suite', 'PyPerformance'])
622638

623639

624640
@override_settings(ALLOW_ANONYMOUS_POST=True)
@@ -634,7 +650,7 @@ def setUp(self):
634650
'benchmark': 'float',
635651
'environment': 'Dual Core',
636652
'result_value': 200,
637-
'source': 'legacy',
653+
'source': '2010-suite',
638654
}
639655
resp = self.client.post(reverse('add-result'),
640656
self.data)

‎codespeed/tests/test_views_data.py‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,18 @@ def test_full_ident_with_valid_source_suffix(self):
294294
parse_benchmark_ident('mybenchmark.pyperformance'),
295295
('mybenchmark', 'pyperformance'))
296296
self.assertEqual(
297-
parse_benchmark_ident('mybenchmark.legacy'),
298-
('mybenchmark', 'legacy'))
297+
parse_benchmark_ident('mybenchmark.2010-suite'),
298+
('mybenchmark', '2010-suite'))
299299

300-
def test_bare_legacy_name_without_dot(self):
301-
Benchmark.objects.create(name='ai', source='legacy')
302-
self.assertEqual(parse_benchmark_ident('ai'), ('ai', 'legacy'))
300+
def test_former_source_name_is_an_alias(self):
301+
# Permalinks from before the rename still say '.legacy'
302+
self.assertEqual(
303+
parse_benchmark_ident('mybenchmark.' + 'legacy'),
304+
('mybenchmark', '2010-suite'))
305+
306+
def test_bare_2010_suite_name_without_dot(self):
307+
Benchmark.objects.create(name='ai', source='2010-suite')
308+
self.assertEqual(parse_benchmark_ident('ai'), ('ai', '2010-suite'))
303309

304310
def test_bare_pyperformance_name_containing_dot(self):
305311
# Regression test: this name contains a dot but isn't a valid
@@ -310,16 +316,16 @@ def test_bare_pyperformance_name_containing_dot(self):
310316
parse_benchmark_ident('base16_large.pyperf'),
311317
('base16_large.pyperf', 'pyperformance'))
312318

313-
def test_unknown_name_falls_back_to_legacy(self):
319+
def test_unknown_name_falls_back_to_2010_suite(self):
314320
self.assertEqual(
315321
parse_benchmark_ident('nosuchbenchmark'),
316-
('nosuchbenchmark', 'legacy'))
322+
('nosuchbenchmark', '2010-suite'))
317323

318-
def test_ambiguous_name_across_sources_falls_back_to_legacy(self):
319-
Benchmark.objects.create(name='float', source='legacy')
324+
def test_ambiguous_name_across_sources_falls_back_to_2010_suite(self):
325+
Benchmark.objects.create(name='float', source='2010-suite')
320326
Benchmark.objects.create(name='float', source='pyperformance')
321327
self.assertEqual(
322-
parse_benchmark_ident('float'), ('float', 'legacy'))
328+
parse_benchmark_ident('float'), ('float', '2010-suite'))
323329

324330

325331
class TestGetDefaultEnvironment(TestCase):

0 commit comments

Comments
 (0)