Project

General

Profile

Actions

Defect #40856

open

random failing integration test for plugin routes in 5.1.3

Added by Evgeni Golov 6 months ago. Updated 4 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

Hi,

I think this is related to #38707 and #39864. I have a plugin that carries routes and when I run rails test with that plugin installed, the tests randomly fail in 5.1-stable (and 5.1.3).

Here is a sort-of-minimal reproducer:

user@host % git clone -b 5.1-stable https://github.com/redmine/redmine
Cloning into 'redmine'...
remote: Enumerating objects: 199100, done.
remote: Counting objects: 100% (4955/4955), done.
remote: Compressing objects: 100% (1562/1562), done.
remote: Total 199100 (delta 3587), reused 4404 (delta 3328), pack-reused 194145
Receiving objects: 100% (199100/199100), 87.42 MiB | 28.39 MiB/s, done.
Resolving deltas: 100% (157526/157526), done.

user@host % cd redmine/plugins 

user@host % git clone -b redmine-5 https://github.com/theforeman/redmine_lightbox2
Cloning into 'redmine_lightbox2'...
remote: Enumerating objects: 850, done.
remote: Counting objects: 100% (36/36), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 850 (delta 11), reused 28 (delta 10), pack-reused 814
Receiving objects: 100% (850/850), 226.67 KiB | 3.15 MiB/s, done.
Resolving deltas: 100% (369/369), done.

user@host % cd ..
user@host % printf 'test:\n  adapter: sqlite3\n  database: db/redmine.sqlite3' > config/database.yml
user@host % bundle install   
user@host % SCMS=git DATABASE_ADAPTER=sqlite3 RAILS_ENV=test bundle exec rake ci:setup redmine:plugins:migrate

user@host % SCMS=git DATABASE_ADAPTER=sqlite3 RAILS_ENV=test bundle exec rails test --seed 14026

The following failure is expected (the plugin changes the layout of attachments):

Failure:
IssuesControllerTest#test_show_with_thumbnails_enabled_should_display_thumbnails [test/functional/issues_controller_test.rb:2781]:
Expected at least 1 element matching "a[href=\"/attachments/16\"]", found 0.
Expected 0 to be >= 1.

The following (and similar others from the same file) are not expected:

WikiControllerTest#test_show_page_without_edit_link:
RuntimeError: Neutered Exception ActionView::Template::Error: No route matches {:action=>"download_inline", :controller=>"attachments", :filename=>"ecookbook-gantt.pdf", :id=>#<Attachment id: 23, container_id: 1, container_type: "WikiPage", filename: "ecookbook-gantt.pdf", disk_filename: "190511141819_ecookbook-gantt.pdf", filesize: 31620, content_type: "application/pdf", digest: "da9c52e79d9eee7d47b9ee5db477985c542ea683e9f23ed32d...", downloads: 0, author_id: 2, created_on: "2019-05-11 05:18:19.000000000 +0000", description: "Gantt chart as of May 11", disk_directory: "2019/05">, :project_id=>"1"}
    plugins/redmine_lightbox2/app/views/attachments/_links.html.erb:32
    plugins/redmine_lightbox2/app/views/attachments/_links.html.erb:12
    app/helpers/attachments_helper.rb:52:in `link_to_attachments'
    app/views/wiki/show.html.erb:68
    lib/redmine/sudo_mode.rb:61:in `sudo_mode'
    test/functional/wiki_controller_test.rb:1158:in `test_show_page_without_edit_link'

Neither is this:

Failure:
WikiIntegrationTest#test_updating_a_renamed_page [test/integration/wiki_test.rb:39]:
Expected response to be a <2XX: success>, but was a <500: Internal Server Error>

The same tests do not fail on 5.0.6 and I could not see them fail on trunk (r22882) either.

The following patch makes the tests work reliably, but I think it's a crude hack:

commit 0d26803f78ff3e3ef87b7df34740090aa912c6d6
Author: Evgeni Golov <evgeni@golov.de>
Date:   Tue Jun 18 12:54:53 2024 +0200

    reset Redmine::Plugin.directory to Rails.root/plugins

    otherwise plugin routes are not properly loaded and tests fail

diff --git a/test/integration/routing/plugins_test.rb b/test/integration/routing/plugins_test.rb
index ddbf415a1..beb8597e7 100644
--- a/test/integration/routing/plugins_test.rb
+++ b/test/integration/routing/plugins_test.rb
@@ -65,6 +65,7 @@ class RoutingPluginsTest < Redmine::RoutingTest

     Redmine::Plugin.clear
     Redmine::PluginLoader.directory = @original_plugin_dir
+    Redmine::Plugin.directory = Rails.root.join('plugins')
     Redmine::PluginLoader.load
     RedmineApp::Application.instance.routes_reloader.reload!
   end

Setting Plugin.directory to @original_plugin_dir does not seem to fix it, which I find strange.

Actions #1

Updated by Evgeni Golov 6 months ago

Environment:
  Redmine version                5.1.3.stable
  Ruby version                   3.0.4-p208 (2022-04-12) [x86_64-linux]
  Rails version                  6.1.7.8
  Environment                    test
  Database adapter               SQLite
  Mailer queue                   ActiveJob::QueueAdapters::InlineAdapter
  Mailer delivery                test
Redmine settings:
  Redmine theme                  Default
SCM:
  Subversion                     1.14.3
  Mercurial                      6.7.3
  Git                            2.45.2
  Filesystem                     
Redmine plugins:
  redmine_lightbox2              0.5.1
Actions #2

Updated by Vincent Robert 6 months ago

I have the same problem with my plugins. To fix CI tests with Redmine 5.1.3, I currently have to remove plugins_test.rb from the core before running them.

rm test/integration/routing/plugins_test.rb

Actions #3

Updated by Ko Nagase 6 months ago

Vincent Robert wrote in #note-2:

I have the same problem with my plugins. To fix CI tests with Redmine 5.1.3, I currently have to remove plugins_test.rb from the core before running them.
[...]

I encountered the same issue in our custom fields groups plugin, and removing plugins_test.rb solved the routing errors.
https://github.com/gtt-project/redmine_custom_fields_groups/issues/35

Actions

Also available in: Atom PDF