From f722dbb4c38c8a8aed06d3948149b8f990a1cb1e Mon Sep 17 00:00:00 2001 From: Earlopain Date: Mon, 15 May 2023 13:58:41 +0200 Subject: [PATCH] [Docker] Tentative fix for intermittent CI test failures Elastic indicies aren't ready sometimes. I don't know where they are created, but it seems to be too late. Move creation into the seeds file and execute it in all environments. Calling create_index! multiple times is fine, this is important because the seeds file should be idempotent --- bin/setup | 6 ------ db/seeds.rb | 8 +++----- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/bin/setup b/bin/setup index b5974a293..d74a48b01 100755 --- a/bin/setup +++ b/bin/setup @@ -24,12 +24,6 @@ FileUtils.chdir APP_ROOT do system! 'RAILS_ENV=development bin/rails db:schema:load' system! 'RAILS_ENV=development DANBOORU_DISABLE_THROTTLES=true bin/rails db:seed' - puts "\n== Preparing search indices ==" - system! 'bin/rails r Post.__elasticsearch__.create_index!' - system! 'bin/rails r Post.import' - system! 'bin/rails r PostVersion.__elasticsearch__.create_index!' - system! 'bin/rails r PostVersion.import' - puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' end diff --git a/db/seeds.rb b/db/seeds.rb index a0197e7a7..7d4c84108 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,11 +4,9 @@ require "digest/md5" require "net/http" require "tempfile" -unless Rails.env.test? - puts "== Creating elasticsearch indices ==\n" - - Post.__elasticsearch__.create_index! -end +puts "== Creating elasticsearch indices ==\n" +Post.__elasticsearch__.create_index! +PostVersion.__elasticsearch__.create_index! puts "== Seeding database with sample content ==\n"