fluent-plugin-obsolete-plugins 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64c35dab27cb19ba6b8f33edd023c6dbcc100256b0f372e7f51f8d4dc99a3197
4
- data.tar.gz: aedff69e17e8d8ce189920ee3249e5385b3dbde50157b8b83630e40e276ad8cf
3
+ metadata.gz: b6c07c6ed495bdfdd502305198967a85e1d6f805ef16bc01b8ce742b05eb6512
4
+ data.tar.gz: afb33857dc7feff9a7cc1b8e843ee27bfdadf298d0b950b388c6700c884a7bb0
5
5
  SHA512:
6
- metadata.gz: '028c5a09fc99fac1c8be4a36c4ab1d2bdbd7c88178336771696d6e6e22393b6e2de14d42c7cfc2509a1e12b01b2204845ab1b342f0007badd75e46b96c7cd1b2'
7
- data.tar.gz: 1440e86c8bc39de6bcd6a68624254a624d4d2d235460430c22dc0ae1ded7cf54eb985b1662101f3ab7ebd25b0faf3ffd9e101de8909ef1df8ec1f79784a7ad2d
6
+ metadata.gz: decd922d81f4646b86fd12a39cd05545503560f0b968d0a5f37b14cb9153c837ba8a9cf99e7303e22d20a48c0858c8022197cf836aabf117963df69a78dee08e
7
+ data.tar.gz: 9f4da101e8d69efba32bc1f95ef7622b8947b2968c940e474ffaceafc0773ade65ed32e22de874bfe8491c898de23960517ca3bd86c51823dcc8995e511c1440
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-obsolete-plugins"
6
- spec.version = "0.2.0"
6
+ spec.version = "0.2.2"
7
7
  spec.authors = ["okkez"]
8
8
  spec.email = ["okkez000@gmail.com"]
9
9
 
@@ -15,6 +15,10 @@ module Fluent
15
15
  desc "Raise error if obsolete plugins are detected"
16
16
  config_param :raise_error, :bool, default: false
17
17
 
18
+ def multi_workers_ready?
19
+ true
20
+ end
21
+
18
22
  def configure(conf)
19
23
  super
20
24
 
@@ -28,8 +28,12 @@ class Fluent::Plugin::ObsoletePluginsUtils
28
28
  end
29
29
  end
30
30
 
31
+ def self.installed_plugins
32
+ Gem::Specification.find_all.select { |x| x.name =~ /^fluent(d|-(plugin|mixin)-.*)$/ }.map(&:name)
33
+ end
34
+
31
35
  def self.notify(logger, obsolete_plugins, raise_error: false)
32
- plugins = Gem.loaded_specs.keys & obsolete_plugins.keys
36
+ plugins = Fluent::Plugin::ObsoletePluginsUtils.installed_plugins & obsolete_plugins.keys
33
37
  plugins.each do |name|
34
38
  logger.warn("#{name} is obsolete: #{obsolete_plugins[name].chomp}")
35
39
  end
@@ -14,12 +14,25 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
14
14
  Timecop.return
15
15
  end
16
16
 
17
+ test "multi worker" do
18
+ config = %[
19
+ obsolete_plugins_yml #{fixture_path("obsolete-plugins.yml")}
20
+ ]
21
+
22
+ d = create_driver(config)
23
+ assert_true d.instance.multi_workers_ready?
24
+ end
25
+
17
26
  sub_test_case "obsolete_plugins_yml" do
18
27
  CONFIG_YAML = %[
19
28
  obsolete_plugins_yml #{fixture_path("obsolete-plugins.yml")}
20
29
  ]
21
30
 
22
31
  test "no obsolete plugins" do
32
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
33
+ []
34
+ end
35
+
23
36
  d = create_driver(CONFIG_YAML)
24
37
  d.run(default_tag: "test") do
25
38
  d.feed({ message: "This is test message." })
@@ -32,12 +45,10 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
32
45
  end
33
46
 
34
47
  test "obsolete plugins" do
