|
12 | 12 | IsolationLevel, TopicCollection |
13 | 13 | import concurrent.futures |
14 | 14 |
|
15 | | -# GC module is used to prevent intermittent segfaults in specific Admin tests. |
16 | | -# Tests that make "fire-and-forget" Admin API calls (without waiting for results) |
17 | | -# can leave callbacks queued in librdkafka's background thread. When Python's GC |
18 | | -# runs during subsequent test cleanup, it may try to destroy AdminClient objects while callbacks |
19 | | -# from previous tests are still running in librdkafka's thread. Librdkafka |
20 | | -# forbids calling rd_kafka_destroy() from its own threads and will send an ABORT to crash the tests. |
| 15 | +# GC module is used to prevent intermittent segfaults in specific Admin tests: |
| 16 | +# - Tests that make "fire-and-forget" Admin API calls (without waiting for results) |
| 17 | +# can leave callbacks queued in librdkafka's background thread. |
| 18 | +# - When these callbacks allocate Python objects, they may trigger gargabe collection |
| 19 | +# - When GC tries to destroy an AdminClient object while running in librdkafka's thread, |
| 20 | +# librdkafka (which forbids this) will send an ABORT signal to crash the tests. |
21 | 21 | import gc |
22 | 22 |
|
23 | 23 |
|
@@ -798,7 +798,9 @@ def test_list_consumer_group_offsets_api(): |
798 | 798 | "test-group1", [TopicPartition("test-topic", 1, 1)])]) |
799 | 799 |
|
800 | 800 | a.list_consumer_group_offsets([ConsumerGroupTopicPartitions("test-group1")]) |
801 | | - a.list_consumer_group_offsets([ConsumerGroupTopicPartitions("test-group2", [TopicPartition("test-topic1", 1)])]) |
| 801 | + a.list_consumer_group_offsets([ |
| 802 | + ConsumerGroupTopicPartitions("test-group2", [TopicPartition("test-topic1", 1)]) |
| 803 | + ]) |
802 | 804 | finally: |
803 | 805 | gc.enable() |
804 | 806 |
|
@@ -893,7 +895,9 @@ def test_alter_consumer_group_offsets_api(): |
893 | 895 | a.alter_consumer_group_offsets([ConsumerGroupTopicPartitions("test-group1", [TopicPartition("")])]) |
894 | 896 |
|
895 | 897 | with pytest.raises(ValueError): |
896 | | - a.alter_consumer_group_offsets([ConsumerGroupTopicPartitions("test-group1", [TopicPartition("test-topic")])]) |
| 898 | + a.alter_consumer_group_offsets([ |
| 899 | + ConsumerGroupTopicPartitions("test-group1", [TopicPartition("test-topic")]) |
| 900 | + ]) |
897 | 901 |
|
898 | 902 | with pytest.raises(ValueError): |
899 | 903 | a.alter_consumer_group_offsets([ConsumerGroupTopicPartitions( |
@@ -1018,14 +1022,18 @@ def test_alter_user_scram_credentials_api(): |
1018 | 1022 |
|
1019 | 1023 | # Upsertion salt user test |
1020 | 1024 | with pytest.raises(ValueError): |
1021 | | - a.alter_user_scram_credentials([UserScramCredentialUpsertion("sam", scram_credential_info, b"password", b"")]) |
| 1025 | + a.alter_user_scram_credentials([ |
| 1026 | + UserScramCredentialUpsertion("sam", scram_credential_info, b"password", b"") |
| 1027 | + ]) |
1022 | 1028 | with pytest.raises(TypeError): |
1023 | 1029 | a.alter_user_scram_credentials([UserScramCredentialUpsertion("sam", |
1024 | 1030 | scram_credential_info, |
1025 | 1031 | b"password", |
1026 | 1032 | "salt")]) |
1027 | 1033 | with pytest.raises(TypeError): |
1028 | | - a.alter_user_scram_credentials([UserScramCredentialUpsertion("sam", scram_credential_info, b"password", 123)]) |
| 1034 | + a.alter_user_scram_credentials([ |
| 1035 | + UserScramCredentialUpsertion("sam", scram_credential_info, b"password", 123) |
| 1036 | + ]) |
1029 | 1037 |
|
1030 | 1038 | # Upsertion scram_credential_info tests |
1031 | 1039 | sci_incorrect_mechanism_type = ScramCredentialInfo("string type", 10000) |
@@ -1053,7 +1061,9 @@ def test_alter_user_scram_credentials_api(): |
1053 | 1061 | b"password", |
1054 | 1062 | b"salt")]) |
1055 | 1063 | with pytest.raises(ValueError): |
1056 | | - a.alter_user_scram_credentials([UserScramCredentialUpsertion("sam", sci_zero_iteration, b"password", b"salt")]) |
| 1064 | + a.alter_user_scram_credentials([ |
| 1065 | + UserScramCredentialUpsertion("sam", sci_zero_iteration, b"password", b"salt") |
| 1066 | + ]) |
1057 | 1067 |
|
1058 | 1068 | # Deletion user tests |
1059 | 1069 | with pytest.raises(TypeError): |
|
0 commit comments