Merge "Re-enable test_abandoned_not_timer" into feature/zuulv3
This commit is contained in:
commit
5d944abb65
@ -1761,7 +1761,8 @@ class ZuulTestCase(BaseTestCase):
|
||||
|
||||
def updateConfigLayout(self, path):
|
||||
root = os.path.join(self.test_root, "config")
|
||||
os.makedirs(root)
|
||||
if not os.path.exists(root):
|
||||
os.makedirs(root)
|
||||
f = tempfile.NamedTemporaryFile(dir=root, delete=False)
|
||||
f.write("""
|
||||
- tenant:
|
||||
|
2
tests/fixtures/config/single-tenant/git/layout-idle/playbooks/project-bitrot-stable-old.yaml
vendored
Normal file
2
tests/fixtures/config/single-tenant/git/layout-idle/playbooks/project-bitrot-stable-old.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
- hosts: all
|
||||
tasks: []
|
@ -0,0 +1,2 @@
|
||||
- hosts: all
|
||||
tasks: []
|
2
tests/fixtures/config/single-tenant/git/layout-idle/playbooks/project-test1.yaml
vendored
Normal file
2
tests/fixtures/config/single-tenant/git/layout-idle/playbooks/project-test1.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
- hosts: all
|
||||
tasks: []
|
27
tests/fixtures/config/single-tenant/git/layout-idle/zuul.yaml
vendored
Normal file
27
tests/fixtures/config/single-tenant/git/layout-idle/zuul.yaml
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
- pipeline:
|
||||
name: periodic
|
||||
manager: independent
|
||||
source:
|
||||
gerrit
|
||||
trigger:
|
||||
timer:
|
||||
- time: '* * * * * */1'
|
||||
|
||||
- job:
|
||||
name: project-bitrot-stable-old
|
||||
nodes:
|
||||
- name: static
|
||||
image: ubuntu-xenial
|
||||
|
||||
- job:
|
||||
name: project-bitrot-stable-older
|
||||
nodes:
|
||||
- name: static
|
||||
image: ubuntu-trusty
|
||||
|
||||
- project:
|
||||
name: org/project
|
||||
periodic:
|
||||
jobs:
|
||||
- project-bitrot-stable-old
|
||||
- project-bitrot-stable-older
|
@ -0,0 +1,2 @@
|
||||
- hosts: all
|
||||
tasks: []
|
@ -0,0 +1,2 @@
|
||||
- hosts: all
|
||||
tasks: []
|
2
tests/fixtures/config/single-tenant/git/layout-no-timer/playbooks/project-test1.yaml
vendored
Normal file
2
tests/fixtures/config/single-tenant/git/layout-no-timer/playbooks/project-test1.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
- hosts: all
|
||||
tasks: []
|
50
tests/fixtures/config/single-tenant/git/layout-no-timer/zuul.yaml
vendored
Normal file
50
tests/fixtures/config/single-tenant/git/layout-no-timer/zuul.yaml
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
- pipeline:
|
||||
name: check
|
||||
manager: independent
|
||||
source:
|
||||
gerrit
|
||||
trigger:
|
||||
gerrit:
|
||||
- event: patchset-created
|
||||
success:
|
||||
gerrit:
|
||||
verified: 1
|
||||
failure:
|
||||
gerrit:
|
||||
verified: -1
|
||||
|
||||
- pipeline:
|
||||
name: periodic
|
||||
manager: independent
|
||||
# Trigger is required, set it to one that is a noop
|
||||
# during tests that check the timer trigger.
|
||||
source:
|
||||
gerrit
|
||||
trigger:
|
||||
gerrit:
|
||||
- event: ref-updated
|
||||
|
||||
- job:
|
||||
name: project-test1
|
||||
|
||||
- job:
|
||||
name: project-bitrot-stable-old
|
||||
nodes:
|
||||
- name: static
|
||||
image: ubuntu-xenial
|
||||
|
||||
- job:
|
||||
name: project-bitrot-stable-older
|
||||
nodes:
|
||||
- name: static
|
||||
image: ubuntu-trusty
|
||||
|
||||
- project:
|
||||
name: org/project
|
||||
check:
|
||||
jobs:
|
||||
- project-test1
|
||||
periodic:
|
||||
jobs:
|
||||
- project-bitrot-stable-old
|
||||
- project-bitrot-stable-older
|
12
tests/fixtures/layout-idle.yaml
vendored
12
tests/fixtures/layout-idle.yaml
vendored
@ -1,12 +0,0 @@
|
||||
pipelines:
|
||||
- name: periodic
|
||||
manager: IndependentPipelineManager
|
||||
trigger:
|
||||
timer:
|
||||
- time: '* * * * * */1'
|
||||
|
||||
projects:
|
||||
- name: org/project
|
||||
periodic:
|
||||
- project-bitrot-stable-old
|
||||
- project-bitrot-stable-older
|
28
tests/fixtures/layout-no-timer.yaml
vendored
28
tests/fixtures/layout-no-timer.yaml
vendored
@ -1,28 +0,0 @@
|
||||
pipelines:
|
||||
- name: check
|
||||
manager: IndependentPipelineManager
|
||||
trigger:
|
||||
gerrit:
|
||||
- event: patchset-created
|
||||
success:
|
||||
gerrit:
|
||||
verified: 1
|
||||
failure:
|
||||
gerrit:
|
||||
verified: -1
|
||||
|
||||
- name: periodic
|
||||
manager: IndependentPipelineManager
|
||||
# Trigger is required, set it to one that is a noop
|
||||
# during tests that check the timer trigger.
|
||||
trigger:
|
||||
gerrit:
|
||||
- event: ref-updated
|
||||
|
||||
projects:
|
||||
- name: org/project
|
||||
check:
|
||||
- project-test1
|
||||
periodic:
|
||||
- project-bitrot-stable-old
|
||||
- project-bitrot-stable-older
|
@ -1638,27 +1638,28 @@ class TestScheduler(ZuulTestCase):
|
||||
self.assertEqual(A.reported, 0, "Abandoned change should not report")
|
||||
self.assertEqual(B.reported, 1, "Change should report")
|
||||
|
||||
@skip("Disabled for early v3 development")
|
||||
def test_abandoned_not_timer(self):
|
||||
"Test that an abandoned change does not cancel timer jobs"
|
||||
|
||||
self.launch_server.hold_jobs_in_build = True
|
||||
|
||||
# Start timer trigger - also org/project
|
||||
self.updateConfigLayout(
|
||||
'tests/fixtures/layout-idle.yaml')
|
||||
self.updateConfigLayout('layout-idle')
|
||||
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()
|
||||
# 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')
|
||||
# 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.sched.reconfigure(self.config)
|
||||
self.registerJobs()
|
||||
self.assertEqual(len(self.builds), 2, "Two timer jobs")
|
||||
|
||||
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
|
||||
|
@ -282,6 +282,7 @@ class GerritConnection(BaseConnection):
|
||||
change.url = self._getGitwebUrl(project, sha=event.newrev)
|
||||
else:
|
||||
# TODOv3(jeblair): we need to get the project from the event
|
||||
project = self.getProject(event.project_name)
|
||||
change = NullChange(project)
|
||||
return change
|
||||
|
||||
|
@ -49,7 +49,7 @@ class TimerDriver(Driver, TriggerInterface):
|
||||
def _addJobs(self, tenant):
|
||||
jobs = []
|
||||
self.tenant_jobs[tenant.name] = jobs
|
||||
for pipeline in tenant.layout.pipelines:
|
||||
for pipeline in tenant.layout.pipelines.values():
|
||||
for ef in pipeline.manager.event_filters:
|
||||
if not isinstance(ef.trigger, timertrigger.TimerTrigger):
|
||||
continue
|
||||
@ -88,8 +88,8 @@ class TimerDriver(Driver, TriggerInterface):
|
||||
def stop(self):
|
||||
self.apsched.shutdown()
|
||||
|
||||
def getTrigger(self, connection_name):
|
||||
return timertrigger.TimerTrigger(self)
|
||||
def getTrigger(self, connection_name, config=None):
|
||||
return timertrigger.TimerTrigger(self, config)
|
||||
|
||||
def getTriggerSchema(self):
|
||||
return timertrigger.getSchema()
|
||||
|
@ -42,6 +42,10 @@ def make_merger_item(item):
|
||||
oldrev = item.change.oldrev
|
||||
newrev = item.change.newrev
|
||||
branch = item.change.ref
|
||||
else:
|
||||
oldrev = None
|
||||
newrev = None
|
||||
branch = None
|
||||
connection_name = item.pipeline.source.connection.connection_name
|
||||
project = item.change.project.name
|
||||
|
||||
|
@ -17,6 +17,7 @@ import re
|
||||
import zuul.driver.zuul
|
||||
import zuul.driver.gerrit
|
||||
import zuul.driver.smtp
|
||||
import zuul.driver.timer
|
||||
from zuul.connection import BaseConnection
|
||||
|
||||
|
||||
@ -34,6 +35,7 @@ class ConnectionRegistry(object):
|
||||
self.registerDriver(zuul.driver.zuul.ZuulDriver())
|
||||
self.registerDriver(zuul.driver.gerrit.GerritDriver())
|
||||
self.registerDriver(zuul.driver.smtp.SMTPDriver())
|
||||
self.registerDriver(zuul.driver.timer.TimerDriver())
|
||||
|
||||
def registerDriver(self, driver):
|
||||
if driver.name in self.drivers:
|
||||
|
Loading…
Reference in New Issue
Block a user