From c9c7ec576bb17180aa3cee70ef12e81aa9692289 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 27 Aug 2020 18:11:52 +0200 Subject: [PATCH 1/6] Move python path configuration to conftest.py Use the python tests runner to setup python paths so each test doesn't need to setup their own python paths. --- auditbeat/conftest.py | 5 +++++ auditbeat/tests/system/auditbeat.py | 2 -- filebeat/conftest.py | 4 ++++ filebeat/tests/system/filebeat.py | 1 - generator/_templates/beat/{beat}/tests/system/{beat}.py | 1 - heartbeat/conftest.py | 4 ++++ heartbeat/tests/system/heartbeat.py | 3 --- journalbeat/conftest.py | 4 ++++ journalbeat/tests/system/journalbeat.py | 1 - metricbeat/conftest.py | 5 +++++ metricbeat/module/aerospike/test_aerospike.py | 1 - metricbeat/module/apache/test_apache.py | 1 - metricbeat/module/ceph/test_ceph.py | 1 - metricbeat/module/consul/test_consul.py | 1 - metricbeat/module/couchbase/test_couchbase.py | 1 - metricbeat/module/couchdb/test_couchdb.py | 1 - metricbeat/module/docker/test_docker.py | 1 - metricbeat/module/dropwizard/test_dropwizard.py | 1 - metricbeat/module/elasticsearch/test_elasticsearch.py | 1 - metricbeat/module/envoyproxy/test_envoyproxy.py | 1 - metricbeat/module/etcd/test_etcd.py | 1 - metricbeat/module/golang/test_golang.py | 1 - metricbeat/module/haproxy/test_haproxy.py | 1 - metricbeat/module/http/test_http.py | 1 - metricbeat/module/jolokia/test_jolokia.py | 1 - metricbeat/module/kafka/test_kafka.py | 1 - metricbeat/module/kibana/test_kibana.py | 1 - metricbeat/module/logstash/test_logstash.py | 1 - metricbeat/module/memcached/test_memcached.py | 1 - metricbeat/module/mongodb/test_mongodb.py | 1 - metricbeat/module/munin/test_munin.py | 1 - metricbeat/module/mysql/test_mysql.py | 1 - metricbeat/module/nats/test_nats.py | 1 - metricbeat/module/php_fpm/test_phpfpm.py | 1 - metricbeat/module/postgresql/test_postgresql.py | 1 - metricbeat/module/prometheus/test_prometheus.py | 1 - metricbeat/module/redis/test_redis.py | 1 - metricbeat/module/system/test_system.py | 1 - metricbeat/module/traefik/test_traefik.py | 1 - metricbeat/module/uwsgi/test_uwsgi.py | 1 - metricbeat/module/vsphere/test_vsphere.py | 1 - metricbeat/module/zookeeper/test_zookeeper.py | 1 - metricbeat/tests/system/metricbeat.py | 1 - packetbeat/tests/system/packetbeat.py | 1 - packetbeat/tests/system/test_base.py | 1 - winlogbeat/tests/system/winlogbeat.py | 1 - x-pack/auditbeat/tests/system/auditbeat_xpack.py | 1 - x-pack/filebeat/tests/system/test_filebeat_xpack.py | 1 - x-pack/filebeat/tests/system/test_http_endpoint.py | 1 - x-pack/filebeat/tests/system/test_xpack_modules.py | 1 - x-pack/functionbeat/tests/system/functionbeat.py | 1 - x-pack/libbeat/conftest.py | 4 ++++ x-pack/libbeat/tests/system/base.py | 5 ----- x-pack/metricbeat/conftest.py | 6 ++++++ x-pack/metricbeat/module/activemq/test_activemq.py | 1 - x-pack/metricbeat/module/appsearch/test_appsearch.py | 1 - x-pack/metricbeat/module/cockroachdb/test_cockroachdb.py | 1 - x-pack/metricbeat/module/coredns/test_coredns.py | 1 - x-pack/metricbeat/module/ibmmq/test_ibmmq.py | 1 - x-pack/metricbeat/module/mssql/test_mssql.py | 1 - x-pack/metricbeat/module/openmetrics/test_openmetrics.py | 1 - .../module/redisenterprise/test_redisenterprise.py | 1 - x-pack/metricbeat/module/sql/test_sql.py | 1 - x-pack/metricbeat/module/stan/test_stan.py | 1 - x-pack/metricbeat/module/statsd/test_statsd.py | 1 - x-pack/metricbeat/tests/system/xpack_metricbeat.py | 1 - 66 files changed, 32 insertions(+), 66 deletions(-) create mode 100644 auditbeat/conftest.py create mode 100644 filebeat/conftest.py create mode 100644 heartbeat/conftest.py create mode 100644 journalbeat/conftest.py create mode 100644 metricbeat/conftest.py create mode 100644 x-pack/libbeat/conftest.py create mode 100644 x-pack/metricbeat/conftest.py diff --git a/auditbeat/conftest.py b/auditbeat/conftest.py new file mode 100644 index 00000000000..060b8f8073f --- /dev/null +++ b/auditbeat/conftest.py @@ -0,0 +1,5 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../libbeat/tests/system')) +sys.path.append(os.path.join(os.path.dirname(__file__), '../metricbeat/tests/system')) diff --git a/auditbeat/tests/system/auditbeat.py b/auditbeat/tests/system/auditbeat.py index 417b60fe894..320e7da9ea6 100644 --- a/auditbeat/tests/system/auditbeat.py +++ b/auditbeat/tests/system/auditbeat.py @@ -3,8 +3,6 @@ import sys import tempfile -sys.path.append(os.path.join(os.path.dirname(__file__), '../../../metricbeat/tests/system')) - if os.name == "nt": import win32file diff --git a/filebeat/conftest.py b/filebeat/conftest.py new file mode 100644 index 00000000000..2f3f8199559 --- /dev/null +++ b/filebeat/conftest.py @@ -0,0 +1,4 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../libbeat/tests/system')) diff --git a/filebeat/tests/system/filebeat.py b/filebeat/tests/system/filebeat.py index 32902e3b321..04714265ae7 100644 --- a/filebeat/tests/system/filebeat.py +++ b/filebeat/tests/system/filebeat.py @@ -4,7 +4,6 @@ import sys curdir = os.path.dirname(__file__) -sys.path.append(os.path.join(curdir, '../../../libbeat/tests/system')) from beat.beat import TestCase, TimeoutError, REGEXP_TYPE diff --git a/generator/_templates/beat/{beat}/tests/system/{beat}.py b/generator/_templates/beat/{beat}/tests/system/{beat}.py index 9cf1a5879a1..9bd7453c6fd 100644 --- a/generator/_templates/beat/{beat}/tests/system/{beat}.py +++ b/generator/_templates/beat/{beat}/tests/system/{beat}.py @@ -1,6 +1,5 @@ import os import sys -sys.path.append('../../vendor/github.com/elastic/beats/libbeat/tests/system') from beat.beat import TestCase diff --git a/heartbeat/conftest.py b/heartbeat/conftest.py new file mode 100644 index 00000000000..2f3f8199559 --- /dev/null +++ b/heartbeat/conftest.py @@ -0,0 +1,4 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../libbeat/tests/system')) diff --git a/heartbeat/tests/system/heartbeat.py b/heartbeat/tests/system/heartbeat.py index 70b7faf1ac3..d6255141d84 100644 --- a/heartbeat/tests/system/heartbeat.py +++ b/heartbeat/tests/system/heartbeat.py @@ -3,9 +3,6 @@ import http.server import threading -sys.path.append(os.path.join(os.path.dirname( - __file__), '../../../libbeat/tests/system')) - from beat.beat import TestCase from time import sleep diff --git a/journalbeat/conftest.py b/journalbeat/conftest.py new file mode 100644 index 00000000000..2f3f8199559 --- /dev/null +++ b/journalbeat/conftest.py @@ -0,0 +1,4 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../libbeat/tests/system')) diff --git a/journalbeat/tests/system/journalbeat.py b/journalbeat/tests/system/journalbeat.py index 11381395e29..2ad3bd3c37f 100644 --- a/journalbeat/tests/system/journalbeat.py +++ b/journalbeat/tests/system/journalbeat.py @@ -1,6 +1,5 @@ import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '../../../libbeat/tests/system')) from beat.beat import TestCase diff --git a/metricbeat/conftest.py b/metricbeat/conftest.py new file mode 100644 index 00000000000..818eb72a9db --- /dev/null +++ b/metricbeat/conftest.py @@ -0,0 +1,5 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../libbeat/tests/system')) +sys.path.append(os.path.join(os.path.dirname(__file__), './tests/system')) diff --git a/metricbeat/module/aerospike/test_aerospike.py b/metricbeat/module/aerospike/test_aerospike.py index 4c7e026ca92..4b069d42720 100644 --- a/metricbeat/module/aerospike/test_aerospike.py +++ b/metricbeat/module/aerospike/test_aerospike.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/apache/test_apache.py b/metricbeat/module/apache/test_apache.py index 396c60e3847..ebb088a2f4c 100644 --- a/metricbeat/module/apache/test_apache.py +++ b/metricbeat/module/apache/test_apache.py @@ -8,7 +8,6 @@ import semver import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat APACHE_FIELDS = metricbeat.COMMON_FIELDS + ["apache"] diff --git a/metricbeat/module/ceph/test_ceph.py b/metricbeat/module/ceph/test_ceph.py index 9f9c70561f5..c6aa9763905 100644 --- a/metricbeat/module/ceph/test_ceph.py +++ b/metricbeat/module/ceph/test_ceph.py @@ -5,7 +5,6 @@ import unittest from parameterized import parameterized -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/consul/test_consul.py b/metricbeat/module/consul/test_consul.py index 2702c144c3a..3949eecfccf 100644 --- a/metricbeat/module/consul/test_consul.py +++ b/metricbeat/module/consul/test_consul.py @@ -3,7 +3,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/couchbase/test_couchbase.py b/metricbeat/module/couchbase/test_couchbase.py index 71c5edd92cb..3c8ad87d767 100644 --- a/metricbeat/module/couchbase/test_couchbase.py +++ b/metricbeat/module/couchbase/test_couchbase.py @@ -3,7 +3,6 @@ import unittest from parameterized import parameterized -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/couchdb/test_couchdb.py b/metricbeat/module/couchdb/test_couchdb.py index b7f2b539440..12894370323 100644 --- a/metricbeat/module/couchdb/test_couchdb.py +++ b/metricbeat/module/couchdb/test_couchdb.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/docker/test_docker.py b/metricbeat/module/docker/test_docker.py index 8eacc289358..9cc1c767051 100644 --- a/metricbeat/module/docker/test_docker.py +++ b/metricbeat/module/docker/test_docker.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/dropwizard/test_dropwizard.py b/metricbeat/module/dropwizard/test_dropwizard.py index 8e771c511c2..c5bae4269ef 100644 --- a/metricbeat/module/dropwizard/test_dropwizard.py +++ b/metricbeat/module/dropwizard/test_dropwizard.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/elasticsearch/test_elasticsearch.py b/metricbeat/module/elasticsearch/test_elasticsearch.py index 2ccf3b0fddd..0cbd424a1be 100644 --- a/metricbeat/module/elasticsearch/test_elasticsearch.py +++ b/metricbeat/module/elasticsearch/test_elasticsearch.py @@ -10,7 +10,6 @@ from elasticsearch import Elasticsearch, TransportError, client from parameterized import parameterized -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/envoyproxy/test_envoyproxy.py b/metricbeat/module/envoyproxy/test_envoyproxy.py index 978283ab5b1..9bb85739357 100644 --- a/metricbeat/module/envoyproxy/test_envoyproxy.py +++ b/metricbeat/module/envoyproxy/test_envoyproxy.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/etcd/test_etcd.py b/metricbeat/module/etcd/test_etcd.py index 1832f2dfe46..f9e04da7837 100644 --- a/metricbeat/module/etcd/test_etcd.py +++ b/metricbeat/module/etcd/test_etcd.py @@ -4,7 +4,6 @@ import time from parameterized import parameterized -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/golang/test_golang.py b/metricbeat/module/golang/test_golang.py index 5000c0de8fd..45161ebd645 100644 --- a/metricbeat/module/golang/test_golang.py +++ b/metricbeat/module/golang/test_golang.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/haproxy/test_haproxy.py b/metricbeat/module/haproxy/test_haproxy.py index 39ec3cfe6d9..9da2e75f45f 100644 --- a/metricbeat/module/haproxy/test_haproxy.py +++ b/metricbeat/module/haproxy/test_haproxy.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/http/test_http.py b/metricbeat/module/http/test_http.py index 92aa693552b..7bdf3b35361 100644 --- a/metricbeat/module/http/test_http.py +++ b/metricbeat/module/http/test_http.py @@ -4,7 +4,6 @@ import time import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/jolokia/test_jolokia.py b/metricbeat/module/jolokia/test_jolokia.py index db6055fe91e..d52f43d0662 100644 --- a/metricbeat/module/jolokia/test_jolokia.py +++ b/metricbeat/module/jolokia/test_jolokia.py @@ -3,7 +3,6 @@ import unittest from parameterized import parameterized -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/kafka/test_kafka.py b/metricbeat/module/kafka/test_kafka.py index adfc8eb5978..c68830e1116 100644 --- a/metricbeat/module/kafka/test_kafka.py +++ b/metricbeat/module/kafka/test_kafka.py @@ -3,7 +3,6 @@ import unittest from parameterized import parameterized -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/kibana/test_kibana.py b/metricbeat/module/kibana/test_kibana.py index cbd4f365979..511cabc9ef3 100644 --- a/metricbeat/module/kibana/test_kibana.py +++ b/metricbeat/module/kibana/test_kibana.py @@ -7,7 +7,6 @@ import urllib.parse import urllib.request -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/logstash/test_logstash.py b/metricbeat/module/logstash/test_logstash.py index b526515fdf0..3924b4fd4e7 100644 --- a/metricbeat/module/logstash/test_logstash.py +++ b/metricbeat/module/logstash/test_logstash.py @@ -8,7 +8,6 @@ import urllib.parse import urllib.request -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/memcached/test_memcached.py b/metricbeat/module/memcached/test_memcached.py index d5858e08c02..4e8145f3dc4 100644 --- a/metricbeat/module/memcached/test_memcached.py +++ b/metricbeat/module/memcached/test_memcached.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/mongodb/test_mongodb.py b/metricbeat/module/mongodb/test_mongodb.py index bd53edd1060..40173cce834 100644 --- a/metricbeat/module/mongodb/test_mongodb.py +++ b/metricbeat/module/mongodb/test_mongodb.py @@ -3,7 +3,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/munin/test_munin.py b/metricbeat/module/munin/test_munin.py index 43f68a04e22..90248289aa1 100644 --- a/metricbeat/module/munin/test_munin.py +++ b/metricbeat/module/munin/test_munin.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/mysql/test_mysql.py b/metricbeat/module/mysql/test_mysql.py index 4a8b34728ed..2e25f9fd9c4 100644 --- a/metricbeat/module/mysql/test_mysql.py +++ b/metricbeat/module/mysql/test_mysql.py @@ -3,7 +3,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat MYSQL_FIELDS = metricbeat.COMMON_FIELDS + ["mysql"] diff --git a/metricbeat/module/nats/test_nats.py b/metricbeat/module/nats/test_nats.py index 0b9e547e471..1fe0059a85f 100644 --- a/metricbeat/module/nats/test_nats.py +++ b/metricbeat/module/nats/test_nats.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/php_fpm/test_phpfpm.py b/metricbeat/module/php_fpm/test_phpfpm.py index a325b62c297..a937167390a 100644 --- a/metricbeat/module/php_fpm/test_phpfpm.py +++ b/metricbeat/module/php_fpm/test_phpfpm.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/postgresql/test_postgresql.py b/metricbeat/module/postgresql/test_postgresql.py index a8d286d5685..e28e94a7d8f 100644 --- a/metricbeat/module/postgresql/test_postgresql.py +++ b/metricbeat/module/postgresql/test_postgresql.py @@ -3,7 +3,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/prometheus/test_prometheus.py b/metricbeat/module/prometheus/test_prometheus.py index e58b1138b99..30a803c0ad0 100644 --- a/metricbeat/module/prometheus/test_prometheus.py +++ b/metricbeat/module/prometheus/test_prometheus.py @@ -3,7 +3,6 @@ import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/redis/test_redis.py b/metricbeat/module/redis/test_redis.py index 1f6082b5626..a42242e8f28 100644 --- a/metricbeat/module/redis/test_redis.py +++ b/metricbeat/module/redis/test_redis.py @@ -4,7 +4,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/system/test_system.py b/metricbeat/module/system/test_system.py index 82e59e71af4..f23687d6ae3 100644 --- a/metricbeat/module/system/test_system.py +++ b/metricbeat/module/system/test_system.py @@ -5,7 +5,6 @@ import getpass import os -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/traefik/test_traefik.py b/metricbeat/module/traefik/test_traefik.py index cc2cfe667d4..68b0a2502ba 100644 --- a/metricbeat/module/traefik/test_traefik.py +++ b/metricbeat/module/traefik/test_traefik.py @@ -4,7 +4,6 @@ import time from parameterized import parameterized -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/uwsgi/test_uwsgi.py b/metricbeat/module/uwsgi/test_uwsgi.py index 1659a7e3e4f..0869d417ccc 100644 --- a/metricbeat/module/uwsgi/test_uwsgi.py +++ b/metricbeat/module/uwsgi/test_uwsgi.py @@ -5,7 +5,6 @@ import unittest from parameterized import parameterized -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/vsphere/test_vsphere.py b/metricbeat/module/vsphere/test_vsphere.py index b9e3e4709e9..99e8ec86ab1 100644 --- a/metricbeat/module/vsphere/test_vsphere.py +++ b/metricbeat/module/vsphere/test_vsphere.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/module/zookeeper/test_zookeeper.py b/metricbeat/module/zookeeper/test_zookeeper.py index 99184119cea..5d4bd0bc8ed 100644 --- a/metricbeat/module/zookeeper/test_zookeeper.py +++ b/metricbeat/module/zookeeper/test_zookeeper.py @@ -3,7 +3,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) import metricbeat diff --git a/metricbeat/tests/system/metricbeat.py b/metricbeat/tests/system/metricbeat.py index b0a0a232b0c..8a49f42168b 100644 --- a/metricbeat/tests/system/metricbeat.py +++ b/metricbeat/tests/system/metricbeat.py @@ -3,7 +3,6 @@ import sys import yaml -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../libbeat/tests/system'))) from beat.beat import TestCase from beat.tags import tag diff --git a/packetbeat/tests/system/packetbeat.py b/packetbeat/tests/system/packetbeat.py index 2243d433c4c..3db240bb21d 100644 --- a/packetbeat/tests/system/packetbeat.py +++ b/packetbeat/tests/system/packetbeat.py @@ -3,7 +3,6 @@ import subprocess import json -sys.path.append(os.path.join(os.path.dirname(__file__), '../../../libbeat/tests/system')) from beat.beat import TestCase from beat.beat import Proc diff --git a/packetbeat/tests/system/test_base.py b/packetbeat/tests/system/test_base.py index 959d36b3911..e475f558187 100644 --- a/packetbeat/tests/system/test_base.py +++ b/packetbeat/tests/system/test_base.py @@ -2,7 +2,6 @@ import sys from packetbeat import BaseTest -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../libbeat/tests/system'))) from beat import common_tests diff --git a/winlogbeat/tests/system/winlogbeat.py b/winlogbeat/tests/system/winlogbeat.py index 4e297bb0c18..7ea59d8d858 100644 --- a/winlogbeat/tests/system/winlogbeat.py +++ b/winlogbeat/tests/system/winlogbeat.py @@ -11,7 +11,6 @@ import win32security import win32evtlogutil -sys.path.append(os.path.join(os.path.dirname(__file__), '../../../libbeat/tests/system')) from beat.beat import TestCase diff --git a/x-pack/auditbeat/tests/system/auditbeat_xpack.py b/x-pack/auditbeat/tests/system/auditbeat_xpack.py index af8e5ae68fa..2ac1806eff6 100644 --- a/x-pack/auditbeat/tests/system/auditbeat_xpack.py +++ b/x-pack/auditbeat/tests/system/auditbeat_xpack.py @@ -2,7 +2,6 @@ import os import sys -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../../metricbeat/tests/system'))) from metricbeat import BaseTest as MetricbeatTest diff --git a/x-pack/filebeat/tests/system/test_filebeat_xpack.py b/x-pack/filebeat/tests/system/test_filebeat_xpack.py index 1890498fd0a..3474a575f94 100644 --- a/x-pack/filebeat/tests/system/test_filebeat_xpack.py +++ b/x-pack/filebeat/tests/system/test_filebeat_xpack.py @@ -2,7 +2,6 @@ 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 diff --git a/x-pack/filebeat/tests/system/test_http_endpoint.py b/x-pack/filebeat/tests/system/test_http_endpoint.py index 5c73a8e2d19..479fdf55375 100644 --- a/x-pack/filebeat/tests/system/test_http_endpoint.py +++ b/x-pack/filebeat/tests/system/test_http_endpoint.py @@ -5,7 +5,6 @@ import json from requests.auth import HTTPBasicAuth -sys.path.append(os.path.join(os.path.dirname(__file__), '../../../../filebeat/tests/system')) from filebeat import BaseTest diff --git a/x-pack/filebeat/tests/system/test_xpack_modules.py b/x-pack/filebeat/tests/system/test_xpack_modules.py index 566850a4720..04aecf403a2 100644 --- a/x-pack/filebeat/tests/system/test_xpack_modules.py +++ b/x-pack/filebeat/tests/system/test_xpack_modules.py @@ -1,7 +1,6 @@ import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '../../../../filebeat/tests/system')) import test_modules diff --git a/x-pack/functionbeat/tests/system/functionbeat.py b/x-pack/functionbeat/tests/system/functionbeat.py index b2af1dbb11a..1e02018356d 100644 --- a/x-pack/functionbeat/tests/system/functionbeat.py +++ b/x-pack/functionbeat/tests/system/functionbeat.py @@ -1,7 +1,6 @@ import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '../../../../libbeat/tests/system')) from beat.beat import TestCase diff --git a/x-pack/libbeat/conftest.py b/x-pack/libbeat/conftest.py new file mode 100644 index 00000000000..8c3ec5a61c5 --- /dev/null +++ b/x-pack/libbeat/conftest.py @@ -0,0 +1,4 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../../libbeat/tests/system')) diff --git a/x-pack/libbeat/tests/system/base.py b/x-pack/libbeat/tests/system/base.py index 287a13f3502..4b706f1b9e2 100644 --- a/x-pack/libbeat/tests/system/base.py +++ b/x-pack/libbeat/tests/system/base.py @@ -1,11 +1,6 @@ import sys import os - -sys.path.append(os.path.join(os.path.dirname(__file__), - '../../../../libbeat/tests/system')) - - from beat.beat import TestCase diff --git a/x-pack/metricbeat/conftest.py b/x-pack/metricbeat/conftest.py new file mode 100644 index 00000000000..2f3a40d0838 --- /dev/null +++ b/x-pack/metricbeat/conftest.py @@ -0,0 +1,6 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../../libbeat/tests/system')) +sys.path.append(os.path.join(os.path.dirname(__file__), '../../metricbeat/tests/system')) +sys.path.append(os.path.join(os.path.dirname(__file__), './tests/system')) diff --git a/x-pack/metricbeat/module/activemq/test_activemq.py b/x-pack/metricbeat/module/activemq/test_activemq.py index 278752b3089..cf22a2d614b 100644 --- a/x-pack/metricbeat/module/activemq/test_activemq.py +++ b/x-pack/metricbeat/module/activemq/test_activemq.py @@ -5,7 +5,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/appsearch/test_appsearch.py b/x-pack/metricbeat/module/appsearch/test_appsearch.py index e9f72a23123..b725f54ce6b 100644 --- a/x-pack/metricbeat/module/appsearch/test_appsearch.py +++ b/x-pack/metricbeat/module/appsearch/test_appsearch.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/cockroachdb/test_cockroachdb.py b/x-pack/metricbeat/module/cockroachdb/test_cockroachdb.py index 72c3517c04e..f5dd8a69c6c 100644 --- a/x-pack/metricbeat/module/cockroachdb/test_cockroachdb.py +++ b/x-pack/metricbeat/module/cockroachdb/test_cockroachdb.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/coredns/test_coredns.py b/x-pack/metricbeat/module/coredns/test_coredns.py index e453fcdf183..4bddce6a265 100644 --- a/x-pack/metricbeat/module/coredns/test_coredns.py +++ b/x-pack/metricbeat/module/coredns/test_coredns.py @@ -3,7 +3,6 @@ import unittest from xpack_metricbeat import XPackTest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/ibmmq/test_ibmmq.py b/x-pack/metricbeat/module/ibmmq/test_ibmmq.py index c7e930335aa..8eedb763861 100644 --- a/x-pack/metricbeat/module/ibmmq/test_ibmmq.py +++ b/x-pack/metricbeat/module/ibmmq/test_ibmmq.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/mssql/test_mssql.py b/x-pack/metricbeat/module/mssql/test_mssql.py index 225dde74fb2..aa77a0b47cd 100644 --- a/x-pack/metricbeat/module/mssql/test_mssql.py +++ b/x-pack/metricbeat/module/mssql/test_mssql.py @@ -3,7 +3,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/openmetrics/test_openmetrics.py b/x-pack/metricbeat/module/openmetrics/test_openmetrics.py index 6e86ad3a506..be2743b5b49 100644 --- a/x-pack/metricbeat/module/openmetrics/test_openmetrics.py +++ b/x-pack/metricbeat/module/openmetrics/test_openmetrics.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/redisenterprise/test_redisenterprise.py b/x-pack/metricbeat/module/redisenterprise/test_redisenterprise.py index 806f7a37c7a..2b2c92bfe3a 100644 --- a/x-pack/metricbeat/module/redisenterprise/test_redisenterprise.py +++ b/x-pack/metricbeat/module/redisenterprise/test_redisenterprise.py @@ -4,7 +4,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/sql/test_sql.py b/x-pack/metricbeat/module/sql/test_sql.py index 8a18791b386..a85e4cf7e74 100644 --- a/x-pack/metricbeat/module/sql/test_sql.py +++ b/x-pack/metricbeat/module/sql/test_sql.py @@ -2,7 +2,6 @@ import sys import unittest -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/stan/test_stan.py b/x-pack/metricbeat/module/stan/test_stan.py index 8acd47984f9..e6b9d118050 100644 --- a/x-pack/metricbeat/module/stan/test_stan.py +++ b/x-pack/metricbeat/module/stan/test_stan.py @@ -3,7 +3,6 @@ import unittest from parameterized import parameterized -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat STAN_FIELDS = metricbeat.COMMON_FIELDS + ["stan"] diff --git a/x-pack/metricbeat/module/statsd/test_statsd.py b/x-pack/metricbeat/module/statsd/test_statsd.py index 15d4b0513b7..c5f3ff945b9 100644 --- a/x-pack/metricbeat/module/statsd/test_statsd.py +++ b/x-pack/metricbeat/module/statsd/test_statsd.py @@ -2,7 +2,6 @@ import socket import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) from xpack_metricbeat import XPackTest, metricbeat STATSD_HOST = '127.0.0.1' diff --git a/x-pack/metricbeat/tests/system/xpack_metricbeat.py b/x-pack/metricbeat/tests/system/xpack_metricbeat.py index 9164a3bf529..2647c44915e 100644 --- a/x-pack/metricbeat/tests/system/xpack_metricbeat.py +++ b/x-pack/metricbeat/tests/system/xpack_metricbeat.py @@ -1,7 +1,6 @@ import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '../../../../metricbeat/tests/system')) import metricbeat From de9b0a0a8ee4820303e7f017e7ff00a62361a322 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 27 Aug 2020 18:26:03 +0200 Subject: [PATCH 2/6] Reorder imports --- filebeat/tests/system/filebeat.py | 2 -- heartbeat/tests/system/heartbeat.py | 1 - metricbeat/module/aerospike/test_aerospike.py | 3 +-- metricbeat/module/apache/test_apache.py | 13 ++++++------- metricbeat/module/ceph/test_ceph.py | 2 +- metricbeat/module/consul/test_consul.py | 3 +-- metricbeat/module/couchbase/test_couchbase.py | 3 +-- metricbeat/module/couchdb/test_couchdb.py | 3 +-- metricbeat/module/docker/test_docker.py | 3 +-- metricbeat/module/dropwizard/test_dropwizard.py | 3 +-- .../module/elasticsearch/test_elasticsearch.py | 12 +++++------- metricbeat/module/envoyproxy/test_envoyproxy.py | 3 +-- metricbeat/module/etcd/test_etcd.py | 6 ++---- metricbeat/module/golang/test_golang.py | 3 +-- metricbeat/module/haproxy/test_haproxy.py | 3 +-- metricbeat/module/http/test_http.py | 3 +-- metricbeat/module/jolokia/test_jolokia.py | 3 +-- metricbeat/module/kafka/test_kafka.py | 3 +-- metricbeat/module/kibana/test_kibana.py | 3 +-- metricbeat/module/logstash/test_logstash.py | 3 +-- metricbeat/module/memcached/test_memcached.py | 3 +-- metricbeat/module/mongodb/test_mongodb.py | 3 +-- metricbeat/module/munin/test_munin.py | 3 +-- metricbeat/module/mysql/test_mysql.py | 3 +-- metricbeat/module/nats/test_nats.py | 4 +--- metricbeat/module/php_fpm/test_phpfpm.py | 4 +--- metricbeat/module/postgresql/test_postgresql.py | 3 +-- metricbeat/module/prometheus/test_prometheus.py | 4 +--- metricbeat/module/redis/test_redis.py | 3 +-- metricbeat/module/system/test_system.py | 7 +++---- metricbeat/module/traefik/test_traefik.py | 6 ++---- metricbeat/module/uwsgi/test_uwsgi.py | 3 +-- metricbeat/module/vsphere/test_vsphere.py | 3 +-- metricbeat/module/zookeeper/test_zookeeper.py | 3 +-- metricbeat/tests/system/metricbeat.py | 2 -- packetbeat/tests/system/packetbeat.py | 2 -- packetbeat/tests/system/test_base.py | 4 +--- winlogbeat/tests/system/winlogbeat.py | 1 - x-pack/auditbeat/tests/system/auditbeat_xpack.py | 2 -- x-pack/filebeat/tests/system/test_filebeat_xpack.py | 4 +--- x-pack/filebeat/tests/system/test_http_endpoint.py | 4 +--- x-pack/filebeat/tests/system/test_xpack_modules.py | 2 -- x-pack/functionbeat/tests/system/functionbeat.py | 1 - x-pack/libbeat/tests/system/base.py | 1 - x-pack/metricbeat/module/activemq/test_activemq.py | 1 - .../metricbeat/module/appsearch/test_appsearch.py | 1 - .../module/cockroachdb/test_cockroachdb.py | 1 - x-pack/metricbeat/module/coredns/test_coredns.py | 2 -- x-pack/metricbeat/module/ibmmq/test_ibmmq.py | 1 - x-pack/metricbeat/module/mssql/test_mssql.py | 1 - .../module/openmetrics/test_openmetrics.py | 1 - .../module/redisenterprise/test_redisenterprise.py | 3 +-- x-pack/metricbeat/module/sql/test_sql.py | 1 - x-pack/metricbeat/module/stan/test_stan.py | 1 - x-pack/metricbeat/module/statsd/test_statsd.py | 1 - x-pack/metricbeat/tests/system/xpack_metricbeat.py | 4 +--- 56 files changed, 50 insertions(+), 121 deletions(-) diff --git a/filebeat/tests/system/filebeat.py b/filebeat/tests/system/filebeat.py index 04714265ae7..9bd796fd210 100644 --- a/filebeat/tests/system/filebeat.py +++ b/filebeat/tests/system/filebeat.py @@ -3,8 +3,6 @@ import stat import sys -curdir = os.path.dirname(__file__) - from beat.beat import TestCase, TimeoutError, REGEXP_TYPE default_registry_path = 'registry/filebeat' diff --git a/heartbeat/tests/system/heartbeat.py b/heartbeat/tests/system/heartbeat.py index d6255141d84..388c4ac42c4 100644 --- a/heartbeat/tests/system/heartbeat.py +++ b/heartbeat/tests/system/heartbeat.py @@ -2,7 +2,6 @@ import sys import http.server import threading - from beat.beat import TestCase from time import sleep diff --git a/metricbeat/module/aerospike/test_aerospike.py b/metricbeat/module/aerospike/test_aerospike.py index 4b069d42720..d3a1e7ec2a6 100644 --- a/metricbeat/module/aerospike/test_aerospike.py +++ b/metricbeat/module/aerospike/test_aerospike.py @@ -1,9 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/apache/test_apache.py b/metricbeat/module/apache/test_apache.py index ebb088a2f4c..181fb73593d 100644 --- a/metricbeat/module/apache/test_apache.py +++ b/metricbeat/module/apache/test_apache.py @@ -1,14 +1,13 @@ +import metricbeat import os -import unittest -import urllib.request -import urllib.error -import urllib.parse import pytest -import time import semver import sys - -import metricbeat +import time +import unittest +import urllib.error +import urllib.parse +import urllib.request APACHE_FIELDS = metricbeat.COMMON_FIELDS + ["apache"] diff --git a/metricbeat/module/ceph/test_ceph.py b/metricbeat/module/ceph/test_ceph.py index c6aa9763905..9b5488853f5 100644 --- a/metricbeat/module/ceph/test_ceph.py +++ b/metricbeat/module/ceph/test_ceph.py @@ -1,3 +1,4 @@ +import metricbeat import os import requests import sys @@ -5,7 +6,6 @@ import unittest from parameterized import parameterized -import metricbeat @metricbeat.parameterized_with_supported_versions diff --git a/metricbeat/module/consul/test_consul.py b/metricbeat/module/consul/test_consul.py index 3949eecfccf..c18dff5a2f1 100644 --- a/metricbeat/module/consul/test_consul.py +++ b/metricbeat/module/consul/test_consul.py @@ -1,10 +1,9 @@ +import metricbeat import os import pytest import sys import unittest -import metricbeat - CONSUL_FIELDS = metricbeat.COMMON_FIELDS + ["consul"] diff --git a/metricbeat/module/couchbase/test_couchbase.py b/metricbeat/module/couchbase/test_couchbase.py index 3c8ad87d767..c42133233dc 100644 --- a/metricbeat/module/couchbase/test_couchbase.py +++ b/metricbeat/module/couchbase/test_couchbase.py @@ -1,10 +1,9 @@ +import metricbeat import os import sys import unittest from parameterized import parameterized -import metricbeat - class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/couchdb/test_couchdb.py b/metricbeat/module/couchdb/test_couchdb.py index 12894370323..c80a5f231a0 100644 --- a/metricbeat/module/couchdb/test_couchdb.py +++ b/metricbeat/module/couchdb/test_couchdb.py @@ -1,9 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/docker/test_docker.py b/metricbeat/module/docker/test_docker.py index 9cc1c767051..a7379cdbcbb 100644 --- a/metricbeat/module/docker/test_docker.py +++ b/metricbeat/module/docker/test_docker.py @@ -1,9 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/dropwizard/test_dropwizard.py b/metricbeat/module/dropwizard/test_dropwizard.py index c5bae4269ef..1e81d70175e 100644 --- a/metricbeat/module/dropwizard/test_dropwizard.py +++ b/metricbeat/module/dropwizard/test_dropwizard.py @@ -1,9 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - @metricbeat.parameterized_with_supported_versions class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/elasticsearch/test_elasticsearch.py b/metricbeat/module/elasticsearch/test_elasticsearch.py index 0cbd424a1be..8202e6cebd4 100644 --- a/metricbeat/module/elasticsearch/test_elasticsearch.py +++ b/metricbeat/module/elasticsearch/test_elasticsearch.py @@ -1,19 +1,17 @@ +import json +import metricbeat +import os import re +import semver import sys -import os import unittest -import urllib.request import urllib.error import urllib.parse -import json -import semver +import urllib.request from elasticsearch import Elasticsearch, TransportError, client from parameterized import parameterized -import metricbeat - - class Test(metricbeat.BaseTest): COMPOSE_SERVICES = ['elasticsearch'] diff --git a/metricbeat/module/envoyproxy/test_envoyproxy.py b/metricbeat/module/envoyproxy/test_envoyproxy.py index 9bb85739357..b8964eb67fc 100644 --- a/metricbeat/module/envoyproxy/test_envoyproxy.py +++ b/metricbeat/module/envoyproxy/test_envoyproxy.py @@ -1,9 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - @metricbeat.parameterized_with_supported_versions class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/etcd/test_etcd.py b/metricbeat/module/etcd/test_etcd.py index f9e04da7837..4cd629ee63f 100644 --- a/metricbeat/module/etcd/test_etcd.py +++ b/metricbeat/module/etcd/test_etcd.py @@ -1,13 +1,11 @@ +import metricbeat import os import sys -import unittest import time +import unittest from parameterized import parameterized -import metricbeat - - @metricbeat.parameterized_with_supported_versions class Test(metricbeat.BaseTest): COMPOSE_SERVICES = ['etcd'] diff --git a/metricbeat/module/golang/test_golang.py b/metricbeat/module/golang/test_golang.py index 45161ebd645..e5b372a3a26 100644 --- a/metricbeat/module/golang/test_golang.py +++ b/metricbeat/module/golang/test_golang.py @@ -1,9 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - GOLANG_FIELDS = metricbeat.COMMON_FIELDS + ["golang"] diff --git a/metricbeat/module/haproxy/test_haproxy.py b/metricbeat/module/haproxy/test_haproxy.py index 9da2e75f45f..86dc1c1fb34 100644 --- a/metricbeat/module/haproxy/test_haproxy.py +++ b/metricbeat/module/haproxy/test_haproxy.py @@ -1,9 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - HAPROXY_FIELDS = metricbeat.COMMON_FIELDS + ["haproxy"] diff --git a/metricbeat/module/http/test_http.py b/metricbeat/module/http/test_http.py index 7bdf3b35361..792cbd86b68 100644 --- a/metricbeat/module/http/test_http.py +++ b/metricbeat/module/http/test_http.py @@ -1,11 +1,10 @@ +import metricbeat import os import requests import sys import time import unittest -import metricbeat - HTTP_FIELDS = metricbeat.COMMON_FIELDS + ["http"] diff --git a/metricbeat/module/jolokia/test_jolokia.py b/metricbeat/module/jolokia/test_jolokia.py index d52f43d0662..aefa63c9a4c 100644 --- a/metricbeat/module/jolokia/test_jolokia.py +++ b/metricbeat/module/jolokia/test_jolokia.py @@ -1,10 +1,9 @@ +import metricbeat import os import sys import unittest from parameterized import parameterized -import metricbeat - class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/kafka/test_kafka.py b/metricbeat/module/kafka/test_kafka.py index c68830e1116..c57ac4b0d5a 100644 --- a/metricbeat/module/kafka/test_kafka.py +++ b/metricbeat/module/kafka/test_kafka.py @@ -1,10 +1,9 @@ +import metricbeat import os import sys import unittest from parameterized import parameterized -import metricbeat - @metricbeat.parameterized_with_supported_versions class KafkaTest(metricbeat.BaseTest): diff --git a/metricbeat/module/kibana/test_kibana.py b/metricbeat/module/kibana/test_kibana.py index 511cabc9ef3..3955baf190e 100644 --- a/metricbeat/module/kibana/test_kibana.py +++ b/metricbeat/module/kibana/test_kibana.py @@ -1,4 +1,5 @@ import json +import metricbeat import os import semver import sys @@ -7,8 +8,6 @@ import urllib.parse import urllib.request -import metricbeat - class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/logstash/test_logstash.py b/metricbeat/module/logstash/test_logstash.py index 3924b4fd4e7..5c37f52057f 100644 --- a/metricbeat/module/logstash/test_logstash.py +++ b/metricbeat/module/logstash/test_logstash.py @@ -1,4 +1,5 @@ import json +import metricbeat import os import semver import sys @@ -8,8 +9,6 @@ import urllib.parse import urllib.request -import metricbeat - class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/memcached/test_memcached.py b/metricbeat/module/memcached/test_memcached.py index 4e8145f3dc4..39f2bf2d707 100644 --- a/metricbeat/module/memcached/test_memcached.py +++ b/metricbeat/module/memcached/test_memcached.py @@ -1,9 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/mongodb/test_mongodb.py b/metricbeat/module/mongodb/test_mongodb.py index 40173cce834..1cfe51cb0b4 100644 --- a/metricbeat/module/mongodb/test_mongodb.py +++ b/metricbeat/module/mongodb/test_mongodb.py @@ -1,10 +1,9 @@ +import metricbeat import os import pytest import sys import unittest -import metricbeat - MONGODB_FIELDS = metricbeat.COMMON_FIELDS + ["mongodb"] diff --git a/metricbeat/module/munin/test_munin.py b/metricbeat/module/munin/test_munin.py index 90248289aa1..456b136372e 100644 --- a/metricbeat/module/munin/test_munin.py +++ b/metricbeat/module/munin/test_munin.py @@ -1,9 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/mysql/test_mysql.py b/metricbeat/module/mysql/test_mysql.py index 2e25f9fd9c4..f2c59053c85 100644 --- a/metricbeat/module/mysql/test_mysql.py +++ b/metricbeat/module/mysql/test_mysql.py @@ -1,10 +1,9 @@ +import metricbeat import os import pytest import sys import unittest -import metricbeat - MYSQL_FIELDS = metricbeat.COMMON_FIELDS + ["mysql"] MYSQL_STATUS_FIELDS = ["clients", "cluster", "cpu", "keyspace", "memory", diff --git a/metricbeat/module/nats/test_nats.py b/metricbeat/module/nats/test_nats.py index 1fe0059a85f..406ee61d66d 100644 --- a/metricbeat/module/nats/test_nats.py +++ b/metricbeat/module/nats/test_nats.py @@ -1,10 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - - NATS_FIELDS = metricbeat.COMMON_FIELDS + ["nats"] diff --git a/metricbeat/module/php_fpm/test_phpfpm.py b/metricbeat/module/php_fpm/test_phpfpm.py index a937167390a..ca2eaf42a3a 100644 --- a/metricbeat/module/php_fpm/test_phpfpm.py +++ b/metricbeat/module/php_fpm/test_phpfpm.py @@ -1,10 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - - PHPFPM_FIELDS = metricbeat.COMMON_FIELDS + ["php_fpm"] diff --git a/metricbeat/module/postgresql/test_postgresql.py b/metricbeat/module/postgresql/test_postgresql.py index e28e94a7d8f..6ac3c0aa131 100644 --- a/metricbeat/module/postgresql/test_postgresql.py +++ b/metricbeat/module/postgresql/test_postgresql.py @@ -1,10 +1,9 @@ +import metricbeat import os import pytest import sys import unittest -import metricbeat - class Test(metricbeat.BaseTest): diff --git a/metricbeat/module/prometheus/test_prometheus.py b/metricbeat/module/prometheus/test_prometheus.py index 30a803c0ad0..f882cedb6df 100644 --- a/metricbeat/module/prometheus/test_prometheus.py +++ b/metricbeat/module/prometheus/test_prometheus.py @@ -1,11 +1,9 @@ +import metricbeat import os import sys import unittest -import metricbeat - - PROMETHEUS_FIELDS = metricbeat.COMMON_FIELDS + ["prometheus"] diff --git a/metricbeat/module/redis/test_redis.py b/metricbeat/module/redis/test_redis.py index a42242e8f28..cbfef13cf7b 100644 --- a/metricbeat/module/redis/test_redis.py +++ b/metricbeat/module/redis/test_redis.py @@ -1,11 +1,10 @@ +import metricbeat import os import pytest import redis import sys import unittest -import metricbeat - REDIS_FIELDS = metricbeat.COMMON_FIELDS + ["redis"] diff --git a/metricbeat/module/system/test_system.py b/metricbeat/module/system/test_system.py index f23687d6ae3..2805513183e 100644 --- a/metricbeat/module/system/test_system.py +++ b/metricbeat/module/system/test_system.py @@ -1,11 +1,10 @@ +import getpass +import metricbeat +import os import re import six import sys import unittest -import getpass -import os - -import metricbeat SYSTEM_CPU_FIELDS = ["cores", "idle.pct", "iowait.pct", "irq.pct", "nice.pct", diff --git a/metricbeat/module/traefik/test_traefik.py b/metricbeat/module/traefik/test_traefik.py index 68b0a2502ba..2752033d023 100644 --- a/metricbeat/module/traefik/test_traefik.py +++ b/metricbeat/module/traefik/test_traefik.py @@ -1,13 +1,11 @@ +import metricbeat import os import sys -import unittest import time +import unittest from parameterized import parameterized -import metricbeat - - class Test(metricbeat.BaseTest): COMPOSE_SERVICES = ['traefik'] diff --git a/metricbeat/module/uwsgi/test_uwsgi.py b/metricbeat/module/uwsgi/test_uwsgi.py index 0869d417ccc..ee33228a9d1 100644 --- a/metricbeat/module/uwsgi/test_uwsgi.py +++ b/metricbeat/module/uwsgi/test_uwsgi.py @@ -1,12 +1,11 @@ import logging +import metricbeat import os import pytest import sys import unittest from parameterized import parameterized -import metricbeat - logger = logging.getLogger(__name__) diff --git a/metricbeat/module/vsphere/test_vsphere.py b/metricbeat/module/vsphere/test_vsphere.py index 99e8ec86ab1..c0c2b0db4bb 100644 --- a/metricbeat/module/vsphere/test_vsphere.py +++ b/metricbeat/module/vsphere/test_vsphere.py @@ -1,9 +1,8 @@ +import metricbeat import os import sys import unittest -import metricbeat - VSPHERE_FIELDS = metricbeat.COMMON_FIELDS + ["vsphere"] diff --git a/metricbeat/module/zookeeper/test_zookeeper.py b/metricbeat/module/zookeeper/test_zookeeper.py index 5d4bd0bc8ed..079c3696c4c 100644 --- a/metricbeat/module/zookeeper/test_zookeeper.py +++ b/metricbeat/module/zookeeper/test_zookeeper.py @@ -1,10 +1,9 @@ +import metricbeat import os import pytest import sys import unittest -import metricbeat - ZK_FIELDS = metricbeat.COMMON_FIELDS + ["zookeeper"] diff --git a/metricbeat/tests/system/metricbeat.py b/metricbeat/tests/system/metricbeat.py index 8a49f42168b..725e33c675b 100644 --- a/metricbeat/tests/system/metricbeat.py +++ b/metricbeat/tests/system/metricbeat.py @@ -2,8 +2,6 @@ import re import sys import yaml - - from beat.beat import TestCase from beat.tags import tag from parameterized import parameterized_class diff --git a/packetbeat/tests/system/packetbeat.py b/packetbeat/tests/system/packetbeat.py index 3db240bb21d..32a9366ee33 100644 --- a/packetbeat/tests/system/packetbeat.py +++ b/packetbeat/tests/system/packetbeat.py @@ -2,8 +2,6 @@ import sys import subprocess import json - - from beat.beat import TestCase from beat.beat import Proc diff --git a/packetbeat/tests/system/test_base.py b/packetbeat/tests/system/test_base.py index e475f558187..9ec4bc6c24f 100644 --- a/packetbeat/tests/system/test_base.py +++ b/packetbeat/tests/system/test_base.py @@ -1,9 +1,7 @@ import os import sys -from packetbeat import BaseTest - - from beat import common_tests +from packetbeat import BaseTest class Test(BaseTest, common_tests.TestExportsMixin): diff --git a/winlogbeat/tests/system/winlogbeat.py b/winlogbeat/tests/system/winlogbeat.py index 7ea59d8d858..e869db397ca 100644 --- a/winlogbeat/tests/system/winlogbeat.py +++ b/winlogbeat/tests/system/winlogbeat.py @@ -11,7 +11,6 @@ import win32security import win32evtlogutil - from beat.beat import TestCase PROVIDER = "WinlogbeatTestPython" diff --git a/x-pack/auditbeat/tests/system/auditbeat_xpack.py b/x-pack/auditbeat/tests/system/auditbeat_xpack.py index 2ac1806eff6..8086ee52c5e 100644 --- a/x-pack/auditbeat/tests/system/auditbeat_xpack.py +++ b/x-pack/auditbeat/tests/system/auditbeat_xpack.py @@ -1,8 +1,6 @@ import jinja2 import os import sys - - from metricbeat import BaseTest as MetricbeatTest diff --git a/x-pack/filebeat/tests/system/test_filebeat_xpack.py b/x-pack/filebeat/tests/system/test_filebeat_xpack.py index 3474a575f94..7da62ca7264 100644 --- a/x-pack/filebeat/tests/system/test_filebeat_xpack.py +++ b/x-pack/filebeat/tests/system/test_filebeat_xpack.py @@ -1,10 +1,8 @@ import jinja2 import os import sys - - -from filebeat import BaseTest as FilebeatTest from beat import common_tests +from filebeat import BaseTest as FilebeatTest class FilebeatXPackTest(FilebeatTest, common_tests.TestExportsMixin): diff --git a/x-pack/filebeat/tests/system/test_http_endpoint.py b/x-pack/filebeat/tests/system/test_http_endpoint.py index 479fdf55375..cfb8aa37ebf 100644 --- a/x-pack/filebeat/tests/system/test_http_endpoint.py +++ b/x-pack/filebeat/tests/system/test_http_endpoint.py @@ -3,10 +3,8 @@ import sys import os import json -from requests.auth import HTTPBasicAuth - - from filebeat import BaseTest +from requests.auth import HTTPBasicAuth class Test(BaseTest): diff --git a/x-pack/filebeat/tests/system/test_xpack_modules.py b/x-pack/filebeat/tests/system/test_xpack_modules.py index 04aecf403a2..e0397a99811 100644 --- a/x-pack/filebeat/tests/system/test_xpack_modules.py +++ b/x-pack/filebeat/tests/system/test_xpack_modules.py @@ -1,7 +1,5 @@ import os import sys - - import test_modules diff --git a/x-pack/functionbeat/tests/system/functionbeat.py b/x-pack/functionbeat/tests/system/functionbeat.py index 1e02018356d..24327363aef 100644 --- a/x-pack/functionbeat/tests/system/functionbeat.py +++ b/x-pack/functionbeat/tests/system/functionbeat.py @@ -1,6 +1,5 @@ import os import sys - from beat.beat import TestCase diff --git a/x-pack/libbeat/tests/system/base.py b/x-pack/libbeat/tests/system/base.py index 4b706f1b9e2..ac2fdb84858 100644 --- a/x-pack/libbeat/tests/system/base.py +++ b/x-pack/libbeat/tests/system/base.py @@ -1,6 +1,5 @@ import sys import os - from beat.beat import TestCase diff --git a/x-pack/metricbeat/module/activemq/test_activemq.py b/x-pack/metricbeat/module/activemq/test_activemq.py index cf22a2d614b..8b3f9694964 100644 --- a/x-pack/metricbeat/module/activemq/test_activemq.py +++ b/x-pack/metricbeat/module/activemq/test_activemq.py @@ -4,7 +4,6 @@ import string import sys import unittest - from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/appsearch/test_appsearch.py b/x-pack/metricbeat/module/appsearch/test_appsearch.py index b725f54ce6b..276c4e47f8f 100644 --- a/x-pack/metricbeat/module/appsearch/test_appsearch.py +++ b/x-pack/metricbeat/module/appsearch/test_appsearch.py @@ -1,7 +1,6 @@ import os import sys import unittest - from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/cockroachdb/test_cockroachdb.py b/x-pack/metricbeat/module/cockroachdb/test_cockroachdb.py index f5dd8a69c6c..b348388e8f4 100644 --- a/x-pack/metricbeat/module/cockroachdb/test_cockroachdb.py +++ b/x-pack/metricbeat/module/cockroachdb/test_cockroachdb.py @@ -1,7 +1,6 @@ import os import sys import unittest - from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/coredns/test_coredns.py b/x-pack/metricbeat/module/coredns/test_coredns.py index 4bddce6a265..b885934ea13 100644 --- a/x-pack/metricbeat/module/coredns/test_coredns.py +++ b/x-pack/metricbeat/module/coredns/test_coredns.py @@ -1,8 +1,6 @@ import os import sys import unittest -from xpack_metricbeat import XPackTest - from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/ibmmq/test_ibmmq.py b/x-pack/metricbeat/module/ibmmq/test_ibmmq.py index 8eedb763861..187f548a371 100644 --- a/x-pack/metricbeat/module/ibmmq/test_ibmmq.py +++ b/x-pack/metricbeat/module/ibmmq/test_ibmmq.py @@ -1,7 +1,6 @@ import os import sys import unittest - from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/mssql/test_mssql.py b/x-pack/metricbeat/module/mssql/test_mssql.py index aa77a0b47cd..1f1eb144943 100644 --- a/x-pack/metricbeat/module/mssql/test_mssql.py +++ b/x-pack/metricbeat/module/mssql/test_mssql.py @@ -2,7 +2,6 @@ import pytest import sys import unittest - from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/openmetrics/test_openmetrics.py b/x-pack/metricbeat/module/openmetrics/test_openmetrics.py index be2743b5b49..d2b9c3ba14b 100644 --- a/x-pack/metricbeat/module/openmetrics/test_openmetrics.py +++ b/x-pack/metricbeat/module/openmetrics/test_openmetrics.py @@ -1,7 +1,6 @@ import os import sys import unittest - from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/redisenterprise/test_redisenterprise.py b/x-pack/metricbeat/module/redisenterprise/test_redisenterprise.py index 2b2c92bfe3a..17e30e58fea 100644 --- a/x-pack/metricbeat/module/redisenterprise/test_redisenterprise.py +++ b/x-pack/metricbeat/module/redisenterprise/test_redisenterprise.py @@ -1,9 +1,8 @@ import os -from parameterized import parameterized import redis import sys import unittest - +from parameterized import parameterized from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/sql/test_sql.py b/x-pack/metricbeat/module/sql/test_sql.py index a85e4cf7e74..e091c4185db 100644 --- a/x-pack/metricbeat/module/sql/test_sql.py +++ b/x-pack/metricbeat/module/sql/test_sql.py @@ -1,7 +1,6 @@ import os import sys import unittest - from xpack_metricbeat import XPackTest, metricbeat diff --git a/x-pack/metricbeat/module/stan/test_stan.py b/x-pack/metricbeat/module/stan/test_stan.py index e6b9d118050..11f862a31ba 100644 --- a/x-pack/metricbeat/module/stan/test_stan.py +++ b/x-pack/metricbeat/module/stan/test_stan.py @@ -2,7 +2,6 @@ import sys import unittest from parameterized import parameterized - from xpack_metricbeat import XPackTest, metricbeat STAN_FIELDS = metricbeat.COMMON_FIELDS + ["stan"] diff --git a/x-pack/metricbeat/module/statsd/test_statsd.py b/x-pack/metricbeat/module/statsd/test_statsd.py index c5f3ff945b9..92798009247 100644 --- a/x-pack/metricbeat/module/statsd/test_statsd.py +++ b/x-pack/metricbeat/module/statsd/test_statsd.py @@ -1,7 +1,6 @@ import os import socket import sys - from xpack_metricbeat import XPackTest, metricbeat STATSD_HOST = '127.0.0.1' diff --git a/x-pack/metricbeat/tests/system/xpack_metricbeat.py b/x-pack/metricbeat/tests/system/xpack_metricbeat.py index 2647c44915e..7554c9e339a 100644 --- a/x-pack/metricbeat/tests/system/xpack_metricbeat.py +++ b/x-pack/metricbeat/tests/system/xpack_metricbeat.py @@ -1,10 +1,8 @@ +import metricbeat import os import sys -import metricbeat - - class XPackTest(metricbeat.BaseTest): @classmethod From 7f26cd4f6ee49de120b781caa5093d4bf3d27603 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 27 Aug 2020 18:44:30 +0200 Subject: [PATCH 3/6] pep8 --- metricbeat/module/ceph/test_ceph.py | 1 - 1 file changed, 1 deletion(-) diff --git a/metricbeat/module/ceph/test_ceph.py b/metricbeat/module/ceph/test_ceph.py index 9b5488853f5..91bb6e56e7c 100644 --- a/metricbeat/module/ceph/test_ceph.py +++ b/metricbeat/module/ceph/test_ceph.py @@ -7,7 +7,6 @@ from parameterized import parameterized - @metricbeat.parameterized_with_supported_versions class Test(metricbeat.BaseTest): From b0cef0a067bbdb1f9b224ae47f1bcb78343ea099 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 27 Aug 2020 21:04:17 +0200 Subject: [PATCH 4/6] Add missing coftest files --- packetbeat/conftest.py | 4 ++++ winlogbeat/conftest.py | 4 ++++ x-pack/auditbeat/conftest.py | 5 +++++ x-pack/filebeat/conftest.py | 5 +++++ x-pack/functionbeat/conftest.py | 5 +++++ 5 files changed, 23 insertions(+) create mode 100644 packetbeat/conftest.py create mode 100644 winlogbeat/conftest.py create mode 100644 x-pack/auditbeat/conftest.py create mode 100644 x-pack/filebeat/conftest.py create mode 100644 x-pack/functionbeat/conftest.py diff --git a/packetbeat/conftest.py b/packetbeat/conftest.py new file mode 100644 index 00000000000..2f3f8199559 --- /dev/null +++ b/packetbeat/conftest.py @@ -0,0 +1,4 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../libbeat/tests/system')) diff --git a/winlogbeat/conftest.py b/winlogbeat/conftest.py new file mode 100644 index 00000000000..2f3f8199559 --- /dev/null +++ b/winlogbeat/conftest.py @@ -0,0 +1,4 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../libbeat/tests/system')) diff --git a/x-pack/auditbeat/conftest.py b/x-pack/auditbeat/conftest.py new file mode 100644 index 00000000000..8e1002b41e5 --- /dev/null +++ b/x-pack/auditbeat/conftest.py @@ -0,0 +1,5 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../../libbeat/tests/system')) +sys.path.append(os.path.join(os.path.dirname(__file__), './tests/system')) diff --git a/x-pack/filebeat/conftest.py b/x-pack/filebeat/conftest.py new file mode 100644 index 00000000000..8e1002b41e5 --- /dev/null +++ b/x-pack/filebeat/conftest.py @@ -0,0 +1,5 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../../libbeat/tests/system')) +sys.path.append(os.path.join(os.path.dirname(__file__), './tests/system')) diff --git a/x-pack/functionbeat/conftest.py b/x-pack/functionbeat/conftest.py new file mode 100644 index 00000000000..8e1002b41e5 --- /dev/null +++ b/x-pack/functionbeat/conftest.py @@ -0,0 +1,5 @@ +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '../../libbeat/tests/system')) +sys.path.append(os.path.join(os.path.dirname(__file__), './tests/system')) From 0d39c24558a37b97516647cdce8221cda30e6b53 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 27 Aug 2020 21:57:59 +0200 Subject: [PATCH 5/6] Add oss paths --- x-pack/auditbeat/conftest.py | 1 + x-pack/filebeat/conftest.py | 1 + 2 files changed, 2 insertions(+) diff --git a/x-pack/auditbeat/conftest.py b/x-pack/auditbeat/conftest.py index 8e1002b41e5..2f3a40d0838 100644 --- a/x-pack/auditbeat/conftest.py +++ b/x-pack/auditbeat/conftest.py @@ -2,4 +2,5 @@ import sys sys.path.append(os.path.join(os.path.dirname(__file__), '../../libbeat/tests/system')) +sys.path.append(os.path.join(os.path.dirname(__file__), '../../metricbeat/tests/system')) sys.path.append(os.path.join(os.path.dirname(__file__), './tests/system')) diff --git a/x-pack/filebeat/conftest.py b/x-pack/filebeat/conftest.py index 8e1002b41e5..4592085fbd9 100644 --- a/x-pack/filebeat/conftest.py +++ b/x-pack/filebeat/conftest.py @@ -2,4 +2,5 @@ import sys sys.path.append(os.path.join(os.path.dirname(__file__), '../../libbeat/tests/system')) +sys.path.append(os.path.join(os.path.dirname(__file__), '../../filebeat/tests/system')) sys.path.append(os.path.join(os.path.dirname(__file__), './tests/system')) From ca8119f14c035d7ddb0d7ce26fa6b1a6a2e954d8 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 27 Aug 2020 23:35:05 +0200 Subject: [PATCH 6/6] Fix paths order --- x-pack/metricbeat/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/metricbeat/conftest.py b/x-pack/metricbeat/conftest.py index 2f3a40d0838..c4b7e3833d2 100644 --- a/x-pack/metricbeat/conftest.py +++ b/x-pack/metricbeat/conftest.py @@ -1,6 +1,6 @@ import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '../../libbeat/tests/system')) sys.path.append(os.path.join(os.path.dirname(__file__), '../../metricbeat/tests/system')) +sys.path.append(os.path.join(os.path.dirname(__file__), '../../libbeat/tests/system')) sys.path.append(os.path.join(os.path.dirname(__file__), './tests/system'))