Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(python-client-ci): build the server instead of downloading it from external site #1815

Merged
merged 3 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 53 additions & 13 deletions .github/workflows/test_python-client.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#
# 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
Expand All @@ -15,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

name: Test - python client
on:
Expand All @@ -35,21 +33,63 @@ defaults:
run:
shell: bash

env:
ARTIFACT_NAME: release_for_python_client

jobs:
build_server:
name: Build server
runs-on: ubuntu-latest
env:
USE_JEMALLOC: OFF
BUILD_OPTIONS: -t release
container:
image: apache/pegasus:thirdparties-bin-test-ubuntu2204-${{ github.base_ref }}
steps:
- uses: actions/checkout@v3
- uses: "./.github/actions/rebuild_thirdparty_if_needed"
- uses: "./.github/actions/build_pegasus"
- uses: "./.github/actions/upload_artifact"

test:
name: test
runs-on: ubuntu-20.04
name: Test Python client
needs: build_server
runs-on: ubuntu-latest
container:
image: apache/pegasus:thirdparties-bin-test-ubuntu2204-${{ github.base_ref }}
steps:
- name: Install thrift
# python-client imports thrift package of 0.13.0, so we must use thrift-compiler 0.13.0
# to generate code as well. The thrift-compiler version on ubuntu-20.04 is 0.13.0
run: sudo apt-get install -y thrift-compiler
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: test
python-version: '3.11'
# python-client imports thrift package of 0.13.0, so we must use thrift-compiler 0.13.0
# to generate code as well. The thrift-compiler version on ubuntu-22.04 is 0.16.0, so
# build and install thrift-compiler 0.13.0 manually.
- name: Install thrift
run: |
export THRIFT_VERSION=0.13.0
wget --progress=dot:giga https://github.com/apache/thrift/archive/refs/tags/v${THRIFT_VERSION}.tar.gz
tar -xzf v${THRIFT_VERSION}.tar.gz
cd thrift-${THRIFT_VERSION}
./bootstrap.sh
./configure --enable-libs=no
make -j $(nproc)
make install
cd - && rm -rf thrift-${THRIFT_VERSION} v${THRIFT_VERSION}.tar.gz
- name: Download artifact
uses: "./.github/actions/download_artifact"
- name: Start Pegasus cluster
run: |
export LD_LIBRARY_PATH=$(pwd)/thirdparty/output/lib:${JAVA_HOME}/jre/lib/amd64/server
ulimit -s unlimited
./run.sh start_onebox
- name: Run Python client tests
working-directory: ./python-client
run: |
pip install -r requirement.txt
./test.sh
python -m pip install -r requirement.txt
thrift -v --gen py -out . ../idl/dsn.layer2.thrift
thrift -v --gen py -out . ../idl/rrdb.thrift
python setup.py install
python sample.py
cd tests
python -m unittest -v test_basics.TestBasics
71 changes: 46 additions & 25 deletions python-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ specific language governing permissions and limitations
under the License.
-->

pegasus-python-client
=====================
# pegasus-python-client

It uses [Twisted](http://twistedmatrix.com) for the asynchronous communication with pegasus server.

Installation
------------
## Installation

Python 3.8+

pypegasus can be installed via pip as follows:
Expand All @@ -36,40 +35,59 @@ thrift --gen py -out . ../idl/dsn.layer2.thrift
python3 setup.py install
```

Usage
-----
## Usage

There are some basic guide in [`sample.py`](sample.py).

Test
----
Before testing, you should firstly start an onebox cluster, referring to [`how to start an onebox cluster`](https://pegasus.apache.org/overview/onebox/).
## Test

Note: Before testing, you should firstly start an [onebox](https://pegasus.apache.org/overview/onebox/).

### Run sample

## Basic interfaces test:
```shell
python3 sample.py
```

`cd tests && python3 -m unittest test_basics.TestBasics`
### Basic interfaces test

## Integration test:
```shell
cd tests
python3 -m unittest test_basics.TestBasics
```

`cd tests && python3 -m twisted.trial test_integration.py`
<!-- markdown-link-check-disable -->
ATTENTION: you should firstly set proper pegasus shell path in [`test_integration.py`](test_integration.py#L10).
<!-- markdown-link-check-enable-->
### Integration test

> Note: You should firstly set proper Pegasus shell path in test_integration.py.
> ```python
> shell_path = '/your/pegasus-shell/dir'
> ```

## Benchmark test:
```shell
cd tests
python3 -m twisted.trial test_integration.py
```

`cd tests && python3 -m unittest test_benchmark.TestBasics`
## Benchmark test

```shell
cd tests
python3 -m unittest test_benchmark.TestBasics
```

The test result on my personal PC (CPU: Intel i7-7700 3.60GHz, mem: 8G) is:
```
10000 get cost: 3.80077195168 s, 0.000380077195168 s per op
10000 remove cost: 7.61887693405 s, 0.000761887693405 s per op
10000 set cost: 6.26366090775 s, 0.000626366090775 s per op
```
FAQ
---
### Q: When I run sample.py, error occured as following:
```

## FAQ

### Q: Error occurred about `'module' object has no attribute 'OP_NO_TLSv1_1'`:

Error details:
```shell
Traceback (most recent call last):
File "./sample.py", line 3, in <module>
from pgclient import *
Expand All @@ -80,9 +98,12 @@ Traceback (most recent call last):
TLSVersion.TLSv1_1: SSL.OP_NO_TLSv1_1,
AttributeError: 'module' object has no attribute 'OP_NO_TLSv1_1'
```
### A: pyOpenSSL version too low
the twisted version we used is 17.9.0, which requires pyOpenSSL>=16.0.0, you can

`pip install --upgrade pyopenssl`
#### A: pyOpenSSL version too low
The twisted version we used is 17.9.0, which requires pyOpenSSL>=16.0.0, you can

```shell
pip install --upgrade pyopenssl
```

ref: https://github.com/scrapy/scrapy/issues/2473
44 changes: 0 additions & 44 deletions python-client/test.sh

This file was deleted.

Loading