ruby on rails - RSpec: How to test methods that use Parallel (PG::ConnectionBad error) -
in app have several builder classes responsible taking data received external api request , building/saving resources database. i'm dealing large amount of data , have implemented parallel gem speed using multiple processes.
however, i'm finding test method uses parallel fails same error:
activerecord::statementinvalid: pg::connectionbad: pqconsumeinput() server closed connection unexpectedly means server terminated abnormally before or while processing request.
here example of code being tested:
class airportbuilder < resource def build_from_collection parallel.each(object_producer, in_processes: 24) |params| instance = airport.find_or_initialize_by(fsid: params[:fs]) build!(instance, params) end end end
i've done searching on results in google have using multiple threads/processes make test suite run faster, different problem.
any ideas on how can test without causing pg error? realize may need stub out not quite sure stub , still have meaningful test.
thanks in advance might able help!
are using many database connections configured test database? maybe try setting pool size equal needs of script (which looks 24)?
test: adapter: whatever host: whatever username: whatever password: whatever database: whatever pool: 24
heads may want math on the default activerecord connection pool. info in this heroku dev center article.
Comments
Post a Comment