本文整理汇总了Python中test.fixtures.ZookeeperFixture.instance方法的典型用法代码示例。如果您正苦于以下问题:Python ZookeeperFixture.instance方法的具体用法?Python ZookeeperFixture.instance怎么用?Python ZookeeperFixture.instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.fixtures.ZookeeperFixture
的用法示例。
在下文中一共展示了ZookeeperFixture.instance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: zookeeper
# 需要导入模块: from test.fixtures import ZookeeperFixture [as 别名]
# 或者: from test.fixtures.ZookeeperFixture import instance [as 别名]
def zookeeper(version, request):
assert version
zk = ZookeeperFixture.instance()
def fin():
zk.close()
request.addfinalizer(fin)
return zk
示例2: setUpClass
# 需要导入模块: from test.fixtures import ZookeeperFixture [as 别名]
# 或者: from test.fixtures.ZookeeperFixture import instance [as 别名]
def setUpClass(cls):
if not os.environ.get('KAFKA_VERSION'):
return
cls.zk = ZookeeperFixture.instance()
cls.server1 = KafkaFixture.instance(0, cls.zk.host, cls.zk.port)
cls.server2 = KafkaFixture.instance(1, cls.zk.host, cls.zk.port)
cls.server = cls.server1 # Bootstrapping server
示例3: setUpClass
# 需要导入模块: from test.fixtures import ZookeeperFixture [as 别名]
# 或者: from test.fixtures.ZookeeperFixture import instance [as 别名]
def setUpClass(cls):
if not os.environ.get('KAFKA_VERSION'):
return
cls.zk = ZookeeperFixture.instance()
chroot = random_string(10)
cls.server1 = KafkaFixture.instance(0, cls.zk,
zk_chroot=chroot)
cls.server2 = KafkaFixture.instance(1, cls.zk,
zk_chroot=chroot)
cls.server = cls.server1 # Bootstrapping server
示例4: setUpClass
# 需要导入模块: from test.fixtures import ZookeeperFixture [as 别名]
# 或者: from test.fixtures.ZookeeperFixture import instance [as 别名]
def setUpClass(cls): # noqa
if not os.environ.get('KAFKA_VERSION'):
return
zk_chroot = random_string(10)
replicas = 2
partitions = 2
# mini zookeeper, 2 kafka brokers
cls.zk = ZookeeperFixture.instance()
kk_args = [cls.zk.host, cls.zk.port, zk_chroot, replicas, partitions]
cls.brokers = [KafkaFixture.instance(i, *kk_args) for i in range(replicas)]
hosts = ['%s:%d' % (b.host, b.port) for b in cls.brokers]
cls.client = KafkaClient(hosts)
示例5: setUp
# 需要导入模块: from test.fixtures import ZookeeperFixture [as 别名]
# 或者: from test.fixtures.ZookeeperFixture import instance [as 别名]
def setUp(self):
if not os.environ.get('KAFKA_VERSION'):
self.skipTest('integration test requires KAFKA_VERSION')
zk_chroot = random_string(10)
replicas = 3
partitions = 3
# mini zookeeper, 3 kafka brokers
self.zk = ZookeeperFixture.instance()
kk_args = [self.zk.host, self.zk.port, zk_chroot, replicas, partitions]
self.brokers = [KafkaFixture.instance(i, *kk_args) for i in range(replicas)]
hosts = ['%s:%d' % (b.host, b.port) for b in self.brokers]
self.client = SimpleClient(hosts, timeout=2)
super(TestFailover, self).setUp()
示例6: setUp
# 需要导入模块: from test.fixtures import ZookeeperFixture [as 别名]
# 或者: from test.fixtures.ZookeeperFixture import instance [as 别名]
def setUp(self):
if not os.environ.get('KAFKA_VERSION'):
return
zk_chroot = random_string(10)
replicas = 2
partitions = 2
# mini zookeeper, 2 kafka brokers
self.zk = ZookeeperFixture.instance()
kk_args = [self.zk.host, self.zk.port, zk_chroot, replicas, partitions]
self.brokers = [KafkaFixture.instance(i, *kk_args) for i in range(replicas)]
hosts = ['%s:%d' % (b.host, b.port) for b in self.brokers]
self.client = KafkaClient(hosts)
super(TestFailover, self).setUp()
示例7: start_brokers
# 需要导入模块: from test.fixtures import ZookeeperFixture [as 别名]
# 或者: from test.fixtures.ZookeeperFixture import instance [as 别名]
def start_brokers(n):
print('Starting {0} {1}-node cluster...'.format(KafkaFixture.kafka_version, n))
print('-> 1 Zookeeper')
zk = ZookeeperFixture.instance()
print('---> {0}:{1}'.format(zk.host, zk.port))
print()
partitions = min(n, 3)
replicas = min(n, 3)
print('-> {0} Brokers [{1} partitions / {2} replicas]'.format(n, partitions, replicas))
brokers = [
KafkaFixture.instance(i, zk.host, zk.port, zk_chroot='',
partitions=partitions, replicas=replicas)
for i in range(n)
]
for broker in brokers:
print('---> {0}:{1}'.format(broker.host, broker.port))
print()
return brokers
示例8: setUpClass
# 需要导入模块: from test.fixtures import ZookeeperFixture [as 别名]
# 或者: from test.fixtures.ZookeeperFixture import instance [as 别名]
def setUpClass(cls): # noqa
if not os.environ.get('KAFKA_VERSION'):
return
cls.zk = ZookeeperFixture.instance()
cls.server = KafkaFixture.instance(0, cls.zk.host, cls.zk.port)
示例9: zookeeper
# 需要导入模块: from test.fixtures import ZookeeperFixture [as 别名]
# 或者: from test.fixtures.ZookeeperFixture import instance [as 别名]
def zookeeper():
"""Return a Zookeeper fixture"""
zk_instance = ZookeeperFixture.instance()
yield zk_instance
zk_instance.close()