Autotest: add link to retry dashboard for autofiled bugs.

BUG=chromium:438462
TEST=reporting_unittests.py

Change-Id: I1a18e1dab0b05c72358857d4ac7414eb70734f37
Reviewed-on: https://chromium-review.googlesource.com/245537
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
Commit-Queue: Simran Basi <sbasi@chromium.org>
Tested-by: Simran Basi <sbasi@chromium.org>
diff --git a/server/cros/dynamic_suite/reporting.py b/server/cros/dynamic_suite/reporting.py
index 8f09225..f0dc488 100644
--- a/server/cros/dynamic_suite/reporting.py
+++ b/server/cros/dynamic_suite/reporting.py
@@ -144,7 +144,9 @@
                     'results log: %(results_log)s.\n'
                     'status log: %(status_log)s.\n'
                     'buildbot stages: %(buildbot_stages)s.\n'
-                    'job link: %(job)s.\n')
+                    'job link: %(job)s.\n\n'
+                    'You may want to check the test retry dashboard in case '
+                    'this is a flakey test: %(retry_url)s\n')
 
         specifics = {
             'status': self.status,
@@ -158,6 +160,7 @@
             'status_log': links.status_log,
             'buildbot_stages': links.buildbot,
             'job': links.job,
+            'retry_url': links.retry_url,
         }
 
         return template % specifics
@@ -175,14 +178,16 @@
                                                  'status_log,'
                                                  'artifacts,'
                                                  'buildbot,'
-                                                 'job'))
+                                                 'job',
+                                                 'retry_url'))
         return links(reporting_utils.link_result_logs(
                          self.job_id, self.result_owner, self.hostname),
                      reporting_utils.link_status_log(
                          self.job_id, self.result_owner, self.hostname),
                      reporting_utils.link_build_artifacts(self.build),
                      reporting_utils.link_buildbot_stages(self.build),
-                     reporting_utils.link_job(self.job_id))
+                     reporting_utils.link_job(self.job_id),
+                     reporting_utils.link_retry_url(self.name))
 
 
 class MachineKillerBug(Bug):
diff --git a/server/cros/dynamic_suite/reporting_utils.py b/server/cros/dynamic_suite/reporting_utils.py
index 509d858..cf5be22 100644
--- a/server/cros/dynamic_suite/reporting_utils.py
+++ b/server/cros/dynamic_suite/reporting_utils.py
@@ -67,6 +67,10 @@
     BUG_CONFIG_SECTION, 'build_prefix', default='')
 
 
+WMATRIX_RETRY_URL = ('https://wmatrix.googleplex.com/retry_teststats/?'
+                     'days_back=30&tests=%s')
+
+
 class InvalidBugTemplateException(Exception):
     """Exception raised when a bug template is not valid, e.g., missing value
     for essential attributes.
@@ -320,3 +324,13 @@
                      metadata.get('builder-name'),
                      metadata.get('build-number'))).replace(' ', '%20')
     return 'NA'
+
+
+def link_retry_url(test_name):
+    """Link to the wmatrix retry stats page for this test.
+
+    @param test_name: Test we want to search the retry stats page for.
+
+    @return: A link to the wmatrix retry stats dashboard for this test.
+    """
+    return WMATRIX_RETRY_URL % test_name
\ No newline at end of file