[Groonga-commit] groonga/groonga at cbd6f99 [master] grndb recover: add a test for --force-truncate with index column

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Apr 2 15:13:20 JST 2018


Kouhei Sutou	2018-04-02 15:13:20 +0900 (Mon, 02 Apr 2018)

  New Revision: cbd6f999c1f8d12394619ace580efcaf8f5bc2ea
  https://github.com/groonga/groonga/commit/cbd6f999c1f8d12394619ace580efcaf8f5bc2ea

  Message:
    grndb recover: add a test for --force-truncate with index column

  Modified files:
    lib/mrb/scripts/command_line/grndb.rb
    test/command_line/suite/grndb/test_recover.rb

  Modified: lib/mrb/scripts/command_line/grndb.rb (+1 -0)
===================================================================
--- lib/mrb/scripts/command_line/grndb.rb    2018-04-02 15:10:29 +0900 (3ac7d0e14)
+++ lib/mrb/scripts/command_line/grndb.rb    2018-04-02 15:13:20 +0900 (f5557c8f4)
@@ -474,6 +474,7 @@ module Groonga
 
           case object
           when IndexColumn
+            # It'll be recovered later.
             false
           when Column, Table
             object.locked?

  Modified: test/command_line/suite/grndb/test_recover.rb (+33 -20)
===================================================================
--- test/command_line/suite/grndb/test_recover.rb    2018-04-02 15:10:29 +0900 (4702bac09)
+++ test/command_line/suite/grndb/test_recover.rb    2018-04-02 15:13:20 +0900 (0329b4be2)
@@ -56,7 +56,8 @@ object corrupt: <[db][recover] table may be broken: <Users>: please truncate the
       groonga("column_create", "Users", "age", "COLUMN_SCALAR", "UInt8")
       groonga("lock_acquire", "Users.age")
 
-      _id, _name, path, *_ = JSON.parse(groonga("column_list Users").output)[1][2]
+      users_column_list = JSON.parse(groonga("column_list", "Users").output)
+      _id, _name, path, *_ = users_column_list[1][2]
       @column_path = path
     end
 
@@ -78,29 +79,41 @@ object corrupt: <[db][recover] column may be broken: <Users.age>: please truncat
     end
   end
 
-  def test_locked_index_column
-    groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText")
-    groonga("column_create", "Users", "age", "COLUMN_SCALAR", "UInt8")
+  sub_test_case("locked index column") do
+    def setup
+      groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText")
+      groonga("column_create", "Users", "age", "COLUMN_SCALAR", "UInt8")
 
-    groonga("table_create", "Ages", "TABLE_PAT_KEY", "UInt8")
-    groonga("column_create", "Ages", "users_age", "COLUMN_INDEX", "Users", "age")
+      groonga("table_create", "Ages", "TABLE_PAT_KEY", "UInt8")
+      groonga("column_create", "Ages", "users_age",
+              "COLUMN_INDEX", "Users", "age")
+
+      values = [{"_key" => "alice", "age" => 29}]
+      groonga("load",
+              "--table", "Users",
+              "--values",
+              Shellwords.escape(JSON.generate(values)))
+      groonga("truncate", "Ages")
+      groonga("lock_acquire", "Ages.users_age")
+    end
 
-    groonga("load",
-            "--table", "Users",
-            "--values",
-            Shellwords.escape(JSON.generate([{"_key" => "alice", "age" => 29}])))
-    groonga("truncate", "Ages")
-    groonga("lock_acquire", "Ages.users_age")
-    select_result = groonga_select("Users", "--query", "age:29")
-    n_hits, _columns, *_records = select_result[0]
-    assert_equal([0], n_hits)
+    def test_default
+      result = grndb("recover")
+      assert_equal("", result.error_output)
 
-    result = grndb("recover")
-    assert_equal("", result.error_output)
+      select_result = groonga_select("Users", "--query", "age:29")
+      n_hits, _columns, *_records = select_result[0]
+      assert_equal([1], n_hits)
+    end
 
-    select_result = groonga_select("Users", "--query", "age:29")
-    n_hits, _columns, *_records = select_result[0]
-    assert_equal([1], n_hits)
+    def test_force_truncate
+      result = grndb("recover", "--force-truncate")
+      assert_equal("", result.error_output)
+
+      select_result = groonga_select("Users", "--query", "age:29")
+      n_hits, _columns, *_records = select_result[0]
+      assert_equal([1], n_hits)
+    end
   end
 
   def test_force_clear_locked_database
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180402/becc0152/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index