Skip to content

Commit

Permalink
Adds system test to Metricbeat to load dashboards (#5770)
Browse files Browse the repository at this point in the history
This adds a test to the system tests to load all dashboards into Kibana throught the Kibana API.

In a follow up PR this should be added to all Beats.
  • Loading branch information
ruflin authored and exekias committed Nov 30, 2017
1 parent d9011ec commit 75a1fc8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions metricbeat/tests/system/config/metricbeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ queue.mem:
flush.min_events: {{ flush_min_events|default(8) }}
flush.timeout: 0.1s

{% if kibana -%}
setup.kibana.host: "{{ kibana.host }}"
{%- endif %}

#================================ Outputs =====================================

# Configure what outputs to use when sending the data collected by the beat.
Expand Down
28 changes: 27 additions & 1 deletion metricbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
import sys
import unittest
import time
import os
import shutil
from metricbeat import BaseTest
from elasticsearch import Elasticsearch
from beat.beat import INTEGRATION_TESTS


class Test(BaseTest):

COMPOSE_SERVICES = ['elasticsearch']
COMPOSE_SERVICES = ['elasticsearch', 'kibana']

@unittest.skipUnless(re.match("(?i)win|linux|darwin|freebsd|openbsd", sys.platform), "os")
def test_start_stop(self):
Expand Down Expand Up @@ -50,3 +52,27 @@ def test_template(self):
assert exit_code == 0
assert self.log_contains('Loaded index template')
assert len(es.cat.templates(name='metricbeat-*', h='name')) > 0

@unittest.skipUnless(INTEGRATION_TESTS, "integration test")
def test_dashboards(self):
"""
Test that the dashboards can be loaded with `setup --dashboards`
"""

kibana_dir = os.path.join(self.beat_path, "_meta", "kibana")
shutil.copytree(kibana_dir, os.path.join(self.working_dir, "kibana"))

es = Elasticsearch([self.get_elasticsearch_url()])
self.render_config_template(
modules=[{
"name": "apache",
"metricsets": ["status"],
"hosts": ["localhost"],
}],
elasticsearch={"host": self.get_elasticsearch_url()},
kibana={"host": self.get_kibana_url()},
)
exit_code = self.run_beat(extra_args=["setup", "--dashboards"])

assert exit_code == 0
assert self.log_contains("Kibana dashboards successfully loaded.")

0 comments on commit 75a1fc8

Please sign in to comment.