RSpec tests won't pass on discourse_dev docker image


(David Taylor) #1

I’ve been experimenting with different dev environments, and am trying to get the development docker image working. While everything seems to work fairly well, I can’t get the rspec tests to pass. Repro steps:

git clone -b tests-passed https://github.com/discourse/discourse discourse
cd discourse
./bin/docker/boot_dev --init
./bin/docker/bundle exec rspec

3 tests fail every time:

Failures:
  1) i18n integrity checks has an i18n key for each Site Setting
     Failure/Error: value = send(s)
     
     NoMethodError:
       undefined method `last_vacuum' for #<Class:0x00562777625f30>
     # ./lib/site_setting_extension.rb:180:in `block in all_settings'
     # ./lib/site_setting_extension.rb:179:in `each'
     # ./lib/site_setting_extension.rb:179:in `map'
     # ./lib/site_setting_extension.rb:179:in `all_settings'
     # ./spec/integrity/i18n_spec.rb:49:in `block (2 levels) in <top (required)>'
  2) Admin::SiteSettingsController while logged in as an admin index returns JSON
     Failure/Error: value = send(s)
     
     NoMethodError:
       undefined method `last_vacuum' for #<Class:0x00562777625f30>
     # ./lib/site_setting_extension.rb:180:in `block in all_settings'
     # ./lib/site_setting_extension.rb:179:in `each'
     # ./lib/site_setting_extension.rb:179:in `map'
     # ./lib/site_setting_extension.rb:179:in `all_settings'
     # ./app/controllers/admin/site_settings_controller.rb:4:in `index'
     # ./spec/controllers/admin/site_settings_controller_spec.rb:21:in `block (4 levels) in <top (required)>'
  3) Admin::SiteSettingsController while logged in as an admin index returns success
     Failure/Error: value = send(s)
     
     NoMethodError:
       undefined method `last_vacuum' for #<Class:0x00562777625f30>
     # ./lib/site_setting_extension.rb:180:in `block in all_settings'
     # ./lib/site_setting_extension.rb:179:in `each'
     # ./lib/site_setting_extension.rb:179:in `map'
     # ./lib/site_setting_extension.rb:179:in `all_settings'
     # ./app/controllers/admin/site_settings_controller.rb:4:in `index'
     # ./spec/controllers/admin/site_settings_controller_spec.rb:16:in `block (4 levels) in <top (required)>'

I’ve replicated this exact process on macOS and on Ubuntu.

Installing all the dependencies and running natively works on both macOS and Ubuntu, but I’d far rather use Docker if possible.

Am I missing a step somewhere, or is there something wrong with the docker scripts?


(Régis Hanol) #2

This is weird because there is no mention of “last_vacuum” in the entire source tree of Discourse…


(David Taylor) #3

Indeed, I did come across this (cannot remember how I managed to find this)

But that’s not in the current codebase of master or tests-passed. I wonder if it’s been left behind in some kind of database template in the docker image??? Or something like that

Edit: looks like it was removed in this commit by @tgxworld


(David Taylor) #4

Ok, I got it working by doing

git clone -b tests-passed https://github.com/discourse/discourse discourse
cd discourse
./bin/docker/boot_dev
./bin/docker/bundle install --retry=3 --jobs=3
./bin/docker/psql "-c 'ALTER USER discourse WITH SUPERUSER;'"
RAILS_ENV=test ./bin/docker/rake db:drop db:create db:migrate
./bin/docker/bundle exec rspec

Had to change the database permissions for the user ‘discourse’ because otherwise db:drop wouldn’t work.

So from that, I guess there is some kind of stale database setup in the docker image. Would it be possible to get that updated? Or maybe assign enough privileges to the postgres ‘discourse’ user to allow for dropping/creating tables in the discourse_dev image?


QUnit tests won't pass in discourse_dev docker image
Failing tests in discourse_dev due to multisite
(Leo McArdle) #5

This is still an issue, but this got it working, cheers!

Just a note to anybody else affected out there, this didn’t work on my first attempt and I think it’s because I don’t allow non-root to run docker, so the RAILS_ENV=test wasn’t getting passed through sudo.

So if you’re like me, use this to drop, create and migrate the db instead:

sudo d/shell
cd /src
RAILS_ENV=test rake db:drop db:create db:migrate