Revision 6f2b9836 snf-tools/synnefo_tools/burnin/common.py

b/snf-tools/synnefo_tools/burnin/common.py
37 37
"""
38 38

  
39 39
import sys
40
import datetime
40 41
import traceback
41 42
# Use backported unittest functionality if Python < 2.7
42 43
try:
......
79 80
    def _test_failed(self, test, err):
80 81
        """Test failed"""
81 82
        # Access to a protected member. pylint: disable-msg=W0212
82
        err_msg = test._testMethodDoc + "... failed."
83
        logger.error(test.__class__.__name__, err_msg)
83
        err_msg = test._testMethodDoc + "... failed (%s)."
84
        timestamp = datetime.datetime.strftime(
85
            datetime.datetime.now(), "%a %b %d %Y %H:%M:%S")
86
        logger.error(test.__class__.__name__, err_msg, timestamp)
84 87
        (err_type, err_value, err_trace) = err
85 88
        trcback = traceback.format_exception(err_type, err_value, err_trace)
86 89
        logger.info(test.__class__.__name__, trcback)
......
116 119
    """Common class that all burnin tests should implement"""
117 120
    clients = Clients()
118 121
    opts = None
122
    run_id = None
119 123

  
120 124
    @classmethod
121 125
    def setUpClass(cls):  # noqa
......
141 145
            self.clients.compute_url, self.clients.token)
142 146
        self.clients.compute.CONNECTION_RETRY_LIMIT = self.clients.retry
143 147

  
148
    # ----------------------------------
149
    # Loggers helper functions
144 150
    def log(self, msg, *args):
145 151
        """Pass the section value to logger"""
146 152
        logger.log(self.suite_name, msg, *args)
......
161 167
        """Pass the section value to logger"""
162 168
        logger.error(self.suite_name, msg, *args)
163 169

  
170
    # ----------------------------------
171
    # Helper functions that every testsuite may need
172
    def _get_uuid(self):
173
        """Get our uuid"""
174
        authenticate = self.clients.astakos.authenticate()
175
        uuid = authenticate['access']['user']['id']
176
        self.info("User's uuid is %s", uuid)
177
        return uuid
178

  
179
    def _get_username(self):
180
        """Get our User Name"""
181
        authenticate = self.clients.astakos.authenticate()
182
        username = authenticate['access']['user']['name']
183
        self.info("User's name is %s", username)
184
        return username
185

  
164 186

  
165 187
# --------------------------------------------------------------------
166 188
# Initialize Burnin
......
182 204

  
183 205
    # Pass the rest options to BurninTests
184 206
    BurninTests.opts = opts
207
    BurninTests.run_id = datetime.datetime.strftime(
208
        datetime.datetime.now(), "%Y%m%d%H%M%S")
185 209

  
186 210
    # Choose tests to run
187 211
    if opts.tests != "all":

Also available in: Unified diff