HOTFIX: Avoid mutable default arguments in system test services

Author: Jason Gustafson <jason@confluent.io>

Reviewers: Apurva Mehta <apurva.1618@gmail.com>, Ewen Cheslack-Postava <ewen@confluent.io>

Closes #1947 from hachikuji/hotfix-producer-perf-service
This commit is contained in:
Jason Gustafson 2016-10-01 17:21:19 -07:00
parent 8124f6e099
commit 33c7b88ffe
4 changed files with 11 additions and 11 deletions

View File

@ -89,7 +89,7 @@ class ConsoleConsumer(KafkaPathResolverMixin, JmxMixin, BackgroundThreadService)
def __init__(self, context, num_nodes, kafka, topic, group_id="test-consumer-group", new_consumer=False,
message_validator=None, from_beginning=True, consumer_timeout_ms=None, version=TRUNK,
client_id="console-consumer", print_key=False, jmx_object_names=None, jmx_attributes=[],
client_id="console-consumer", print_key=False, jmx_object_names=None, jmx_attributes=None,
enable_systest_events=False, stop_timeout_sec=15):
"""
Args:
@ -110,7 +110,7 @@ class ConsoleConsumer(KafkaPathResolverMixin, JmxMixin, BackgroundThreadService)
stop_timeout_sec After stopping a node, wait up to stop_timeout_sec for the node to stop,
and the corresponding background thread to finish successfully.
"""
JmxMixin.__init__(self, num_nodes, jmx_object_names, jmx_attributes)
JmxMixin.__init__(self, num_nodes, jmx_object_names, jmx_attributes or [])
BackgroundThreadService.__init__(self, context, num_nodes)
self.kafka = kafka
self.new_consumer = new_consumer

View File

@ -68,14 +68,14 @@ class KafkaService(KafkaPathResolverMixin, JmxMixin, Service):
def __init__(self, context, num_nodes, zk, security_protocol=SecurityConfig.PLAINTEXT, interbroker_security_protocol=SecurityConfig.PLAINTEXT,
client_sasl_mechanism=SecurityConfig.SASL_MECHANISM_GSSAPI, interbroker_sasl_mechanism=SecurityConfig.SASL_MECHANISM_GSSAPI,
authorizer_class_name=None, topics=None, version=TRUNK, jmx_object_names=None,
jmx_attributes=[], zk_connect_timeout=5000, zk_session_timeout=6000):
jmx_attributes=None, zk_connect_timeout=5000, zk_session_timeout=6000):
"""
:type context
:type zk: ZookeeperService
:type topics: dict
"""
Service.__init__(self, context, num_nodes)
JmxMixin.__init__(self, num_nodes, jmx_object_names, jmx_attributes)
JmxMixin.__init__(self, num_nodes, jmx_object_names, jmx_attributes or [])
self.zk = zk

View File

@ -21,9 +21,9 @@ class JmxMixin(object):
- this is not a service in its own right.
- we assume the service using JmxMixin also uses KafkaPathResolverMixin
"""
def __init__(self, num_nodes, jmx_object_names=None, jmx_attributes=[]):
def __init__(self, num_nodes, jmx_object_names=None, jmx_attributes=None):
self.jmx_object_names = jmx_object_names
self.jmx_attributes = jmx_attributes
self.jmx_attributes = jmx_attributes or []
self.jmx_port = 9192
self.started = [False] * num_nodes
@ -88,4 +88,4 @@ class JmxMixin(object):
def read_jmx_output_all_nodes(self):
for node in self.nodes:
self.read_jmx_output(self.idx(node), node)
self.read_jmx_output(self.idx(node), node)

View File

@ -34,10 +34,10 @@ class ProducerPerformanceService(JmxMixin, PerformanceService):
LOG_FILE = os.path.join(LOG_DIR, "producer_performance.log")
LOG4J_CONFIG = os.path.join(PERSISTENT_ROOT, "tools-log4j.properties")
def __init__(self, context, num_nodes, kafka, topic, num_records, record_size, throughput, version=TRUNK, settings={},
intermediate_stats=False, client_id="producer-performance", jmx_object_names=None, jmx_attributes=[]):
def __init__(self, context, num_nodes, kafka, topic, num_records, record_size, throughput, version=TRUNK, settings=None,
intermediate_stats=False, client_id="producer-performance", jmx_object_names=None, jmx_attributes=None):
JmxMixin.__init__(self, num_nodes, jmx_object_names, jmx_attributes)
JmxMixin.__init__(self, num_nodes, jmx_object_names, jmx_attributes or [])
PerformanceService.__init__(self, context, num_nodes)
self.logs = {
@ -71,7 +71,7 @@ class ProducerPerformanceService(JmxMixin, PerformanceService):
'record_size': record_size,
'throughput': throughput
}
self.settings = settings
self.settings = settings or {}
self.intermediate_stats = intermediate_stats
self.client_id = client_id