Skip to content

Commit 951463a

Browse files
authored
Add system test for Openmetrics module (elastic#17200) (elastic#17259)
(cherry picked from commit 4af31be)
1 parent 6d6264b commit 951463a

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ARG NODE_EXPORTER_VERSION
2+
FROM prom/node-exporter:v${NODE_EXPORTER_VERSION}
3+
EXPOSE 9100
4+
HEALTHCHECK --interval=1s --retries=90 CMD wget -q http://localhost:9100/metrics -O - | grep "node_cpu_seconds_total"
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '2.3'
2+
3+
services:
4+
openmetrics-node_exporter:
5+
image: docker.elastic.co/integrations-ci/beats-openmetrics-node-exporter:${NODE_EXPORTER_VERSION:-0.18.1}-1
6+
build:
7+
context: ./_meta
8+
args:
9+
NODE_EXPORTER_VERSION: ${NODE_EXPORTER_VERSION:-0.18.1}
10+
ports:
11+
- 9100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import os
2+
import sys
3+
import unittest
4+
5+
sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system'))
6+
from xpack_metricbeat import XPackTest, metricbeat
7+
8+
9+
class Test(XPackTest):
10+
11+
COMPOSE_SERVICES = ['openmetrics-node_exporter']
12+
13+
@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, "integration test")
14+
def test_openmetrics(self):
15+
"""
16+
openmetrics collector test
17+
"""
18+
self.render_config_template(modules=[{
19+
"name": "openmetrics",
20+
"metricsets": ["collector"],
21+
"hosts": self.get_hosts(),
22+
"period": "5s",
23+
}])
24+
proc = self.start_beat(home=self.beat_path)
25+
self.wait_until(lambda: self.output_lines() > 0, 60)
26+
proc.check_kill_and_wait()
27+
self.assert_no_logged_warnings()
28+
29+
output = self.read_output_json()
30+
self.assertGreater(len(output), 0)
31+
32+
for evt in output:
33+
self.assert_fields_are_documented(evt)
34+
self.assertIn("openmetrics", evt.keys(), evt)
35+
self.assertIn("metrics", evt["openmetrics"].keys(), evt)
36+
self.assertGreater(len(evt["openmetrics"]["metrics"].keys()), 0)

0 commit comments

Comments
 (0)