ローカルマシンで壊れた wizard_builder_spec と application_controller_spec

ローカルマシンで壊れた仕様(specs)についてお手伝いをお願いできますでしょうか。今朝最新の master をクローンしたところ、ローカルマシンで 4 つの仕様が失敗しています:

1) Wizard::Builder colors step when the default them hass been override should set the right default values
   Failure/Error: expect(field.required).to eq(false)

     expected: false
          got: true

     (compared using ==)
   # ./spec/components/wizard/wizard_builder_spec.rb:171:in `block (4 levels) in <main>'

2) Wizard::Builder colors step when the default theme has not been override should set the right default values
   Failure/Error: SiteSetting.find_by(name: "default_theme_id").destroy!

   NoMethodError:
     undefined method `destroy!' for nil:NilClass
   # ./spec/components/wizard/wizard_builder_spec.rb:156:in `block (4 levels) in <main>'

3) ApplicationController#handle_theme selects the theme the user has selected
   Failure/Error: expect(controller.theme_ids).to eq([SiteSetting.default_theme_id])

     expected: [-1]
          got: []

     (compared using ==)
   # ./spec/requests/application_controller_spec.rb:295:in `block (3 levels) in <main>'

4) ApplicationController#handle_theme does not allow non privileged user to preview themes
   Failure/Error: expect(controller.theme_ids).to eq([SiteSetting.default_theme_id])

     expected: [-1]
          got: []

     (compared using ==)
   # ./spec/requests/application_controller_spec.rb:341:in `block (3 levels) in <main>'

私は postgres 11.5 を実行しており、discourse_development および discourse_test に対して hstorepg_trgm 拡張機能が有効になっていることを確認しました:

➜  discourse-master git:(master) ✗ psql --user lis2 discourse_development
psql (11.5 (Ubuntu 11.5-0ubuntu0.19.04.1))
Type "help" for help.

discourse_development=# \dx
                                    List of installed extensions
  Name   | Version |   Schema   |                            Description
---------+---------+------------+-------------------------------------------------------------------
 hstore  | 1.5     | public     | data type for storing sets of (key, value) pairs
 pg_trgm | 1.4     | public     | text similarity measurement and index searching based on trigrams
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language

以下は、すべての gem とそのバージョンのリストです:

