Skip to content

Commit

Permalink
System test for logstash module, xpack code path (#12676)
Browse files Browse the repository at this point in the history
* Getting logstash basic node info

* Get basic node info from GET _node/stats call

* Inlining single-use const

* Updating code per LS API changes

* Adding logstash module system test for xpack.enabled: true

* Add version check + skip
  • Loading branch information
ycombinator authored Jun 27, 2019
1 parent 4f3844b commit 5cd611a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions metricbeat/tests/system/test_logstash.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os
import metricbeat
import unittest
from nose.plugins.skip import SkipTest
import urllib2
import json
import semver
import time


Expand All @@ -22,3 +26,37 @@ def test_node_stats(self):
logstash node_stats metricset test
"""
self.check_metricset("logstash", "node_stats", self.get_hosts(), self.FIELDS)

@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, "integration test")
def test_xpack(self):
"""
logstash-xpack module tests
"""
version = self.get_version()
if semver.compare(version, "7.3.0") == -1:
# Skip for Logstash versions < 7.3.0 as necessary APIs not available
raise SkipTest

self.render_config_template(modules=[{
"name": "logstash",
"metricsets": ["node", "node_stats"],
"hosts": self.get_hosts(),
"period": "1s",
"extras": {
"xpack.enabled": "true"
}
}])

proc = self.start_beat()
self.wait_until(lambda: self.output_lines() > 0)
proc.check_kill_and_wait()
self.assert_no_logged_warnings()

def get_version(self):
host = self.get_hosts()[0]
res = urllib2.urlopen("http://" + host + "/").read()

body = json.loads(res)
version = body["version"]

return version

0 comments on commit 5cd611a

Please sign in to comment.