[Groonga-commit] droonga/droonga-engine at 38f23e2 [master] Add tests for EngineNode's status detections for absorb-source node

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Thu Apr 30 13:06:15 JST 2015


YUKI Hiroshi	2015-04-30 13:06:15 +0900 (Thu, 30 Apr 2015)

  New Revision: 38f23e246afb49ff05b042d6549edb8eccb4c162
  https://github.com/droonga/droonga-engine/commit/38f23e246afb49ff05b042d6549edb8eccb4c162

  Message:
    Add tests for EngineNode's status detections for absorb-source node

  Modified files:
    test/unit/test_engine_node.rb

  Modified: test/unit/test_engine_node.rb (+159 -0)
===================================================================
--- test/unit/test_engine_node.rb    2015-04-30 13:04:12 +0900 (d5a3425)
+++ test/unit/test_engine_node.rb    2015-04-30 13:06:15 +0900 (faa26ce)
@@ -233,4 +233,163 @@ class EngineNodeTest < Test::Unit::TestCase
                                   :state => data[:state]).status)
     end
   end
+
+  class FromAbsorbSource < self
+    class EngineNode < Droonga::EngineNode
+      private
+      def sender_role
+        Droonga::NodeRole::ABSORB_SOURCE
+      end
+    end
+
+    class BufferedEngineNode < EngineNode
+      private
+      def create_buffer
+        [0]
+      end
+    end
+
+    class NotBufferedEngineNode < EngineNode
+      private
+      def create_buffer
+        []
+      end
+    end
+
+    data(:same_role => {
+           "live" => true,
+           "role" => Droonga::NodeRole::ABSORB_SOURCE,
+         })
+    def test_forwardable(state)
+      assert_true(EngineNode.new(:name => "node29:2929/droonga",
+                                 :state => state).forwardable?)
+    end
+
+    data(:dead => {
+           "live" => false,
+           "role" => Droonga::NodeRole::ABSORB_SOURCE,
+         },
+         :to_service_provider => {
+           "live" => true,
+           "role" => Droonga::NodeRole::SERVICE_PROVIDER,
+         },
+         :to_absorb_destination => {
+           "live" => true,
+           "role" => Droonga::NodeRole::ABSORB_DESTINATION,
+         })
+    def test_not_forwardable(state)
+      assert_false(EngineNode.new(:name => "node29:2929/droonga",
+                                  :state => state).forwardable?)
+    end
+
+    data(:same_role_with_no_unprocessed_message => {
+           :state => {
+             "live" => true,
+             "role" => Droonga::NodeRole::ABSORB_SOURCE,
+           },
+           :class => NotBufferedEngineNode,
+         },
+         :have_unprocessed_message_in_other_node => {
+           :state => {
+             "live" => true,
+             "role" => Droonga::NodeRole::ABSORB_SOURCE,
+             "have_unprocessed_messages" => true,
+           },
+           :class => NotBufferedEngineNode,
+         })
+    def test_readable(data)
+      assert_true(data[:class].new(:name => "node29:2929/droonga",
+                                   :state => data[:state]).readable?)
+    end
+
+    data(:dead => {
+           :state => {
+             "live" => false,
+             "role" => Droonga::NodeRole::ABSORB_SOURCE,
+           },
+           :class => NotBufferedEngineNode,
+         },
+         :have_unprocessed_message => {
+           :state => {
+             "live" => true,
+             "role" => Droonga::NodeRole::ABSORB_SOURCE,
+           },
+           :class => BufferedEngineNode,
+         },
+         :to_service_provider => {
+           :state => {
+             "live" => true,
+             "role" => Droonga::NodeRole::SERVICE_PROVIDER,
+           },
+           :class => NotBufferedEngineNode,
+         },
+         :to_absorb_destination => {
+           :state => {
+             "live" => true,
+             "role" => Droonga::NodeRole::ABSORB_DESTINATION,
+           },
+           :class => NotBufferedEngineNode,
+         })
+    def test_not_readable(data)
+      assert_false(data[:class].new(:name => "node29:2929/droonga",
+                                    :state => data[:state]).readable?)
+    end
+
+    data(:same_role => {
+           "live" => true,
+           "role" => Droonga::NodeRole::ABSORB_SOURCE,
+         },
+         :to_dead => {
+           "live" => false,
+           "role" => Droonga::NodeRole::ABSORB_SOURCE,
+         },
+         :to_node_have_unprocessed_message => {
+           "live" => true,
+           "role" => Droonga::NodeRole::ABSORB_SOURCE,
+           "have_unprocessed_messages" => true,
+         })
+    def test_writable(state)
+      assert_true(EngineNode.new(:name => "node29:2929/droonga",
+                                 :state => state).writable?)
+    end
+
+    data(:to_service_provider => {
+           "live" => true,
+           "role" => Droonga::NodeRole::SERVICE_PROVIDER,
+         },
+         :to_absorb_destination => {
+           "live" => true,
+           "role" => Droonga::NodeRole::ABSORB_DESTINATION,
+         })
+    def test_not_writable(state)
+      assert_false(EngineNode.new(:name => "node29:2929/droonga",
+                                  :state => state).writable?)
+    end
+
+    data(:dead => {
+           :state => {
+             "live" => false,
+           },
+           :expected => "dead",
+         },
+         :readable => {
+           :state => {
+             "live" => true,
+             "role" => Droonga::NodeRole::ABSORB_SOURCE,
+           },
+           :expected => "active",
+         },
+         :not_readable_but_writable => {
+           :state => {
+             "live" => true,
+             "role" => Droonga::NodeRole::SERVICE_PROVIDER,
+           },
+           :expected => "inactive",
+         })
+    def test_status(data)
+      assert_equal(data[:expected],
+                   EngineNode.new(:name => "node29:2929/droonga",
+                                  :state => data[:state]).status)
+    end
+  end
 end
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る