Skip to content

Commit dda42a3

Browse files
authored
Enable CI for the streamstorage python client (#3875)
1 parent c3e5bfe commit dda42a3

File tree

20 files changed

+823
-4234
lines changed

20 files changed

+823
-4234
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
name: BookKeeper StreamStorage Python Client
21+
on:
22+
pull_request:
23+
branches:
24+
- master
25+
- branch-*
26+
paths:
27+
- 'stream/**'
28+
- '.github/workflows/bk-streamstorage-python.yml'
29+
push:
30+
branches:
31+
- master
32+
- branch-*
33+
paths:
34+
- 'stream/**'
35+
- '.github/workflows/bk-streamstorage-python.yml'
36+
37+
jobs:
38+
stream-storage-python-client-unit-tests:
39+
name: StreamStorage Python Client Unit Tests
40+
runs-on: ubuntu-latest
41+
timeout-minutes: 60
42+
steps:
43+
- name: checkout
44+
uses: actions/checkout@v3
45+
- name: Tune Runner VM
46+
uses: ./.github/actions/tune-runner-vm
47+
- name: Test
48+
run: ./stream/clients/python/scripts/test.sh
49+
50+
51+
Stream-storage-python-client-integration-tests:
52+
name: StreamStorage Python Client Integration Tests
53+
runs-on: ubuntu-latest
54+
timeout-minutes: 60
55+
steps:
56+
- name: checkout
57+
uses: actions/checkout@v3
58+
- name: Tune Runner VM
59+
uses: ./.github/actions/tune-runner-vm
60+
- name: Cache local Maven repository
61+
id: cache
62+
uses: actions/cache@v3
63+
with:
64+
path: |
65+
~/.m2/repository/*/*/*
66+
!~/.m2/repository/org/apache/bookkeeper
67+
!~/.m2/repository/org/apache/distributedlog
68+
key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
69+
- name: Set up JDK 11
70+
uses: actions/setup-java@v2
71+
with:
72+
distribution: 'temurin'
73+
java-version: 11
74+
- name: Set up Maven
75+
uses: apache/pulsar-test-infra/setup-maven@master
76+
with:
77+
maven-version: 3.8.7
78+
- name: Build
79+
run: mvn -q -T 1C -B -nsu clean install -DskipTests -Dcheckstyle.skip -Dspotbugs.skip -Drat.skip -Dmaven.javadoc.skip
80+
- name: Build Test image
81+
run: ./stream/clients/python/docker/build-local-image.sh
82+
- name: Test
83+
run: ./stream/clients/python/scripts/docker_integration_tests.sh
84+
85+

stream/clients/pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,22 @@
2929
<modules>
3030
<module>java</module>
3131
</modules>
32+
<build>
33+
<plugins>
34+
<plugin>
35+
<groupId>org.apache.rat</groupId>
36+
<artifactId>apache-rat-plugin</artifactId>
37+
<configuration>
38+
<excludes>
39+
<exclude>**/apache_bookkeeper_client.egg-info/**</exclude>
40+
<exclude>**/.nox/**</exclude>
41+
<exclude>**/.pytest_cache/**</exclude>
42+
<exclude>**/.idea/**</exclude>
43+
<exclude>**/build/**</exclude>
44+
<exclude>**/proto/**</exclude>
45+
</excludes>
46+
</configuration>
47+
</plugin>
48+
</plugins>
49+
</build>
3250
</project>

stream/clients/python/.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# limitations under the License.
1212

1313
[flake8]
14+
max-line-length = 120
1415
exclude =
1516
# Exclude generated code.
1617
**/proto/**

stream/clients/python/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ pip-selfcheck.json
2626

2727
# egg-info
2828
**egg-info/
29+
30+
**/bookkeeper-server-bin.tar.gz

stream/clients/python/README.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
..
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+
120
Python Client for Apache BookKeeper
221
===================================
322

stream/clients/python/bookkeeper/common/protobuf_helpers.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212

1313
"""Helpers for :mod:`protobuf`."""
1414

15-
import collections
1615
import copy
1716
import inspect
1817

18+
from collections.abc import Mapping
19+
from collections.abc import MutableMapping
20+
from collections.abc import MutableSequence
21+
from collections import OrderedDict
22+
1923
from google.protobuf import field_mask_pb2
2024
from google.protobuf import message
2125
from google.protobuf import wrappers_pb2
@@ -82,7 +86,7 @@ def get_messages(module):
8286
Message class names as keys, and the Message subclasses themselves
8387
as values.
8488
"""
85-
answer = collections.OrderedDict()
89+
answer = OrderedDict()
8690
for name in dir(module):
8791
candidate = getattr(module, name)
8892
if (inspect.isclass(candidate) and
@@ -143,7 +147,7 @@ def get(msg_or_dict, key, default=_SENTINEL):
143147
# If we get something else, complain.
144148
if isinstance(msg_or_dict, message.Message):
145149
answer = getattr(msg_or_dict, key, default)
146-
elif isinstance(msg_or_dict, collections.Mapping):
150+
elif isinstance(msg_or_dict, Mapping):
147151
answer = msg_or_dict.get(key, default)
148152
else:
149153
raise TypeError(
@@ -166,21 +170,21 @@ def _set_field_on_message(msg, key, value):
166170
"""Set helper for protobuf Messages."""
167171
# Attempt to set the value on the types of objects we know how to deal
168172
# with.
169-
if isinstance(value, (collections.MutableSequence, tuple)):
173+
if isinstance(value, (MutableSequence, tuple)):
170174
# Clear the existing repeated protobuf message of any elements
171175
# currently inside it.
172176
while getattr(msg, key):
173177
getattr(msg, key).pop()
174178

175179
# Write our new elements to the repeated field.
176180
for item in value:
177-
if isinstance(item, collections.Mapping):
181+
if isinstance(item, Mapping):
178182
getattr(msg, key).add(**item)
179183
else:
180184
# protobuf's RepeatedCompositeContainer doesn't support
181185
# append.
182186
getattr(msg, key).extend([item])
183-
elif isinstance(value, collections.Mapping):
187+
elif isinstance(value, Mapping):
184188
# Assign the dictionary values to the protobuf message.
185189
for item_key, item_value in value.items():
186190
set(getattr(msg, key), item_key, item_value)
@@ -202,7 +206,7 @@ def set(msg_or_dict, key, value):
202206
"""
203207
# Sanity check: Is our target object valid?
204208
if (not isinstance(msg_or_dict,
205-
(collections.MutableMapping, message.Message))):
209+
(MutableMapping, message.Message))):
206210
raise TypeError(
207211
'set() expected a dict or protobuf message, got {!r}.'.format(
208212
type(msg_or_dict)))
@@ -213,12 +217,12 @@ def set(msg_or_dict, key, value):
213217
# If a subkey exists, then get that object and call this method
214218
# recursively against it using the subkey.
215219
if subkey is not None:
216-
if isinstance(msg_or_dict, collections.MutableMapping):
220+
if isinstance(msg_or_dict, MutableMapping):
217221
msg_or_dict.setdefault(basekey, {})
218222
set(get(msg_or_dict, basekey), subkey, value)
219223
return
220224

221-
if isinstance(msg_or_dict, collections.MutableMapping):
225+
if isinstance(msg_or_dict, MutableMapping):
222226
msg_or_dict[key] = value
223227
else:
224228
_set_field_on_message(msg_or_dict, key, value)

0 commit comments

Comments
 (0)