From 4270b25a12d7659713d0cda25364f7528475a8e0 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 16 Apr 2020 20:25:32 +0200 Subject: [PATCH 1/4] Fix dashboards export test Test is checking an error message from Kibana that has changed. --- libbeat/tests/system/test_dashboard.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libbeat/tests/system/test_dashboard.py b/libbeat/tests/system/test_dashboard.py index 47564455c0d..36a7570da32 100644 --- a/libbeat/tests/system/test_dashboard.py +++ b/libbeat/tests/system/test_dashboard.py @@ -175,6 +175,7 @@ def test_export_dashboard_cmd_export_dashboard_by_id_unknown_id(self): """ Test testbeat export dashboard fails gracefully when dashboard with unknown ID is requested """ + dashboard_id = 'No-such-dashboard' self.render_config_template() beat = self.start_beat( logging_args=["-e", "-d", "*"], @@ -183,12 +184,12 @@ def test_export_dashboard_cmd_export_dashboard_by_id_unknown_id(self): "-E", "setup.kibana.protocol=http", "-E", "setup.kibana.host=" + self.get_kibana_host(), "-E", "setup.kibana.port=" + self.get_kibana_port(), - "-id", "No-such-dashboard"] + "-id", dashboard_id] ) beat.check_wait(exit_code=1) - assert self.log_contains("error exporting dashboard: Not found") is True + assert self.log_contains("error exporting dashboard: Saved object [dashboard/{}] not found".format(dashboard_id)) is True @unittest.skipUnless(INTEGRATION_TESTS, "integration test") @attr('integration') From d006058e6d2ef9fdafad936b246254d33e1797a0 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 16 Apr 2020 20:48:30 +0200 Subject: [PATCH 2/4] PEP8 --- libbeat/tests/system/test_dashboard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libbeat/tests/system/test_dashboard.py b/libbeat/tests/system/test_dashboard.py index 36a7570da32..7304e89f8b9 100644 --- a/libbeat/tests/system/test_dashboard.py +++ b/libbeat/tests/system/test_dashboard.py @@ -189,7 +189,8 @@ def test_export_dashboard_cmd_export_dashboard_by_id_unknown_id(self): beat.check_wait(exit_code=1) - assert self.log_contains("error exporting dashboard: Saved object [dashboard/{}] not found".format(dashboard_id)) is True + expected_error = "error exporting dashboard: Saved object [dashboard/{}] not found".format(dashboard_id) + assert self.log_contains(expected_error) @unittest.skipUnless(INTEGRATION_TESTS, "integration test") @attr('integration') From 12c0bf17915a3bb8465d3f6122c94f7226a04bbe Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 17 Apr 2020 12:31:38 +0200 Subject: [PATCH 3/4] Use a regexp to match old and new logs --- libbeat/tests/system/test_dashboard.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libbeat/tests/system/test_dashboard.py b/libbeat/tests/system/test_dashboard.py index 7304e89f8b9..b00eda162b2 100644 --- a/libbeat/tests/system/test_dashboard.py +++ b/libbeat/tests/system/test_dashboard.py @@ -1,12 +1,14 @@ -from base import BaseTest import os import os.path +import re +import requests +import semver import subprocess -from nose.plugins.attrib import attr import unittest + +from base import BaseTest +from nose.plugins.attrib import attr from unittest import SkipTest -import requests -import semver INTEGRATION_TESTS = os.environ.get('INTEGRATION_TESTS', False) @@ -189,7 +191,7 @@ def test_export_dashboard_cmd_export_dashboard_by_id_unknown_id(self): beat.check_wait(exit_code=1) - expected_error = "error exporting dashboard: Saved object [dashboard/{}] not found".format(dashboard_id) + expected_error = re.compile("error exporting dashboard:.*not found", re.IGNORECASE) assert self.log_contains(expected_error) @unittest.skipUnless(INTEGRATION_TESTS, "integration test") From 25234b2d500234c56a6ceca8529746d170fb8006 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 17 Apr 2020 12:36:53 +0200 Subject: [PATCH 4/4] Remove unneeded variable --- libbeat/tests/system/test_dashboard.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libbeat/tests/system/test_dashboard.py b/libbeat/tests/system/test_dashboard.py index b00eda162b2..2ed79fd2743 100644 --- a/libbeat/tests/system/test_dashboard.py +++ b/libbeat/tests/system/test_dashboard.py @@ -177,7 +177,6 @@ def test_export_dashboard_cmd_export_dashboard_by_id_unknown_id(self): """ Test testbeat export dashboard fails gracefully when dashboard with unknown ID is requested """ - dashboard_id = 'No-such-dashboard' self.render_config_template() beat = self.start_beat( logging_args=["-e", "-d", "*"], @@ -186,7 +185,7 @@ def test_export_dashboard_cmd_export_dashboard_by_id_unknown_id(self): "-E", "setup.kibana.protocol=http", "-E", "setup.kibana.host=" + self.get_kibana_host(), "-E", "setup.kibana.port=" + self.get_kibana_port(), - "-id", dashboard_id] + "-id", "No-such-dashboard"] ) beat.check_wait(exit_code=1)