Closed rwilliams3088 closed 1 year ago
I need to see the full backtrace to determine the cause.
Here's the trace from one of the failed tests:
1) Api::PrinterValidation should call ZIFT to retrieve the printer validation data for the requested LineItems
Failure/Error: StorePriorityUpdateWorker.perform_async({ id: id })
Errno::ECONNREFUSED:
Connection refused - connect(2) for "localhost" port 7419
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/client.rb:264:in `initialize'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/client.rb:264:in `new'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/client.rb:264:in `open_socket'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/client.rb:60:in `initialize'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/connection.rb:11:in `new'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/connection.rb:11:in `block in create'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/connection_pool-2.3.0/lib/connection_pool/timed_stack.rb:169:in `try_create'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/connection_pool-2.3.0/lib/connection_pool/timed_stack.rb:73:in `block (2 levels) in pop'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/connection_pool-2.3.0/lib/connection_pool/timed_stack.rb:69:in `loop'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/connection_pool-2.3.0/lib/connection_pool/timed_stack.rb:69:in `block in pop'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/connection_pool-2.3.0/lib/connection_pool/timed_stack.rb:68:in `synchronize'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/connection_pool-2.3.0/lib/connection_pool/timed_stack.rb:68:in `pop'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/connection_pool-2.3.0/lib/connection_pool.rb:80:in `checkout'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/connection_pool-2.3.0/lib/connection_pool.rb:62:in `block in with'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/connection_pool-2.3.0/lib/connection_pool.rb:61:in `handle_interrupt'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/connection_pool-2.3.0/lib/connection_pool.rb:61:in `with'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/job.rb:102:in `block in client_push'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/middleware/chain.rb:129:in `block in invoke'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/middleware/batch.rb:14:in `call'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/middleware/chain.rb:131:in `block in invoke'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/middleware/chain.rb:134:in `invoke'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/job.rb:101:in `client_push'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/job.rb:65:in `perform_async'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/faktory_worker_ruby-1.2.0/lib/faktory/job.rb:117:in `perform_async'
# ./app/models/store.rb:35:in `update_batch_priority!'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/evaluation.rb:18:in `create'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/strategy/create.rb:9:in `tap'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/strategy/create.rb:9:in `result'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/factory.rb:43:in `run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/factory_runner.rb:28:in `run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/strategy/create.rb:5:in `association'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/evaluator.rb:33:in `association'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute/association.rb:19:in `block in to_proc'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/evaluator.rb:76:in `instance_exec'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/evaluator.rb:76:in `block in define_attribute'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:59:in `get'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:16:in `block (2 levels) in object'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:15:in `each'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:15:in `block in object'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:14:in `tap'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:14:in `object'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/evaluation.rb:13:in `object'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/strategy/create.rb:9:in `result'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/factory.rb:43:in `run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/factory_runner.rb:28:in `run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/strategy/create.rb:5:in `association'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/evaluator.rb:33:in `association'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute/association.rb:19:in `block in to_proc'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/evaluator.rb:76:in `instance_exec'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/evaluator.rb:76:in `block in define_attribute'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:59:in `get'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:16:in `block (2 levels) in object'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:15:in `each'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:15:in `block in object'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:14:in `tap'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:14:in `object'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/evaluation.rb:13:in `object'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/strategy/create.rb:9:in `result'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/factory.rb:43:in `run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/factory_runner.rb:28:in `run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/factory_bot-6.2.1/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/api/api/printer_validation_spec.rb:15:in `block (3 levels) in <top (required)>'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/vcr-6.1.0/lib/vcr/util/variable_args_block_caller.rb:9:in `call_block'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/vcr-6.1.0/lib/vcr.rb:194:in `use_cassette'
# ./spec/support/vcr.rb:18:in `use_cassette'
# ./spec/api/api/printer_validation_spec.rb:13:in `block (2 levels) in <top (required)>'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:124:in `block in run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:110:in `loop'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:110:in `run'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/rspec-retry-0.6.2/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
# /home/rwilliams/.rvm/gems/ruby-2.7.6/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:37:in `block (2 levels) in setup'
{"status":201,"time":{"total":25.23,"db":0,"view":25.23},"method":"POST","path":"/printer_validation","params":{"zift_ids":["OP-aN3xypxYokNmT77mZTYtRH","OP-PNSR24viwhrRoVfhEirME8","OP-nztYuyfeBRhUgXzf9NA2XQ","OP-66ogXiwW7prfexSe7uqYq8","OP-dzV6yxxuNGaQdRHHqRYzjF"]},"host":"www.example.com","date":"2023-03-30T14:04:06.444-07:00","level":"INFO","latency":25.23}
It looks like you have a test fixture factory which is creating a Faktory job.
# ./app/models/store.rb:35:in `update_batch_priority!'
# ./spec/api/api/printer_validation_spec.rb:15:in `block (3 levels) in <top (required)>'
The store model is setup to kick off a job using perform_async
whenever a particular attribute on the model is modified on the after_commit hook. It's not a test fixture - it just gets executed (indirectly) . Since this is a test, and I've called Faktory::Testing.fake!, then my expectation is that the perform_async in the model be faked.
Until you show me the code, I can't possibly know any of this.
Well I did tell you that in the OP
I talked with one of my coworkers who ran into similar errors in one of our other projects. It turns out there is a bug in version 1.2 of faktory_worker_ruby. Reverting to 1.1.1 fixes it.
Have you tried upgrading?
v1.2.0 is the latest, and according to my coworker it hasn't been fixed in that version yet. They notified the owner of the repo of the breakage, however, so it should hopefully be fixed in an upcoming release.
Sorry I misread and thought you said 1.1.2.
It took me too long to realize that this is a dupe of #74. v1.3.0 is now available with the fix.
I've added a line of code that calls perform_async on a job as part of an after_commit handler on one of my Active Record models, and now a bunch of unit tests are failing. I have attempted (in many locations) to call Faktory::Testing.fake!, yet it is still attempting to hit a faktory server rather than just mock things locally.
How can I properly mock Faktory for the purposes of unit testing (not integration testing)