Module: TDriverErrorRecovery
- Included in:
- TDriverReportCreator
- Defined in:
- lib/tdriver/report/error_recovery/tdriver_error_recovery.rb
Instance Method Summary collapse
-
#attempt_reconnect(current_sut) ⇒ Object
attempts a reconnect for the current SUT === params current_sut === returns === raises.
-
#initialize_error_recovery ⇒ Object
Initializes error recovery settings === params === returns === raises.
-
#ping_device(current_sut) ⇒ Object
Ping the current SUT by querying xml state === params current sut === returns true for succesful ping false for failed ping === raises.
-
#ping_devices_and_reconnect ⇒ Object
Ping the devices and reconnect if ping fails === params === returns === raises.
-
#reconnect_devices ⇒ Object
Reconnects the devices without ping === params === returns === raises.
-
#start_error_recovery ⇒ Object
Starts the error recovery for SUTs === params === returns === raises.
Instance Method Details
#attempt_reconnect(current_sut) ⇒ Object
attempts a reconnect for the current SUT
params
current_sut
returns
raises
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 |
# File 'lib/tdriver/report/error_recovery/tdriver_error_recovery.rb', line 70 def attempt_reconnect(current_sut) MobyUtil::Logger.instance.log "behaviour" , "WARNING;Connection lost attempting to reconnect" attempt_reconnects=@recovery_settings.get_reconnect_attempts current_reconnect_attempt=0 b_error_recovery_succesful=false while current_reconnect_attempt.to_i<attempt_reconnects.to_i if @recovery_settings.get_ats4_error_recovery_enabled=='true' MobyUtil::Logger.instance.log "behaviour" , "WARNING;ATS4 Restarting Device #{current_sut.id}" #TDriver_Error_Recovery_ATS4.restartDatagateway(current_sut.id.to_s); current_sut.disconnect TDriver_Error_Recovery_ATS4.restartHardware(current_sut.id.to_s); ats_timeout=TDriver_Error_Recovery_ATS4.getBootTimeout(current_sut.id.to_s); MobyUtil::Logger.instance.log "behaviour" , "WARNING;Waiting for ATS4 error recovery #{ats_timeout}s" if ats_timeout.to_i > 0 sleep ats_timeout.to_i else MobyUtil::Logger.instance.log "behaviour" , "WARNING;Waiting ATS4 boot timeout is 0 using wait_time_for_ats4_error_recovery parameter timeout #{@recovery_settings.wait_time_for_ats4_error_recovery}s" sleep @recovery_settings.wait_time_for_ats4_error_recovery.to_i end MobyUtil::Logger.instance.log "behaviour" , "WARNING;ATS4 Restarted Device #{current_sut.id}" else MobyUtil::Logger.instance.log "behaviour" , "WARNING;Resetting sut: #{current_sut.id.to_s}" current_sut.reset MobyUtil::Logger.instance.log "behaviour" , "WARNING;Sut resetted" end if ping_device(current_sut)==true b_error_recovery_succesful=true MobyUtil::Logger.instance.log "behaviour" , "PASS;Device reconnected" current_reconnect_attempt=attempt_reconnects.to_i else current_reconnect_attempt+=1 end end raise MobyBase::BehaviourError.new("Error Recovery", "Error recovery failed after #{attempt_reconnects} recovery attempts") if b_error_recovery_succesful==false end |
#initialize_error_recovery ⇒ Object
Initializes error recovery settings
params
returns
raises
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tdriver/report/error_recovery/tdriver_error_recovery.rb', line 27 def initialize_error_recovery @recovery_settings=TDriverErrorRecoverySettings.new if @recovery_settings.get_ats4_error_recovery_enabled=='true' eval('module TDriver_Error_Recovery_ATS4 require \'dl/import\' extend DL::Importable dlload "callbackif" extern "void restartDatagateway(const char*)" extern "void restartHardware(const char*)" extern "int getBootTimeout(const char*)" extern "int error()" end') end end |
#ping_device(current_sut) ⇒ Object
Ping the current SUT by querying xml state
params
current sut
returns
true for succesful ping false for failed ping
raises
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/tdriver/report/error_recovery/tdriver_error_recovery.rb', line 130 def ping_device(current_sut) begin ui_xml=current_sut.get_ui_dump if !ui_xml MobyUtil::Logger.instance.log "behaviour" , "WARNING;Device ping failed" false else MobyUtil::Logger.instance.log "behaviour" , "PASS;Device ping succesful" true end rescue Exception => e puts e. puts e.backtrace MobyUtil::Logger.instance.log "behaviour" , "WARNING;Device ping failed" false end end |
#ping_devices_and_reconnect ⇒ Object
Ping the devices and reconnect if ping fails
params
returns
raises
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/tdriver/report/error_recovery/tdriver_error_recovery.rb', line 152 def ping_devices_and_reconnect() resetted=false TDriver::SUTFactory.connected_suts.each do |sut_id, sut_attributes| suts=@recovery_settings.get_monitored_sut suts.each do |monitored_sut| if sut_id.to_s==monitored_sut.to_s if ping_device(sut_attributes[:sut])==false resetted=true attempt_reconnect(sut_attributes[:sut]) end end end end resetted end |
#reconnect_devices ⇒ Object
Reconnects the devices without ping
params
returns
raises
110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/tdriver/report/error_recovery/tdriver_error_recovery.rb', line 110 def reconnect_devices() TDriver::SUTFactory.connected_suts.each do |sut_id, sut_attributes| suts=@recovery_settings.get_monitored_sut suts.each do |monitored_sut| if sut_id.to_s==monitored_sut.to_s attempt_reconnect(sut_attributes[:sut]) end end end end |
#start_error_recovery ⇒ Object
Starts the error recovery for SUTs
params
returns
raises
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/tdriver/report/error_recovery/tdriver_error_recovery.rb', line 47 def start_error_recovery() resetted=false initialize_error_recovery if @recovery_settings==nil if @recovery_settings.get_error_recovery_enabled=='true' MobyUtil::Logger.instance.log "behaviour" , "PASS;Starting error recovery" if @recovery_settings.get_reconnect_device=='true' if @recovery_settings.get_ping_connection=='true' resetted=ping_devices_and_reconnect() else reconnect_devices() resetted=true end end MobyUtil::Logger.instance.log "behaviour" , "PASS;Error recovery complete" end resetted end |