Re-enable test_idle
This is the second test that wants to switch between two sources. This time it wants to do that 3 times, so we just reset hard each time. To make this simpler, we made addCommitToRepo return the commit from before this one. We also refactor the update from one config fixture to another into a generic method that should be useful a few more times. Change-Id: I409a86b3c92cc8f7984967f50ef0db50bf37ea6b Story: 2000773 Task: 3473
This commit is contained in:
@@ -1793,12 +1793,23 @@ class ZuulTestCase(BaseTestCase):
|
||||
f.write(content)
|
||||
repo.index.add([fn])
|
||||
commit = repo.index.commit(message)
|
||||
before = repo.heads[branch].commit
|
||||
repo.heads[branch].commit = commit
|
||||
repo.head.reference = branch
|
||||
repo.git.clean('-x', '-f', '-d')
|
||||
repo.heads[branch].checkout()
|
||||
if tag:
|
||||
repo.create_tag(tag)
|
||||
return before
|
||||
|
||||
def commitLayoutUpdate(self, orig_name, source_name):
|
||||
source_path = os.path.join(self.test_root, 'upstream',
|
||||
source_name, 'zuul.yaml')
|
||||
with open(source_path, 'r') as nt:
|
||||
before = self.addCommitToRepo(
|
||||
orig_name, 'Pulling content from %s' % source_name,
|
||||
{'zuul.yaml': nt.read()})
|
||||
return before
|
||||
|
||||
def addEvent(self, connection, event):
|
||||
"""Inject a Fake (Gerrit) event.
|
||||
|
||||
@@ -1663,11 +1663,7 @@ class TestScheduler(ZuulTestCase):
|
||||
# Stop queuing timer triggered jobs so that the assertions
|
||||
# below don't race against more jobs being queued.
|
||||
# Must be in same repo, so overwrite config with another one
|
||||
no_timer_path = os.path.join(self.test_root, 'upstream',
|
||||
'layout-no-timer', 'zuul.yaml')
|
||||
with open(no_timer_path, 'r') as nt:
|
||||
self.addCommitToRepo('layout-idle', 'Removing timer jobs',
|
||||
{'zuul.yaml': nt.read()})
|
||||
self.commitLayoutUpdate('layout-idle', 'layout-no-timer')
|
||||
|
||||
self.sched.reconfigure(self.config)
|
||||
self.assertEqual(len(self.builds), 2, "Two timer jobs")
|
||||
@@ -2821,19 +2817,16 @@ class TestScheduler(ZuulTestCase):
|
||||
self.assertIn('project-bitrot-stable-old', status_jobs)
|
||||
self.assertIn('project-bitrot-stable-older', status_jobs)
|
||||
|
||||
@skip("Disabled for early v3 development")
|
||||
def test_idle(self):
|
||||
"Test that frequent periodic jobs work"
|
||||
self.launch_server.hold_jobs_in_build = True
|
||||
self.updateConfigLayout('layout-idle')
|
||||
|
||||
for x in range(1, 3):
|
||||
# Test that timer triggers periodic jobs even across
|
||||
# layout config reloads.
|
||||
# Start timer trigger
|
||||
self.updateConfigLayout(
|
||||
'tests/fixtures/layout-idle.yaml')
|
||||
self.sched.reconfigure(self.config)
|
||||
self.registerJobs()
|
||||
self.waitUntilSettled()
|
||||
|
||||
# The pipeline triggers every second, so we should have seen
|
||||
@@ -2842,17 +2835,20 @@ class TestScheduler(ZuulTestCase):
|
||||
|
||||
# Stop queuing timer triggered jobs so that the assertions
|
||||
# below don't race against more jobs being queued.
|
||||
self.updateConfigLayout(
|
||||
'tests/fixtures/layout-no-timer.yaml')
|
||||
before = self.commitLayoutUpdate('layout-idle', 'layout-no-timer')
|
||||
self.sched.reconfigure(self.config)
|
||||
self.registerJobs()
|
||||
self.waitUntilSettled()
|
||||
|
||||
self.assertEqual(len(self.builds), 2)
|
||||
self.assertEqual(len(self.builds), 2,
|
||||
'Timer builds iteration #%d' % x)
|
||||
self.launch_server.release('.*')
|
||||
self.waitUntilSettled()
|
||||
self.assertEqual(len(self.builds), 0)
|
||||
self.assertEqual(len(self.history), x * 2)
|
||||
# Revert back to layout-idle
|
||||
repo = git.Repo(os.path.join(self.test_root,
|
||||
'upstream',
|
||||
'layout-idle'))
|
||||
repo.git.reset('--hard', before)
|
||||
|
||||
def test_check_smtp_pool(self):
|
||||
self.updateConfigLayout('layout-smtp')
|
||||
|
||||
Reference in New Issue
Block a user