Skip to content

Commit

Permalink
Merge remote-tracking branch 'apache/main' into bewaremypower/enable-…
Browse files Browse the repository at this point in the history
…batch-default
  • Loading branch information
merlimat committed Nov 2, 2024
2 parents 63a9907 + 43792ea commit 065b05f
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 38 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ set(CMAKE_PREFIX_PATH ${PROJECT_SOURCE_DIR}/pybind11/include ${CMAKE_PREFIX_PATH
option(LINK_STATIC "Link against static libraries" OFF)
MESSAGE(STATUS "LINK_STATIC: " ${LINK_STATIC})

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
MESSAGE(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion pkg/manylinux2014/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ENV PATH="/opt/python/${PYTHON_SPEC}/bin:${PATH}"
ENV PYTHON_INCLUDE_DIR /opt/python/${PYTHON_SPEC}/include
ENV PYTHON_LIBRARIES /opt/python/${PYTHON_SPEC}/lib/python${PYTHON_VERSION}

RUN pip3 install pyyaml
RUN pip3 install pyyaml setuptools

ADD .build/dependencies.yaml /
ADD .build/dep-version.py /usr/local/bin
Expand Down
2 changes: 1 addition & 1 deletion pkg/manylinux_musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ENV PATH="/opt/python/${PYTHON_SPEC}/bin:${PATH}"
ENV PYTHON_INCLUDE_DIR /opt/python/${PYTHON_SPEC}/include
ENV PYTHON_LIBRARIES /opt/python/${PYTHON_SPEC}/lib/python${PYTHON_VERSION}

RUN pip install pyyaml
RUN pip install pyyaml setuptools

RUN apk add cmake

Expand Down
2 changes: 1 addition & 1 deletion pulsar/functions/serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"""
SerDe defines the interface for serialization/deserialization.
Everytime a message is read from pulsar topic, the serde is invoked to
Every time a message is read from pulsar topic, the serde is invoked to
serialize the bytes into an object before invoking the process method.
Anytime a python object needs to be written back to pulsar, it is
serialized into bytes before writing.
Expand Down
5 changes: 3 additions & 2 deletions tests/asyncio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
class AsyncioTest(IsolatedAsyncioTestCase):

async def asyncSetUp(self) -> None:
self._client = Client(service_url)
self._client = Client(service_url,
operation_timeout_seconds=5)

async def asyncTearDown(self) -> None:
await self._client.close()
Expand Down Expand Up @@ -62,7 +63,7 @@ async def test_create_producer_failure(self):
await self._client.create_producer('tenant/ns/awaitio-test-send-failure')
self.fail()
except PulsarException as e:
self.assertEqual(e.error(), pulsar.Result.AuthorizationError)
self.assertEqual(e.error(), pulsar.Result.Timeout)

async def test_send_failure(self):
producer = await self._client.create_producer('awaitio-test-send-failure')
Expand Down
51 changes: 51 additions & 0 deletions tests/debug_logger_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

from unittest import TestCase, main
import pulsar

class DebugLoggerTest(TestCase):

def test_configure_log_level(self):
client = pulsar.Client(
service_url="pulsar://localhost:6650",
logger=pulsar.ConsoleLogger(pulsar.LoggerLevel.Debug)
)

producer = client.create_producer(
topic='test_log_level'
)

producer.send(b'hello')

def test_configure_log_to_file(self):
client = pulsar.Client(
service_url="pulsar://localhost:6650",
logger=pulsar.FileLogger(pulsar.LoggerLevel.Debug, 'test.log')
)

producer = client.create_producer(
topic='test_log_to_file'
)

producer.send(b'hello')

if __name__ == "__main__":
main()
26 changes: 0 additions & 26 deletions tests/pulsar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@

from _pulsar import ProducerConfiguration, ConsumerConfiguration, RegexSubscriptionMode

from schema_test import *
from reader_test import *

from urllib.request import urlopen, Request

TM = 10000 # Do not wait forever in tests
Expand Down Expand Up @@ -1430,29 +1427,6 @@ def test_json_schema_encode(self):
second_encode = schema.encode(record)
self.assertEqual(first_encode, second_encode)

def test_configure_log_level(self):
client = pulsar.Client(
service_url="pulsar://localhost:6650",
logger=pulsar.ConsoleLogger(pulsar.LoggerLevel.Debug)
)

producer = client.create_producer(
topic='test_log_level'
)

producer.send(b'hello')

def test_configure_log_to_file(self):
client = pulsar.Client(
service_url="pulsar://localhost:6650",
logger=pulsar.FileLogger(pulsar.LoggerLevel.Debug, 'test.log')
)

producer = client.create_producer(
topic='test_log_to_file'
)

producer.send(b'hello')

def test_logger_thread_leaks(self):
def _do_connect(close):
Expand Down
3 changes: 3 additions & 0 deletions tests/run-unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
cd $ROOT_DIR/tests

python3 custom_logger_test.py
python3 debug_logger_test.py
python3 interrupted_test.py
python3 pulsar_test.py
python3 schema_test.py
python3 reader_test.py
python3 asyncio_test.py
5 changes: 0 additions & 5 deletions tests/schema_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#

import math
import logging
import requests
from typing import List
from unittest import TestCase, main
Expand All @@ -31,10 +30,6 @@
import json
from fastavro.schema import load_schema

logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)-5s %(message)s')


class ExampleRecord(Record):
str_field = String()
int_field = Integer()
Expand Down
2 changes: 1 addition & 1 deletion tests/test-conf/standalone-ssl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ acknowledgmentAtBatchIndexLevelEnabled=true
# Authentication plugin to use when connecting to bookies
bookkeeperClientAuthenticationPlugin=

# BookKeeper auth plugin implementatation specifics parameters name and values
# BookKeeper auth plugin implementation specifics parameters name and values
bookkeeperClientAuthenticationParametersName=
bookkeeperClientAuthenticationParameters=

Expand Down
2 changes: 1 addition & 1 deletion tests/test-conf/standalone.conf
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ acknowledgmentAtBatchIndexLevelEnabled=true
# Authentication plugin to use when connecting to bookies
bookkeeperClientAuthenticationPlugin=

# BookKeeper auth plugin implementatation specifics parameters name and values
# BookKeeper auth plugin implementation specifics parameters name and values
bookkeeperClientAuthenticationParametersName=
bookkeeperClientAuthenticationParameters=

Expand Down

0 comments on commit 065b05f

Please sign in to comment.