Hashar has uploaded a new change for review.
https://gerrit.wikimedia.org/r/278914
Change subject: test: speed up valid_jobs_in_check_pipelines
......................................................................
test: speed up valid_jobs_in_check_pipelines
The test called getPipelineProjectsNames and getProjectDef too many
times, which was fairly slow.
Instead retrieve the whole project -> pipeline -> job map with the
lightweight getProjectsDefs() helper.
Change loops nesting orders, switch pipeline and project:
- pipeline -> project ->jobs
+ project -> pipeline ->jobs
Adjust code in consequence, specially creation of nested dicts.
Move definition of 'expected' at the top, then copy it to forge the
'actual' variable which is used in the test whenever unsafe jobs are
detected.
Run time down to 3 seconds from 25 seconds on my machine.
Change-Id: Ie83873a2c387d0e00c71e70ef0e4288a786fca19
---
M tests/test_zuul_scheduler.py
1 file changed, 15 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/integration/config
refs/changes/14/278914/1
diff --git a/tests/test_zuul_scheduler.py b/tests/test_zuul_scheduler.py
index 1c08618..6f4eff0 100644
--- a/tests/test_zuul_scheduler.py
+++ b/tests/test_zuul_scheduler.py
@@ -4,6 +4,7 @@
# Copyright (c) 2014 - Wikimedia Foundation Inc.
import ConfigParser
+import copy
import re
import os
import unittest
@@ -279,8 +280,11 @@
check_pipelines = [p.name for p in self.getPipelines()
if p.name.startswith('check')]
- # Uniq list of projects having a check* pipeline defined
- actual = {}
+ # We expect check pipelines to have no unsafe jobs
+ expected = {k: {} for k in check_pipelines}
+ # Map of pipelines -> projects -> unsafe jobs
+ actual = copy.deepcopy(expected)
+
# List of jobs allowed in check* pipelines
safe_jobs = [
'(php5[35]|perl|json|yaml)lint',
@@ -301,20 +305,21 @@
]
safe_jobs_re = re.compile('^(' + '|'.join(safe_jobs) + ')$')
- for check_pipeline in check_pipelines:
- actual[check_pipeline] = {}
- for project in self.getPipelineProjectsNames(check_pipeline):
- jobs = self.getProjectDef(project)[check_pipeline]
+ all_defs = self.getProjectsDefs()
+ for (project_name, defs) in all_defs.iteritems():
+ for (pipeline, jobs) in defs.iteritems():
+ if not pipeline.startswith('check'):
+ continue
unsafe_jobs = [j for j in jobs
if not re.match(safe_jobs_re, j)]
if unsafe_jobs:
- actual[check_pipeline][project] = unsafe_jobs
+ actual[pipeline].update({project_name: unsafe_jobs})
self.maxDiff = None
+ self.longMessage = True
- # We expect check pipelines to have no unsafe jobs
- expected = {k: {} for k in check_pipelines}
- self.assertEquals(expected, actual)
+ self.assertEquals(expected, actual,
+ "No project have unsafe jobs in check* pipelines")
def test_recheck_comment_trusted_user(self):
test_manager = self.getPipeline('test').manager
--
To view, visit https://gerrit.wikimedia.org/r/278914
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie83873a2c387d0e00c71e70ef0e4288a786fca19
Gerrit-PatchSet: 1
Gerrit-Project: integration/config
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits