Rehome python bazel distribtest (#29275)

* WIP

* Test multiple languages

* Yapf

* isort

* Shellcheck

* comment not provided

* Fix import ordering issue.

* Turn up Bazel logging
reviewable/pr29289/r1
Richard Belleville 3 years ago committed by GitHub
parent 2fd632a4c1
commit f688f5fcf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .bazelignore
  2. 1
      bazel/test/python_test_repo/tools/bazel
  3. 0
      test/distrib/bazel/python/.gitignore
  4. 0
      test/distrib/bazel/python/BUILD
  5. 0
      test/distrib/bazel/python/README.md
  6. 2
      test/distrib/bazel/python/WORKSPACE
  7. 0
      test/distrib/bazel/python/helloworld.proto
  8. 8
      test/distrib/bazel/python/helloworld.py
  9. 9
      test/distrib/bazel/python/helloworld_moved.py
  10. 0
      test/distrib/bazel/python/import_from_proto_library_package.py
  11. 0
      test/distrib/bazel/python/import_from_this_package.py
  12. 0
      test/distrib/bazel/python/in_subpackage/BUILD
  13. 0
      test/distrib/bazel/python/in_subpackage/subpackage.proto
  14. 0
      test/distrib/bazel/python/namespaced/upper/example/BUILD
  15. 10
      test/distrib/bazel/python/namespaced/upper/example/import_no_strip_test.py
  16. 4
      test/distrib/bazel/python/namespaced/upper/example/import_strip_test.py
  17. 0
      test/distrib/bazel/python/namespaced/upper/example/namespaced_dependency.proto
  18. 0
      test/distrib/bazel/python/namespaced/upper/example/namespaced_example.proto
  19. 10
      test/distrib/bazel/python/namespaced/upper/example/no_import_no_strip_test.py
  20. 4
      test/distrib/bazel/python/namespaced/upper/example/no_import_strip_test.py
  21. 0
      test/distrib/bazel/python/subdir/hello_dep.proto
  22. 1
      test/distrib/bazel/python/tools/bazel
  23. 0
      test/distrib/bazel/python/transitive_proto_dep.py
  24. 0
      test/distrib/bazel/python_second_test_repo/WORKSPACE
  25. 0
      test/distrib/bazel/python_second_test_repo/proto/BUILD
  26. 13
      test/distrib/bazel/test_single_bazel_version.sh
  27. 7
      tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh

@ -20,8 +20,9 @@ third_party/re2
third_party/upb
third_party/xds
bazel/test/python_test_repo
test/distrib/bazel/cpp
test/distrib/bazel/python
test/distrib/bazel/python_second_test_repo
# Directories generated by setuptools build containing BUILD files.
src/python/grpcio_tests/src/

@ -1 +0,0 @@
../../../../tools/bazel

@ -2,7 +2,7 @@
local_repository(
name = "com_github_grpc_grpc",
path = "../../..",
path = "../../../..",
)
# Ensure rules don't rely on __main__ naming convention.

@ -13,16 +13,15 @@
# limitations under the License.
"""The Python implementation of the GRPC helloworld.Greeter client."""
from concurrent import futures
import contextlib
import datetime
import logging
import unittest
import grpc
from google.protobuf import duration_pb2
from google.protobuf import timestamp_pb2
from concurrent import futures
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
@ -56,6 +55,7 @@ def _listening_server():
class ImportTest(unittest.TestCase):
def test_import(self):
with _listening_server() as port:
with grpc.insecure_channel('{}:{}'.format(_HOST, port)) as channel:
@ -66,7 +66,7 @@ class ImportTest(unittest.TestCase):
name='you',
request_initiation=request_timestamp,
),
wait_for_ready=True)
wait_for_ready=True)
self.assertEqual(response.message, "Hello, you!")
self.assertGreater(response.request_duration.nanos, 0)

@ -13,18 +13,20 @@
# limitations under the License.
"""The Python implementation of the GRPC helloworld.Greeter client."""
from concurrent import futures
import contextlib
import datetime
import logging
import unittest
# TODO(https://github.com/grpc/grpc/issues/29284)
# isort: off
import grpc
from google.protobuf import duration_pb2
from google.protobuf import timestamp_pb2
from concurrent import futures
from google.cloud import helloworld_pb2
from google.cloud import helloworld_pb2_grpc
# isort: on
_HOST = 'localhost'
_SERVER_ADDRESS = '{}:0'.format(_HOST)
@ -56,6 +58,7 @@ def _listening_server():
class ImportTest(unittest.TestCase):
def test_import(self):
with _listening_server() as port:
with grpc.insecure_channel('{}:{}'.format(_HOST, port)) as channel:
@ -66,7 +69,7 @@ class ImportTest(unittest.TestCase):
name='you',
request_initiation=request_timestamp,
),
wait_for_ready=True)
wait_for_ready=True)
self.assertEqual(response.message, "Hello, you!")
self.assertGreater(response.request_duration.nanos, 0)

