summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test_cloner.py65
-rw-r--r--zuul/lib/cloner.py4
2 files changed, 67 insertions, 2 deletions
diff --git a/tests/test_cloner.py b/tests/test_cloner.py
index ab2683d81..a639a52f4 100644
--- a/tests/test_cloner.py
+++ b/tests/test_cloner.py
@@ -18,6 +18,7 @@
import logging
import os
import shutil
+import time
import git
@@ -481,3 +482,67 @@ class TestCloner(ZuulTestCase):
self.worker.hold_jobs_in_build = False
self.worker.release()
self.waitUntilSettled()
+
+ def test_periodic(self):
+ self.worker.hold_jobs_in_build = True
+ self.create_branch('org/project', 'stable/havana')
+ self.config.set('zuul', 'layout_config',
+ 'tests/fixtures/layout-timer.yaml')
+ self.sched.reconfigure(self.config)
+ self.registerJobs()
+
+ # The pipeline triggers every second, so we should have seen
+ # several by now.
+ time.sleep(5)
+ self.waitUntilSettled()
+
+ builds = self.builds[:]
+
+ self.worker.hold_jobs_in_build = False
+ # Stop queuing timer triggered jobs so that the assertions
+ # below don't race against more jobs being queued.
+ self.config.set('zuul', 'layout_config',
+ 'tests/fixtures/layout-no-timer.yaml')
+ self.sched.reconfigure(self.config)
+ self.registerJobs()
+ self.worker.release()
+ self.waitUntilSettled()
+
+ projects = ['org/project']
+
+ self.assertEquals(2, len(builds), "Two builds are running")
+
+ upstream = self.getUpstreamRepos(projects)
+ states = [
+ {'org/project': str(upstream['org/project'].commit('stable/havana')),
+ },
+ {'org/project': str(upstream['org/project'].commit('stable/havana')),
+ },
+ ]
+
+ for number, build in enumerate(builds):
+ self.log.debug("Build parameters: %s", build.parameters)
+ cloner = zuul.lib.cloner.Cloner(
+ git_base_url=self.upstream_root,
+ projects=projects,
+ workspace=self.workspace_root,
+ zuul_branch=build.parameters.get('ZUUL_BRANCH', None),
+ zuul_ref=build.parameters.get('ZUUL_REF', None),
+ zuul_url=self.git_root,
+ branch='stable/havana',
+ )
+ cloner.execute()
+ work = self.getWorkspaceRepos(projects)
+ state = states[number]
+
+ for project in projects:
+ self.assertEquals(state[project],
+ str(work[project].commit('HEAD')),
+ 'Project %s commit for build %s should '
+ 'be correct' % (project, number))
+
+ shutil.rmtree(self.workspace_root)
+
+ self.worker.hold_jobs_in_build = False
+ self.worker.release()
+ self.waitUntilSettled()
diff --git a/zuul/lib/cloner.py b/zuul/lib/cloner.py
index 89ebada0e..e0f704b67 100644
--- a/zuul/lib/cloner.py
+++ b/zuul/lib/cloner.py
@@ -39,8 +39,8 @@ class Cloner(object):
self.cache_dir = cache_dir
self.projects = projects
self.workspace = workspace
- self.zuul_branch = zuul_branch
- self.zuul_ref = zuul_ref
+ self.zuul_branch = zuul_branch or ''
+ self.zuul_ref = zuul_ref or ''
self.zuul_url = zuul_url
self.project_branches = project_branches or {}