def test_gather_log_to_default_file(self): if os.path.exists(_DEFAULT_OUT_FILE): os.remove(_DEFAULT_OUT_FILE) self.assertFalse(os.path.exists(_DEFAULT_OUT_FILE)) start_time = time.time() PSQL.run_sql_command("select pg_sleep(2)") end_time = time.time() GpLog.gather_log(start_time=start_time, end_time=end_time) self.assertTrue(os.path.exists(_DEFAULT_OUT_FILE)) self.assertTrue(os.path.getsize(_DEFAULT_OUT_FILE) > 0)
def test_gather_log_out_file(self): out_file = '/tmp/cluster2.logs' if os.path.exists(out_file): os.remove(out_file) self.assertFalse(os.path.exists(out_file)) start_time = time.time() time.sleep(2) end_time = time.time() GpLog.gather_log(start_time=start_time, end_time=end_time, out_file=out_file) self.assertTrue(os.path.exists(out_file)) self.assertTrue(os.path.getsize(out_file) > 0)
def gather_log(self): """ This method will gather logs from all segments between start_time and end_time of the test and write it to an out file in the output directory. The default name of the log file will be <testmethodname>.logs """ tinctest.logger.trace_in() start_time = self.start_time if start_time == 0 or not start_time: return end_time = self.end_time if end_time == 0 or not end_time: end_time = time.time() out_file = os.path.join(self.get_out_dir(), self._testMethodName + '.logs') GpLog.gather_log(start_time, end_time, out_file) tinctest.logger.trace_out()