@ -17,15 +17,19 @@ import unittest
class ImportTest(unittest.TestCase):
def test_import(self):
from foo.bar.namespaced.upper.example.namespaced_example_pb2 import NamespacedExample
from foo.bar.namespaced.upper.example.namespaced_example_pb2 import \
NamespacedExample
namespaced_example = NamespacedExample()
namespaced_example.value = "hello"
# Dummy assert, important part is namespaced example was imported.
# Superfluous assert, important part is namespaced example was imported.
self.assertEqual(namespaced_example.value, "hello")
def test_grpc(self):
from foo.bar.namespaced.upper.example.namespaced_example_pb2_grpc import NamespacedServiceStub
from foo.bar.namespaced.upper.example.namespaced_example_pb2_grpc import \
NamespacedServiceStub
# No error from import
self.assertEqual(1, 1)

@ -17,15 +17,17 @@ import unittest
class ImportTest(unittest.TestCase):
def test_import(self):
from foo.bar.namespaced_example_pb2 import NamespacedExample
namespaced_example = NamespacedExample()
namespaced_example.value = "hello"
# Dummy assert, important part is namespaced example was imported.
# Superfluous assert, important part is namespaced example was imported.
self.assertEqual(namespaced_example.value, "hello")
def test_grpc(self):
from foo.bar.namespaced_example_pb2_grpc import NamespacedServiceStub
# No error from import
self.assertEqual(1, 1)

@ -17,15 +17,19 @@ import unittest
class ImportTest(unittest.TestCase):
def test_import(self):
from namespaced.upper.example.namespaced_example_pb2 import NamespacedExample
from namespaced.upper.example.namespaced_example_pb2 import \
NamespacedExample
namespaced_example = NamespacedExample()
namespaced_example.value = "hello"
# Dummy assert, important part is namespaced example was imported.
# Superfluous assert, important part is namespaced example was imported.
self.assertEqual(namespaced_example.value, "hello")
def test_grpc(self):
from namespaced.upper.example.namespaced_example_pb2_grpc import NamespacedServiceStub
from namespaced.upper.example.namespaced_example_pb2_grpc import \
NamespacedServiceStub
# No error from import
self.assertEqual(1, 1)

@ -17,15 +17,17 @@ import unittest
class ImportTest(unittest.TestCase):
def test_import(self):
from namespaced_example_pb2 import NamespacedExample
namespaced_example = NamespacedExample()
namespaced_example.value = "hello"
# Dummy assert, important part is namespaced example was imported.
# Superfluous assert, important part is namespaced example was imported.
self.assertEqual(namespaced_example.value, "hello")
def test_grpc(self):
from namespaced_example_pb2_grpc import NamespacedServiceStub
# No error from import
self.assertEqual(1, 1)

@ -0,0 +1 @@
../../../../../tools/bazel

@ -41,6 +41,11 @@ EXCLUDED_TARGETS=(
"-//examples/android/binder/..."
)
TEST_DIRECTORIES=(
"cpp"
"python"
)
FAILED_TESTS=""
export OVERRIDE_BAZEL_VERSION="$VERSION"
@ -48,9 +53,13 @@ export OVERRIDE_BAZEL_VERSION="$VERSION"
export OVERRIDE_BAZEL_WRAPPER_DOWNLOAD_DIR=/tmp
bazel build -- //... "${EXCLUDED_TARGETS[@]}" || FAILED_TESTS="${FAILED_TESTS}Build "
cd test/distrib/bazel/cpp/
for TEST_DIRECTORY in "${TEST_DIRECTORIES[@]}"; do
pushd "test/distrib/bazel/$TEST_DIRECTORY/"
bazel test --test_output=all //:all || FAILED_TESTS="${FAILED_TESTS}${TEST_DIRECTORY} Distribtest"
bazel test //:all || FAILED_TESTS="${FAILED_TESTS}C++ Distribtest"
popd
done
if [ "$FAILED_TESTS" != "" ]
then

@ -29,10 +29,3 @@ BAZEL_FLAGS="--test_output=errors"
bazel test ${BAZEL_FLAGS} ${TEST_TARGETS}
bazel test --config=python_single_threaded_unary_stream ${BAZEL_FLAGS} ${TEST_TARGETS}
bazel test --config=python_poller_engine ${BAZEL_FLAGS} ${TEST_TARGETS}
# TODO(https://github.com/grpc/grpc/issues/19854): Move this to a new Kokoro
# job.
(cd /var/local/git/grpc/bazel/test/python_test_repo;
bazel test --test_output=errors //...
)

Loading…
Cancel
Save