>From d47e1513b8e15ba50865e3e76a47837a6955ec61 Mon Sep 17 00:00:00 2001
From: Josef Skladanka <jskladan@redhat.com>
Date: Fri, 7 May 2010 12:42:43 +0200
Subject: [PATCH 3/3] 65,130 - updated current tests so they use autotest_url

---
 tests/conflicts/conflicts.py       |    7 ++++++-
 tests/initscripts/initscripts.py   |    5 ++++-
 tests/rats_install/rats_install.py |    6 +++++-
 tests/rats_sanity/rats_sanity.py   |    6 +++++-
 tests/repoclosure/repoclosure.py   |    7 ++++++-
 tests/rpmguard/rpmguard.py         |    6 +++++-
 tests/rpmlint/rpmlint.py           |    6 +++++-
 7 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/tests/conflicts/conflicts.py b/tests/conflicts/conflicts.py
index 16f8644..3b9d178 100644
--- a/tests/conflicts/conflicts.py
+++ b/tests/conflicts/conflicts.py
@@ -18,6 +18,7 @@
 # Author: Will Woods <wwoods@redhat.com>
 
 import os
+import autoqa.util
 from autotest_lib.client.bin import test, utils
 from autotest_lib.client.bin.test_config import config_loader
 
@@ -26,6 +27,8 @@ class conflicts(test.test):
 
     def initialize(self, config):
         self.config = config_loader(config, self.tmpdir)
+        #URL of logs/results stored on autotest-server
+        self.autotest_url = autoqa.util.make_autotest_url(self.config)
 
     def writelog(self, logname, logdata):
         fullname = os.path.join(self.resultsdir, logname)
@@ -65,10 +68,12 @@ class conflicts(test.test):
 
         result_email = self.config.get('test','result_email')
         if result_email:
+            mail_body = "Stored logs available at <%s>\n\n" % self.autotest_url
+            mail_body += out
             utils.send_email(mail_to=result_email,
                              mail_from=self.config.get('test','mail_from'),
                              mail_server=self.config.get('test','smtpserver'),
                              subject='conflicts: %u packages with file conflicts in %s' % (len(conflicting_pkgs), reponame),
-                             body = out)
+                             body = mail_body)
 
         # TODO fail test if file conflicts exist?
diff --git a/tests/initscripts/initscripts.py b/tests/initscripts/initscripts.py
index 634a04d..a9d4037 100644
--- a/tests/initscripts/initscripts.py
+++ b/tests/initscripts/initscripts.py
@@ -33,6 +33,8 @@ class initscripts(test.test):
 
     def initialize(self, envr, name, kojitag, config):
         self.config = config_loader(config, self.tmpdir)
