Skip to content

Commit 51a94f2

Browse files
committed
Add protobuf 6 support
1 parent 364ea66 commit 51a94f2

159 files changed

Lines changed: 20392 additions & 79 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/style.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ name: Style checks
22

33
on:
44
push:
5+
branches:
6+
- main
57
pull_request:
68

79
jobs:
8-
build:
10+
lint:
911
runs-on: ubuntu-latest
1012
strategy:
1113
max-parallel: 4

.github/workflows/tests.yaml

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Functional tests
1+
name: Tests
22

33
on:
44
push:
@@ -7,26 +7,18 @@ on:
77
pull_request:
88

99
jobs:
10-
build:
10+
integration:
1111
runs-on: ubuntu-latest
1212

1313
concurrency:
14-
group: unit-${{ github.ref }}-${{ matrix.environment }}-${{ matrix.python-version }}-${{ matrix.folder }}
14+
group: integration-${{ github.ref }}-${{ matrix.python-version }}-${{ matrix.protobuf-version }}
1515
cancel-in-progress: true
1616

1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
python-version: [3.8, 3.9]
21-
environment: [py, py-tls, py-proto4, py-tls-proto4, py-proto3, py-tls-proto3]
22-
folder: [ydb, tests]
23-
exclude:
24-
- environment: py-tls
25-
folder: ydb
26-
- environment: py-tls-proto4
27-
folder: ydb
28-
- environment: py-tls-proto3
29-
folder: ydb
20+
python-version: ["3.8", "3.9", "3.10"]
21+
protobuf-version: [proto3, proto4, proto5, proto6]
3022

3123
steps:
3224
- uses: actions/checkout@v1
@@ -41,4 +33,31 @@ jobs:
4133
pip install tox==4.2.6
4234
4335
- name: Run unit tests
44-
run: tox -e ${{ matrix.environment }} -- ${{ matrix.folder }}
36+
run: tox -e py-${{ matrix.protobuf-version }} -- tests
37+
38+
unit:
39+
runs-on: ubuntu-latest
40+
41+
concurrency:
42+
group: unit-${{ github.ref }}-${{ matrix.python-version }}
43+
cancel-in-progress: true
44+
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
python-version: ["3.8", "3.9", "3.10"]
49+
50+
steps:
51+
- uses: actions/checkout@v1
52+
- name: Set up Python ${{ matrix.python-version }}
53+
uses: actions/setup-python@v2
54+
with:
55+
python-version: ${{ matrix.python-version }}
56+
57+
- name: Install tox
58+
run: |
59+
python -m pip install --upgrade pip
60+
pip install tox==4.2.6
61+
62+
- name: Run unit tests
63+
run: tox -e py -- ydb

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ protobuf-4:
1010

1111
protobuf-5:
1212
docker build -f generate-protobuf.Dockerfile . -t ydb-python-sdk-proto-generator-env-5 --build-arg PY_PROTOBUF_VER=5.26.1 --build-arg PROTOC_VER=26.1
13-
docker run --rm -it -v $${PWD}:$${PWD} -w $${PWD} ydb-python-sdk-proto-generator-env-5 python generate_protoc.py --target-version=v5
13+
docker run --rm -it -v $${PWD}:$${PWD} -w $${PWD} ydb-python-sdk-proto-generator-env-5 python generate_protoc.py --target-version=v5
14+
15+
protobuf-6:
16+
docker build -f generate-protobuf.Dockerfile . -t ydb-python-sdk-proto-generator-env-6 --build-arg GRPCIO_VER=1.76.0 --build-arg PY_PROTOBUF_VER=6.30.2 --build-arg PROTOC_VER=30.2
17+
docker run --rm -it -v $${PWD}:$${PWD} -w $${PWD} ydb-python-sdk-proto-generator-env-6 python generate_protoc.py --target-version=v6

docker-compose-tls.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
version: "3.3"
1+
version: "3.9"
22
services:
33
ydb:
44
image: ydbplatform/local-ydb:trunk
55
restart: always
66
ports:
77
- 2136:2136
8+
- 2135:2135
89
hostname: localhost
10+
volumes:
11+
- ./ydb_certs:/ydb_certs
912
environment:
1013
- YDB_ENABLE_COLUMN_TABLES=true
1114
- YDB_USE_IN_MEMORY_PDISKS=true

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jsonschema==3.2.0
1616
packaging==21.0
1717
paramiko==2.10.1
1818
pluggy==0.13.1
19-
protobuf>=3.13.0,<6.0.0
19+
protobuf>=3.13.0,<7.0.0
2020
py==1.10.0
2121
pycparser==2.20
2222
PyNaCl==1.4.0

tests/ssl/test_ssl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ def test_connect_secure(secure_endpoint, database):
1212
) as driver:
1313
driver.wait(timeout=10)
1414
driver.scheme_client.make_directory("/local/test")
15+
driver.scheme_client.remove_directory("/local/test")

