-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestDataTable-API_requests_perf.robot
175 lines (148 loc) · 4.8 KB
/
TestDataTable-API_requests_perf.robot
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
*** Settings ***
Resource environment.robot
Library Collections
Library JsonValidator
Library RequestsLibrary
Library OperatingSystem
Library String
Suite Setup Ensure Test Data Exists
Test Tags Performance API RequestsLibrary
*** Variables ***
# ${Table} TT3
${Table} TT20
${Col 1} GC_20k
${Col 2} BNE_20k
${STT_MIN} 15
${STT_MAX} 45
# ${STT_MIN} 1
# ${STT_MAX} 2
*** Test cases ***
Get Hold Return Value GC
FOR ${index} IN RANGE 10
${column}= Set Variable ${Col 1}
Get TDT Value ${Table} ${column}
Standard Think Time
# put the values back
Return TDT Value ${Table} ${column} ${${column}}
Standard Think Time
END
# GET /<table name>/<column name>
Get Hold Return Value BNE
FOR ${index} IN RANGE 10
${column}= Set Variable ${Col 2}
Get TDT Value ${Table} ${column}
Standard Think Time
# put the values back
Return TDT Value ${Table} ${column} ${${column}}
Standard Think Time
END
Data cycle test
FOR ${index} IN RANGE 10
Create Perf_P1 Value
${column}= Set Variable P1
Standard Think Time
${p1val}= Get Perf Column ${column}
Standard Think Time
${column}= Set Variable P2
Set Perf Column ${column} ${p1val}
Standard Think Time
${p2val}= Get Perf Column ${column}
Standard Think Time
${column}= Set Variable P3
Set Perf Column ${column} ${p2val}
Standard Think Time
END
${column}= Set Variable P3
Delete Perf Column ${column}
Standard Think Time
Short Data cycle test
Create Perf_P1 Value
${column}= Set Variable P1
Standard Think Time
${p1val}= Get Perf Column ${column}
Standard Think Time
${column}= Set Variable P2
Set Perf Column ${column} ${p1val}
Standard Think Time
${p2val}= Get Perf Column ${column}
Standard Think Time
${column}= Set Variable ${p2val}
Set Perf Column ${column} ${p2val}
Standard Think Time
Delete Perf Column ${column}
${column}= Set Variable P3
Set Perf Column ${column} ${p2val}
Standard Think Time
${column}= Set Variable P3
Delete Perf Column ${column}
Standard Think Time
*** Keywords ***
Connect to TDT
[Documentation] Connect to TDT: http://${TDT_Host}
Create Session TDT http://${TDT_Host}
Log Connect to TDT:http://${TDT_Host}
Ensure Test Data Exists
Connect to TDT
${resp}= GET On Session TDT /${Table}/${Col 1}/all
Log ${resp.json()}
@{coldata}= Set Variable ${resp.json()['${Col 1}']}
${len}= Get Length ${coldata}
IF ${len} < 1000
${filedata}= Get File ${CURDIR}${/}testdata${/}${Col 1}.csv
@{filelines}= Split To Lines ${filedata}
FOR ${line} IN @{filelines}
# ${resp}= POST On Session TDT /${Table}/row {"${Col 1}":"${line}"} expected_status=201
${resp}= PUT On Session TDT /${Table}/${Col 1}/${line} expected_status=201
END
END
${resp}= GET On Session TDT /${Table}/${Col 2}/all
@{coldata}= Set Variable ${resp.json()['${Col 2}']}
${len}= Get Length ${coldata}
IF ${len} < 1000
${filedata}= Get File ${CURDIR}${/}testdata${/}${Col 2}.csv
@{filelines}= Split To Lines ${filedata}
FOR ${line} IN @{filelines}
# ${resp}= POST On Session TDT /${Table}/row {"${Col 1}":"${line}"} expected_status=201
${resp}= PUT On Session TDT /${Table}/${Col 2}/${line} expected_status=201
END
END
Get TDT Value
[Arguments] ${table} ${column}
[Documentation] Get TDT Value /${table}/${column}
${resp}= GET On Session TDT /${table}/${column}
Should Be Equal As Strings ${resp.status_code} 200
# ${TDT["${column}"]}= Set Variable ${resp.json()['${column}']}
${checkval}= Set Variable ${resp.json()['${column}']}
Set Global Variable ${${column}} ${checkval}
RETURN ${checkval}
Return TDT Value
[Arguments] ${table} ${column} ${value}
[Documentation] Return TDT Value /${table}/${column}
${resp}= PUT On Session TDT /${table}/${column}/${value}
Should Be Equal As Strings ${resp.status_code} 201
Standard Think Time
${number} Evaluate random.randint(${STT_MIN}, ${STT_MAX}) random
Log Standard Think Time (${number})
Sleep ${number}
Create Perf_P1 Value
[Documentation] Create Value in Table Perf Col P1
${number} Evaluate random.randint(5, 30) random
${RANDVAL}= Generate Random String ${number}
PUT On Session TDT /Perf/P1/${RANDVAL}
RETURN ${RANDVAL}
Get Perf Column
[Arguments] ${column}
[Documentation] Get Value from Perf ${column}
${resp}= GET On Session TDT /Perf/${column}
Should Be Equal As Strings ${resp.status_code} 200
RETURN ${resp.json()['${column}']}
Set Perf Column
[Arguments] ${column} ${value}
[Documentation] Set Value to Perf ${column}
${resp}= PUT On Session TDT /Perf/${column}/${value}
Should Be Equal As Strings ${resp.status_code} 201
Delete Perf Column
[Arguments] ${column}
[Documentation] Delete Value from Perf ${column}
${resp}= DELETE On Session TDT /Perf/${column}
Should Be Equal As Strings ${resp.status_code} 200