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()
def test_check_log(self): start_time = time.time() PSQL.run_sql_command( "SELECT * from some_table_that_does_not_exist_to_generate_errors_in_logs" ) time.sleep(2) end_time = time.time() self.assertTrue(GpLog.check_log_for_errors(start_time, end_time))
def inspect_cluster(self): """ This function will inspect the cluster from the start time of this test till now. Returns true if there are no errors in logs, False if there are errors in logs. @return: Returns True / False depending on whether errors were found in the log @rtype: boolean """ tinctest.logger.trace_in() start_time = self.start_time if start_time == 0 or not start_time: return True end_time = self.end_time if end_time == 0 or not end_time: end_time = time.time() return_status = not GpLog.check_log_for_errors(start_time, end_time) tinctest.logger.trace_out(str(return_status)) return return_status
def test_check_log(self): start_time = time.time() PSQL.run_sql_command("SELECT * from some_table_that_does_not_exist_to_generate_errors_in_logs") time.sleep(2) end_time = time.time() self.assertTrue(GpLog.check_log_for_errors(start_time, end_time))