Merge "Re-enable test_success_pattern as test_success_url" into feature/zuulv3
diff --git a/tests/fixtures/config/success-url/git/common-config/zuul.yaml b/tests/fixtures/config/success-url/git/common-config/zuul.yaml
new file mode 100644
index 0000000..7edb340
--- /dev/null
+++ b/tests/fixtures/config/success-url/git/common-config/zuul.yaml
@@ -0,0 +1,35 @@
+- pipeline:
+ name: check
+ manager: independent
+ source:
+ gerrit
+ trigger:
+ gerrit:
+ - event: patchset-created
+ start:
+ smtp:
+ to: alternative_me@example.com
+ success:
+ gerrit:
+ verified: 1
+ smtp:
+ to: alternative_me@example.com
+ failure:
+ gerrit:
+ verified: -1
+
+
+- job:
+ name: docs-draft-test
+ success-url: http://docs-draft.example.org/{build.parameters[LOG_PATH]}/publish-docs/
+
+- job:
+ name: docs-draft-test2
+ success-url: http://docs-draft.example.org/{NOPE}/{build.parameters[BAD]}/publish-docs/
+
+- project:
+ name: org/docs
+ check:
+ jobs:
+ - docs-draft-test
+ - docs-draft-test2
diff --git a/tests/fixtures/config/success-url/git/org_docs/README b/tests/fixtures/config/success-url/git/org_docs/README
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/tests/fixtures/config/success-url/git/org_docs/README
@@ -0,0 +1 @@
+test
diff --git a/tests/fixtures/config/success-url/main.yaml b/tests/fixtures/config/success-url/main.yaml
new file mode 100644
index 0000000..a22ed5c
--- /dev/null
+++ b/tests/fixtures/config/success-url/main.yaml
@@ -0,0 +1,6 @@
+- tenant:
+ name: tenant-one
+ source:
+ gerrit:
+ config-repos:
+ - common-config
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index a25815a..1ca0539 100755
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -4553,42 +4553,6 @@
self.assertEqual(3, len(self.smtp_messages))
@skip("Disabled for early v3 development")
- def test_success_pattern(self):
- "Ensure bad build params are ignored"
-
- # Use SMTP reporter to grab the result message easier
- self.init_repo("org/docs")
- self.config.set('zuul', 'layout_config',
- 'tests/fixtures/layout-success-pattern.yaml')
- self.sched.reconfigure(self.config)
- self.launch_server.hold_jobs_in_build = True
- self.registerJobs()
-
- A = self.fake_gerrit.addFakeChange('org/docs', 'master', 'A')
- self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
- self.waitUntilSettled()
-
- # Grab build id
- self.assertEqual(len(self.builds), 1)
- uuid = self.builds[0].unique[:7]
-
- self.launch_server.hold_jobs_in_build = False
- self.launch_server.release()
- self.waitUntilSettled()
-
- self.assertEqual(len(self.smtp_messages), 1)
- body = self.smtp_messages[0]['body'].splitlines()
- self.assertEqual('Build succeeded.', body[0])
-
- self.assertIn(
- '- docs-draft-test http://docs-draft.example.org/1/1/1/check/'
- 'docs-draft-test/%s/publish-docs/' % uuid,
- body[2])
- self.assertIn(
- '- docs-draft-test2 https://server/job/docs-draft-test2/1/',
- body[3])
-
- @skip("Disabled for early v3 development")
def test_rerun_on_abort(self):
"Test that if a worker fails to run a job, it is run again"
@@ -4715,3 +4679,37 @@
).result, 'SUCCESS')
self.assertEqual(self.getJobFromHistory('project-test6').result,
'SUCCESS')
+
+
+class TestSchedulerSuccessURL(ZuulTestCase):
+ tenant_config_file = 'config/success-url/main.yaml'
+
+ def test_success_url(self):
+ "Ensure bad build params are ignored"
+ self.sched.reconfigure(self.config)
+ self.init_repo('org/docs')
+
+ A = self.fake_gerrit.addFakeChange('org/docs', 'master', 'A')
+ self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
+ self.waitUntilSettled()
+
+ # Both builds ran: docs-draft-test + docs-draft-test2
+ self.assertEqual(len(self.history), 2)
+
+ # Grab build id
+ uuid = self.history[0].uuid[:7]
+
+ # Two msgs: 'Starting...' + results
+ self.assertEqual(len(self.smtp_messages), 2)
+ body = self.smtp_messages[1]['body'].splitlines()
+ self.assertEqual('Build succeeded.', body[0])
+
+ self.assertIn(
+ '- docs-draft-test http://docs-draft.example.org/1/1/1/check/'
+ 'docs-draft-test/%s/publish-docs/' % uuid,
+ body[2])
+
+ # NOTE: This default URL is currently hard-coded in launcher/server.py
+ self.assertIn(
+ '- docs-draft-test2 https://server/job',
+ body[3])