做一个开发人员认可的测试人员(四)
作者:网络转载 发布时间:[ 2014/1/26 10:03:11 ] 推荐标签:响应时间 代码
SimpleDateFormat df = new SimpleDateFormat("dd MMM yyyy HH:mm:ss", Locale.US);
SimpleDateFormat df_db = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//get "test_no"
//check existing test_no first
// If same env_id , sc_id and start_time between +- 30 seconds, then it should be considered as same test
ps.execute("lock table execution in exclusive mode");
rs = ps.executeQuery("SELECT test_no FROM execution where env_id="+envID+" and sc_id="+scID+" and test_start between to_date('" + df_db.format(df.parse(testStart_timestamp)) + "','YYYY-MM-DD HH24:MI:SS') - 30 seconds and " +
"to_date('" + df_db.format(df.parse(testStart_timestamp)) + "','YYYY-MM-DD HH24:MI:SS') + 30 seconds ");
if (rs!=null && rs.next())
{
test_no = rs.getInt(1);
}
else {
rs = ps.executeQuery("SELECT nextval for Test_Seq FROM SYSDUMMY1");
if (rs!=null && rs.next())
test_no = rs.getInt(1);
}
//get exec_id
rs = ps.executeQuery("SELECT nextval for Exec_Seq FROM SYSDUMMY1");
if (rs!=null && rs.next())
{
execId = rs.getInt(1);
}
rs.close();
rs = null;
//execution
String sqlcmd = "INSERT INTO Execution(Exec_ID,Test_No, Build_ID,sc_id, env_id,VU,TESTER,Levelload_Start,Levelload_End" +
",Driver_Interval,Test_Start,Test_End, Description, machine_id) " +
"VALUES(" + execId + "," + test_no + ","+ buildId + "," + scID + "," + envID + "," +
vu + ",'" + tester + "',to_date('" + df_db.format(df.parse(levelloadStart_timestamp)) + "','YYYY-MM-DD HH24:MI:SS')," +
"to_date('" + df_db.format(df.parse(levelloadEnd_timestamp)) + "','YYYY-MM-DD HH24:MI:SS')," +
Config.getInstance().histoInterval + "," +
"to_date('" + df_db.format(df.parse(testStart_timestamp)) + "','YYYY-MM-DD HH24:MI:SS')," +
"to_date('" + df_db.format(df.parse(testStop_timestamp)) + "','YYYY-MM-DD HH24:MI:SS'),'" +
test_desc+ "',"+ machine_ID+")";
//System.out.println(sqlcmd);
ps.executeUpdate(sqlcmd);
for (i = 0; i< testcases.size(); i++)
{
//case
//Get case ID
caseId = 0;
rs = ps.executeQuery("SELECT nextval for Case_Seq FROM SYSDUMMY1");
if (rs!=null && rs.next())
caseId = rs.getInt(1);
//ps.close();
rs.close();
rs = null;
ArrayList casedetail = (ArrayList)testcases.get(i);
String tc_desc = casedetail.get(0).toString();
sqlcmd = "INSERT INTO CASEINFO(CASE_ID, CASE_NAME, DESCRIPTION, EXEC_ID) VALUES(" +
caseId + ", '" + tc_desc.substring(tc_desc.indexOf(" "), tc_desc.lastIndexOf(":")).trim() + "', '"+ tc_desc.substring(tc_desc.indexOf(":")+1, tc_desc.lastIndexOf(" ")).trim()+"'," + execId + ")" ;
//System.out.println(sqlcmd);
ps.executeUpdate(sqlcmd);
//result
PreparedStatement ps1 = conn.prepareStatement("INSERT INTO TRESULT( CASE_ID, INTERVAL_SEQ" +
", LOOP_COUNT, AVG, MIN, MAX, TOTAL_SLEEPTIME,ERROR_COUNT, EXE_COUNT, Exec_ID) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
for (int j = 2; j<casedetail.size();j++) {
//System.out.println(casedetail.get(j).toString());
String tmp[] = casedetail.get(j).toString().split(" ");
ps1.setInt(1, caseId);
ps1.setInt(2, Integer.parseInt(tmp[0]));
ps1.setInt(3, Integer.parseInt(tmp[1]));
ps1.setInt(4, Integer.parseInt(tmp[2]));
ps1.setInt(5, Integer.parseInt(tmp[3]));
ps1.setInt(6, Integer.parseInt(tmp[4]));
ps1.setInt(7, Integer.parseInt(tmp[5]));
ps1.setInt(8, Integer.parseInt(tmp[6]));
ps1.setInt(9, Integer.parseInt(tmp[7]));
ps1.setInt(10, execId);
ps1.addBatch();
}
ps1.clearParameters();
ps1.executeBatch();
}
conn.commit();
conn.close();
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11