+        #URL of logs/results stored on autotest-server
+        self.autotest_url = autoqa.util.make_autotest_url(self.config)
 
     def setup(self):
         """
@@ -151,7 +153,8 @@ class initscripts(test.test):
         mail_from = self.config.get('test', 'mail_from')
         mail_server = self.config.get('test', 'smtpserver')
         if (mail_to and mail_from and mail_server):
-            msg =  "Following tests returned zero exit code: %s\n" % repr(tests_exit_status_zero)
+            msg = "Stored logs available at <%s>\n\n" % self.autotest_url
+            msg +=  "Following tests returned zero exit code: %s\n" % repr(tests_exit_status_zero)
             msg += "Following tests returned NON-zero exit code: %s\n" % repr(tests_exit_status_nonzero)
             msg += "%s\n" % ("#" * 79,)
 
diff --git a/tests/rats_install/rats_install.py b/tests/rats_install/rats_install.py
index 3a46606..d09c869 100644
--- a/tests/rats_install/rats_install.py
+++ b/tests/rats_install/rats_install.py
@@ -31,6 +31,8 @@ class rats_install(test.test):
     def initialize(self, config):
         self.config = config_loader(config, self.tmpdir)
         self.irb_conf = os.path.join(self.bindir, 'irb.cfg')
+        #URL of logs/results stored on autotest-server
+        self.autotest_url = util.make_autotest_url(self.config)
 
     def setup(self):
         if os.path.exists(self.irb_conf):
@@ -64,11 +66,13 @@ class rats_install(test.test):
 
         result_email = self.config.get('test','result_email')
         if result_email:
+            mail_body = "Stored results available at <%s>\n\n" % self.autotest_url
+            mail_body += out
             utils.send_email(mail_to=result_email,
                              mail_from=self.config.get('test','mail_from'),
                              mail_server=self.config.get('test','smtpserver'),
                              subject='rats_install %s %s' % (result, treename),
-                             body = out)
+                             body = mail_body)
 
         # grab extra key = val data
         keyvals = util.read_keyvals()
diff --git a/tests/rats_sanity/rats_sanity.py b/tests/rats_sanity/rats_sanity.py
index 3e1f7fb..37946a4 100644
--- a/tests/rats_sanity/rats_sanity.py
+++ b/tests/rats_sanity/rats_sanity.py
@@ -29,6 +29,8 @@ class rats_sanity(test.test):
     def initialize(self, config):
         self.config = config_loader(config, self.tmpdir)
         self.irb_conf = os.path.join(self.bindir, 'irb.cfg')
+        #URL of logs/results stored on autotest-server
+        self.autotest_url = util.make_autotest_url(self.config)
 
     def setup(self):
         if os.path.exists(self.irb_conf):
@@ -47,11 +49,13 @@ class rats_sanity(test.test):
 
         result_email = self.config.get('test','result_email')
         if result_email:
+            mail_body = "Stored logs available at <%s>\n\n" % self.autotest_url
+            mail_body += out
             utils.send_email(mail_to=result_email,
                              mail_from=self.config.get('test','mail_from'),
                              mail_server=self.config.get('test','smtpserver'),
                              subject='rats_sanity %s %s' % (result, reponame),
-                             body = out)
+                             body = mail_body)
 
         # grab extra key = val data
         keyvals = util.read_keyvals()
diff --git a/tests/repoclosure/repoclosure.py b/tests/repoclosure/repoclosure.py
index 29b0106..1306296 100644
--- a/tests/repoclosure/repoclosure.py
+++ b/tests/repoclosure/repoclosure.py
@@ -17,6 +17,7 @@
 #
 # Author: Will Woods <wwoods@redhat.com>
 
+import autoqa.util
 from autotest_lib.client.bin import test, utils
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin.test_config import config_loader
@@ -26,6 +27,8 @@ class repoclosure(test.test):
 
     def initialize(self, config):
         self.config = config_loader(config, self.tmpdir)
+        #URL of logs/results stored on autotest-server
+        self.autotest_url = autoqa.util.make_autotest_url(self.config)
 
     def setup(self):
         utils.system('yum -y install yum-utils')
@@ -47,11 +50,13 @@ class repoclosure(test.test):
 
         result_email = self.config.get('test','result_email')
         if result_email:
+            mail_body = "Stored logs available at <%s>\n\n" % self.autotest_url
+            mail_body += out
             utils.send_email(mail_to=result_email,
                              mail_from=self.config.get('test','mail_from'),
                              mail_server=self.config.get('test','smtpserver'),
                              subject='repoclosure: %u packages with unresolved deps in %s' % (unresolved_count, reponame),
-                             body = out)
+                             body = mail_body)
 
         if unresolved_count:
             raise error.TestFail, "%u packages with unresolved deps" % unresolved_count
diff --git a/tests/rpmguard/rpmguard.py b/tests/rpmguard/rpmguard.py
index 61eec64..7709151 100644
--- a/tests/rpmguard/rpmguard.py
+++ b/tests/rpmguard/rpmguard.py
@@ -49,6 +49,8 @@ rpmlint | cut -d ' ' -f 1", retain_output=True)
         self.arch_results = {}
         self.rpmguard = os.path.join(self.bindir, 'rpmguard')
         self.rpmdir = os.path.join(self.tmpdir, 'rpms')
+        #URL of logs/results stored on autotest-server
+        self.autotest_url = autoqa.util.make_autotest_url(self.config)
         os.makedirs(self.rpmdir)
 
 
@@ -181,12 +183,14 @@ rpmlint | cut -d ' ' -f 1", retain_output=True)
             warning_count = len([line for line in log.splitlines() \
                             if line.startswith('W: ')])
             print 'Sending email with results to %s ...' % result_email
+            mail_body = "Stored logs available at <%s>\n\n" % self.autotest_url
+            mail_body += log
             utils.send_email(mail_to=result_email,
                 mail_from=self.config.get('test','mail_from'),
                 mail_server=self.config.get('test','smtpserver'),
                 subject='rpmguard: %u warnings for package %s' % \
                     (warning_count, envr),
-                body = log)
+                body = mail_body)
 
         # if some command failed, make this test fail
         if test_result == 'FAIL':
diff --git a/tests/rpmlint/rpmlint.py b/tests/rpmlint/rpmlint.py
index 7ad6f90..c461346 100644
--- a/tests/rpmlint/rpmlint.py
+++ b/tests/rpmlint/rpmlint.py
@@ -28,6 +28,8 @@ class rpmlint(test.test):
 
     def initialize(self, envr, config):
         self.config = config_loader(config, self.tmpdir)
+        #URL of logs/results stored on autotest-server
+        self.autotest_url = autoqa.util.make_autotest_url(self.config)
 
     def setup(self):
         utils.system('yum -y install rpmlint')
@@ -66,12 +68,14 @@ class rpmlint(test.test):
             # parse last line for summary ('N errors, N warnings')
             summary = ((self.results.splitlines()[-1]).split(';')[-1])[1:-1]
             print 'Sending email with results to %s ...' % result_email
+            mail_body = "Stored logs available at <%s>\n\n" % self.autotest_url
+            mail_body += self.results
             utils.send_email(mail_to=result_email,
                 mail_from=self.config.get('test','mail_from'),
                 mail_server=self.config.get('test','smtpserver'),
                 subject='rpmlint: %s for package %s' % \
                     (summary, envr),
-                body = self.results)
+                body = mail_body)
         
         # if some command failed, make this test fail
         if result == 'FAIL':
-- 
1.6.6.1

