-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
perf-script-ng
executable file
·110 lines (85 loc) · 3.12 KB
/
perf-script-ng
1
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python
"""
A script which is intended to mimic a more realistic usage of
Kiwi TCMS so we can collect some performance metrics.
Sample size: R
Number of test results: R^2
Number of API requests: 10 + 3R + 2R^2
"""
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = _create_unverified_https_context
import tcms_api
from datetime import datetime
RANGE_SIZE = 30
rpc_client = tcms_api.TCMS().exec
# ID values at public.tenant.kiwitcms.org
user = rpc_client.User.filter()[0]
# WARNING: target server needs to have 1 classification created
classification = rpc_client.Classification.filter({})[0]
# create a separate Product, Version & TestCase
product = rpc_client.Product.create({
'name': 'Product created at %s' % datetime.now().isoformat(),
'classification': classification['id'],
})
version = rpc_client.Version.create({
'product': product['id'],
'value': 'ver-%s' % datetime.now().isoformat(),
})
# create TestPlan
test_plan = rpc_client.TestPlan.create({
'name': 'TP: created at %s' % datetime.now().isoformat(),
'text': 'A script is creating this TP and adds TCs and TRs to it to establish a performance baseline',
'type': 7, # Performance
'product': product['id'],
'product_version': version['id'],
'is_active': True,
})
test_cases = []
priority = rpc_client.Priority.filter({})[0]
category = rpc_client.Category.filter({
'product': product['id'],
})[0]
confirmed_status = rpc_client.TestCaseStatus.filter({'is_confirmed': True})[0]
for j in range(RANGE_SIZE):
test_case = rpc_client.TestCase.create({
'summary': 'Case created at %s' % datetime.now().isoformat(),
'product': product['id'],
'category': category['id'],
'priority': priority['id'],
'case_status': confirmed_status['id'],
})
test_cases.append(test_case)
rpc_client.TestPlan.add_case(test_plan['id'], test_case['id'])
# create build, test run & test executions
pass_status = rpc_client.TestExecutionStatus.filter({'weight__gt': 0})[0]
build = rpc_client.Build.create({
'name': 'b.%s' % datetime.now().isoformat(),
'description': 'the product build at %s' % datetime.now().isoformat(),
'version': version['id'],
})
# create a separate TestPlan
for i in range(RANGE_SIZE):
test_run = rpc_client.TestRun.create({
'summary': 'TR %d %s' % (i, datetime.now().isoformat()),
'manager': user['id'],
'plan': test_plan['id'],
'build': build['id'],
})
print("TR-%d created" % test_run['id'])
# add cases to TR
for case in test_cases:
result = rpc_client.TestRun.add_case(test_run['id'], case['id'])
if not isinstance(result, list):
result = [result]
# record the results
for execution in result:
rpc_client.TestExecution.update(execution['id'], {
'status': pass_status['id'],
})