1
- from toolset .benchmark .test_types .framework_test_type import FrameworkTestType
2
- from toolset .benchmark .test_types .verifications import basic_body_verification , verify_headers
3
- from time import sleep
1
+ from toolset .test_types .verifications import basic_body_verification , verify_headers
2
+ from toolset .test_types .abstract_test_type import AbstractTestType
4
3
5
4
6
- class PlaintextTestType ( FrameworkTestType ):
5
+ class TestType ( AbstractTestType ):
7
6
def __init__ (self , config ):
8
7
self .plaintext_url = ""
9
8
kwargs = {
@@ -12,14 +11,21 @@ def __init__(self, config):
12
11
'accept_header' : self .accept ('plaintext' ),
13
12
'args' : ['plaintext_url' ]
14
13
}
15
- FrameworkTestType .__init__ (self , config , ** kwargs )
14
+ AbstractTestType .__init__ (self , config , ** kwargs )
16
15
17
16
def verify (self , base_url ):
18
17
url = base_url + self .plaintext_url
19
18
headers , body = self .request_headers_and_body (url )
20
19
21
20
_ , problems = basic_body_verification (body , url , is_json_check = False )
22
21
22
+ # plaintext_url should be at least "/plaintext"
23
+ if len (self .plaintext_url ) < 10 :
24
+ problems .append (
25
+ ("fail" ,
26
+ "Route for plaintext must be at least 10 characters, found '{}' instead" .format (self .plaintext_url ),
27
+ url ))
28
+
23
29
if len (problems ) > 0 :
24
30
return problems
25
31
@@ -55,20 +61,20 @@ def get_script_name(self):
55
61
def get_script_variables (self , name , url ):
56
62
return {
57
63
'max_concurrency' :
58
- max (self .config .concurrency_levels ),
64
+ max (self .config .concurrency_levels ),
59
65
'name' :
60
- name ,
66
+ name ,
61
67
'duration' :
62
- self .config .duration ,
68
+ self .config .duration ,
63
69
'levels' :
64
- " " .join ("{}" .format (item )
65
- for item in self .config .pipeline_concurrency_levels ),
70
+ " " .join ("{}" .format (item )
71
+ for item in self .config .pipeline_concurrency_levels ),
66
72
'server_host' :
67
- self .config .server_host ,
73
+ self .config .server_host ,
68
74
'url' :
69
- url ,
75
+ url ,
70
76
'pipeline' :
71
- 16 ,
77
+ 16 ,
72
78
'accept' :
73
- "text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7"
79
+ "text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7"
74
80
}
0 commit comments