Method: TestGemTM::ProxyAgent#clear_server_mem

Defined in:
lib/TestGemTM/ProxyAgent.rb

#clear_server_mem(max_delete_retries = 2) ⇒ Object

clears proxy server memory returns: None



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
# File 'lib/TestGemTM/ProxyAgent.rb', line 70

def clear_server_mem(max_delete_retries=2)
  max_delete_retries.times do |n|
  	begin
    	    puts "Trying to Clear server memory at #{_proxy_url} for device #{@device_ip}..." if Calabash::Cucumber::Logging.full_console_logging?
          RestClient.delete ("#{_proxy_url}/log?src_ip=#{@device_ip}") { |response, request, result, &block|
          sleep 1
          case response.code
              when 200
              puts 'Success...!' if Calabash::Cucumber::Logging.full_console_logging?
              return response
          else
             puts "Failed to delete the logs on the proxy server. (attempt #{n+1})"
             if n==max_delete_retries-1
                 puts "Delete retry attempts exhausted.\nResponse: #{result.code} #{result.message}"
                 return false
             else
                 puts 'Retrying to delete after failure.'
             end
          end
          }
       rescue
          return false
       end
  end
end