Skip to content

Commit

Permalink
[Filebeat] Add export tests to x-pack/filebeat (#20156)
Browse files Browse the repository at this point in the history
* Add export tests to x-pack/filebeat

Add export sub-command tests to x-pack/filebeat and add an assertion for the
size the Kibana index-pattern due to the Kibana API limiting payloads to 1 MiB.

* Assert size of index pattern document is less than 1 MiB
  • Loading branch information
andrewkroh authored Jul 29, 2020
1 parent ea63f05 commit 36c8468
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion filebeat/tests/system/filebeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setUpClass(self):
if not hasattr(self, "beat_name"):
self.beat_name = "filebeat"
if not hasattr(self, "beat_path"):
self.beat_path = os.path.abspath(os.path.join(curdir, "../../"))
self.beat_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))

super(BaseTest, self).setUpClass()

Expand Down
4 changes: 4 additions & 0 deletions libbeat/tests/system/beat/common_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def test_export_index_pattern(self):
output = self.run_export_cmd("index-pattern")
js = json.loads(output)
assert "objects" in js
size = len(output.encode('utf-8'))
assert size < 1024*1024, "Kibana index pattern must be less than 1MiB " \
"to keep the Beat setup request size below " \
"Kibana's server.maxPayloadBytes."

@unittest.skipUnless(INTEGRATION_TESTS, "integration test")
def test_export_config(self):
Expand Down
30 changes: 30 additions & 0 deletions x-pack/filebeat/tests/system/test_filebeat_xpack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import jinja2
import os
import sys

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../../filebeat/tests/system')))

from filebeat import BaseTest as FilebeatTest
from beat import common_tests


class FilebeatXPackTest(FilebeatTest, common_tests.TestExportsMixin):

@classmethod
def setUpClass(self):
self.beat_name = "filebeat"
self.beat_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), "../../"))

super(FilebeatTest, self).setUpClass()

def setUp(self):
super(FilebeatTest, self).setUp()

# Hack to make jinja2 have the right paths
self.template_env = jinja2.Environment(
loader=jinja2.FileSystemLoader([
os.path.abspath(os.path.join(self.beat_path, "../../filebeat")),
os.path.abspath(os.path.join(self.beat_path, "../../libbeat"))
])
)

0 comments on commit 36c8468

Please sign in to comment.