• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# Copyright 2018 gRPC authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16set -ex
17
18cd "$(dirname "$0")"
19
20shopt -s nullglob
21
22if [[ "$1" == "binary" ]]
23then
24  echo "Testing Python binary distribution"
25  ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-[0-9]*.whl)
26  TOOLS_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio_tools-[0-9]*.whl)
27else
28  echo "Testing Python source distribution"
29  ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-[0-9]*.tar.gz)
30  TOOLS_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-tools-[0-9]*.tar.gz)
31fi
32
33HEALTH_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-health-checking-[0-9]*.tar.gz)
34REFLECTION_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-reflection-[0-9]*.tar.gz)
35TESTING_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-testing-[0-9]*.tar.gz)
36
37VIRTUAL_ENV=$(mktemp -d)
38virtualenv "$VIRTUAL_ENV"
39PYTHON=$VIRTUAL_ENV/bin/python
40"$PYTHON" -m pip install --upgrade six pip
41
42function at_least_one_installs() {
43  for file in "$@"; do
44    if "$PYTHON" -m pip install "$file"; then
45      return 0
46    fi
47  done
48  return 1
49}
50
51
52#
53# Install our distributions in order of dependencies
54#
55
56at_least_one_installs "${ARCHIVES[@]}"
57at_least_one_installs "${TOOLS_ARCHIVES[@]}"
58at_least_one_installs "${HEALTH_ARCHIVES[@]}"
59at_least_one_installs "${REFLECTION_ARCHIVES[@]}"
60at_least_one_installs "${TESTING_ARCHIVES[@]}"
61
62
63#
64# Test our distributions
65#
66
67# TODO(jtattermusch): add a .proto file to the distribtest, generate python
68# code from it and then use the generated code from distribtest.py
69"$PYTHON" -m grpc.tools.protoc --help
70
71"$PYTHON" distribtest.py
72