zombocom/derailed_benchmarks

Authentication with Devise issue

Closed this issue · 2 comments

I am using rails 5.2 and ruby 2.7.2

I am trying to authenticate using the perf.rake but i have no luck doing it until now.
When i uncomment the lines

# module DerailedBenchmarks
#   def auth.user
#     @user ||= User.find_by_email("jrodriguez@justclick.media")
#   end
# end

image

Running the code below produces the following output:
image

require 'bundler'
Bundler.setup
# 
require 'derailed_benchmarks'
require 'derailed_benchmarks/tasks'
# module DerailedBenchmarks
#   def auth.user
#     @user ||= User.find_by_email("jrodriguez@test.mail")
#   end
# end

DerailedBenchmarks.auth.user = -> { User.find_by_email("jrodriguez@test.mail") }

Gemfile

ruby '2.7.2'

source 'http://rubygems.org'

source 'http://rails-assets.org' do
  gem 'rails-assets-bootstrap', '3.3.7'
  gem 'rails-assets-chosen',  '1.6.2'
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '>= 5.2', '< 6.0'

gem 'pg', '~> 0.18.4'
# Use Puma as the app server
gem 'unicorn'
gem 'listen'
gem 'activerecord-import'
gem 'activerecord-session_store'
gem 'execjs'
gem 'therubyracer', platforms: :ruby

# gem 'dalli'
# gem 'memcached'

gem 'bootsnap'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.13'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
  gem 'xmpp4r'
  gem 'rollbar'
  gem 'bugsnag'
  gem 'ruby-debug-ide'
  gem 'debase'
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
gem 'rubocop'
gem 'acts_as_tenant'
gem 'devise'
gem 'authtrail'
gem 'aws-sdk-s3', '~> 1'
gem 'spy'
gem 'fastimage'
gem 'cocoon'
gem 'responders'
gem 'exception_notification'
gem 'bootstrap-datepicker-rails'
gem 'pagy', '~> 3.5'
# gem 'elastic-apm', group: :production

# Performance Improvement and Benchmarking
gem 'unicorn-worker-killer'
gem 'rack-mini-profiler', require: ['enable_rails_patches', 'rack-mini-profiler']

# # For memory profiling
gem 'memory_profiler'

# # For call-stack profiling flamegraphs
gem 'stackprof'
gem 'derailed_benchmarks', group: :development
root@07e8735272e9:/app# RAILS_ENV=production USE_AUTH=true bundle exec derailed exec perf:mem &> report.html
root@07e8735272e9:/app# RAILS_ENV=production USE_AUTH=true bundle exec derailed exec perf:mem &> report.html
root@07e8735272e9:/app# cat Gemfile
ruby '2.7.2'

source 'http://rubygems.org'

source 'http://rails-assets.org' do
  gem 'rails-assets-bootstrap', '3.3.7'
  gem 'rails-assets-chosen',  '1.6.2'
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '>= 5.2', '< 6.0'

gem 'pg', '~> 0.18.4'
# Use Puma as the app server
gem 'unicorn'
gem 'listen'
gem 'activerecord-import'
gem 'activerecord-session_store'
gem 'execjs'
gem 'therubyracer', platforms: :ruby

# gem 'dalli'
# gem 'memcached'

gem 'bootsnap'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.13'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
  gem 'xmpp4r'
  gem 'rollbar'
  gem 'bugsnag'
  gem 'ruby-debug-ide'
  gem 'debase'
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
gem 'rubocop'
gem 'acts_as_tenant'
gem 'devise'
gem 'authtrail'
gem 'aws-sdk-s3', '~> 1'
gem 'spy'
gem 'fastimage'
gem 'cocoon'
gem 'responders'
gem 'exception_notification'
gem 'bootstrap-datepicker-rails'
gem 'pagy', '~> 3.5'
# gem 'elastic-apm', group: :production

# Performance Improvement and Benchmarking
gem 'unicorn-worker-killer'
gem 'rack-mini-profiler', require: ['enable_rails_patches', 'rack-mini-profiler']

# # For memory profiling
gem 'memory_profiler'

# # For call-stack profiling flamegraphs
gem 'stackprof'
gem 'derailed_benchmarks'

Has anyone experienced the same trouble? What is the solution to this? Sorry if this is spam :'c

I was having a similar problem this morning.

Eventually getting into the console and ensuring that the call in perf.rake returned a valid user solved the problem.

#perf.rake
DerailedBenchmarks.auth.user = -> {  Refinery::Authentication::Devise::User.find_by_email('anita@joli.com.au')}

You were right Anita. thanks! I was providing the wrong class.