test/plugin/test_out_mackerel.rb in fluent-plugin-mackerel-0.0.2 vs test/plugin/test_out_mackerel.rb in fluent-plugin-mackerel-0.0.3

- old
+ new

@@ -8,25 +8,41 @@ CONFIG = %[ type mackerel api_key 123456 hostid xyz - metrics_prefix service + metrics_prefix custom.service out_keys val1,val2,val3 ] CONFIG_NOHOST = %[ type mackerel api_key 123456 metrics_prefix service out_keys val1,val2,val3 ] + CONFIG_BLANK_METRICS = %[ + type mackerel + api_key 123456 + metrics_prefix + out_keys val1,val2,val3 + ] + CONFIG_SMALL_FLUSH_INTERVAL = %[ type mackerel api_key 123456 hostid xyz + metrics_prefix custom.service + out_keys val1,val2,val3 + flush_interval 1s + ] + + CONFIG_NOT_INSUFFICIENT_PREFIX = %[ + type mackerel + api_key 123456 + hostid xyz metrics_prefix service out_keys val1,val2,val3 flush_interval 1s ] @@ -42,29 +58,36 @@ assert_raise(Fluent::ConfigError) { d = create_driver(CONFIG_NOHOST) } + assert_raise(Fluent::ConfigError) { + d = create_driver(CONFIG_BLANK_METRICS) + } + d = create_driver(CONFIG_SMALL_FLUSH_INTERVAL) assert_equal d.instance.instance_variable_get(:@flush_interval), 60 + d = create_driver(CONFIG_NOT_INSUFFICIENT_PREFIX) + assert_equal d.instance.instance_variable_get(:@metrics_prefix), "custom.service" + d = create_driver() assert_equal d.instance.instance_variable_get(:@api_key), '123456' assert_equal d.instance.instance_variable_get(:@hostid), 'xyz' - assert_equal d.instance.instance_variable_get(:@metrics_prefix), 'service' + assert_equal d.instance.instance_variable_get(:@metrics_prefix), 'custom.service' assert_equal d.instance.instance_variable_get(:@out_keys), ['val1','val2','val3'] assert_equal d.instance.instance_variable_get(:@flush_interval), 60 end def test_write d = create_driver() stub(d.instance.mackerel).post_metrics([ - {"hostId"=>"xyz", "value"=>1.0, "time"=>1399997498, "name"=>"service.val1"}, - {"hostId"=>"xyz", "value"=>2.0, "time"=>1399997498, "name"=>"service.val2"}, - {"hostId"=>"xyz", "value"=>3.0, "time"=>1399997498, "name"=>"service.val3"}, - {"hostId"=>"xyz", "value"=>5.0, "time"=>1399997498, "name"=>"service.val1"}, - {"hostId"=>"xyz", "value"=>6.0, "time"=>1399997498, "name"=>"service.val2"}, - {"hostId"=>"xyz", "value"=>7.0, "time"=>1399997498, "name"=>"service.val3"}, + {"hostId"=>"xyz", "value"=>1.0, "time"=>1399997498, "name"=>"custom.service.val1"}, + {"hostId"=>"xyz", "value"=>2.0, "time"=>1399997498, "name"=>"custom.service.val2"}, + {"hostId"=>"xyz", "value"=>3.0, "time"=>1399997498, "name"=>"custom.service.val3"}, + {"hostId"=>"xyz", "value"=>5.0, "time"=>1399997498, "name"=>"custom.service.val1"}, + {"hostId"=>"xyz", "value"=>6.0, "time"=>1399997498, "name"=>"custom.service.val2"}, + {"hostId"=>"xyz", "value"=>7.0, "time"=>1399997498, "name"=>"custom.service.val3"}, ]) ENV["TZ"]="Asia/Tokyo" t = Time.strptime('2014-05-14 01:11:38', '%Y-%m-%d %T') d.emit({'val1' => 1, 'val2' => 2, 'val3' => 3, 'val4' => 4}, t) \ No newline at end of file