Re-enable test_disable_at test
Update configuration and tenant info for zuulv3.
Story: #2000773
Change-Id: I22ac419a7f5a7da26bef06930b64a062166d84c3
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
diff --git a/tests/fixtures/config/single-tenant/git/layout-disabled-at/zuul.yaml b/tests/fixtures/config/single-tenant/git/layout-disabled-at/zuul.yaml
new file mode 100644
index 0000000..4cf6f16
--- /dev/null
+++ b/tests/fixtures/config/single-tenant/git/layout-disabled-at/zuul.yaml
@@ -0,0 +1,30 @@
+- pipeline:
+ name: check
+ manager: independent
+ source:
+ gerrit
+ trigger:
+ gerrit:
+ - event: patchset-created
+ success:
+ gerrit:
+ verified: 1
+ failure:
+ gerrit:
+ verified: -1
+ disabled:
+ smtp:
+ to: you@example.com
+ disable-after-consecutive-failures: 3
+
+- job:
+ name: project-test1
+ nodes:
+ - name: controller
+ image: image1
+
+- project:
+ name: org/project
+ check:
+ jobs:
+ - project-test1
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index e24c72a..5d24fbe 100755
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -4418,18 +4418,17 @@
source._getChange(u'1', u'2', True)
source._getChange(u'2', u'2', True)
- @skip("Disabled for early v3 development")
def test_disable_at(self):
"Test a pipeline will only report to the disabled trigger when failing"
- self.updateConfigLayout(
- 'tests/fixtures/layout-disable-at.yaml')
+ self.updateConfigLayout('layout-disabled-at')
self.sched.reconfigure(self.config)
- self.assertEqual(3, self.sched.layout.pipelines['check'].disable_at)
+ tenant = self.sched.abide.tenants.get('openstack')
+ self.assertEqual(3, tenant.layout.pipelines['check'].disable_at)
self.assertEqual(
- 0, self.sched.layout.pipelines['check']._consecutive_failures)
- self.assertFalse(self.sched.layout.pipelines['check']._disabled)
+ 0, tenant.layout.pipelines['check']._consecutive_failures)
+ self.assertFalse(tenant.layout.pipelines['check']._disabled)
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B')
@@ -4460,15 +4459,15 @@
self.waitUntilSettled()
self.assertEqual(
- 2, self.sched.layout.pipelines['check']._consecutive_failures)
- self.assertFalse(self.sched.layout.pipelines['check']._disabled)
+ 2, tenant.layout.pipelines['check']._consecutive_failures)
+ self.assertFalse(tenant.layout.pipelines['check']._disabled)
self.fake_gerrit.addEvent(C.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
self.assertEqual(
- 0, self.sched.layout.pipelines['check']._consecutive_failures)
- self.assertFalse(self.sched.layout.pipelines['check']._disabled)
+ 0, tenant.layout.pipelines['check']._consecutive_failures)
+ self.assertFalse(tenant.layout.pipelines['check']._disabled)
self.fake_gerrit.addEvent(D.getPatchsetCreatedEvent(1))
self.fake_gerrit.addEvent(E.getPatchsetCreatedEvent(1))
@@ -4477,8 +4476,8 @@
# We should be disabled now
self.assertEqual(
- 3, self.sched.layout.pipelines['check']._consecutive_failures)
- self.assertTrue(self.sched.layout.pipelines['check']._disabled)
+ 3, tenant.layout.pipelines['check']._consecutive_failures)
+ self.assertTrue(tenant.layout.pipelines['check']._disabled)
# We need to wait between each of these patches to make sure the
# smtp messages come back in an expected order
@@ -4508,30 +4507,35 @@
self.assertEqual(3, len(self.smtp_messages))
self.assertEqual(0, len(G.messages))
self.assertIn('Build failed.', self.smtp_messages[0]['body'])
- self.assertIn('/7/1/check', self.smtp_messages[0]['body'])
+ self.assertIn(
+ 'project-test1 https://server/job', self.smtp_messages[0]['body'])
self.assertEqual(0, len(H.messages))
self.assertIn('Build failed.', self.smtp_messages[1]['body'])
- self.assertIn('/8/1/check', self.smtp_messages[1]['body'])
+ self.assertIn(
+ 'project-test1 https://server/job', self.smtp_messages[1]['body'])
self.assertEqual(0, len(I.messages))
self.assertIn('Build succeeded.', self.smtp_messages[2]['body'])
- self.assertIn('/9/1/check', self.smtp_messages[2]['body'])
+ self.assertIn(
+ 'project-test1 https://server/job', self.smtp_messages[2]['body'])
# Now reload the configuration (simulate a HUP) to check the pipeline
# comes out of disabled
self.sched.reconfigure(self.config)
- self.assertEqual(3, self.sched.layout.pipelines['check'].disable_at)
+ tenant = self.sched.abide.tenants.get('openstack')
+
+ self.assertEqual(3, tenant.layout.pipelines['check'].disable_at)
self.assertEqual(
- 0, self.sched.layout.pipelines['check']._consecutive_failures)
- self.assertFalse(self.sched.layout.pipelines['check']._disabled)
+ 0, tenant.layout.pipelines['check']._consecutive_failures)
+ self.assertFalse(tenant.layout.pipelines['check']._disabled)
self.fake_gerrit.addEvent(J.getPatchsetCreatedEvent(1))
self.fake_gerrit.addEvent(K.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
self.assertEqual(
- 2, self.sched.layout.pipelines['check']._consecutive_failures)
- self.assertFalse(self.sched.layout.pipelines['check']._disabled)
+ 2, tenant.layout.pipelines['check']._consecutive_failures)
+ self.assertFalse(tenant.layout.pipelines['check']._disabled)
# J and K went back to gerrit
self.assertEqual(1, len(J.messages))