tests/table/test_tx.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def test_tx_snapshot_ro(driver_sync, database):
7878
)
7979
assert data[0].rows == [{"value": 2}]
8080

81+
with suppress(ydb.issues.SchemeError):
82+
session.drop_table(tb_name)
83+
8184

8285
def test_split_transactions_deny_split(driver_sync, table_name):
8386
with ydb.SessionPool(driver_sync, 1) as pool:

tox.ini

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,84 +12,50 @@ setenv =
1212
deps =
1313
-r{toxinidir}/test-requirements.txt
1414

15-
[testenv:dev-proto5]
15+
[testenv:py]
1616
commands =
17+
pytest -v {posargs}
1718
deps =
1819
-r{toxinidir}/test-requirements.txt
19-
protobuf<6.0.0
20+
protobuf<7.0.0
2021

21-
[testenv:dev-proto4]
22+
[testenv:py-proto6]
2223
commands =
24+
pytest -v {posargs}
2325
deps =
2426
-r{toxinidir}/test-requirements.txt
25-
protobuf<5.0.0
27+
protobuf<7.0.0
2628

27-
[testenv:dev-proto3]
29+
[testenv:py-proto5]
2830
commands =
29-
deps =
30-
-r{toxinidir}/test-requirements.txt
31-
protobuf<4.0.0
32-
33-
[testenv:py]
34-
commands =
35-
pytest -v -m "not tls" {posargs}
31+
pytest -v {posargs}
3632
deps =
3733
-r{toxinidir}/test-requirements.txt
3834
protobuf<6.0.0
3935

4036
[testenv:py-proto4]
4137
commands =
42-
pytest -v -m "not tls" {posargs}
43-
deps =
44-
-r{toxinidir}/test-requirements.txt
45-
protobuf<5.0.0
46-
47-
[testenv:py-cov-proto4]
48-
commands =
49-
pytest -v -m "not tls" \
50-
--cov-report html:cov_html --cov=ydb \
51-
{posargs}
38+
pytest -v {posargs}
5239
deps =
5340
-r{toxinidir}/test-requirements.txt
5441
protobuf<5.0.0
5542

5643
[testenv:py-proto3]
5744
commands =
58-
pytest -v -m "not tls" {posargs}
59-
deps =
60-
-r{toxinidir}/test-requirements.txt
61-
protobuf<4.0.0
62-
63-
[testenv:py-tls]
64-
commands =
65-
pytest -v -m tls --docker-compose-file=docker-compose-tls.yml {posargs}
66-
deps =
67-
-r{toxinidir}/test-requirements.txt
68-
protobuf<6.0.0
69-
70-
[testenv:py-tls-proto4]
71-
commands =
72-
pytest -v -m tls --docker-compose-file=docker-compose-tls.yml {posargs}
73-
deps =
74-
-r{toxinidir}/test-requirements.txt
75-
protobuf<5.0.0
76-
77-
[testenv:py-tls-proto3]
78-
commands =
79-
pytest -v -m tls --docker-compose-file=docker-compose-tls.yml {posargs}
45+
pytest -v {posargs}
8046
deps =
8147
-r{toxinidir}/test-requirements.txt
8248
protobuf<4.0.0
8349

8450
[testenv:black-format]
8551
skip_install = true
8652
commands =
87-
black ydb examples tests --extend-exclude "ydb/_grpc/v3|ydb/_grpc/v4|ydb/_grpc/v5"
53+
black ydb examples tests --extend-exclude "ydb/_grpc/v3|ydb/_grpc/v4|ydb/_grpc/v5|ydb/_grpc/v6"
8854

8955
[testenv:black]
9056
skip_install = true
9157
commands =
92-
black --diff --check ydb examples tests --extend-exclude "ydb/_grpc/v3|ydb/_grpc/v4|ydb/_grpc/v5"
58+
black --diff --check ydb examples tests --extend-exclude "ydb/_grpc/v3|ydb/_grpc/v4|ydb/_grpc/v5|ydb/_grpc/v6"
9359

9460
[testenv:pylint]
9561
deps = pylint

ydb/_grpc/common/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,20 @@
4545

4646
sys.modules["ydb._grpc.common.protos"] = sys.modules["ydb._grpc.v4.protos"]
4747

48-
else:
48+
elif protobuf_version < Version("6.0"):
4949
from ydb._grpc.v5 import * # noqa
5050

5151
sys.modules["ydb._grpc.common"] = sys.modules["ydb._grpc.v5"]
5252

5353
from ydb._grpc.v5 import protos # noqa
5454

5555
sys.modules["ydb._grpc.common.protos"] = sys.modules["ydb._grpc.v5.protos"]
56+
57+
else:
58+
from ydb._grpc.v6 import * # noqa
59+
60+
sys.modules["ydb._grpc.common"] = sys.modules["ydb._grpc.v6"]
61+
62+
from ydb._grpc.v6 import protos # noqa
63+
64+
sys.modules["ydb._grpc.common.protos"] = sys.modules["ydb._grpc.v6.protos"]

0 commit comments

Comments
 (0)