13
13
# See the License for the specific language governing permissions and
14
14
# limitations under the License.
15
15
16
- import confluent_kafka
17
16
import struct
18
17
import time
19
- from confluent_kafka import ConsumerGroupTopicPartitions , TopicPartition , ConsumerGroupState
18
+
19
+ from confluent_kafka import ConsumerGroupTopicPartitions , TopicPartition , ConsumerGroupState , KafkaError
20
20
from confluent_kafka .admin import (NewPartitions , ConfigResource ,
21
21
AclBinding , AclBindingFilter , ResourceType ,
22
22
ResourcePatternType , AclOperation , AclPermissionType )
@@ -58,6 +58,8 @@ def verify_admin_acls(admin_client,
58
58
for acl_binding , f in fs .items ():
59
59
f .result () # trigger exception if there was an error
60
60
61
+ time .sleep (1 )
62
+
61
63
acl_binding_filter1 = AclBindingFilter (ResourceType .ANY , None , ResourcePatternType .ANY ,
62
64
None , None , AclOperation .ANY , AclPermissionType .ANY )
63
65
acl_binding_filter2 = AclBindingFilter (ResourceType .ANY , None , ResourcePatternType .PREFIXED ,
@@ -83,6 +85,8 @@ def verify_admin_acls(admin_client,
83
85
"Deleted ACL bindings don't match, actual {} expected {}" .format (deleted_acl_bindings ,
84
86
expected_acl_bindings )
85
87
88
+ time .sleep (1 )
89
+
86
90
#
87
91
# Delete the ACLs with TOPIC and GROUP
88
92
#
@@ -94,6 +98,9 @@ def verify_admin_acls(admin_client,
94
98
assert deleted_acl_bindings == expected , \
95
99
"Deleted ACL bindings don't match, actual {} expected {}" .format (deleted_acl_bindings ,
96
100
expected )
101
+
102
+ time .sleep (1 )
103
+
97
104
#
98
105
# All the ACLs should have been deleted
99
106
#
@@ -201,14 +208,14 @@ def test_basic_operations(kafka_cluster):
201
208
# Second iteration: create topic.
202
209
#
203
210
for validate in (True , False ):
204
- our_topic = kafka_cluster .create_topic (topic_prefix ,
205
- {
206
- "num_partitions" : num_partitions ,
207
- "config" : topic_config ,
208
- "replication_factor" : 1 ,
209
- },
210
- validate_only = validate
211
- )
211
+ our_topic = kafka_cluster .create_topic_and_wait_propogation (topic_prefix ,
212
+ {
213
+ "num_partitions" : num_partitions ,
214
+ "config" : topic_config ,
215
+ "replication_factor" : 1 ,
216
+ },
217
+ validate_only = validate
218
+ )
212
219
213
220
admin_client = kafka_cluster .admin ()
214
221
@@ -270,7 +277,7 @@ def consume_messages(group_id, num_messages=None):
270
277
print ('Read all the required messages: exiting' )
271
278
break
272
279
except ConsumeError as e :
273
- if msg is not None and e .code == confluent_kafka . KafkaError ._PARTITION_EOF :
280
+ if msg is not None and e .code == KafkaError ._PARTITION_EOF :
274
281
print ('Reached end of %s [%d] at offset %d' % (
275
282
msg .topic (), msg .partition (), msg .offset ()))
276
283
eof_reached [(msg .topic (), msg .partition ())] = True
@@ -345,6 +352,8 @@ def verify_config(expconfig, configs):
345
352
fs = admin_client .alter_configs ([resource ])
346
353
fs [resource ].result () # will raise exception on failure
347
354
355
+ time .sleep (1 )
356
+
348
357
#
349
358
# Read the config back again and verify.
350
359
#
0 commit comments