敏捷开发和测试中重现缺陷和验证缺陷的解决方案(3)

发表于:2013-4-11 11:08

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:章岩 吴江丽 王建秋    来源:51Testing软件测试网采编

  实现部分 2:缺陷验证环境的部署

  由于我们在系列第二篇中曾经提到对 RTC 中存储的缺陷添加"IWD Pattern"字段,用于存储虚拟系统模式的名字,这里可以直接通过 RTC RESTAPI 获得虚拟系统模式名称,然后通过 IWD 的命令行工具 (Command Line Tool) 或者 RESTAPI 在对应的 IWD 服务器上创建缺陷验证环境。

  IWD 提供的命令行工具可以直接从 IWD 的登陆界面上下载:

图 5. IWD 登陆界面中命令行工具下载页面

 

图 6. IWD 命令行工具本地文件结构

  IWD 命令行工具是通过 python 脚本调用 IWD RESTAPI 实现具体功能的,工具中的 readme 文件具体描述了如何调用 python 脚本,或者读者也可以从参考资源中提供的链接学习如何调用。以下是两个 python 脚本,在部署缺陷环境前先查找缺陷中记录的虚拟系统模式是否包含在这个 IWD 服务器中,如果在则继续部署这个虚拟系统模式为一个虚拟机环境。

  清单 2. 查看 IWD 服务器上所有虚拟系统模式信息

#
# For each pattern returned, the name of the pattern is presented
#
import ConfigParser
import threading, time, csv, random

# get all the vsystems associated with a pattern
# this emulates the user clicking on the "Systems" selection in the tree view
def get_systems(pattern, fname, fhandle):
    nsystems = 0
    start = time.time()
    nSystems = len(pattern.virtualsystems)
    for cnt in range (nSystems):
        try:
            system = pattern.virtualsystems[cnt]
        except:
            break       
    finish = time.time()
    fname.writerow([time.strftime("%m/%d/%Y"), time.strftime("%H:%M:%S"),'system',
                     nSystems, (finish-start)])
    fhandle.flush()
   
# get all the patterns
# this emulates the user clicking on the "Patterns" selection in the tree view
def get_patterns(fname, fhandle):
    start = time.time()
    patterns = deployer.patterns
    finish = time.time()
    fname.writerow([time.strftime("%m/%d/%Y"), time.strftime("%H:%M:%S"),'pattern',
                   len(patterns), (finish-start)])
    fhandle.flush()
   
    for pattern in patterns:
        if (len(pattern.virtualsystems) > 0):
            time.sleep(random.randint(1, 10))           
            get_systems(pattern, fname, fhandle)

######
config = ConfigParser.RawConfigParser()
config.read('listPatterns.cfg')

try:
    output = '%s_%s.csv' % (config.get('Main', 'outfile'),time.strftime("%Y%m%d@%H%M%S"))
    interval = config.getint('Main', 'interval')
    duration = config.getint('Main', 'duration')
except ConfigParser.Error:
    print "Error reading config file"
    sys.exit

fhandle = open(output, 'w')
fname = csv.writer(fhandle, delimiter=',')
fname.writerow(['date', 'time', 'type', 'number','duration'])
fhandle.flush()

print 'Running ...'
print 'Output File: %s\tDuration: %d\tInterval: %d' % (output, duration, interval)

end_time = time.time()+(60*duration)
while (end_time > time.time()):
    start = time.time()
    time.sleep(random.randint(1, 10))
    get_patterns(fname, fhandle)
   
    # only sleep the remainder of the interval
    time.sleep((time.time()+interval) - start)
   
print 'Completed on %s at %s' % (time.strftime("%m/%d/%Y"), time.strftime("%H:%M:%S"))
fhandle.close()

63/6<123456>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号