Skip to content

Commit eb04683

Browse files
committed
Fix failed AsyncioTest.test_send_failure and clean up tests
1 parent c3c12c4 commit eb04683

File tree

5 files changed

+57
-33
lines changed

5 files changed

+57
-33
lines changed

tests/asyncio_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
class AsyncioTest(IsolatedAsyncioTestCase):
3535

3636
async def asyncSetUp(self) -> None:
37-
self._client = Client(service_url)
37+
self._client = Client(service_url,
38+
operation_timeout_seconds=5)
3839

3940
async def asyncTearDown(self) -> None:
4041
await self._client.close()
@@ -62,7 +63,7 @@ async def test_create_producer_failure(self):
6263
await self._client.create_producer('tenant/ns/awaitio-test-send-failure')
6364
self.fail()
6465
except PulsarException as e:
65-
self.assertEqual(e.error(), pulsar.Result.AuthorizationError)
66+
self.assertEqual(e.error(), pulsar.Result.Timeout)
6667

6768
async def test_send_failure(self):
6869
producer = await self._client.create_producer('awaitio-test-send-failure')

tests/debug_logger_test.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
from unittest import TestCase, main
22+
import pulsar
23+
24+
class DebugLoggerTest(TestCase):
25+
26+
def test_configure_log_level(self):
27+
client = pulsar.Client(
28+
service_url="pulsar://localhost:6650",
29+
logger=pulsar.ConsoleLogger(pulsar.LoggerLevel.Debug)
30+
)
31+
32+
producer = client.create_producer(
33+
topic='test_log_level'
34+
)
35+
36+
producer.send(b'hello')
37+
38+
def test_configure_log_to_file(self):
39+
client = pulsar.Client(
40+
service_url="pulsar://localhost:6650",
41+
logger=pulsar.FileLogger(pulsar.LoggerLevel.Debug, 'test.log')
42+
)
43+
44+
producer = client.create_producer(
45+
topic='test_log_to_file'
46+
)
47+
48+
producer.send(b'hello')
49+
50+
if __name__ == "__main__":
51+
main()

tests/pulsar_test.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151

5252
from _pulsar import ProducerConfiguration, ConsumerConfiguration, RegexSubscriptionMode
5353

54-
from schema_test import *
55-
from reader_test import *
56-
5754
from urllib.request import urlopen, Request
5855

5956
TM = 10000 # Do not wait forever in tests
@@ -1427,29 +1424,6 @@ def test_json_schema_encode(self):
14271424
second_encode = schema.encode(record)
14281425
self.assertEqual(first_encode, second_encode)
14291426

1430-
def test_configure_log_level(self):
1431-
client = pulsar.Client(
1432-
service_url="pulsar://localhost:6650",
1433-
logger=pulsar.ConsoleLogger(pulsar.LoggerLevel.Debug)
1434-
)
1435-
1436-
producer = client.create_producer(
1437-
topic='test_log_level'
1438-
)
1439-
1440-
producer.send(b'hello')
1441-
1442-
def test_configure_log_to_file(self):
1443-
client = pulsar.Client(
1444-
service_url="pulsar://localhost:6650",
1445-
logger=pulsar.FileLogger(pulsar.LoggerLevel.Debug, 'test.log')
1446-
)
1447-
1448-
producer = client.create_producer(
1449-
topic='test_log_to_file'
1450-
)
1451-
1452-
producer.send(b'hello')
14531427

14541428
def test_logger_thread_leaks(self):
14551429
def _do_connect(close):

tests/run-unit-tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
2424
cd $ROOT_DIR/tests
2525

2626
python3 custom_logger_test.py
27+
python3 debug_logger_test.py
2728
python3 interrupted_test.py
2829
python3 pulsar_test.py
30+
python3 schema_test.py
31+
python3 reader_test.py
2932
python3 asyncio_test.py

tests/schema_test.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#
2020

2121
import math
22-
import logging
2322
import requests
2423
from typing import List
2524
from unittest import TestCase, main
@@ -31,10 +30,6 @@
3130
import json
3231
from fastavro.schema import load_schema
3332

34-
logging.basicConfig(level=logging.INFO,
35-
format='%(asctime)s %(levelname)-5s %(message)s')
36-
37-
3833
class ExampleRecord(Record):
3934
str_field = String()
4035
int_field = Integer()

0 commit comments

Comments
 (0)