Remove six
Replace the following items with Python 3 style code. - six.PY2 - six.add_metaclass - six.string_types - six.text_type - six.moves - six.StringIO - six.wraps - six.integer_types Story: 2008305 Task: 41191 Change-Id: I68710421b69d4049c9e990451da491dc14251fb5
This commit is contained in:
parent
b7179b7dc2
commit
c84e98d6b6
@ -17,7 +17,7 @@ import threading
|
||||
|
||||
import eventlet
|
||||
import multiprocessing
|
||||
from six.moves.queue import Queue
|
||||
from queue import Queue
|
||||
|
||||
import monasca_agent.collector.checks
|
||||
|
||||
|
@ -15,8 +15,7 @@
|
||||
|
||||
import logging
|
||||
import socket
|
||||
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
# project
|
||||
import monasca_agent.collector.checks as checks
|
||||
|
@ -13,8 +13,8 @@
|
||||
|
||||
import requests
|
||||
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from six.moves.urllib.parse import urlunparse
|
||||
from urllib.parse import urlparse
|
||||
from urllib.parse import urlunparse
|
||||
|
||||
from monasca_agent.collector.checks import AgentCheck
|
||||
from monasca_agent.collector.checks import utils
|
||||
|
@ -15,7 +15,7 @@ from datetime import datetime
|
||||
import socket
|
||||
import ssl
|
||||
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from monasca_agent.collector.checks import AgentCheck
|
||||
|
||||
|
@ -12,8 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
from monasca_agent.collector.checks import AgentCheck
|
||||
from monasca_agent.common.util import headers
|
||||
|
@ -14,8 +14,8 @@
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import urllib
|
||||
|
||||
from six.moves import urllib
|
||||
|
||||
from monasca_agent.collector.checks import AgentCheck
|
||||
from monasca_agent.collector.checks.utils import add_basic_auth
|
||||
|
@ -16,7 +16,6 @@ import os
|
||||
import re
|
||||
|
||||
from datetime import datetime
|
||||
from six import text_type
|
||||
|
||||
import monasca_agent.collector.checks as checks
|
||||
|
||||
@ -78,7 +77,7 @@ class Crash(checks.AgentCheck):
|
||||
|
||||
# Return the date-/timestamp of the most recent crash
|
||||
if dump_count == 1:
|
||||
value_meta = {'latest': text_type(dt)}
|
||||
value_meta = {'latest': str(dt)}
|
||||
|
||||
log.debug('dump_count: %s', dump_count)
|
||||
self.gauge('crash.dump_count', dump_count, dimensions=dimensions,
|
||||
|
@ -15,8 +15,8 @@ import json
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib
|
||||
|
||||
from six.moves import urllib
|
||||
|
||||
from monasca_agent.collector.checks import AgentCheck
|
||||
from monasca_agent.collector.checks.utils import add_basic_auth
|
||||
|
@ -12,7 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
from collections import defaultdict
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
|
||||
from monasca_agent.collector.checks import AgentCheck
|
||||
|
@ -22,9 +22,9 @@ import socket
|
||||
import sys
|
||||
import time
|
||||
|
||||
from http import client as http_client
|
||||
from httplib2 import Http
|
||||
from httplib2 import HttpLib2Error
|
||||
from six.moves import http_client
|
||||
|
||||
import monasca_agent.collector.checks.services_checks as services_checks
|
||||
import monasca_agent.common.config as cfg
|
||||
|
@ -16,8 +16,6 @@ from glob import glob
|
||||
import os
|
||||
import time
|
||||
|
||||
from six import moves
|
||||
|
||||
try:
|
||||
from xml.etree.ElementTree import ElementTree
|
||||
except ImportError:
|
||||
@ -103,7 +101,7 @@ class Jenkins(AgentCheck):
|
||||
if len(dirs) > 0:
|
||||
dirs = sorted(dirs, reverse=True)
|
||||
# We try to get the last valid build
|
||||
for index in moves.range(0, len(dirs) - 1):
|
||||
for index in range(0, len(dirs) - 1):
|
||||
dir_name = dirs[index]
|
||||
try:
|
||||
timestamp = self._extract_timestamp(dir_name)
|
||||
|
@ -14,7 +14,6 @@
|
||||
import collections
|
||||
import logging
|
||||
|
||||
import six
|
||||
|
||||
import monasca_agent.collector.checks as checks
|
||||
|
||||
@ -66,11 +65,11 @@ class KafkaCheck(checks.AgentCheck):
|
||||
|
||||
try:
|
||||
for group, topics in raw_val.items():
|
||||
assert isinstance(group, six.string_types)
|
||||
assert isinstance(group, str)
|
||||
if isinstance(topics, dict):
|
||||
self.log.info("Found old config format, discarding partition list")
|
||||
topics = list(topics.keys())
|
||||
assert isinstance(topics[0], six.string_types)
|
||||
assert isinstance(topics[0], str)
|
||||
consumer_groups[group] = topics
|
||||
return consumer_groups
|
||||
except Exception as e:
|
||||
|
@ -13,8 +13,7 @@
|
||||
|
||||
from collections import defaultdict
|
||||
import re
|
||||
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
from monasca_agent.collector.checks import AgentCheck
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
from monasca_agent.collector.checks import AgentCheck
|
||||
from monasca_agent.collector.checks.utils import add_basic_auth
|
||||
|
@ -17,8 +17,6 @@ import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from six import text_type
|
||||
|
||||
import monasca_agent.collector.checks as checks
|
||||
|
||||
GAUGE = "gauge"
|
||||
@ -256,7 +254,7 @@ class MySql(checks.AgentCheck):
|
||||
return self._collect_type(key, dict, float)
|
||||
|
||||
def _collect_string(self, key, dict):
|
||||
return self._collect_type(key, dict, text_type)
|
||||
return self._collect_type(key, dict, str)
|
||||
|
||||
def _collect_type(self, key, dict, the_type):
|
||||
self.log.debug("Collecting data with %s" % key)
|
||||
|
@ -12,8 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import re
|
||||
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
from monasca_agent.collector.checks import AgentCheck
|
||||
from monasca_agent.collector.checks.utils import add_basic_auth
|
||||
|
@ -13,8 +13,7 @@
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
import monasca_agent.collector.checks as checks
|
||||
|
||||
|
@ -10,13 +10,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import functools
|
||||
import json
|
||||
import logging
|
||||
import time
|
||||
|
||||
import requests
|
||||
from requests.packages.urllib3 import exceptions
|
||||
import six
|
||||
import warnings
|
||||
|
||||
import monasca_agent.collector.checks as checks
|
||||
@ -186,7 +186,7 @@ class SolidFire(checks.AgentCheck):
|
||||
def retry(exc_tuple, tries=5, delay=1, backoff=2):
|
||||
# Retry decorator used for issuing API requests.
|
||||
def retry_dec(f):
|
||||
@six.wraps(f)
|
||||
@functools.wraps(f)
|
||||
def func_retry(*args, **kwargs):
|
||||
_tries, _delay = tries, delay
|
||||
while _tries > 1:
|
||||
|
@ -18,8 +18,7 @@ import itertools
|
||||
import re
|
||||
import socket
|
||||
import time
|
||||
|
||||
from six.moves import xmlrpc_client
|
||||
from xmlrpc import client as xmlrpc_client
|
||||
|
||||
# 3p
|
||||
import supervisor.xmlrpc
|
||||
|
@ -1,8 +1,7 @@
|
||||
import json
|
||||
import os
|
||||
import six
|
||||
from six.moves import urllib
|
||||
import socket
|
||||
import urllib
|
||||
|
||||
import monasca_agent.collector.checks as checks
|
||||
|
||||
@ -32,7 +31,7 @@ class SwiftRecon(checks.AgentCheck):
|
||||
url = base_url + recon_type
|
||||
try:
|
||||
body = urllib.request.urlopen(url, timeout=timeout).read()
|
||||
if six.PY3 and isinstance(body, six.binary_type):
|
||||
if isinstance(body, bytes):
|
||||
body = body.decode('utf8')
|
||||
content = json.loads(body)
|
||||
self.log.debug("-> %s: %s" % (url, content))
|
||||
@ -180,7 +179,7 @@ class SwiftRecon(checks.AgentCheck):
|
||||
continue
|
||||
dimensions['device'] = drive['device']
|
||||
for stat in ('mounted', 'size', 'used', 'avail'):
|
||||
if isinstance(drive[stat], six.string_types) and \
|
||||
if isinstance(drive[stat], str) and \
|
||||
not drive[stat].isdigit():
|
||||
continue
|
||||
self.gauge('swift_recon.disk_usage.{0}'.format(stat),
|
||||
|
@ -39,8 +39,8 @@ import re
|
||||
import socket
|
||||
import struct
|
||||
|
||||
from io import StringIO
|
||||
from oslo_utils import encodeutils
|
||||
from six import StringIO
|
||||
|
||||
from monasca_agent.collector.checks import AgentCheck
|
||||
|
||||
|
@ -14,11 +14,11 @@
|
||||
|
||||
# Core modules
|
||||
import glob
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import pstats
|
||||
import signal
|
||||
import six
|
||||
import sys
|
||||
import time
|
||||
|
||||
@ -137,7 +137,7 @@ class CollectorDaemon(monasca_agent.common.daemon.Daemon):
|
||||
if config.get('profile', False) and profiled:
|
||||
try:
|
||||
profiler.disable()
|
||||
s = six.StringIO()
|
||||
s = io.StringIO()
|
||||
ps = pstats.Stats(profiler, stream=s).sort_stats("cumulative")
|
||||
ps.print_stats()
|
||||
log.debug(s.getvalue())
|
||||
|
@ -20,7 +20,6 @@ import logging
|
||||
from lxml import etree
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import units
|
||||
import six
|
||||
|
||||
from monasca_agent.collector.virt import inspector as virt_inspector
|
||||
|
||||
@ -87,7 +86,7 @@ class LibvirtInspector(virt_inspector.Inspector):
|
||||
return self._get_connection().lookupByUUIDString(instance.UUIDString())
|
||||
except Exception as ex:
|
||||
if not libvirt or not isinstance(ex, libvirt.libvirtError):
|
||||
raise virt_inspector.InspectorException(six.text_type(ex))
|
||||
raise virt_inspector.InspectorException(str(ex))
|
||||
error_code = ex.get_error_code()
|
||||
if (error_code == libvirt.VIR_ERR_SYSTEM_ERROR and
|
||||
ex.get_error_domain() in (libvirt.VIR_FROM_REMOTE,
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
import logging
|
||||
import os
|
||||
import six
|
||||
import yaml
|
||||
|
||||
from monasca_agent.common import exceptions
|
||||
@ -30,8 +29,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
# Make this a singleton class so we don't get the config every time
|
||||
# the class is created
|
||||
@six.add_metaclass(singleton.Singleton)
|
||||
class Config(object):
|
||||
class Config(object, metaclass=singleton.Singleton):
|
||||
|
||||
def __init__(self, configFile=None):
|
||||
# importing it here, in order to avoid a circular import
|
||||
@ -107,7 +105,7 @@ class Config(object):
|
||||
def get_config(self, sections='Main'):
|
||||
"""Get the config info."""
|
||||
section_list = []
|
||||
if isinstance(sections, six.string_types):
|
||||
if isinstance(sections, str):
|
||||
section_list.append(sections)
|
||||
elif isinstance(sections, list):
|
||||
section_list.extend(sections)
|
||||
|
@ -13,11 +13,10 @@
|
||||
|
||||
from hashlib import md5
|
||||
import json
|
||||
from six.moves.urllib.error import HTTPError
|
||||
from six.moves.urllib.request import build_opener
|
||||
from six.moves.urllib.request import ProxyHandler
|
||||
from six.moves.urllib.request import Request
|
||||
from six import PY3
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import build_opener
|
||||
from urllib.request import ProxyHandler
|
||||
from urllib.request import Request
|
||||
|
||||
|
||||
def post_headers(payload):
|
||||
@ -41,7 +40,6 @@ def http_emitter(message, log, url):
|
||||
partial_payload.append(measurement)
|
||||
|
||||
payload = json.dumps(partial_payload)
|
||||
if PY3:
|
||||
payload = payload.encode('utf-8')
|
||||
url = "%s/intake" % url
|
||||
headers = post_headers(payload)
|
||||
|
@ -17,7 +17,6 @@ import logging
|
||||
from keystoneauth1 import identity
|
||||
from keystoneauth1 import session
|
||||
from keystoneclient import discover
|
||||
import six
|
||||
|
||||
from monasca_agent.common import singleton
|
||||
from monasca_agent import version as ma_version
|
||||
@ -244,8 +243,7 @@ def get_args(config):
|
||||
return clean_args
|
||||
|
||||
|
||||
@six.add_metaclass(singleton.Singleton)
|
||||
class Keystone(object):
|
||||
class Keystone(object, metaclass=singleton.Singleton):
|
||||
|
||||
def __init__(self, config):
|
||||
self._config = get_args(config)
|
||||
|
@ -34,7 +34,6 @@ import logging
|
||||
import logging.handlers
|
||||
from numbers import Number
|
||||
from oslo_utils import encodeutils
|
||||
from six import integer_types
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -45,7 +44,7 @@ VALID_HOSTNAME_RFC_1123_PATTERN = re.compile(
|
||||
MAX_HOSTNAME_LEN = 255
|
||||
LOGGING_MAX_BYTES = 5 * 1024 * 1024
|
||||
|
||||
NumericTypes = (float,) + integer_types
|
||||
NumericTypes = (float,) + (int,)
|
||||
|
||||
import monasca_agent.common.config as configuration
|
||||
from monasca_agent.common.exceptions import PathNotFound
|
||||
|
@ -24,8 +24,6 @@ import signal
|
||||
import socket
|
||||
import sys
|
||||
|
||||
from six import text_type
|
||||
|
||||
# set up logging before importing any other components
|
||||
import monasca_agent.common.util as util
|
||||
util.initialize_logging('forwarder')
|
||||
@ -222,10 +220,10 @@ def main():
|
||||
skip_ssl_validation = False
|
||||
use_simple_http_client = False
|
||||
|
||||
if text_type(tornado.options.options.sslcheck) == u"0":
|
||||
if str(tornado.options.options.sslcheck) == u"0":
|
||||
skip_ssl_validation = True
|
||||
|
||||
if text_type(tornado.options.options.use_simple_http_client) == u"1":
|
||||
if str(tornado.options.options.use_simple_http_client) == u"1":
|
||||
use_simple_http_client = True
|
||||
|
||||
# If we don't have any arguments, run the server.
|
||||
|
@ -15,8 +15,7 @@
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
import monasca_setup.agent_config
|
||||
import monasca_setup.detection
|
||||
|
@ -11,11 +11,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import configparser
|
||||
import logging
|
||||
import os
|
||||
|
||||
from six.moves import configparser
|
||||
|
||||
from monasca_agent.common.psutil_wrapper import psutil
|
||||
import monasca_setup.agent_config
|
||||
import monasca_setup.detection
|
||||
|
@ -20,11 +20,11 @@
|
||||
uses statsd.
|
||||
"""
|
||||
|
||||
import configparser
|
||||
import logging
|
||||
import re
|
||||
import yaml
|
||||
|
||||
from six.moves import configparser
|
||||
|
||||
import monasca_setup.agent_config
|
||||
import monasca_setup.detection
|
||||
|
@ -11,9 +11,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import configparser
|
||||
import logging
|
||||
import os
|
||||
from six.moves import configparser
|
||||
|
||||
import monasca_setup.agent_config
|
||||
import monasca_setup.detection
|
||||
|
@ -11,13 +11,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import configparser
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import importutils
|
||||
from six.moves import configparser
|
||||
|
||||
from monasca_setup import agent_config
|
||||
from monasca_setup import detection
|
||||
|
@ -15,7 +15,6 @@ import json
|
||||
import logging
|
||||
import yaml
|
||||
|
||||
import six
|
||||
|
||||
import monasca_setup.agent_config
|
||||
import monasca_setup.detection
|
||||
@ -136,7 +135,7 @@ class ProcessCheck(monasca_setup.detection.Plugin):
|
||||
if found_process_names:
|
||||
process_item['found_process_names'] = found_process_names
|
||||
if 'exact_match' in process_item:
|
||||
if isinstance(process_item['exact_match'], six.string_types):
|
||||
if isinstance(process_item['exact_match'], str):
|
||||
process_item['exact_match'] = (
|
||||
process_item['exact_match'].lower() == 'true')
|
||||
else:
|
||||
|
@ -12,8 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
import monasca_setup.agent_config
|
||||
import monasca_setup.detection
|
||||
|
@ -11,10 +11,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import configparser
|
||||
import logging
|
||||
|
||||
from six.moves import configparser
|
||||
|
||||
from monasca_agent.common.psutil_wrapper import psutil
|
||||
import monasca_setup.agent_config
|
||||
from monasca_setup.detection import Plugin
|
||||
|
@ -12,8 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
from monasca_setup import agent_config
|
||||
from monasca_setup.detection.plugin import Plugin
|
||||
|
@ -26,7 +26,6 @@ import socket
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
from monasca_setup import agent_config
|
||||
from monasca_setup.service.detection import detect_init
|
||||
@ -288,7 +287,7 @@ def parse_arguments(parser):
|
||||
parser.add_argument(
|
||||
'--monasca_url',
|
||||
help="Monasca API url, if not defined the url is pulled from keystone",
|
||||
type=six.text_type,
|
||||
type=str,
|
||||
default='')
|
||||
parser.add_argument(
|
||||
'--service_type',
|
||||
|
@ -18,7 +18,6 @@ python-memcached>=1.56 # PSF
|
||||
python-monascaclient>=1.7.0 # Apache-2.0
|
||||
python-keystoneclient>=3.8.0 # Apache-2.0
|
||||
redis>=2.10.0 # MIT
|
||||
six>=1.10.0 # MIT
|
||||
stevedore>=1.20.0 # Apache-2.0
|
||||
tornado>=4.5.3 # Apache-2.0
|
||||
# NOTE(sdague): before allowing in >= 0.21 please be sure
|
||||
|
@ -18,7 +18,6 @@ from unittest import mock
|
||||
import unittest
|
||||
import psutil
|
||||
import json
|
||||
import six
|
||||
|
||||
from monasca_setup.detection.plugins import kibana
|
||||
|
||||
@ -91,7 +90,7 @@ class KibanaDetectionTest(unittest.TestCase):
|
||||
for instance in kibana_check['instances']:
|
||||
self.assertIn('metrics', instance)
|
||||
self.assertEqual(list, type(instance['metrics']))
|
||||
six.assertCountEqual(self, _KIBANA_METRICS, instance['metrics'])
|
||||
self.assertCountEqual(_KIBANA_METRICS, instance['metrics'])
|
||||
|
||||
def _verify_process_conf(self, process_check, kibana_user):
|
||||
# minimize check here, do not check how process should work
|
||||
@ -249,6 +248,6 @@ class KibanaDetectionTest(unittest.TestCase):
|
||||
conf = self.kibana_plugin.build_config()
|
||||
self.assertIsNotNone(conf)
|
||||
|
||||
six.assertCountEqual(self, ['kibana', 'process'], conf.keys())
|
||||
self.assertCountEqual(['kibana', 'process'], conf.keys())
|
||||
self._verify_kibana_conf(conf['kibana'], kibana_url)
|
||||
self._verify_process_conf(conf['process'], kibana_user)
|
||||
|
@ -17,7 +17,7 @@ import unittest
|
||||
|
||||
import logging
|
||||
import psutil
|
||||
import six
|
||||
import configparser
|
||||
|
||||
from monasca_setup.detection.plugins import mon
|
||||
|
||||
@ -187,8 +187,6 @@ class TestMonPersisterDetectionPlugin(unittest.TestCase):
|
||||
)
|
||||
|
||||
mod = "builtins.open"
|
||||
if six.PY2:
|
||||
mod = "__builtin__.open"
|
||||
|
||||
with mock.patch(
|
||||
mod,
|
||||
@ -220,7 +218,7 @@ class TestMonPersisterDetectionPlugin(unittest.TestCase):
|
||||
rcf.assert_called_once_with(config_file)
|
||||
self.assertTrue(iih.get_bound_port.called_once)
|
||||
|
||||
@mock.patch('six.moves.configparser.RawConfigParser')
|
||||
@mock.patch('configparser.RawConfigParser')
|
||||
def test_should_detect_python_persister_has_config(self, _):
|
||||
# NOTE(trebskit) this cannot use mocking the read of the file
|
||||
# because when either RawConfigParser or mock_open messes up with
|
||||
@ -261,8 +259,6 @@ class TestMonPersisterDetectionPlugin(unittest.TestCase):
|
||||
)
|
||||
|
||||
mod = "builtins.open"
|
||||
if six.PY2:
|
||||
mod = "__builtin__.open"
|
||||
|
||||
with mock.patch(
|
||||
mod,
|
||||
@ -501,8 +497,6 @@ class TestMonAPIDetectionPlugin(unittest.TestCase):
|
||||
)
|
||||
|
||||
mod = "builtins.open"
|
||||
if six.PY2:
|
||||
mod = "__builtin__.open"
|
||||
|
||||
with mock.patch(
|
||||
mod,
|
||||
@ -513,7 +507,7 @@ class TestMonAPIDetectionPlugin(unittest.TestCase):
|
||||
|
||||
self.assertTrue(self._mon_api.available)
|
||||
|
||||
@mock.patch('six.moves.configparser.RawConfigParser')
|
||||
@mock.patch('configparser.RawConfigParser')
|
||||
def test_should_detect_python_api_has_config(self, rcp):
|
||||
expected_port = 6666
|
||||
actual_port = 6666
|
||||
@ -535,7 +529,7 @@ class TestMonAPIDetectionPlugin(unittest.TestCase):
|
||||
self._detect(retval=[fake_processes])
|
||||
self.assertTrue(self._mon_api.available)
|
||||
|
||||
@mock.patch('six.moves.configparser.RawConfigParser')
|
||||
@mock.patch('configparser.RawConfigParser')
|
||||
def test_should_not_detect_if_port_dont_match(self, rcp):
|
||||
expected_port = 6666
|
||||
actual_port = 8070
|
||||
@ -569,7 +563,7 @@ class TestMonAPIDetectionPlugin(unittest.TestCase):
|
||||
def test_build_java_config_with_hibernate(self):
|
||||
self._run_java_build_config(hibernate_enabled=True)
|
||||
|
||||
@mock.patch('six.moves.configparser.RawConfigParser')
|
||||
@mock.patch('configparser.RawConfigParser')
|
||||
def test_build_python_config(self, rcp):
|
||||
expected_port = 8070
|
||||
|
||||
@ -620,8 +614,6 @@ class TestMonAPIDetectionPlugin(unittest.TestCase):
|
||||
)
|
||||
|
||||
mod = "builtins.open"
|
||||
if six.PY2:
|
||||
mod = "__builtin__.open"
|
||||
|
||||
with mock.patch(
|
||||
mod,
|
||||
|
@ -11,6 +11,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import configparser
|
||||
import logging
|
||||
import os
|
||||
import psutil
|
||||
@ -19,7 +20,6 @@ from unittest import mock
|
||||
from unittest import TestCase
|
||||
|
||||
from oslo_config import cfg
|
||||
from six.moves import configparser
|
||||
|
||||
from monasca_setup.detection import utils
|
||||
from monasca_setup.detection.plugins.ovs import Ovs
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
import unittest
|
||||
|
||||
import six
|
||||
|
||||
import monasca_agent.common.aggregator as aggregator
|
||||
import monasca_agent.common.metrics as metrics_pkg
|
||||
@ -66,7 +65,7 @@ class TestMetricsAggregator(unittest.TestCase):
|
||||
value_meta=value_meta)
|
||||
|
||||
def testValidMetricUnicodeDimensionValue(self):
|
||||
dimensions = {six.unichr(2440): 'B', 'B': 'C', 'D': 'E'}
|
||||
dimensions = {chr(2440): 'B', 'B': 'C', 'D': 'E'}
|
||||
value_meta = {"This is a test": "test, test, test"}
|
||||
self.submit_metric("Foo",
|
||||
5,
|
||||
@ -74,7 +73,7 @@ class TestMetricsAggregator(unittest.TestCase):
|
||||
value_meta=value_meta)
|
||||
|
||||
def testValidMetricUnicodeDimensionKey(self):
|
||||
dimensions = {'A': 'B', 'B': six.unichr(920), 'D': 'E'}
|
||||
dimensions = {'A': 'B', 'B': chr(920), 'D': 'E'}
|
||||
value_meta = {"This is a test": "test, test, test"}
|
||||
self.submit_metric("Foo",
|
||||
5,
|
||||
@ -84,7 +83,7 @@ class TestMetricsAggregator(unittest.TestCase):
|
||||
def testValidMetricUnicodeMetricName(self):
|
||||
dimensions = {'A': 'B', 'B': 'C', 'D': 'E'}
|
||||
value_meta = {"This is a test": "test, test, test"}
|
||||
self.submit_metric(six.unichr(6021),
|
||||
self.submit_metric(chr(6021),
|
||||
5,
|
||||
dimensions=dimensions,
|
||||
value_meta=value_meta)
|
||||
|
@ -14,7 +14,6 @@
|
||||
import os.path
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
@ -129,5 +128,5 @@ class TestConfig(unittest.TestCase):
|
||||
def test_verify_common_config_opts(self):
|
||||
opts = util.get_parsed_args(prog='test')
|
||||
opts_dict = vars(opts[0])
|
||||
six.assertCountEqual(self, ['config_file', 'clean', 'verbose'],
|
||||
self.assertCountEqual(['config_file', 'clean', 'verbose'],
|
||||
opts_dict.keys())
|
||||
|
@ -14,8 +14,6 @@
|
||||
Performance tests for the agent/dogstatsd metrics aggregator.
|
||||
"""
|
||||
|
||||
from six.moves import range
|
||||
|
||||
|
||||
from monasca_agent.common.aggregator import MetricsAggregator
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
import urllib
|
||||
import logging
|
||||
logging.basicConfig()
|
||||
import subprocess
|
||||
@ -18,8 +19,6 @@ import time
|
||||
from nose.plugins.skip import SkipTest
|
||||
from tests.common import load_check
|
||||
|
||||
from six.moves import urllib
|
||||
|
||||
|
||||
PORT = 9200
|
||||
MAX_WAIT = 150
|
||||
|
@ -15,13 +15,13 @@ import subprocess
|
||||
import time
|
||||
import tempfile
|
||||
import os
|
||||
import urllib
|
||||
import logging
|
||||
|
||||
from tests.common import load_check, kill_subprocess
|
||||
from nose.plugins.attrib import attr
|
||||
from nose.plugins.skip import SkipTest
|
||||
|
||||
from six.moves import urllib
|
||||
|
||||
|
||||
logging.basicConfig()
|
||||
|
@ -11,11 +11,11 @@
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
from io import StringIO
|
||||
import unittest
|
||||
|
||||
from collector.checks import LaconicFilter
|
||||
|
||||
from six.moves import cStringIO as StringIO
|
||||
|
||||
|
||||
class TestLaconic(unittest.TestCase):
|
||||
|
@ -15,7 +15,6 @@ import time
|
||||
import unittest
|
||||
|
||||
import nose.tools as nt
|
||||
from six.moves import range
|
||||
|
||||
from monasca_agent.common.aggregator import MetricsAggregator
|
||||
|
||||
|
@ -19,7 +19,6 @@ import binascii
|
||||
import re
|
||||
import shutil
|
||||
from nose.plugins.skip import SkipTest
|
||||
from six.moves import range
|
||||
|
||||
class TestPostfix(unittest.TestCase):
|
||||
#
|
||||
|
@ -10,13 +10,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from functools import reduce
|
||||
import logging
|
||||
import platform
|
||||
import re
|
||||
import unittest
|
||||
|
||||
from six.moves import reduce
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger = logging.getLogger(__file__)
|
||||
|
@ -13,8 +13,6 @@
|
||||
import unittest
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
from six.moves import range
|
||||
|
||||
from monasca_agent.forwarder.transaction import Transaction, TransactionManager
|
||||
from monasca_agent.forwarder.daemon import MAX_QUEUE_SIZE, THROTTLING_DELAY
|
||||
|
||||
|
@ -11,8 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
from six import StringIO
|
||||
from io import StringIO
|
||||
|
||||
from tests.common import get_check
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user