diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 013bfdd35da24..ce7a20f5b0d8b 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -28,11 +28,19 @@ RUN apt-get update && \ add-apt-repository ppa:openjdk-r/ppa && \ apt-get update && \ apt-get install -y tig g++ cmake libssl-dev libcurl4-openssl-dev \ - liblog4cxx-dev libprotobuf-dev libboost-all-dev google-mock libgtest-dev \ + liblog4cxx-dev libprotobuf-dev google-mock libgtest-dev \ libjsoncpp-dev libxml2-utils protobuf-compiler wget \ curl doxygen openjdk-8-jdk-headless openjdk-11-jdk-headless clang-format-5.0 \ gnupg2 golang-1.13-go zip unzip libzstd-dev libsnappy-dev python3-pip +# Compile and install Boost because Boost.Python for Python3 is required +RUN apt-get install -y curl +RUN cd /usr/src && curl -O -L https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.gz && \ + tar zxf boost_1_75_0.tar.gz && cd boost_1_75_0 && \ + ./bootstrap.sh --with-python=/usr/bin/python3 --with-libraries=program_options,python && \ + ./b2 address-model=64 cxxflags=-fPIC link=static threading=multi variant=release install && \ + cd .. && rm -rf boost_1_75_0 boost_1_75_0.tar.gz + # Compile and install gtest RUN cd /usr/src/gtest && cmake . && make && cp libgtest.a /usr/lib diff --git a/pulsar-client-cpp/docker-build.sh b/pulsar-client-cpp/docker-build.sh index 31fa5d9d1b31a..cf4634145eb8b 100755 --- a/pulsar-client-cpp/docker-build.sh +++ b/pulsar-client-cpp/docker-build.sh @@ -26,7 +26,7 @@ set -e ROOT_DIR=$(git rev-parse --show-toplevel) cd $ROOT_DIR/pulsar-client-cpp -BUILD_IMAGE_NAME="${BUILD_IMAGE_NAME:-apachepulsar/pulsar-build}" +BUILD_IMAGE_NAME="${BUILD_IMAGE_NAME:-bewaremypower/pulsar-build}" BUILD_IMAGE_VERSION="${BUILD_IMAGE_VERSION:-ubuntu-16.04}" IMAGE="$BUILD_IMAGE_NAME:$BUILD_IMAGE_VERSION" diff --git a/pulsar-client-cpp/docker-tests.sh b/pulsar-client-cpp/docker-tests.sh index e5fd3e80969f8..cfcd5c10177e6 100755 --- a/pulsar-client-cpp/docker-tests.sh +++ b/pulsar-client-cpp/docker-tests.sh @@ -33,7 +33,7 @@ fi ROOT_DIR=$(git rev-parse --show-toplevel) cd $ROOT_DIR/pulsar-client-cpp -BUILD_IMAGE_NAME="${BUILD_IMAGE_NAME:-apachepulsar/pulsar-build}" +BUILD_IMAGE_NAME="${BUILD_IMAGE_NAME:-bewaremypower/pulsar-build}" BUILD_IMAGE_VERSION="${BUILD_IMAGE_VERSION:-ubuntu-16.04}" IMAGE="$BUILD_IMAGE_NAME:$BUILD_IMAGE_VERSION" diff --git a/pulsar-client-cpp/python/pulsar/schema/schema.py b/pulsar-client-cpp/python/pulsar/schema/schema.py index 5f69ea2cecedf..6271ffda11737 100644 --- a/pulsar-client-cpp/python/pulsar/schema/schema.py +++ b/pulsar-client-cpp/python/pulsar/schema/schema.py @@ -90,7 +90,7 @@ def encode(self, obj): return json.dumps(obj.__dict__, default=self._get_serialized_value, indent=True).encode('utf-8') def decode(self, data): - return self._record_cls(**json.loads(data)) + return self._record_cls(**json.loads(data.decode())) class AvroSchema(Schema): diff --git a/pulsar-client-cpp/python/pulsar_test.py b/pulsar-client-cpp/python/pulsar_test.py index e7d05f37cd6d6..1e821d34427a0 100755 --- a/pulsar-client-cpp/python/pulsar_test.py +++ b/pulsar-client-cpp/python/pulsar_test.py @@ -370,10 +370,10 @@ def test_encryption(self): producer = client.create_producer(topic=topic, encryption_key="client-rsa.pem", crypto_key_reader=crypto_key_reader) - producer.send('hello') + producer.send(b'hello') msg = consumer.receive(TM) self.assertTrue(msg) - self.assertEqual(msg.value(), 'hello') + self.assertEqual(msg.value(), b'hello') consumer.unsubscribe() client.close() diff --git a/pulsar-client-cpp/python/schema_test.py b/pulsar-client-cpp/python/schema_test.py index a86824cd96152..073317c0f3cf3 100755 --- a/pulsar-client-cpp/python/schema_test.py +++ b/pulsar-client-cpp/python/schema_test.py @@ -326,7 +326,7 @@ class Example(Record): s = JsonSchema(Example) r = Example(a=1, b=2) data = s.encode(r) - self.assertEqual(json.loads(data), {'a': 1, 'b': 2}) + self.assertEqual(json.loads(data.decode()), {'a': 1, 'b': 2}) r2 = s.decode(data) self.assertEqual(r2.__class__.__name__, 'Example') diff --git a/pulsar-client-cpp/run-unit-tests.sh b/pulsar-client-cpp/run-unit-tests.sh index f9429d81a8e9d..fa4cc3a802d15 100755 --- a/pulsar-client-cpp/run-unit-tests.sh +++ b/pulsar-client-cpp/run-unit-tests.sh @@ -45,10 +45,10 @@ popd if [ $RES -eq 0 ]; then pushd python echo "---- Build Python Wheel file" - python setup.py bdist_wheel + python3 setup.py bdist_wheel echo "---- Installing Python Wheel file" - pip install dist/pulsar_client-*-linux_x86_64.whl + pip3 install dist/pulsar_client-*-linux_x86_64.whl echo "---- Running Python unit tests" @@ -57,7 +57,7 @@ if [ $RES -eq 0 ]; then cp *_test.py /tmp pushd /tmp - python pulsar_test.py + python3 pulsar_test.py RES=$? echo "---- Running Python Function Instance unit tests" diff --git a/pulsar-functions/instance/src/scripts/run_python_instance_tests.sh b/pulsar-functions/instance/src/scripts/run_python_instance_tests.sh index 7005b9bfe885e..8f1191cfd80ff 100644 --- a/pulsar-functions/instance/src/scripts/run_python_instance_tests.sh +++ b/pulsar-functions/instance/src/scripts/run_python_instance_tests.sh @@ -20,12 +20,12 @@ # Make sure dependencies are installed -pip install mock --user -pip install protobuf --user -pip install fastavro --user +pip3 install mock --user +pip3 install protobuf --user +pip3 install fastavro --user CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" PULSAR_HOME=$CUR_DIR/../../../../ # run instance tests -PULSAR_HOME=${PULSAR_HOME} PYTHONPATH=${PULSAR_HOME}/pulsar-functions/instance/target/python-instance python -m unittest discover -v ${PULSAR_HOME}/pulsar-functions/instance/target/python-instance/tests +PULSAR_HOME=${PULSAR_HOME} PYTHONPATH=${PULSAR_HOME}/pulsar-functions/instance/target/python-instance python3 -m unittest discover -v ${PULSAR_HOME}/pulsar-functions/instance/target/python-instance/tests