@@ -414,21 +414,26 @@ def _create_zk_chroot(self):
414
414
raise RuntimeError ("Failed to create Zookeeper chroot node" )
415
415
self .out ("Kafka chroot created in Zookeeper!" )
416
416
417
+ def render_jaas (self ):
418
+ self .jaas_config = self ._jaas_config ()
419
+ jaas_conf = self .tmp_dir .join ("kafka_server_jaas.conf" )
420
+ jaas_conf_template = self .test_resource ("kafka_server_jaas.conf" )
421
+ self .render_template (jaas_conf_template , jaas_conf , vars (self ))
422
+ return jaas_conf .strpath
423
+
417
424
def start (self ):
418
425
# Configure Kafka child process
419
426
properties = self .tmp_dir .join ("kafka.properties" )
420
- jaas_conf = self .tmp_dir .join ("kafka_server_jaas.conf" )
421
427
properties_template = self .test_resource ("kafka.properties" )
422
- jaas_conf_template = self .test_resource ("kafka_server_jaas.conf" )
423
428
424
429
# Consider replacing w/ run_script('kafka-server-start.sh', ...)
425
430
args = self .kafka_run_class_args ("kafka.Kafka" , properties .strpath )
426
431
env = self .kafka_run_class_env ()
427
432
if self .sasl_enabled :
433
+ jaas_conf = self .render_jaas ()
428
434
opts = env .get ('KAFKA_OPTS' , '' ).strip ()
429
- opts += ' -Djava.security.auth.login.config={}' .format (jaas_conf . strpath )
435
+ opts += ' -Djava.security.auth.login.config={}' .format (jaas_conf )
430
436
env ['KAFKA_OPTS' ] = opts
431
- self .render_template (jaas_conf_template , jaas_conf , vars (self ))
432
437
433
438
timeout = 5
434
439
max_timeout = 120
@@ -631,6 +636,11 @@ def get_topic_names(self):
631
636
cmd = self .run_script ('kafka-topics.sh' , * args )
632
637
env = self .kafka_run_class_env ()
633
638
env .pop ('KAFKA_LOG4J_OPTS' )
639
+ if self .sasl_enabled :
640
+ jaas_conf = self .render_jaas ()
641
+ opts = env .get ('KAFKA_OPTS' , '' ).strip ()
642
+ opts += ' -Djava.security.auth.login.config={}' .format (jaas_conf )
643
+ env ['KAFKA_OPTS' ] = opts
634
644
proc = subprocess .Popen (cmd , env = env , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
635
645
stdout , stderr = proc .communicate ()
636
646
if proc .returncode != 0 :
0 commit comments