Skip to content

Commit 217a660

Browse files
Jedokukostyanf14
authored andcommitted
Add run_on_studio powershell command fuction
Signed-off-by: Vitalii Chulak <[email protected]>
1 parent b68e0bf commit 217a660

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/engines/hcktest/tools.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class RestartMachineError < AutoHCKError; end
2929
# A custom RunOnMachine error exception
3030
class RunOnMachineError < AutoHCKError; end
3131

32+
# A custom RunOnStudio error exception
33+
class RunOnStudioError < AutoHCKError; end
34+
3235
# A custom UploadToMachineError error exception
3336
class UploadToMachineError < AutoHCKError; end
3437

@@ -160,6 +163,23 @@ def delete_machine(machine, pool)
160163
end
161164
end
162165

166+
def run_on_studio(command)
167+
retries ||= 0
168+
ret = act_with_tools { _1.run_on_studio(command) }
169+
170+
return ret if ret
171+
172+
e_message = "Running command (#{command}) on studio failed"
173+
raise RunOnStudioError, e_message
174+
rescue RunOnStudioError => e
175+
@logger.warn(e.message)
176+
raise unless (retries += 1) < ACTION_RETRIES
177+
178+
sleep ACTION_RETRY_SLEEP
179+
@logger.info("Trying again to run command (#{command}) on studio")
180+
retry
181+
end
182+
163183
def run_on_machine(machine, desc, cmd)
164184
retries ||= 0
165185
ret = act_with_tools { _1.run_on_machine(machine, cmd) }

0 commit comments

Comments
 (0)