18691: Show readable_by query plan in test suite.
authorTom Clegg <tom@curii.com>
Mon, 14 Mar 2022 18:54:57 +0000 (14:54 -0400)
committerTom Clegg <tom@curii.com>
Mon, 14 Mar 2022 18:54:57 +0000 (14:54 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

services/api/test/unit/permission_test.rb

index 647139d9ec9d38d4d5570a19e658b866bd609544..efc43dfde54f6f9b3274c765465a067226a3de27 100644 (file)
@@ -602,4 +602,17 @@ class PermissionTest < ActiveSupport::TestCase
       end
     end
   end
+
+  # Show query plan for readable_by query. The plan for a test db
+  # might not resemble the plan for a production db, but it doesn't
+  # hurt to show the test db plan in test logs, and the .
+  [false, true].each do |include_trash|
+    test "query plan, include_trash=#{include_trash}" do
+      sql = Collection.readable_by(users(:active), include_trash: include_trash).to_sql
+      sql = "explain analyze #{sql}"
+      STDERR.puts sql
+      q = ActiveRecord::Base.connection.exec_query(sql)
+      q.rows.each do |row| STDERR.puts(row) end
+    end
+  end
 end