rake 12.3.2
concurrent-ruby 1.1.5
i18n 1.6.0
minitest 5.11.3
thread_safe 0.3.6
tzinfo 1.2.5
activesupport 5.2.3
builder 3.2.3
erubi 1.8.0
mini_portile2 2.4.0
nokogiri 1.10.4
rails-dom-testing 2.0.3
crass 1.0.4
loofah 2.2.3
rails-html-sanitizer 1.0.4
actionview 5.2.3
rack 2.0.7
rack-test 1.1.0
actionpack 5.2.3
globalid 0.4.2
activejob 5.2.3
mini_mime 1.0.1
mail 2.7.1
actionmailer 5.2.3
activemodel 5.2.3
active_model_serializers 0.8.4
arel 9.0.0
activerecord 5.2.3
public_suffix 3.0.3
addressable 2.5.2
annotate 2.7.5
ast 2.4.0
aws-eventstream 1.0.3
aws-partitions 1.154.0
aws-sigv4 1.1.0
jmespath 1.4.0
aws-sdk-core 3.48.6
aws-sdk-kms 1.17.0
aws-sdk-s3 1.36.1
aws-sdk-sns 1.13.0
ember-source 2.18.2
execjs 2.7.0
barber 0.12.2
coderay 1.1.2
better_errors 2.5.1
debug_inspector 0.0.3
binding_of_caller 0.8.0
msgpack 1.2.10
bootsnap 1.4.4
uniform_notifier 1.12.1
bullet 6.0.0
bundler 1.17.3
byebug 11.0.1
certified 1.0.0
chunky_png 1.3.11
colored2 3.1.2
connection_pool 2.2.2
cppjieba_rb 0.3.3
safe_yaml 1.0.5
crack 0.4.3
css_parser 1.7.0
diff-lcs 1.3
diffy 3.3.0
discourse-ember-source 3.10.0.1
exifr 1.3.6
fspath 3.1.0
image_size 1.5.0
in_threads 1.5.1
progress 3.5.0
discourse_image_optim 0.26.2
docile 1.3.1
email_reply_trimmer 0.1.12
ember-data-source 3.0.2
sprockets 3.7.2
ember-handlebars-template 0.8.0
method_source 0.9.2
thor 0.20.3
railties 5.2.3
jquery-rails 4.3.3
ember-rails 0.18.5
excon 0.64.0
fabrication 2.20.1
fakeweb 1.3.0
multipart-post 2.1.1
faraday 0.15.4
fast_blank 1.0.0
rake-compiler 1.0.7
fast_xor 1.1.3
fast_xs 0.8.0
fastimage 2.1.5
ffi 1.10.0
flamegraph 0.9.5
gc_tracer 1.5.1
guess_html_encoding 0.0.11
hashdiff 0.3.9
hashie 3.6.0
highline 1.7.10
hiredis 0.6.3
hkdf 0.3.0
htmlentities 4.3.4
http_accept_language 2.0.5
jaro_winkler 1.5.2
json 2.2.0
jwt 2.2.1
kgio 2.11.2
libv8 7.3.492.27.1 (x86_64-linux)
rb-fsevent 0.10.3
rb-inotify 0.10.0
ruby_dep 1.5.0
listen 3.1.5
request_store 1.4.1
lograge 0.11.0
logstash-event 1.2.02
logstash-logger 0.26.1
logster 2.3.2
lru_redux 1.1.0
lz4-ruby 0.3.3
maxminddb 0.1.22
memory_profiler 0.9.13
message_bus 2.2.2
metaclass 0.0.4
mini_racer 0.2.6
rack-protection 2.0.7
redis 4.0.1
sidekiq 5.2.7
mini_scheduler 0.12.1
mini_sql 0.2.2
mini_suffix 0.3.0
mocha 1.8.0
mock_redis 0.19.0
moneta 1.1.1
multi_json 1.13.1
multi_xml 0.6.0
mustache 1.1.0
nokogumbo 2.0.1
oauth 0.5.4
oauth2 1.4.1
oj 3.7.12
omniauth 1.9.0
omniauth-oauth2 1.6.0
omniauth-facebook 5.0.0
omniauth-github 1.3.0
omniauth-google-oauth2 0.7.0
omniauth-instagram 1.3.0
omniauth-oauth 1.1.0
ruby-openid 2.7.0
rack-openid 1.3.1
omniauth-openid 1.0.1
omniauth-twitter 1.4.0
sanitize 5.0.0
onebox 1.9.12
openid-redis-store 0.0.2
optimist 3.0.0
parallel 1.17.0
parallel_tests 2.28.0
parser 2.6.3.0
pg 1.1.4
pry 0.12.2
pry-nav 0.3.0
pry-rails 0.3.9
puma 3.12.1
r2 0.2.7
rack-mini-profiler 1.0.2
rails_multisite 2.0.7
rainbow 3.0.0
raindrops 0.19.0
rbtrace 0.4.11
rchardet 1.8.0
redis-namespace 1.6.0
rinku 2.0.6
rotp 3.3.1
rqrcode 0.10.1
rspec-support 3.8.0
rspec-core 3.8.0
rspec-expectations 3.8.3
rspec-mocks 3.8.0
rspec 3.8.0
rspec-html-matchers 0.9.1
rspec-rails 3.8.2
rtlit 0.0.5
ruby-progressbar 1.10.0
unicode-display_width 1.6.0
rubocop 0.69.0
ruby-prof 0.17.0
ruby-readability 0.7.0
rubyzip 1.2.3
sassc 2.0.1
sprockets-rails 3.2.1
tilt 2.0.9
sassc-rails 2.1.1
seed-fu 2.3.9
shoulda-matchers 3.1.3
simplecov-html 0.10.2
simplecov 0.16.1
sshkey 2.0.0
stackprof 0.2.12
test-prof 0.9.0
uglifier 4.1.20
unf_ext 0.0.7.6
unf 0.1.4
unicorn 5.5.1
webmock 3.5.1
webpush 0.3.8
yaml-lint 0.0.10

仕様を失敗させる(赤くする)ような異常な点が見当たりますでしょうか?お手伝いいただきありがとうございます。

これらはすべてテーマやキャッシュに関連しているように感じられます。

