做一个开发人员认可的测试人员(四)
作者:网络转载 发布时间:[ 2014/1/26 10:03:11 ] 推荐标签:响应时间 代码
//parse data
int i = 10;
for (i =10; i< dataList.size(); i++) {
temp = dataList.get(i).toString();
while(temp.indexOf("#Interval_Seq")>=0)
{
ArrayList tc = new ArrayList();
tc.add(dataList.get(i-1)); //tc description
for (; i < dataList.size();i++)
{
temp = dataList.get(i).toString();
if(temp.indexOf("#===")>=0 || temp.indexOf("---->")>=0)
break;
tc.add(temp);
}
testcases.add(tc);
}
if(temp.indexOf("---->")>=0)
break;
}
//Get level load start time
temp = dataList.get(i+1).toString();
String levelloadStart_timestamp = temp.substring(temp.indexOf("Date:")+6, temp.lastIndexOf(" GMT"));
//Get level load start time
temp = dataList.get(i+2).toString();
String levelloadEnd_timestamp = temp.substring(temp.indexOf("Date:")+6, temp.lastIndexOf(" GMT"));
//System.out.println(levelloadStart_timestamp);
String url = Config.getInstance().resultDBURL;
String userid = Config.getInstance().resultDBUser;
String password = Config.getInstance().resultDBPassword;
int execId = 0;
int test_no = 0;
int caseId = 0;
int buildId = 0;
int scID = 0;
int envID = 0;
int machine_ID = 0;
String tester = Config.getInstance().tester;
String env_description=Config.getInstance().test_env_desc;
String build_info=Config.getInstance().test_buildinfo;
String test_desc=Config.getInstance().test_desc;
try {
Class.forName("Name Of JDBC").newInstance();
Connection conn = DriverManager.getConnection(url, userid, password);
Log.getInstance().trace("Connected to resultDB.");
conn.setAutoCommit(false);
Statement ps = null;
ResultSet rs = null;
ps = conn.createStatement();
//get build_id
ps.execute("lock table buildinfo in exclusive mode");
rs = ps.executeQuery("select build_id from buildinfo where release='"+build_info+"'");
if (rs!=null && rs.next())
buildId = rs.getInt(1);
else //Insert a new scenario
{
ps.executeUpdate("insert into buildinfo(release) values('"+build_info+"')");
rs = ps.executeQuery("select build_id from buildinfo where release='"+build_info+"'");
if (rs!=null && rs.next())
buildId = rs.getInt(1);
}
conn.commit();
//get scenario_id by script name(.xml)
ps.execute("lock table scenarios in exclusive mode");
rs = ps.executeQuery("select sc_id from scenarios where name='"+sc_Name.trim()+"'");
if (rs!=null && rs.next())
scID = rs.getInt(1);
else //Insert a new scenario
{
ps.executeUpdate("insert into scenarios(name) values('"+sc_Name.trim()+"')");
rs = ps.executeQuery("SELECT sc_id from scenarios where name='"+sc_Name.trim()+"'");
if (rs!=null && rs.next())
scID = rs.getInt(1);
}
conn.commit();
//get env_id by env_description
InetAddress inet = InetAddress.getLocalHost();
String hostName = inet.getCanonicalHostName();
ps.execute("lock table environment in exclusive mode");
rs = ps.executeQuery("select env_id from environment where description='"+env_description+"'");
if (rs!=null && rs.next())
envID = rs.getInt(1);
else {
ps.executeUpdate("insert into environment(description) values('"+env_description+"')");
rs = ps.executeQuery("select env_id from environment where description='"+env_description+"'");
if (rs!=null && rs.next())
envID = rs.getInt(1);
}
conn.commit();
ps.execute("lock table machine in exclusive mode");
rs = ps.executeQuery("select b.machine_id from machine b where b.hostname='"+hostName+"'");
if (rs!=null && rs.next())
machine_ID = rs.getInt(1);
else {
ps.executeUpdate("insert into machine(hostname) values('"+hostName+"')");
rs = ps.executeQuery("select b.machine_id from machine b where b.hostname='"+hostName+"'");
if (rs!=null && rs.next())
machine_ID = rs.getInt(1);
}
conn.commit();
ps.execute("lock table env_machine in exclusive mode");
rs = ps.executeQuery("select env_id,machine_id from env_machine where env_id ="+ envID +" and machine_id ="+machine_ID);
if (rs!=null && rs.next()==false)
{
ps.executeUpdate("insert into env_machine(env_id, machine_id, m_use) values("+envID+","+machine_ID+",'TestClient')");
}
conn.commit();
相关推荐
更新发布
功能测试和接口测试的区别
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