黄瓜救援异常 (Ruby/HTTParty)

Cucumber rescue Exception (Ruby/HTTParty)

我只是在 运行 Cucumber 测试时遇到异常,我试图找到我能为它做些什么,但运气不好。

当我在最后一步制作post时:

When('accept terms of use') do
  until @o == 200
  @o = CadastroApp.sign_term1.code
  sleep 1
  end
end

class CadastroApp
  include HTTParty
   def self.sign_term1
   post("#{$uat_uri}agree/multipleterms",
     body: {
       'ContractsId': $contract1,
       'deviceType': 'Smartphone',
       'Platform': 'ios',
       'Model': 'Iphone XS max',
     }.to_json,
     headers: {
       'Authorization': "Bearer #{$auth_token}",
       'Content-Type': 'application/json'
     })
   end
  end

我收到错误:

52: def self.cucumber_run_with_backtrace_filtering(pseudo_method)
53:   begin
54:     yield
55:   rescue Exception => e
56:     instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
57:     replace_instance_exec_invocation_line!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
58:     raise e
59:   end
60: end

我不知道这是否是一个问题,但我使用了很多 "until @variable == 200" 来循环 api 直到我得到响应代码 200。

这是一个 MYSQL 问题。当我请求 API 时,MYSQL 没有关闭请求,所以我在检查 Kubernetes 时遇到很多超时。

Exception Caught by LogRequestResponseMiddleware:
1) ----- Exception Type
MySql.Data.MySqlClient.MySqlException
1) ----- Exception Source
MySql.Data
1) ----- Exception TargetSite
MySql.Data.MySqlClient.Driver GetConnection()
1) ----- Exception Message
error connecting: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.
Message = error connecting: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reac
hed.

所以我重新发布了 API 并且自动化工作正常。

这不是错误。这是 Ruby 在步骤失败时发送的响应。