以下の手順を試してみてください。

  • redis-cli flushall
  • dropdb discourse_test
  • rm -fr tmp/*
  • createdb discourse_test
  • RAILS_ENV=test bin/rake db:migrate
  • bin/rake autospec

キャッシュを破棄したファイルを保存しても、テストが正常に動作し始めますか?

これで完了です。動作しました。ありがとうございます!

Postgres 11.5 はすでに本番環境でサポートされていますか?互換性の問題があると聞いていましたが、どうやらそれは誤りのようです。(コミットを検索してみましたが……)

このマシンでのセットアップは開発目的のみです。スペックはグリーンで、基本的なスモークテストも成功しました。

Postgres 11 で問題ないという投稿を見つけました - PostgreSQL 11 Support

PG11 固有のオープンな issue があれば、ぜひ教えてください。問題なく動作するはずです。私の開発環境でも使っています。

今年後半にリリースされる PG 12 が公開されてから数ヶ月後に、Docker イメージ内の PG バージョンを 12 にアップグレードする予定です。

編集:新しいトピックを立てるべきでした。
編集:@sam にこの投稿を見てほしいだけなので、もし単に後回しになっているだけならお詫びします。

私にはそのような問題があると思います。

GCP 上のインスタンスで、同社の PostgreSQL 11 を使用しています。私は以下のコマンドを実行する必要がありました。

   - exec:
        cd: $home
        cmd:
          - apt -y remove postgresql-client-10
          - apt -y install postgresql-client-11

これでうまくいったようです。コンテナ内で以下が表示されます。

root@community-bootstrap-import:/var/www/discourse# psql --version
psql (PostgreSQL) 11.5 (Debian 11.5-1.pgdg100+1)

あ、でも待って!

postgres=> select version();
                                        version                                         
----------------------------------------------------------------------------------------
 PostgreSQL 11.4 on x86_64-pc-linux-gnu, compiled by gcc (Debian 7.3.0-5) 7.3.0, 64-bit
(1 row)

マイナーバージョンは重要でしょうか?

インポートを完了し、バックアップを取り、いくつかの作業を行い、その後そのバックアップを復元しようとしました。しかし、いくつかのテーブルが不足しているというエラーが発生し、それは私が何かを理解していないことによるものではないかと考えました。

そこでデータベースをドロップして再作成し、その後以下のコマンドを実行しました。

rake db:migrate
discourse backup
discourse enable_restore
discourse restore the-backup-filename

すると以下のようなエラーが表示されました。

...
No metadata file to extract.                                                           
Validating metadata...                                                                 
  Current version: 20190908234054                                                      
  Restored version: 20190908234054
tar: dump.sql: Not found in archive
tar: Exiting with failure status due to previous errors
Extracting dump file...
Creating missing functions in the discourse_functions schema
Cannot restore into different schema, restoring in-place
Enabling readonly mode...
Pausing sidekiq...
Waiting for sidekiq to finish running jobs...
Restoring dump file... (can be quite long)
SET
SET
SET
SET
SET
set_config
------------
(1 row)
SET
SET
SET
SET
ERROR:  schema "public" already exists
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block

また、以下のようなエラーも表示されました。

valid command \n                                                                     
invalid command \n                                                                     
invalid command \.                                                                        
ERROR:  syntax error at or near "1"                                                            
LINE 1: 1 20000225050318 AddSchemaMigrationDetails community-bootstr...                     
^                                                                                                   
invalid command \.                                                                     
ERROR:  syntax error at or near "20000225050318"                                       
LINE 1: 20000225050318                                                                 
^                                                                                      
invalid command \.                                                                     
ERROR:  current transaction is aborted, commands ignored until end of transaction block
invalid command \N                                                                     
invalid command \N                                                                     
invalid command \N                                                                     
invalid command \N                                                                      
invalid command \N                                                                     
invalid command \.                                                                     
ERROR:  syntax error at or near "1"                                                    
LINE 1: 1 10.0.0.0/8 2 0                                                               
^                                                                                      
invalid command \.                                                                     
ERROR:  current transaction is aborted, commands ignored until end of transaction block
invalid command \.                                                                     
ERROR:  current transaction is aborted, commands ignored until end of transaction block
invalid command \.                                                                     
ERROR:  current transaction is aborted, commands ignored until end of transaction block