最近需要预言:是否可以通过jira API实现用例管理,对jira的应用、API、扩展等进行了一定的了解。
jira是目前比较流行的基于Java架构的管理系统(Atlassian公司支持),有开源代码,方便做二次开发(可扩展性)。
https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2
https://baijiahao.baidu.com/s?id=1600789671759427109&wfr=spider&for=p
python的库中有专门针对jira的操作。官方文档: https://jira.readthedocs.io/en/latest/api.html#jira
1 #!/usr/bin/env python 2 # encoding: utf-8 3 from jira import JIRA 4 import time 5 6 jac = JIRA('http://xxx.xxx.xx.xxx:8080', basic_auth=('xxx', 'xxxyyy')) 7 issue_list1 = [] 8 for i in range(1000, 2000): 9 issue_list1.append({10 'project': {'key': 'TE'},11 'summary': "[%s]summary bulk added by api" % i,12 'description': '0', 13 'issuetype': {'id': 10007}14 })15 16 def func_time(func):17 def wrapper(*args, **kwargs):18 start = time.time()19 result = func(*args, **kwargs)20 end = time.time()21 print("call %s, time: %f" %(func.__name__, end - start))22 return result23 return wrapper24 25 @func_time26 def create_issues(issue_list2):27 # 批量创建28 issues = jac.create_issues(field_list=issue_list1)29 print(len(issue_list2))30 31 @func_time32 def search_one_issue():33 # 搜索指定的一个issue34 jra = jac.project('TE')35 a=jac.search_issues('project=TE and key = TE-400')36 37 @func_time38 def search_issues():39 # 批量搜索40 issues = jac.search_issues('project=TE', maxResults=600)41 print(len(issues))42 43 @func_time44 def update_one_issue():45 # 更新指定的一个issue46 myissue = jac.issue('TE-400')47 issueupdate = {48 'summary': 'test1001',49 'description': 'update_for_myisue'50 }51 myissue.update(issueupdate)52 53 a = myissue.fields()54 if a.summary == issueupdate.get('summary'):55 print("true")56 else:57 raise RunnerError('error')58 59 @func_time60 def get_issue():61 # 获取一个issue issueid or issuekey62 myissue = jac.issue('12006')63 64 @func_time65 def delete_issues():66 # 批量删除67 issues = jac.search_issues('project = TE AND description ~ "0"')68 for i in issues:69 i.delete()70 71 @func_time72 def delete_one_issue():73 # 删除一个指定的issue74 myissue = jac.issue('TE-1')75 myissue.delete()76 77 78 create_issues(issue_list1)79 search_one_issue()80 search_issues()81 update_one_issue()82 get_issue()83 delete_issues()841.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.
进程池—设定指定数量的进程,当有新的请求提交到pool中时,如果进程池还没有满,那么就会创建一个新的进程来执行该请求;如果进程池中的进程数已经达到最大值,那么该请求就会等待,直到进程池中有进程结束,才会创建新的进程进行相应的执行。
1 #coding:utf-8 2 from multiprocessing import Pool 3 import time 4 import gevent 5 from gevent import monkey 6 from jira import JIRA 7 9 jac = JIRA('http://200.200.84.135:8080', basic_auth=('zjx', 'jiaxin32213'))10 13 def run():14 for i in range(0,10):15 issue_value = {16 'project': {'key': 'TE'},17 'summary': "[%s]summary bulk added by api" % i,18 'description': '0',19 'issuetype': {'id': 10007}20 }21 jac.create_issue(fields = issue_value)22 24 def call_gevent(count):25 """调用gevent 模拟高并发"""26 begin_time = time.time()27 run_gevent_list = []28 for i in range(count):29 print('--------------%d--Test-------------' % i)30 run_gevent_list.append(gevent.spawn(run()))31 gevent.joinall(run_gevent_list)32 end = time.time()33 #print('单次测试时间(平均)s:', (end - begin_time) / count)34 print('累计测试时间 s:', end - begin_time)35 38 def main():39 begin_time = time.time()40 pool = Pool(processes=4)41 for x in range(3):42 result = pool.apply_async(call_gevent,(10,))43 pool.close()44 pool.join()45 if result.successful():46 print 'successful'47 end = time.time()48 print('累计测试时间 s:', end - begin_time)49 51 #main()531.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删