logstash-core 5.6.16-java → 6.0.0.alpha1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemspec_jars.rb +4 -7
- data/lib/logstash-core/logstash-core.jar +0 -0
- data/lib/logstash-core/version.rb +4 -8
- data/lib/logstash-core_jars.rb +12 -26
- data/lib/logstash/agent.rb +261 -246
- data/lib/logstash/api/commands/default_metadata.rb +1 -1
- data/lib/logstash/api/commands/hot_threads_reporter.rb +5 -11
- data/lib/logstash/api/commands/node.rb +3 -2
- data/lib/logstash/api/commands/stats.rb +3 -2
- data/lib/logstash/bootstrap_check/bad_java.rb +16 -0
- data/lib/logstash/bootstrap_check/bad_ruby.rb +12 -0
- data/lib/logstash/bootstrap_check/default_config.rb +17 -0
- data/lib/logstash/compiler.rb +38 -0
- data/lib/logstash/compiler/lscl.rb +566 -0
- data/lib/logstash/compiler/lscl/lscl_grammar.rb +3503 -0
- data/lib/logstash/compiler/treetop_monkeypatches.rb +92 -0
- data/lib/logstash/config/config_ast.rb +4 -82
- data/lib/logstash/config/mixin.rb +73 -41
- data/lib/logstash/config/pipeline_config.rb +48 -0
- data/lib/logstash/config/source/base.rb +16 -0
- data/lib/logstash/config/source/local.rb +215 -0
- data/lib/logstash/config/source_loader.rb +125 -0
- data/lib/logstash/converge_result.rb +103 -0
- data/lib/logstash/environment.rb +6 -19
- data/lib/logstash/errors.rb +2 -0
- data/lib/logstash/execution_context.rb +4 -7
- data/lib/logstash/filter_delegator.rb +6 -9
- data/lib/logstash/inputs/base.rb +0 -2
- data/lib/logstash/instrument/collector.rb +5 -7
- data/lib/logstash/instrument/metric_store.rb +12 -12
- data/lib/logstash/instrument/metric_type/mean.rb +0 -5
- data/lib/logstash/instrument/namespaced_metric.rb +0 -4
- data/lib/logstash/instrument/namespaced_null_metric.rb +0 -4
- data/lib/logstash/instrument/null_metric.rb +0 -10
- data/lib/logstash/instrument/periodic_poller/cgroup.rb +85 -168
- data/lib/logstash/instrument/periodic_poller/jvm.rb +5 -5
- data/lib/logstash/instrument/periodic_poller/pq.rb +3 -7
- data/lib/logstash/instrument/periodic_pollers.rb +1 -3
- data/lib/logstash/instrument/wrapped_write_client.rb +24 -33
- data/lib/logstash/logging/logger.rb +15 -47
- data/lib/logstash/namespace.rb +0 -1
- data/lib/logstash/output_delegator.rb +5 -7
- data/lib/logstash/outputs/base.rb +0 -2
- data/lib/logstash/pipeline.rb +159 -87
- data/lib/logstash/pipeline_action.rb +13 -0
- data/lib/logstash/pipeline_action/base.rb +29 -0
- data/lib/logstash/pipeline_action/create.rb +47 -0
- data/lib/logstash/pipeline_action/reload.rb +48 -0
- data/lib/logstash/pipeline_action/stop.rb +23 -0
- data/lib/logstash/plugin.rb +0 -1
- data/lib/logstash/plugins/hooks_registry.rb +6 -0
- data/lib/logstash/plugins/registry.rb +0 -1
- data/lib/logstash/program.rb +14 -0
- data/lib/logstash/queue_factory.rb +5 -1
- data/lib/logstash/runner.rb +58 -80
- data/lib/logstash/settings.rb +3 -27
- data/lib/logstash/state_resolver.rb +41 -0
- data/lib/logstash/util/java_version.rb +6 -0
- data/lib/logstash/util/safe_uri.rb +12 -148
- data/lib/logstash/util/thread_dump.rb +4 -7
- data/lib/logstash/util/wrapped_acked_queue.rb +36 -39
- data/lib/logstash/util/wrapped_synchronous_queue.rb +29 -39
- data/lib/logstash/version.rb +10 -8
- data/locales/en.yml +3 -54
- data/logstash-core.gemspec +8 -35
- data/spec/{logstash/api/modules → api/lib/api}/logging_spec.rb +10 -1
- data/spec/{logstash/api/modules → api/lib/api}/node_plugins_spec.rb +2 -1
- data/spec/{logstash/api/modules → api/lib/api}/node_spec.rb +3 -3
- data/spec/{logstash/api/modules → api/lib/api}/node_stats_spec.rb +3 -7
- data/spec/{logstash/api/modules → api/lib/api}/plugins_spec.rb +3 -4
- data/spec/{logstash/api/modules → api/lib/api}/root_spec.rb +2 -2
- data/spec/api/lib/api/support/resource_dsl_methods.rb +87 -0
- data/spec/{logstash/api/commands/stats_spec.rb → api/lib/commands/stats.rb} +2 -7
- data/spec/{logstash/api → api/lib}/errors_spec.rb +1 -1
- data/spec/{logstash/api → api/lib}/rack_app_spec.rb +0 -0
- data/spec/api/spec_helper.rb +106 -0
- data/spec/logstash/agent/converge_spec.rb +286 -0
- data/spec/logstash/agent/metrics_spec.rb +244 -0
- data/spec/logstash/agent_spec.rb +213 -225
- data/spec/logstash/compiler/compiler_spec.rb +584 -0
- data/spec/logstash/config/config_ast_spec.rb +8 -47
- data/spec/logstash/config/mixin_spec.rb +2 -42
- data/spec/logstash/config/pipeline_config_spec.rb +75 -0
- data/spec/logstash/config/source/local_spec.rb +395 -0
- data/spec/logstash/config/source_loader_spec.rb +122 -0
- data/spec/logstash/converge_result_spec.rb +179 -0
- data/spec/logstash/event_spec.rb +0 -66
- data/spec/logstash/execution_context_spec.rb +8 -12
- data/spec/logstash/filter_delegator_spec.rb +12 -24
- data/spec/logstash/inputs/base_spec.rb +7 -5
- data/spec/logstash/instrument/periodic_poller/cgroup_spec.rb +92 -225
- data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +1 -1
- data/spec/logstash/instrument/periodic_poller/os_spec.rb +32 -29
- data/spec/logstash/instrument/wrapped_write_client_spec.rb +33 -33
- data/spec/logstash/legacy_ruby_event_spec.rb +13 -4
- data/spec/logstash/output_delegator_spec.rb +11 -20
- data/spec/logstash/outputs/base_spec.rb +7 -5
- data/spec/logstash/pipeline_action/create_spec.rb +83 -0
- data/spec/logstash/pipeline_action/reload_spec.rb +83 -0
- data/spec/logstash/pipeline_action/stop_spec.rb +37 -0
- data/spec/logstash/pipeline_pq_file_spec.rb +1 -1
- data/spec/logstash/pipeline_spec.rb +81 -137
- data/spec/logstash/plugin_spec.rb +2 -1
- data/spec/logstash/plugins/hooks_registry_spec.rb +6 -0
- data/spec/logstash/queue_factory_spec.rb +13 -1
- data/spec/logstash/runner_spec.rb +29 -140
- data/spec/logstash/settings/writable_directory_spec.rb +10 -13
- data/spec/logstash/settings_spec.rb +0 -91
- data/spec/logstash/state_resolver_spec.rb +156 -0
- data/spec/logstash/timestamp_spec.rb +2 -6
- data/spec/logstash/util/java_version_spec.rb +22 -0
- data/spec/logstash/util/safe_uri_spec.rb +0 -56
- data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +22 -0
- data/spec/support/helpers.rb +9 -11
- data/spec/support/matchers.rb +96 -6
- data/spec/support/mocks_classes.rb +80 -0
- data/spec/support/shared_contexts.rb +2 -27
- metadata +100 -149
- data/lib/logstash/config/loader.rb +0 -107
- data/lib/logstash/config/modules_common.rb +0 -103
- data/lib/logstash/config/source/modules.rb +0 -55
- data/lib/logstash/config/string_escape.rb +0 -27
- data/lib/logstash/dependency_report.rb +0 -131
- data/lib/logstash/dependency_report_runner.rb +0 -17
- data/lib/logstash/elasticsearch_client.rb +0 -142
- data/lib/logstash/instrument/global_metrics.rb +0 -13
- data/lib/logstash/instrument/periodic_poller/dlq.rb +0 -24
- data/lib/logstash/modules/cli_parser.rb +0 -74
- data/lib/logstash/modules/elasticsearch_config.rb +0 -22
- data/lib/logstash/modules/elasticsearch_importer.rb +0 -37
- data/lib/logstash/modules/elasticsearch_resource.rb +0 -10
- data/lib/logstash/modules/file_reader.rb +0 -36
- data/lib/logstash/modules/kibana_base.rb +0 -24
- data/lib/logstash/modules/kibana_client.rb +0 -124
- data/lib/logstash/modules/kibana_config.rb +0 -105
- data/lib/logstash/modules/kibana_dashboards.rb +0 -36
- data/lib/logstash/modules/kibana_importer.rb +0 -17
- data/lib/logstash/modules/kibana_resource.rb +0 -10
- data/lib/logstash/modules/kibana_settings.rb +0 -40
- data/lib/logstash/modules/logstash_config.rb +0 -120
- data/lib/logstash/modules/resource_base.rb +0 -38
- data/lib/logstash/modules/scaffold.rb +0 -52
- data/lib/logstash/modules/settings_merger.rb +0 -23
- data/lib/logstash/modules/util.rb +0 -17
- data/lib/logstash/util/dead_letter_queue_manager.rb +0 -61
- data/lib/logstash/util/environment_variables.rb +0 -43
- data/spec/logstash/config/loader_spec.rb +0 -38
- data/spec/logstash/config/string_escape_spec.rb +0 -24
- data/spec/logstash/instrument/periodic_poller/dlq_spec.rb +0 -17
- data/spec/logstash/modules/logstash_config_spec.rb +0 -56
- data/spec/logstash/modules/scaffold_spec.rb +0 -234
- data/spec/logstash/pipeline_dlq_commit_spec.rb +0 -109
- data/spec/logstash/settings/splittable_string_array_spec.rb +0 -51
- data/spec/logstash/util/wrapped_acked_queue_spec.rb +0 -49
- data/versions-gem-copy.yml +0 -12
@@ -2,6 +2,7 @@
|
|
2
2
|
require "spec_helper"
|
3
3
|
require "logstash/execution_context"
|
4
4
|
require "logstash/inputs/base"
|
5
|
+
require "support/shared_contexts"
|
5
6
|
|
6
7
|
# use a dummy NOOP input to test Inputs::Base
|
7
8
|
class LogStash::Inputs::NOOP < LogStash::Inputs::Base
|
@@ -64,23 +65,24 @@ describe "LogStash::Inputs::Base#decorate" do
|
|
64
65
|
end
|
65
66
|
|
66
67
|
context "execution context" do
|
67
|
-
|
68
|
+
include_context "execution_context"
|
69
|
+
|
68
70
|
let(:klass) { LogStash::Inputs::NOOP }
|
69
71
|
|
70
72
|
subject(:instance) { klass.new({}) }
|
71
73
|
|
72
74
|
it "allow to set the context" do
|
73
75
|
expect(instance.execution_context).to be_nil
|
74
|
-
instance.execution_context =
|
76
|
+
instance.execution_context = execution_context
|
75
77
|
|
76
|
-
expect(instance.execution_context).to eq(
|
78
|
+
expect(instance.execution_context).to eq(execution_context)
|
77
79
|
end
|
78
80
|
|
79
81
|
it "propagate the context to the codec" do
|
80
82
|
expect(instance.codec.execution_context).to be_nil
|
81
|
-
instance.execution_context =
|
83
|
+
instance.execution_context = execution_context
|
82
84
|
|
83
|
-
expect(instance.codec.execution_context).to eq(
|
85
|
+
expect(instance.codec.execution_context).to eq(execution_context)
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
@@ -2,258 +2,127 @@
|
|
2
2
|
require "logstash/instrument/periodic_poller/cgroup"
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
LogStash::
|
5
|
+
describe LogStash::Instrument::PeriodicPoller::Cgroup do
|
6
|
+
subject { described_class }
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
let(:relative_path) { "/docker/a1f61" }
|
10
|
-
let(:proc_self_cgroup_content) do
|
11
|
-
%W(14:name=systemd,holaunlimited:#{relative_path}
|
12
|
-
13:pids:#{relative_path}
|
13
|
-
12:hugetlb:#{relative_path}
|
14
|
-
11:net_prio:#{relative_path}
|
15
|
-
10:perf_event:#{relative_path}
|
16
|
-
9:net_cls:#{relative_path}
|
17
|
-
8:freezer:#{relative_path}
|
18
|
-
7:devices:#{relative_path}
|
19
|
-
6:memory:#{relative_path}
|
20
|
-
5:blkio:#{relative_path}
|
21
|
-
4:cpuacct:#{relative_path}
|
22
|
-
3:cpu:#{relative_path}
|
23
|
-
2:cpuset:#{relative_path}
|
24
|
-
1:name=openrc:/docker
|
25
|
-
0::/docker)
|
26
|
-
end
|
27
|
-
describe Cgroup::CGroupResources do
|
28
|
-
subject(:cgroup_resources) { described_class.new }
|
29
|
-
context "method: cgroup_available?" do
|
30
|
-
context "resources exist" do
|
31
|
-
before do
|
32
|
-
allow(::File).to receive(:exist?).and_return(true)
|
33
|
-
end
|
34
|
-
it "returns true" do
|
35
|
-
expect(cgroup_resources.cgroup_available?).to be_truthy
|
36
|
-
end
|
37
|
-
end
|
38
|
-
context "resources do not exist" do
|
39
|
-
subject { described_class.new }
|
40
|
-
before do
|
41
|
-
allow(::File).to receive(:exist?).and_return(true)
|
42
|
-
allow(::File).to receive(:exist?).with("/proc/self/cgroup").and_return(false)
|
43
|
-
end
|
44
|
-
it "returns false" do
|
45
|
-
expect(cgroup_resources.cgroup_available?).to be_falsey
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "method: controller_groups" do
|
8
|
+
context ".are_cgroup_available?" do
|
9
|
+
context "all the file exist" do
|
51
10
|
before do
|
52
|
-
allow(
|
11
|
+
allow(::File).to receive(:exist?).with(subject::PROC_SELF_CGROUP_FILE).and_return(true)
|
12
|
+
allow(::Dir).to receive(:exist?).with(subject::PROC_CGROUP_CPU_DIR).and_return(true)
|
13
|
+
allow(::Dir).to receive(:exist?).with(subject::PROC_CGROUP_CPUACCT_DIR).and_return(true)
|
53
14
|
end
|
54
15
|
|
55
|
-
it "returns
|
56
|
-
|
57
|
-
|
58
|
-
controller = controllers["cpuacct"]
|
59
|
-
expect(controller).to be_a(Cgroup::CpuAcctResource)
|
60
|
-
expect(controller.base_path).to eq("/sys/fs/cgroup/cpuacct")
|
61
|
-
expect(controller.offset_path).to eq(relative_path)
|
62
|
-
expect(controller.override).to be_a(Cgroup::Override)
|
63
|
-
expect(controller.override.nil?).to be_truthy
|
64
|
-
|
65
|
-
controller = controllers["cpu"]
|
66
|
-
expect(controller).to be_a(Cgroup::CpuResource)
|
67
|
-
expect(controller.base_path).to eq("/sys/fs/cgroup/cpu")
|
68
|
-
expect(controller.offset_path).to eq(relative_path)
|
69
|
-
expect(controller.override).to be_a(Cgroup::Override)
|
70
|
-
expect(controller.override.nil?).to be_truthy
|
71
|
-
|
72
|
-
controller = controllers["name=systemd"]
|
73
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
74
|
-
expect(controller.controller).to eq("name=systemd")
|
75
|
-
expect(controller.original_path).to eq(relative_path)
|
76
|
-
|
77
|
-
controller = controllers["holaunlimited"]
|
78
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
79
|
-
expect(controller.controller).to eq("holaunlimited")
|
80
|
-
expect(controller.original_path).to eq(relative_path)
|
81
|
-
|
82
|
-
controller = controllers["pids"]
|
83
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
84
|
-
expect(controller.controller).to eq("pids")
|
85
|
-
expect(controller.original_path).to eq(relative_path)
|
86
|
-
|
87
|
-
controller = controllers["hugetlb"]
|
88
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
89
|
-
expect(controller.controller).to eq("hugetlb")
|
90
|
-
expect(controller.original_path).to eq(relative_path)
|
91
|
-
|
92
|
-
controller = controllers["net_prio"]
|
93
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
94
|
-
expect(controller.controller).to eq("net_prio")
|
95
|
-
expect(controller.original_path).to eq(relative_path)
|
96
|
-
|
97
|
-
controller = controllers["perf_event"]
|
98
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
99
|
-
expect(controller.controller).to eq("perf_event")
|
100
|
-
expect(controller.original_path).to eq(relative_path)
|
101
|
-
|
102
|
-
controller = controllers["net_cls"]
|
103
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
104
|
-
expect(controller.controller).to eq("net_cls")
|
105
|
-
expect(controller.original_path).to eq(relative_path)
|
106
|
-
|
107
|
-
controller = controllers["freezer"]
|
108
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
109
|
-
expect(controller.controller).to eq("freezer")
|
110
|
-
expect(controller.original_path).to eq(relative_path)
|
111
|
-
|
112
|
-
controller = controllers["devices"]
|
113
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
114
|
-
expect(controller.controller).to eq("devices")
|
115
|
-
expect(controller.original_path).to eq(relative_path)
|
116
|
-
|
117
|
-
controller = controllers["memory"]
|
118
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
119
|
-
expect(controller.controller).to eq("memory")
|
120
|
-
expect(controller.original_path).to eq(relative_path)
|
121
|
-
|
122
|
-
controller = controllers["blkio"]
|
123
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
124
|
-
expect(controller.controller).to eq("blkio")
|
125
|
-
expect(controller.original_path).to eq(relative_path)
|
126
|
-
|
127
|
-
controller = controllers["cpuset"]
|
128
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
129
|
-
expect(controller.controller).to eq("cpuset")
|
130
|
-
expect(controller.original_path).to eq(relative_path)
|
131
|
-
|
132
|
-
controller = controllers["name=openrc"]
|
133
|
-
expect(controller).to be_a(Cgroup::UnimplementedResource)
|
134
|
-
expect(controller.controller).to eq("name=openrc")
|
135
|
-
expect(controller.original_path).to eq("/docker")
|
16
|
+
it "returns true" do
|
17
|
+
expect(subject.are_cgroup_available?).to be_truthy
|
136
18
|
end
|
137
19
|
end
|
138
20
|
|
139
|
-
context "
|
21
|
+
context "not all the file exist" do
|
140
22
|
before do
|
141
|
-
|
142
|
-
|
143
|
-
allow(
|
23
|
+
allow(::File).to receive(:exist?).with(subject::PROC_SELF_CGROUP_FILE).and_return(true)
|
24
|
+
allow(::Dir).to receive(:exist?).with(subject::PROC_CGROUP_CPU_DIR).and_return(false)
|
25
|
+
allow(::Dir).to receive(:exist?).with(subject::PROC_CGROUP_CPUACCT_DIR).and_return(true)
|
144
26
|
end
|
145
|
-
after do
|
146
|
-
java.lang.System.clearProperty("ls.cgroup.cpu.path.override")
|
147
|
-
java.lang.System.clearProperty("ls.cgroup.cpuacct.path.override")
|
148
|
-
end
|
149
|
-
it "returns overridden control groups" do
|
150
|
-
controllers = cgroup_resources.controller_groups
|
151
|
-
controller = controllers["cpuacct"]
|
152
|
-
expect(controller).to be_a(Cgroup::CpuAcctResource)
|
153
|
-
expect(controller.override.nil?).to be_falsey
|
154
|
-
expect(controller.base_path).to eq("/sys/fs/cgroup/cpuacct")
|
155
|
-
expect(controller.offset_path).to eq("/bar")
|
156
|
-
expect(controller.override).to be_a(Cgroup::Override)
|
157
|
-
|
158
|
-
controller = controllers["cpu"]
|
159
|
-
expect(controller).to be_a(Cgroup::CpuResource)
|
160
|
-
expect(controller.override.nil?).to be_falsey
|
161
|
-
expect(controller.base_path).to eq("/sys/fs/cgroup/cpu")
|
162
|
-
expect(controller.offset_path).to eq("/foo")
|
163
|
-
expect(controller.override).to be_a(Cgroup::Override)
|
164
27
|
|
165
|
-
|
166
|
-
expect(
|
167
|
-
expect(controller.controller).to eq("cpuset")
|
168
|
-
expect(controller.original_path).to eq(relative_path)
|
28
|
+
it "returns false" do
|
29
|
+
expect(subject.are_cgroup_available?).to be_falsey
|
169
30
|
end
|
170
31
|
end
|
171
32
|
end
|
172
33
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
it "fills in the hash with minus one" do
|
193
|
-
expect(cpuacct_resource.base_path).to eq("/sys/fs/cgroup/cpuacct")
|
194
|
-
expect(cpuacct_resource.offset_path).to eq("/quux")
|
195
|
-
expect(cpuacct_resource.to_hash).to eq({:control_group=>"/quux", :usage_nanos=>-1})
|
196
|
-
end
|
197
|
-
end
|
34
|
+
context ".control_groups" do
|
35
|
+
let(:proc_self_cgroup_content) {
|
36
|
+
%w(14:name=systemd,holaunlimited:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
37
|
+
13:pids:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
38
|
+
12:hugetlb:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
39
|
+
11:net_prio:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
40
|
+
10:perf_event:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
41
|
+
9:net_cls:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
42
|
+
8:freezer:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
43
|
+
7:devices:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
44
|
+
6:memory:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
45
|
+
5:blkio:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
46
|
+
4:cpuacct:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
47
|
+
3:cpu:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
48
|
+
2:cpuset:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
49
|
+
1:name=openrc:/docker) }
|
50
|
+
|
51
|
+
before do
|
52
|
+
allow(subject).to receive(:read_proc_self_cgroup_lines).and_return(proc_self_cgroup_content)
|
198
53
|
end
|
199
|
-
end
|
200
54
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
let(:target) { Hash.new }
|
220
|
-
context "when the files cannot be found" do
|
221
|
-
it "fills in the hash with minus one" do
|
222
|
-
expect(cpu_resource.base_path).to eq("/sys/fs/cgroup/cpu")
|
223
|
-
expect(cpu_resource.offset_path).to eq("/quux")
|
224
|
-
expect(cpu_resource.to_hash).to eq({:cfs_period_micros=>-1, :cfs_quota_micros=>-1, :control_group=>"/quux", :stat=>{:number_of_elapsed_periods=>-1, :number_of_times_throttled=>-1, :time_throttled_nanos=>-1}})
|
225
|
-
end
|
226
|
-
end
|
55
|
+
it "returns the control groups" do
|
56
|
+
expect(subject.control_groups).to match({
|
57
|
+
"name=systemd" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
58
|
+
"holaunlimited" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
59
|
+
"pids" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
60
|
+
"hugetlb" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
61
|
+
"net_prio" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
62
|
+
"perf_event" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
63
|
+
"net_cls" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
64
|
+
"freezer" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
65
|
+
"devices" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
66
|
+
"memory" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
67
|
+
"blkio" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
68
|
+
"cpuacct" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
69
|
+
"cpu" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
70
|
+
"cpuset" => "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61",
|
71
|
+
"name=openrc" => "/docker"
|
72
|
+
})
|
227
73
|
end
|
228
74
|
end
|
229
75
|
|
230
|
-
|
231
|
-
|
76
|
+
context ".get_all" do
|
77
|
+
context "when we can retrieve the stats" do
|
78
|
+
let(:cpuacct_control_group) { "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61" }
|
232
79
|
let(:cpuacct_usage) { 1982 }
|
80
|
+
let(:cpu_control_group) { "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61" }
|
233
81
|
let(:cfs_period_micros) { 500 }
|
234
82
|
let(:cfs_quota_micros) { 98 }
|
235
83
|
let(:cpu_stats_number_of_periods) { 1 }
|
236
84
|
let(:cpu_stats_number_of_time_throttled) { 2 }
|
237
85
|
let(:cpu_stats_time_throttled_nanos) { 3 }
|
238
|
-
let(:
|
239
|
-
|
240
|
-
|
86
|
+
let(:proc_self_cgroup_content) {
|
87
|
+
%W(14:name=systemd,holaunlimited:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
88
|
+
13:pids:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
89
|
+
12:hugetlb:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
90
|
+
11:net_prio:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
91
|
+
10:perf_event:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
92
|
+
9:net_cls:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
93
|
+
8:freezer:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
94
|
+
7:devices:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
95
|
+
6:memory:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
96
|
+
5:blkio:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
97
|
+
4:cpuacct:#{cpuacct_control_group}
|
98
|
+
3:cpu:#{cpu_control_group}
|
99
|
+
2:cpuset:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
100
|
+
1:name=openrc:/docker) }
|
101
|
+
let(:cpu_stat_file_content) {
|
102
|
+
[
|
103
|
+
"nr_periods #{cpu_stats_number_of_periods}",
|
104
|
+
"nr_throttled #{cpu_stats_number_of_time_throttled}",
|
105
|
+
"throttled_time #{cpu_stats_time_throttled_nanos}"
|
106
|
+
]
|
107
|
+
}
|
108
|
+
|
241
109
|
before do
|
242
|
-
allow(
|
243
|
-
allow(
|
244
|
-
|
245
|
-
allow(
|
246
|
-
allow(
|
247
|
-
allow(
|
110
|
+
allow(subject).to receive(:read_proc_self_cgroup_lines).and_return(proc_self_cgroup_content)
|
111
|
+
allow(subject).to receive(:read_sys_fs_cgroup_cpuacct_cpu_stat).and_return(cpu_stat_file_content)
|
112
|
+
|
113
|
+
allow(subject).to receive(:cgroup_cpuacct_usage_nanos).with(cpuacct_control_group).and_return(cpuacct_usage)
|
114
|
+
allow(subject).to receive(:cgroup_cpu_fs_period_micros).with(cpu_control_group).and_return(cfs_period_micros)
|
115
|
+
allow(subject).to receive(:cgroup_cpu_fs_quota_micros).with(cpu_control_group).and_return(cfs_quota_micros)
|
248
116
|
end
|
117
|
+
|
249
118
|
it "returns all the stats" do
|
250
|
-
expect(
|
119
|
+
expect(subject.get_all).to match(
|
251
120
|
:cpuacct => {
|
252
|
-
:control_group =>
|
121
|
+
:control_group => cpuacct_control_group,
|
253
122
|
:usage_nanos => cpuacct_usage,
|
254
123
|
},
|
255
124
|
:cpu => {
|
256
|
-
:control_group =>
|
125
|
+
:control_group => cpu_control_group,
|
257
126
|
:cfs_period_micros => cfs_period_micros,
|
258
127
|
:cfs_quota_micros => cfs_quota_micros,
|
259
128
|
:stat => {
|
@@ -268,14 +137,12 @@ describe "cgroup stats" do
|
|
268
137
|
|
269
138
|
context "when an exception is raised" do
|
270
139
|
before do
|
271
|
-
allow(
|
272
|
-
allow(Cgroup::CGROUP_RESOURCES).to receive(:controller_groups).and_raise("Something went wrong")
|
140
|
+
allow(subject).to receive(:control_groups).and_raise("Something went wrong")
|
273
141
|
end
|
274
142
|
|
275
|
-
it "
|
276
|
-
expect(
|
143
|
+
it "returns nil" do
|
144
|
+
expect(subject.get_all).to be_nil
|
277
145
|
end
|
278
146
|
end
|
279
147
|
end
|
280
148
|
end
|
281
|
-
end end end
|
@@ -44,7 +44,7 @@ describe LogStash::Instrument::PeriodicPoller::JVM do
|
|
44
44
|
before do
|
45
45
|
expect(LogStash::Environment).to receive(:windows?).and_return(false)
|
46
46
|
expect(LogStash::Environment).to receive(:linux?).and_return(true)
|
47
|
-
expect(::File).to receive(:read).with("/proc/loadavg").
|
47
|
+
expect(::File).to receive(:read).with("/proc/loadavg").and_raise("Didnt work out so well")
|
48
48
|
end
|
49
49
|
|
50
50
|
it "doesn't raise an exception" do
|
@@ -12,43 +12,46 @@ describe LogStash::Instrument::PeriodicPoller::Os do
|
|
12
12
|
let(:snapshot_store) { metric.collector.snapshot_metric.metric_store }
|
13
13
|
let(:os_metrics) { snapshot_store.get_shallow(:os) }
|
14
14
|
|
15
|
-
let(:
|
16
|
-
let(:proc_self_cgroup_content) do
|
17
|
-
%W(14:name=systemd,holaunlimited:#{relative_path}
|
18
|
-
13:pids:#{relative_path}
|
19
|
-
12:hugetlb:#{relative_path}
|
20
|
-
11:net_prio:#{relative_path}
|
21
|
-
10:perf_event:#{relative_path}
|
22
|
-
9:net_cls:#{relative_path}
|
23
|
-
8:freezer:#{relative_path}
|
24
|
-
7:devices:#{relative_path}
|
25
|
-
6:memory:#{relative_path}
|
26
|
-
5:blkio:#{relative_path}
|
27
|
-
4:cpuacct:#{relative_path}
|
28
|
-
3:cpu:#{relative_path}
|
29
|
-
2:cpuset:#{relative_path}
|
30
|
-
1:name=openrc:/docker
|
31
|
-
0::/docker)
|
32
|
-
end
|
33
|
-
|
15
|
+
let(:cpuacct_control_group) { "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61" }
|
34
16
|
let(:cpuacct_usage) { 1982 }
|
17
|
+
let(:cpu_control_group) { "/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61" }
|
35
18
|
let(:cpu_period_micros) { 500 }
|
36
19
|
let(:cpu_quota_micros) { 98 }
|
37
20
|
let(:cpu_stats_number_of_periods) { 1 }
|
38
21
|
let(:cpu_stats_number_of_time_throttled) { 2 }
|
39
22
|
let(:cpu_stats_time_throttled_nanos) { 3 }
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
23
|
+
let(:proc_self_cgroup_content) {
|
24
|
+
%W(14:name=systemd,holaunlimited:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
25
|
+
13:pids:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
26
|
+
12:hugetlb:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
27
|
+
11:net_prio:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
28
|
+
10:perf_event:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
29
|
+
9:net_cls:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
30
|
+
8:freezer:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
31
|
+
7:devices:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
32
|
+
6:memory:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
33
|
+
5:blkio:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
34
|
+
4:cpuacct:#{cpuacct_control_group}
|
35
|
+
3:cpu:#{cpu_control_group}
|
36
|
+
2:cpuset:/docker/a10687343f90e97bbb1f7181bd065a42de96c40c4aa91764a9d526ea30475f61
|
37
|
+
1:name=openrc:/docker) }
|
38
|
+
let(:cpu_stat_file_content) {
|
39
|
+
[
|
40
|
+
"nr_periods #{cpu_stats_number_of_periods}",
|
41
|
+
"nr_throttled #{cpu_stats_number_of_time_throttled}",
|
42
|
+
"throttled_time #{cpu_stats_time_throttled_nanos}"
|
43
|
+
]
|
44
|
+
}
|
44
45
|
|
45
46
|
before do
|
46
|
-
allow(::
|
47
|
-
|
48
|
-
allow(
|
49
|
-
allow(
|
50
|
-
|
51
|
-
allow(
|
47
|
+
allow(LogStash::Instrument::PeriodicPoller::Cgroup).to receive(:are_cgroup_available?).and_return(true)
|
48
|
+
|
49
|
+
allow(LogStash::Instrument::PeriodicPoller::Cgroup).to receive(:read_proc_self_cgroup_lines).and_return(proc_self_cgroup_content)
|
50
|
+
allow(LogStash::Instrument::PeriodicPoller::Cgroup).to receive(:read_sys_fs_cgroup_cpuacct_cpu_stat).and_return(cpu_stat_file_content)
|
51
|
+
|
52
|
+
allow(LogStash::Instrument::PeriodicPoller::Cgroup).to receive(:cgroup_cpuacct_usage_nanos).with(cpuacct_control_group).and_return(cpuacct_usage)
|
53
|
+
allow(LogStash::Instrument::PeriodicPoller::Cgroup).to receive(:cgroup_cpu_fs_period_micros).with(cpu_control_group).and_return(cpu_period_micros)
|
54
|
+
allow(LogStash::Instrument::PeriodicPoller::Cgroup).to receive(:cgroup_cpu_fs_quota_micros).with(cpu_control_group).and_return(cpu_quota_micros)
|
52
55
|
|
53
56
|
subject.collect
|
54
57
|
end
|