Javier Jardón pushed to branch jjardon/pycodestyle_test at BuildStream / buildstream
Commits:
-
e0bb71b2
by Tiago Gomes at 2018-09-10T15:27:53Z
-
47f3064a
by Jürg Billeter at 2018-09-10T15:43:25Z
-
1a7fb3cb
by Jürg Billeter at 2018-09-10T15:43:25Z
-
b3ffcdc8
by Jürg Billeter at 2018-09-10T16:07:30Z
-
501060b3
by Javier Jardón at 2018-09-13T07:22:38Z
-
a1bef8c4
by Javier Jardón at 2018-09-13T07:22:38Z
-
96609e72
by Javier Jardón at 2018-09-13T07:25:24Z
6 changed files:
- .gitlab-ci.yml
- buildstream/_artifactcache/casserver.py
- buildstream/_ostree.py
- buildstream/element.py
- dev-requirements.txt
- setup.cfg
Changes:
... | ... | @@ -84,25 +84,25 @@ source_dist: |
84 | 84 |
- coverage-linux/
|
85 | 85 |
|
86 | 86 |
tests-debian-9:
|
87 |
- image: buildstream/testsuite-debian:9-master-117-aa3a33b3
|
|
87 |
+ image: buildstream/testsuite-debian:9-master-117-b3ffcdc8
|
|
88 | 88 |
<<: *linux-tests
|
89 | 89 |
|
90 | 90 |
tests-fedora-27:
|
91 |
- image: buildstream/testsuite-fedora:27-master-117-aa3a33b3
|
|
91 |
+ image: buildstream/testsuite-fedora:27-master-117-b3ffcdc8
|
|
92 | 92 |
<<: *linux-tests
|
93 | 93 |
|
94 | 94 |
tests-fedora-28:
|
95 |
- image: buildstream/testsuite-fedora:28-master-117-aa3a33b3
|
|
95 |
+ image: buildstream/testsuite-fedora:28-master-117-b3ffcdc8
|
|
96 | 96 |
<<: *linux-tests
|
97 | 97 |
|
98 | 98 |
tests-ubuntu-18.04:
|
99 |
- image: buildstream/testsuite-ubuntu:18.04-master-117-aa3a33b3
|
|
99 |
+ image: buildstream/testsuite-ubuntu:18.04-master-117-b3ffcdc8
|
|
100 | 100 |
<<: *linux-tests
|
101 | 101 |
|
102 | 102 |
tests-unix:
|
103 | 103 |
# Use fedora here, to a) run a test on fedora and b) ensure that we
|
104 | 104 |
# can get rid of ostree - this is not possible with debian-8
|
105 |
- image: buildstream/testsuite-fedora:27-master-117-aa3a33b3
|
|
105 |
+ image: buildstream/testsuite-fedora:27-master-117-b3ffcdc8
|
|
106 | 106 |
stage: test
|
107 | 107 |
variables:
|
108 | 108 |
BST_FORCE_BACKEND: "unix"
|
... | ... | @@ -38,6 +38,10 @@ from .._context import Context |
38 | 38 |
from .cascache import CASCache
|
39 | 39 |
|
40 | 40 |
|
41 |
+# The default limit for gRPC messages is 4 MiB
|
|
42 |
+_MAX_BATCH_TOTAL_SIZE_BYTES = 4 * 1024 * 1024
|
|
43 |
+ |
|
44 |
+ |
|
41 | 45 |
# Trying to push an artifact that is too large
|
42 | 46 |
class ArtifactTooLargeException(Exception):
|
43 | 47 |
pass
|
... | ... | @@ -67,6 +71,9 @@ def create_server(repo, *, enable_push): |
67 | 71 |
remote_execution_pb2_grpc.add_ContentAddressableStorageServicer_to_server(
|
68 | 72 |
_ContentAddressableStorageServicer(artifactcache), server)
|
69 | 73 |
|
74 |
+ remote_execution_pb2_grpc.add_CapabilitiesServicer_to_server(
|
|
75 |
+ _CapabilitiesServicer(), server)
|
|
76 |
+ |
|
70 | 77 |
buildstream_pb2_grpc.add_ReferenceStorageServicer_to_server(
|
71 | 78 |
_ReferenceStorageServicer(artifactcache, enable_push=enable_push), server)
|
72 | 79 |
|
... | ... | @@ -229,6 +236,48 @@ class _ContentAddressableStorageServicer(remote_execution_pb2_grpc.ContentAddres |
229 | 236 |
d.size_bytes = digest.size_bytes
|
230 | 237 |
return response
|
231 | 238 |
|
239 |
+ def BatchReadBlobs(self, request, context):
|
|
240 |
+ response = remote_execution_pb2.BatchReadBlobsResponse()
|
|
241 |
+ batch_size = 0
|
|
242 |
+ |
|
243 |
+ for digest in request.digests:
|
|
244 |
+ batch_size += digest.size_bytes
|
|
245 |
+ if batch_size > _MAX_BATCH_TOTAL_SIZE_BYTES:
|
|
246 |
+ context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
|
|
247 |
+ return response
|
|
248 |
+ |
|
249 |
+ blob_response = response.responses.add()
|
|
250 |
+ blob_response.digest.hash = digest.hash
|
|
251 |
+ blob_response.digest.size_bytes = digest.size_bytes
|
|
252 |
+ try:
|
|
253 |
+ with open(self.cas.objpath(digest), 'rb') as f:
|
|
254 |
+ if os.fstat(f.fileno()).st_size != digest.size_bytes:
|
|
255 |
+ blob_response.status.code = grpc.StatusCode.NOT_FOUND
|
|
256 |
+ continue
|
|
257 |
+ |
|
258 |
+ blob_response.data = f.read(digest.size_bytes)
|
|
259 |
+ except FileNotFoundError:
|
|
260 |
+ blob_response.status.code = grpc.StatusCode.NOT_FOUND
|
|
261 |
+ |
|
262 |
+ return response
|
|
263 |
+ |
|
264 |
+ |
|
265 |
+class _CapabilitiesServicer(remote_execution_pb2_grpc.CapabilitiesServicer):
|
|
266 |
+ def GetCapabilities(self, request, context):
|
|
267 |
+ response = remote_execution_pb2.ServerCapabilities()
|
|
268 |
+ |
|
269 |
+ cache_capabilities = response.cache_capabilities
|
|
270 |
+ cache_capabilities.digest_function.append(remote_execution_pb2.SHA256)
|
|
271 |
+ cache_capabilities.action_cache_update_capabilities.update_enabled = False
|
|
272 |
+ cache_capabilities.max_batch_total_size_bytes = _MAX_BATCH_TOTAL_SIZE_BYTES
|
|
273 |
+ cache_capabilities.symlink_absolute_path_strategy = remote_execution_pb2.CacheCapabilities.ALLOWED
|
|
274 |
+ |
|
275 |
+ response.deprecated_api_version.major = 2
|
|
276 |
+ response.low_api_version.major = 2
|
|
277 |
+ response.high_api_version.major = 2
|
|
278 |
+ |
|
279 |
+ return response
|
|
280 |
+ |
|
232 | 281 |
|
233 | 282 |
class _ReferenceStorageServicer(buildstream_pb2_grpc.ReferenceStorageServicer):
|
234 | 283 |
def __init__(self, cas, *, enable_push):
|
... | ... | @@ -34,7 +34,7 @@ from ._exceptions import BstError, ErrorDomain |
34 | 34 |
|
35 | 35 |
# pylint: disable=wrong-import-position,wrong-import-order
|
36 | 36 |
gi.require_version('OSTree', '1.0')
|
37 |
-from gi.repository import GLib, Gio, OSTree # nopep8
|
|
37 |
+from gi.repository import GLib, Gio, OSTree # noqa
|
|
38 | 38 |
|
39 | 39 |
|
40 | 40 |
# For users of this file, they must expect (except) it.
|
... | ... | @@ -1528,7 +1528,7 @@ class Element(Plugin): |
1528 | 1528 |
utils._force_rmtree(rootdir)
|
1529 | 1529 |
|
1530 | 1530 |
with _signals.terminator(cleanup_rootdir), \
|
1531 |
- self.__sandbox(rootdir, output_file, output_file, self.__sandbox_config) as sandbox: # nopep8
|
|
1531 |
+ self.__sandbox(rootdir, output_file, output_file, self.__sandbox_config) as sandbox: # noqa
|
|
1532 | 1532 |
|
1533 | 1533 |
sandbox_vroot = sandbox.get_virtual_directory()
|
1534 | 1534 |
|
1 | 1 |
coverage == 4.4.0
|
2 |
-pep8
|
|
3 | 2 |
pylint == 2.1.1
|
4 | 3 |
pytest >= 3.7
|
4 |
+pytest-codestyle >= 1.3.0
|
|
5 | 5 |
pytest-cov >= 2.5.0
|
6 | 6 |
pytest-datafiles
|
7 | 7 |
pytest-env
|
8 |
-pytest-pep8
|
|
9 | 8 |
pytest-pylint
|
10 | 9 |
pytest-xdist
|
11 | 10 |
pytest-timeout
|
... | ... | @@ -11,20 +11,11 @@ parentdir_prefix = BuildStream- |
11 | 11 |
test=pytest
|
12 | 12 |
|
13 | 13 |
[tool:pytest]
|
14 |
-addopts = --verbose --basetemp ./tmp --pep8 --pylint --pylint-rcfile=.pylintrc --cov=buildstream --cov-config .coveragerc --durations=20
|
|
14 |
+addopts = --verbose --basetemp ./tmp --codestyle --pylint --pylint-rcfile=.pylintrc --cov=buildstream --cov-config .coveragerc --durations=20
|
|
15 | 15 |
norecursedirs = tests/integration/project integration-cache tmp __pycache__ .eggs
|
16 | 16 |
python_files = tests/*/*.py
|
17 |
-pep8maxlinelength = 119
|
|
18 |
-pep8ignore =
|
|
19 |
- * E129
|
|
20 |
- * E125
|
|
21 |
- doc/source/conf.py ALL
|
|
22 |
- tmp/* ALL
|
|
23 |
- */lib/python3* ALL
|
|
24 |
- */bin/* ALL
|
|
25 |
- buildstream/_fuse/fuse.py ALL
|
|
26 |
- .eggs/* ALL
|
|
27 |
- *_pb2.py ALL
|
|
28 |
- *_pb2_grpc.py ALL
|
|
17 |
+codestyle_max_line_length = 119
|
|
18 |
+codestyle_ignore = E129 E125 W504 W605
|
|
19 |
+codestyle_exclude = doc/source/conf.py buildstream/_fuse/fuse.py buildstream/_protos/build/bazel/remote/execution/v2/remote_execution_pb2.py buildstream/_protos/google/api/http_pb2.py buildstream/_protos/google/bytestream/bytestream_pb2.py buildstream/_protos/google/longrunning/operations_pb2.py buildstream/_protos/google/rpc/status_pb2.py
|
|
29 | 20 |
env =
|
30 | 21 |
D:BST_TEST_SUITE=True
|