From 141a417de4cdd6a8a8d5ab34e1ce79f44dc27ba7 Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Thu, 26 Oct 2017 15:19:14 +0200 Subject: [PATCH 1/3] Make python tests not executables Turns out that if a `test_*.py` file is executable, nosetests doesn't pick it up, so the tests are not executed on Linux/Mac. This was the case with two files in Filebeat. This adds a `make check` check to look for such files, so this doesn't happen in the future. --- filebeat/tests/system/test_prospector.py | 5 ----- filebeat/tests/system/test_registrar.py | 5 ----- libbeat/scripts/Makefile | 1 + 3 files changed, 1 insertion(+), 10 deletions(-) mode change 100755 => 100644 filebeat/tests/system/test_prospector.py mode change 100755 => 100644 filebeat/tests/system/test_registrar.py diff --git a/filebeat/tests/system/test_prospector.py b/filebeat/tests/system/test_prospector.py old mode 100755 new mode 100644 index f31be9106a7c..8f36243ba5f0 --- a/filebeat/tests/system/test_prospector.py +++ b/filebeat/tests/system/test_prospector.py @@ -714,8 +714,3 @@ def test_restart_recursive_glob(self): name="output contains 'entry2'") filebeat.check_kill_and_wait() - - -if __name__ == '__main__': - import unittest - unittest.main() diff --git a/filebeat/tests/system/test_registrar.py b/filebeat/tests/system/test_registrar.py old mode 100755 new mode 100644 index d96a89239c11..0d8811f1cce0 --- a/filebeat/tests/system/test_registrar.py +++ b/filebeat/tests/system/test_registrar.py @@ -1384,8 +1384,3 @@ def test_registrar_files_with_prospector_level_processors(self): "inode": stat.st_ino, "device": stat.st_dev, }, file_state_os) - - -if __name__ == '__main__': - import unittest - unittest.main() diff --git a/libbeat/scripts/Makefile b/libbeat/scripts/Makefile index 52b2f68abfc0..9ba4e8adfc3a 100755 --- a/libbeat/scripts/Makefile +++ b/libbeat/scripts/Makefile @@ -107,6 +107,7 @@ check: python-env ## @build Checks project and source code if everything is acco @go get $(GOIMPORTS_REPO) @goimports -local ${GOIMPORTS_LOCAL_PREFIX} -l ${GOFILES_NOVENDOR} | (! grep .) || (echo "Code differs from goimports' style ^" && false) @${FIND} -name *.py -exec autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false) + @${FIND} -wholename "*tests/system/test_*.py" -perm "+111" -exec false {} + || (echo "Python test files shouldn't be executable, otherwise nose doesn't find them" && false) .PHONY: fmt fmt: python-env ## @build Runs `goimports -l -w` and `autopep8`on the project's source code, modifying any files that do not match its style. From a86d4bef6f04b8769a2c3294e92f59f03400bc7f Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Thu, 26 Oct 2017 23:49:26 +0200 Subject: [PATCH 2/3] find syntax to work on both linux and mac --- libbeat/scripts/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libbeat/scripts/Makefile b/libbeat/scripts/Makefile index 9ba4e8adfc3a..8f281dceff40 100755 --- a/libbeat/scripts/Makefile +++ b/libbeat/scripts/Makefile @@ -63,6 +63,7 @@ BUILDID?=$(shell git rev-parse HEAD) ## @Building The build ID VIRTUALENV_PARAMS?= INTEGRATION_TESTS?= FIND=. ${PYTHON_ENV}/bin/activate; find . -type f -not -path "*/vendor/*" -not -path "*/build/*" -not -path "*/.git/*" +PERM_EXEC=$(shell [ `uname -s` = "Darwin" ] && echo "+111" || echo "/a+x") # Cross compiling targets CGO?=true ## @building if true, Build with C Go support @@ -107,7 +108,7 @@ check: python-env ## @build Checks project and source code if everything is acco @go get $(GOIMPORTS_REPO) @goimports -local ${GOIMPORTS_LOCAL_PREFIX} -l ${GOFILES_NOVENDOR} | (! grep .) || (echo "Code differs from goimports' style ^" && false) @${FIND} -name *.py -exec autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false) - @${FIND} -wholename "*tests/system/test_*.py" -perm "+111" -exec false {} + || (echo "Python test files shouldn't be executable, otherwise nose doesn't find them" && false) + @${FIND} -wholename "*tests/system/test_*.py" -perm ${PERM_EXEC} -exec false {} + || (echo "Python test files shouldn't be executable, otherwise nose doesn't find them" && false) .PHONY: fmt fmt: python-env ## @build Runs `goimports -l -w` and `autopep8`on the project's source code, modifying any files that do not match its style. From 653d61c52c9c5293e1f76924d8e2327d34108995 Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Fri, 27 Oct 2017 14:51:50 +0200 Subject: [PATCH 3/3] Skip flaky test --- filebeat/tests/system/test_prospector.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/filebeat/tests/system/test_prospector.py b/filebeat/tests/system/test_prospector.py index 8f36243ba5f0..11e233dd8412 100644 --- a/filebeat/tests/system/test_prospector.py +++ b/filebeat/tests/system/test_prospector.py @@ -3,6 +3,7 @@ from filebeat import BaseTest import os import time +import unittest from beat.beat import Proc @@ -582,6 +583,7 @@ def test_skip_symlinks(self): # Make sure there is only one entry, means it didn't follow the symlink assert len(data) == 1 + @unittest.skip("Flaky due to race. Opened https://github.com/elastic/beats/issues/5458") def test_harvester_limit(self): """ Test if harvester_limit applies