@@ -83,37 +83,13 @@ def teardown_class(cls):
83
83
def generate_random_string ():
84
84
return '' .join (choice (ascii_lowercase ) for b in range (10 ))
85
85
86
- @classmethod
87
- def _run_cmd (cls , cmd , cwd = REPO_DIR ):
88
- if isinstance (cmd , list ):
89
- sh = command
90
- elif isinstance (command , str ):
91
- sh = shlex .split (command )
92
- cls .logger .info ("CALL: {}" .format (sh ))
93
- proc = subprocess .Popen (sh , stdout = subprocess .PIPE , stderr = subprocess .PIPE , cwd = cwd )
94
- lines = []
95
- err_lines = []
96
- for line in iter (proc .stdout .readline , '' ):
97
- lines .append (line )
98
- for line in iter (proc .stderr .readline , '' ):
99
- err_lines .append (line )
100
- proc .stdout .close ()
101
- proc .stderr .close ()
102
- proc .wait ()
103
- out = "" .join (lines )
104
- self .logger .info ("STDOUT: {}" .format (out ))
105
- err = "" .join (err_lines )
106
- self .logger .info ("STDERR: {}" .format (err ))
107
- self .logger .info ("RC: {}" .format (proc .returncode ))
108
- return out , err , proc .returncode
109
-
110
86
def handle_request_retry (self , method , url , kwargs ):
111
87
for n in range (Executor .RETRY_COUNT ):
112
88
try :
113
89
self .logger .info ("Attempt #{}: running {} against {} with kwargs {}" .format (n + 1 , method , url , kwargs ))
114
90
resp = requests .request (method , url , ** kwargs )
115
91
resp .raise_for_status ()
116
- return resp
92
+ return resp . status_code , resp . content
117
93
except Exception as e :
118
94
self .logger .error ("Attempt #{} error: {}" .format (n + 1 , str (e )))
119
95
if n < Executor .RETRY_COUNT - 1 :
@@ -187,22 +163,6 @@ def wait_for_containers(self, count, label=None, name=None, timeout=500):
187
163
end = time .time ()
188
164
return True
189
165
190
- def handle_request_retry (self , method , url , kwargs ):
191
- RETRIES = 10
192
- IMPLICIT_WAIT = 6
193
- for n in range (RETRIES ):
194
- try :
195
- self .logger .info ("Attempt #{}: running {} against {} with kwargs {}" .format (n + 1 , method , url , kwargs ))
196
- resp = requests .request (method , url , ** kwargs )
197
- resp .raise_for_status ()
198
- return (resp .status_code , resp .content )
199
- except Exception as e :
200
- self .logger .error ("Attempt #{} error: {}" .format (n + 1 , str (e )))
201
- if n < RETRIES - 1 :
202
- time .sleep (IMPLICIT_WAIT )
203
- continue
204
- raise e
205
-
206
166
def check_splunkd (self , username , password , name = None , scheme = "https" ):
207
167
'''
208
168
NOTE: This helper method can only be used for `compose up` scenarios where self.project_name is defined
@@ -330,8 +290,8 @@ def _run_command(self, command, defaults_url=None, apps_url=None):
330
290
def check_common_keys (self , log_output , role ):
331
291
try :
332
292
assert log_output ["all" ]["vars" ]["ansible_ssh_user" ] == "splunk"
333
- assert log_output ["all" ]["vars" ]["ansible_pre_tasks" ] == None
334
- assert log_output ["all" ]["vars" ]["ansible_post_tasks" ] == None
293
+ assert log_output ["all" ]["vars" ]["ansible_pre_tasks" ] == []
294
+ assert log_output ["all" ]["vars" ]["ansible_post_tasks" ] == []
335
295
assert log_output ["all" ]["vars" ]["retry_num" ] == 60
336
296
assert log_output ["all" ]["vars" ]["retry_delay" ] == 6
337
297
assert log_output ["all" ]["vars" ]["wait_for_splunk_retry_num" ] == 60
@@ -419,4 +379,4 @@ def check_dmc_groups(self, splunkd_port, num_idx, num_sh, num_cm, num_lm):
419
379
{"auth" : ("admin" , self .password ), "verify" : False })
420
380
assert status == 200
421
381
output = json .loads (content )
422
- assert len (output ["entry" ][0 ]["content" ]["member" ]) == num_sh
382
+ assert len (output ["entry" ][0 ]["content" ]["member" ]) == num_sh
0 commit comments