Fix addFailTest

The addFailTest method needed to be updated to catch up with some
test infrastructure changes.  Rather than consulting the merger's
git repo for the ZUUL_REF to find out if a job which is supposed to
fail is present for a given build, use the new FakeBuild.hasChanges
method to inspect the launcher's prepared git repo.

Also rename the method as 'Job' is more descriptive than 'Test' and
document it.

Change-Id: I3224b8a01d49cfa06b799a8028c1bf0d455d25b1
diff --git a/tests/base.py b/tests/base.py
index 1661957..9acc0ef 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -617,9 +617,7 @@
         self.log.debug("Build %s continuing" % self.unique)
 
         result = 'SUCCESS'
-        if (('ZUUL_REF' in self.parameters) and
-            self.launch_server.shouldFailTest(self.name,
-                                              self.parameters['ZUUL_REF'])):
+        if (('ZUUL_REF' in self.parameters) and self.shouldFail()):
             result = 'FAILURE'
         if self.aborted:
             result = 'ABORTED'
@@ -629,6 +627,13 @@
 
         return result
 
+    def shouldFail(self):
+        changes = self.launch_server.fail_tests.get(self.name, [])
+        for change in changes:
+            if self.hasChanges(change):
+                return True
+        return False
+
     def hasChanges(self, *changes):
         """Return whether this build has certain changes in its git repos.
 
@@ -680,24 +685,19 @@
         self.fail_tests = {}
         self.job_builds = {}
 
-    def addFailTest(self, name, change):
+    def failJob(self, name, change):
         """Instruct the launcher to report matching builds as failures.
 
         :arg str name: The name of the job to fail.
-        :arg change: TODO: document
+        :arg Change change: The :py:class:`~tests.base.FakeChange`
+            instance which should cause the job to fail.  This job
+            will also fail for changes depending on this change.
 
         """
         l = self.fail_tests.get(name, [])
         l.append(change)
         self.fail_tests[name] = l
 
-    def shouldFailTest(self, name, ref):
-        l = self.fail_tests.get(name, [])
-        for change in l:
-            if self.test.ref_has_change(ref, change):
-                return True
-        return False
-
     def release(self, regex=None):
         """Release a held build.
 
@@ -1264,6 +1264,8 @@
         return commit.hexsha
 
     def ref_has_change(self, ref, change):
+        # TODOv3(jeblair): this should probably be removed in favor of
+        # build.hasChanges
         path = os.path.join(self.git_root, change.project)
         repo = git.Repo(path)
         try:
diff --git a/tests/test_connection.py b/tests/test_connection.py
index 6d1514b..c128741 100644
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -53,7 +53,7 @@
                          'jenkins')
 
         B = self.fake_review_gerrit.addFakeChange('org/project', 'master', 'B')
-        self.worker.addFailTest('project-test2', B)
+        self.launch_server.failJob('project-test2', B)
         self.addEvent('review_gerrit', B.getPatchsetCreatedEvent(1))
 
         self.waitUntilSettled()
diff --git a/zuul/model.py b/zuul/model.py
index 3921180..649593f 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -372,7 +372,6 @@
         file_matcher=None,
         irrelevant_file_matcher=None,  # skip-if
         parameter_function=None,  # TODOv3(jeblair): remove
-        success_pattern=None,  # TODOv3(jeblair): remove
         tags=set(),
         mutex=None,
     )
@@ -873,13 +872,13 @@
         if result == 'SUCCESS':
             if job.success_message:
                 result = job.success_message
-            if job.success_pattern:
-                pattern = job.success_pattern
+            if job.success_url:
+                pattern = job.success_url
         elif result == 'FAILURE':
             if job.failure_message:
                 result = job.failure_message
-            if job.failure_pattern:
-                pattern = job.failure_pattern
+            if job.failure_url:
+                pattern = job.failure_url
         url = None
         if pattern:
             try: