From 49066d8a132d990674bc9090a484445f6bbd6823 Mon Sep 17 00:00:00 2001 From: beats-jenkins Date: Thu, 9 May 2019 11:05:34 +0200 Subject: [PATCH 1/4] [Filebeat] Introduce UTC as default timezone for modules tests Currently all our modules have convert_timezone disable by default. The reason in 6.x for this was probably that 6.0 did not support convert_timezone and we did not want to introduce a breaking changes. New modules should have convert_timezone enabled by default. If a module has convert_timezone enabled by default the tests will fail as it takes the timezone of the local computer. To circumvent this, this PR sets the timezone of the tests to UTC so the same time zone is always used. No generated files were changed in this PR as all modules have convert_timezone off by default. But it will affect https://github.com/elastic/beats/pull/12079 and https://github.com/elastic/beats/pull/12032 --- filebeat/tests/system/test_modules.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/filebeat/tests/system/test_modules.py b/filebeat/tests/system/test_modules.py index 874c1ae35e7..6a22c8f55cf 100644 --- a/filebeat/tests/system/test_modules.py +++ b/filebeat/tests/system/test_modules.py @@ -4,6 +4,7 @@ import unittest import glob import subprocess +import time from elasticsearch import Elasticsearch import json @@ -114,6 +115,9 @@ def run_on_file(self, module, fileset, test_file, cfgfile): pass self.wait_until(lambda: not self.es.indices.exists(self.index_name)) + os.environ['TZ'] = 'Etc/UTC' + time.tzset() + cmd = [ self.filebeat, "-systemTest", "-e", "-d", "*", "-once", From bc5c1941c19233411e5a2cce78c49d3505334f81 Mon Sep 17 00:00:00 2001 From: beats-jenkins Date: Thu, 9 May 2019 12:19:01 +0200 Subject: [PATCH 2/4] move conversion to process only --- filebeat/tests/system/test_modules.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/filebeat/tests/system/test_modules.py b/filebeat/tests/system/test_modules.py index 6a22c8f55cf..d7d1c0de636 100644 --- a/filebeat/tests/system/test_modules.py +++ b/filebeat/tests/system/test_modules.py @@ -142,7 +142,12 @@ def run_on_file(self, module, fileset, test_file, cfgfile): output_path = os.path.join(self.working_dir) output = open(os.path.join(output_path, "output.log"), "ab") output.write(" ".join(cmd) + "\n") + + local_env = os.environ.copy() + local_env["TZ"] = 'Etc/UTC' + subprocess.Popen(cmd, + env=local_env, stdin=None, stdout=output, stderr=subprocess.STDOUT, From 94a75f1d28add3471c2d2318d8080becc8dee728 Mon Sep 17 00:00:00 2001 From: beats-jenkins Date: Thu, 9 May 2019 12:19:46 +0200 Subject: [PATCH 3/4] remove old conversion --- filebeat/tests/system/test_modules.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/filebeat/tests/system/test_modules.py b/filebeat/tests/system/test_modules.py index d7d1c0de636..d48009bde79 100644 --- a/filebeat/tests/system/test_modules.py +++ b/filebeat/tests/system/test_modules.py @@ -115,9 +115,6 @@ def run_on_file(self, module, fileset, test_file, cfgfile): pass self.wait_until(lambda: not self.es.indices.exists(self.index_name)) - os.environ['TZ'] = 'Etc/UTC' - time.tzset() - cmd = [ self.filebeat, "-systemTest", "-e", "-d", "*", "-once", From 1ba8650ae2df115483bafcb1f90b5325c6bdc381 Mon Sep 17 00:00:00 2001 From: beats-jenkins Date: Thu, 9 May 2019 13:03:20 +0200 Subject: [PATCH 4/4] remove time import --- filebeat/tests/system/test_modules.py | 1 - 1 file changed, 1 deletion(-) diff --git a/filebeat/tests/system/test_modules.py b/filebeat/tests/system/test_modules.py index d48009bde79..41585a7f65f 100644 --- a/filebeat/tests/system/test_modules.py +++ b/filebeat/tests/system/test_modules.py @@ -4,7 +4,6 @@ import unittest import glob import subprocess -import time from elasticsearch import Elasticsearch import json