@@ -71,6 +71,8 @@ class Fixture(object):
71
71
72
72
def __init__ (self ):
73
73
self .child = None
74
+ if not os .path .isdir (self .kafka_root ):
75
+ raise FileNotFoundError (self .kafka_root )
74
76
75
77
@classmethod
76
78
def download_official_distribution (cls ,
@@ -697,10 +699,7 @@ def get_producers(self, cnt, **params):
697
699
698
700
699
701
def get_api_versions ():
700
- import logging
701
702
logging .basicConfig (level = logging .ERROR )
702
-
703
- from test .fixtures import ZookeeperFixture , KafkaFixture
704
703
zk = ZookeeperFixture .instance ()
705
704
k = KafkaFixture .instance (0 , zk )
706
705
@@ -717,6 +716,21 @@ def get_api_versions():
717
716
zk .close ()
718
717
719
718
719
+ def run_brokers ():
720
+ logging .basicConfig (level = logging .ERROR )
721
+ zk = ZookeeperFixture .instance ()
722
+ k = KafkaFixture .instance (0 , zk )
723
+
724
+ print ("Kafka" , k .kafka_version , "running on port:" , k .port )
725
+ try :
726
+ while True :
727
+ time .sleep (5 )
728
+ except KeyboardInterrupt :
729
+ print ("Bye!" )
730
+ k .close ()
731
+ zk .close ()
732
+
733
+
720
734
if __name__ == '__main__' :
721
735
import sys
722
736
if len (sys .argv ) < 2 :
@@ -725,6 +739,8 @@ def get_api_versions():
725
739
cmd = sys .argv [1 ]
726
740
if cmd == 'get_api_versions' :
727
741
get_api_versions ()
742
+ elif cmd == 'kafka' :
743
+ run_brokers ()
728
744
else :
729
745
print ("Unknown cmd: %s" , cmd )
730
746
exit (1 )
0 commit comments