@@ -83,37 +83,13 @@ def teardown_class(cls):
8383 def generate_random_string ():
8484 return '' .join (choice (ascii_lowercase ) for b in range (10 ))
8585
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-
11086 def handle_request_retry (self , method , url , kwargs ):
11187 for n in range (Executor .RETRY_COUNT ):
11288 try :
11389 self .logger .info ("Attempt #{}: running {} against {} with kwargs {}" .format (n + 1 , method , url , kwargs ))
11490 resp = requests .request (method , url , ** kwargs )
11591 resp .raise_for_status ()
116- return resp
92+ return resp . status_code , resp . content
11793 except Exception as e :
11894 self .logger .error ("Attempt #{} error: {}" .format (n + 1 , str (e )))
11995 if n < Executor .RETRY_COUNT - 1 :
@@ -187,22 +163,6 @@ def wait_for_containers(self, count, label=None, name=None, timeout=500):
187163 end = time .time ()
188164 return True
189165
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-
206166 def check_splunkd (self , username , password , name = None , scheme = "https" ):
207167 '''
208168 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):
330290 def check_common_keys (self , log_output , role ):
331291 try :
332292 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" ] == []
335295 assert log_output ["all" ]["vars" ]["retry_num" ] == 60
336296 assert log_output ["all" ]["vars" ]["retry_delay" ] == 6
337297 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):
419379 {"auth" : ("admin" , self .password ), "verify" : False })
420380 assert status == 200
421381 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