35
- mock(Gem).loaded_specs do
36
- {
37
- "fluent-plugin-tail-multiline" => nil,
38
- "fluent-plugin-hostname" => nil
39
- }
48
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
49
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
40
50
  end
51
+
41
52
  d = create_driver(CONFIG_YAML)
42
53
  d.run(default_tag: "test") do
43
54
  d.feed({ message: "This is test message." })
@@ -52,11 +63,8 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
52
63
  end
53
64
 
54
65
  test "raise error when detect obsolete plugins" do
55
- mock(Gem).loaded_specs do
56
- {
57
- "fluent-plugin-tail-multiline" => nil,
58
- "fluent-plugin-hostname" => nil
59
- }
66
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
67
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
60
68
  end
61
69
 
62
70
  ex = assert_raise(Fluent::ConfigError) do
@@ -72,6 +80,10 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
72
80
  ]
73
81
 
74
82
  test "no obsolete plugins" do
83
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
84
+ []
85
+ end
86
+
75
87
  d = create_driver(CONFIG_JSON)
76
88
  d.run(default_tag: "test") do
77
89
  d.feed({ message: "This is test message." })
@@ -81,12 +93,10 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
81
93
  end
82
94
 
83
95
  test "obsolete plugins" do
84
- mock(Gem).loaded_specs do
85
- {
86
- "fluent-plugin-tail-multiline" => nil,
87
- "fluent-plugin-hostname" => nil
88
- }
96
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
97
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
89
98
  end
99
+
90
100
  d = create_driver(CONFIG_JSON)
91
101
  d.run(default_tag: "test") do
92
102
  d.feed({ message: "This is test message." })
@@ -100,11 +110,8 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
100
110
  end
101
111
 
102
112
  test "raise error when detect obsolete plugins" do
103
- mock(Gem).loaded_specs do
104
- {
105
- "fluent-plugin-tail-multiline" => nil,
106
- "fluent-plugin-hostname" => nil
107
- }
113
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
114
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
108
115
  end
109
116
 
110
117
  ex = assert_raise(Fluent::ConfigError) do
@@ -15,12 +15,25 @@ class ObsoletePluginsInputTest < Test::Unit::TestCase
15
15
  Timecop.return
16
16
  end
17
17
 
18
+ test "multi worker" do
19
+ config = %[
20
+ obsolete_plugins_yml #{fixture_path("obsolete-plugins.yml")}
21
+ ]
22
+
23
+ d = create_driver(config)
24
+ assert_true d.instance.multi_workers_ready?
25
+ end
26
+
18
27
  sub_test_case "plugins_json" do
19
28
  CONFIG_JSON = %[
20
29
  plugins_json #{fixture_path("plugins.json")}
21
30
  ]
22
31
 
23
32
  test "no obsolete plugins" do
33
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
34
+ []
35
+ end
36
+
24
37
  d = create_driver(CONFIG_JSON)
25
38
  d.run
26
39
  assert_equal([], d.events)
@@ -28,12 +41,10 @@ class ObsoletePluginsInputTest < Test::Unit::TestCase
28
41
  end
29
42
 
30
43
  test "obsolete plugins" do
31
- stub(Gem).loaded_specs do
32
- {
33
- "fluent-plugin-tail-multiline" => nil,
34
- "fluent-plugin-hostname" => nil
35
- }
44
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
45
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
36
46
  end
47
+
37
48
  d = create_driver(CONFIG_JSON)
38
49
  d.run
39
50
  assert_equal([], d.events)
@@ -45,11 +56,8 @@ class ObsoletePluginsInputTest < Test::Unit::TestCase
45
56
  end
46
57
 
47
58
  test "raise error when detect obsolete plugins" do
48
- stub(Gem).loaded_specs do
49
- {
50
- "fluent-plugin-tail-multiline" => nil,
51
- "fluent-plugin-hostname" => nil
52
- }
59
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
60
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
53
61
  end
54
62
 
55
63
  ex = assert_raise(Fluent::ConfigError) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-obsolete-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - okkez