def instance(cls, broker_id, zk_host, zk_port, zk_chroot=None, host=None, port=None, transport='PLAINTEXT', replicas=1, partitions=2): if zk_chroot is None: zk_chroot = "kafka-python_" + str(uuid.uuid4()).replace("-", "_") if "KAFKA_URI" in os.environ: parse = urlparse(os.environ["KAFKA_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: # force IPv6 here because of a confusing point: # # - if the string "localhost" is passed, Kafka will *only* bind to the IPv4 address of localhost # (127.0.0.1); however, kafka-python will attempt to connect on ::1 and fail # # - if the address literal 127.0.0.1 is passed, the metadata request during bootstrap will return # the name "localhost" and we'll go back to the first case. This is odd! # # Ideally, Kafka would bind to all loopback addresses when we tell it to listen on "localhost" the # way it makes an IPv6 socket bound to both 0.0.0.0/0 and ::/0 when we tell it to bind to "" (that is # to say, when we make a listener of PLAINTEXT://:port. # # Note that even though we specify the bind host in bracket notation, Kafka responds to the bootstrap # metadata request without square brackets later. if host is None: host = "[::1]" fixture = KafkaFixture(host, port, broker_id, zk_host, zk_port, zk_chroot, transport=transport, replicas=replicas, partitions=partitions) fixture.open() return fixture
def instance(cls, broker_id, zk_host, zk_port, zk_chroot=None, host=None, port=None, transport='PLAINTEXT', replicas=1, partitions=2): if zk_chroot is None: zk_chroot = "kafka-python_" + str(uuid.uuid4()).replace("-", "_") if "KAFKA_URI" in os.environ: parse = urlparse(os.environ["KAFKA_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: if port is None: port = get_open_port() # force IPv6 here because of a confusing point: # # - if the string "localhost" is passed, Kafka will *only* bind to the IPv4 address of localhost # (127.0.0.1); however, kafka-python will attempt to connect on ::1 and fail # # - if the address literal 127.0.0.1 is passed, the metadata request during bootstrap will return # the name "localhost" and we'll go back to the first case. This is odd! # # Ideally, Kafka would bind to all loopback addresses when we tell it to listen on "localhost" the # way it makes an IPv6 socket bound to both 0.0.0.0/0 and ::/0 when we tell it to bind to "" (that is # to say, when we make a listener of PLAINTEXT://:port. # # Note that even though we specify the bind host in bracket notation, Kafka responds to the bootstrap # metadata request without square brackets later. if host is None: host = "[::1]" fixture = KafkaFixture(host, port, broker_id, zk_host, zk_port, zk_chroot, transport=transport, replicas=replicas, partitions=partitions) fixture.open() return fixture
def instance(cls, broker_id, zk_host, zk_port, zk_chroot=None, port=None, replicas=1, partitions=2): if zk_chroot is None: zk_chroot = "kafka-python_" + str(uuid.uuid4()).replace("-", "_") if "KAFKA_URI" in os.environ: parse = urlparse(os.environ["KAFKA_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: if port is None: port = get_open_port() host = "127.0.0.1" fixture = KafkaFixture(host, port, broker_id, zk_host, zk_port, zk_chroot, replicas=replicas, partitions=partitions) fixture.open() return fixture
def instance(cls, broker_id, zk_host, zk_port, zk_chroot=None, host=None, port=None, transport='PLAINTEXT', replicas=1, partitions=2): if zk_chroot is None: zk_chroot = "kafka-python_" + str(uuid.uuid4()).replace("-", "_") if "KAFKA_URI" in os.environ: parse = urlparse(os.environ["KAFKA_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: if host is None: host = "localhost" fixture = KafkaFixture(host, port, broker_id, zk_host, zk_port, zk_chroot, transport=transport, replicas=replicas, partitions=partitions) fixture.open() return fixture
def instance(cls): if "ZOOKEEPER_URI" in os.environ: parse = urlparse(os.environ["ZOOKEEPER_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: (host, port) = ("127.0.0.1", get_open_port()) fixture = cls(host, port) fixture.open() return fixture
def instance(cls): if "ZOOKEEPER_URI" in os.environ: parse = urlparse(os.environ["ZOOKEEPER_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: (host, port) = ("127.0.0.1", None) fixture = cls(host, port) fixture.open() return fixture
def instance(cls, broker_id, zk_host, zk_port, zk_chroot=None, replicas=1, partitions=2): if zk_chroot is None: zk_chroot = "kafka-python_" + str(uuid.uuid4()).replace("-", "_") if "KAFKA_URI" in os.environ: parse = urlparse(os.environ["KAFKA_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: (host, port) = ("127.0.0.1", get_open_port()) fixture = KafkaFixture(host, port, broker_id, zk_host, zk_port, zk_chroot, replicas, partitions) fixture.open() return fixture
def instance(cls, broker_id, zookeeper, zk_chroot=None, host=None, port=None, transport='PLAINTEXT', replicas=1, partitions=2, sasl_mechanism=None, auto_create_topic=True, tmp_dir=None): if zk_chroot is None: zk_chroot = "kafka-python_" + str(uuid.uuid4()).replace("-", "_") if "KAFKA_URI" in os.environ: parse = urlparse(os.environ["KAFKA_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: if host is None: host = "localhost" fixture = KafkaFixture(host, port, broker_id, zookeeper, zk_chroot, transport=transport, replicas=replicas, partitions=partitions, sasl_mechanism=sasl_mechanism, auto_create_topic=auto_create_topic, tmp_dir=tmp_dir) fixture.open() return fixture
def instance(cls, broker_id, zookeeper, zk_chroot=None, host=None, port=None, transport='PLAINTEXT', replicas=1, partitions=2, sasl_mechanism='PLAIN', auto_create_topic=True, tmp_dir=None): if zk_chroot is None: zk_chroot = "kafka-python_" + str(uuid.uuid4()).replace("-", "_") if "KAFKA_URI" in os.environ: parse = urlparse(os.environ["KAFKA_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: if host is None: host = "localhost" fixture = KafkaFixture(host, port, broker_id, zookeeper, zk_chroot, transport=transport, replicas=replicas, partitions=partitions, sasl_mechanism=sasl_mechanism, auto_create_topic=auto_create_topic, tmp_dir=tmp_dir) fixture.open() return fixture