def remote_psql_file(sql, user, host, password, local_file = '/tmp/temp.sql', remote_file = '/tmp/temp.sql'): file(filename = local_file, msg = sql) remotecmd.scp_command(from_user = '', from_host = '', from_file = local_file, to_user = '******', to_host = 'gpdb63.qa.dh.greenplum.com', to_file = ':' + remote_file, password = '******') cmd = 'source psql.sh && psql -d hawq_cov -t -f %s' % (remote_file) result = remotecmd.ssh_command(user = user, host = host, password = password, command = cmd) if str(result).find('ERROR:') != -1 or str(result).find('FATAL:') != -1: print(sql) print(str(result)) #sys.exit(2) return result
workloads_executor.execute() end_time = datetime.now() duration = end_time - beg_time duration = duration.days*24*3600*1000 + duration.seconds*1000 + duration.microseconds/1000 if monitor_interval > 0 and start_flag: monitor_control.stop() # update backend database to log execution time if add_database and start_flag: check.update_record(table_name = 'hst.test_run', set_content = "end_time = '%s', duration = %d" % (str(end_time), duration), search_condition = "start_time = '%s'" % (str(beg_time))) # add detailed execution information of test cases into backend database remotecmd.scp_command(from_user = '', from_host = '', from_file = report_sql_file, to_user = '******', to_host = 'gpdb63.qa.dh.greenplum.com', to_file = ':/tmp/', password = '******') cmd = 'source ~/psql.sh && psql -d hawq_cov -t -q -f /tmp/report.sql' remotecmd.ssh_command(user = '******', host = 'gpdb63.qa.dh.greenplum.com', password = '******', command = cmd) # retrieve test report from backend database for pulse report purpose result_file = os.path.join(report_directory, 'result.txt') tr_id = check.check_id(result_id = 'tr_id', table_name = 'hst.test_run', search_condition = "start_time = '%s'" % ( str(beg_time) )) sql = "select 'Test Suite Name|'|| wl_name || '|Test Case Name|' || action_type ||'.' || action_target \ || '|Test Detail|' \ || 'Actural Run time is: ' || CASE WHEN actual_execution_time is NOT NULL THEN actual_execution_time::int::text ELSE 'N.A.' END || ' ms, ' \ || 'Baseline time is: ' || CASE WHEN baseline_execution_time IS NOT NULL THEN baseline_execution_time::int::text ELSE 'N.A.' END || ' ms, ' \ || 'Comparision is: ' || CASE WHEN deviation is NOT NULL THEN deviation::decimal(5,2)::text ELSE 'N.A.' END \ || ' ('|| CASE WHEN actual_execution_time is NOT NULL THEN actual_execution_time::int::text ELSE '0' END || ' ms)' \ || '|Test Status|' || test_result \ from \ hst.f_generate_test_report_detail(%d, 'PHD 3.0', 'HAWQ 1.3.0.0 build 13048GVA HK') where lower(wl_name) not like '%s';" % (tr_id, '%' + 'rwithd' + '%')