xref: /aosp_15_r20/external/grpc-grpc-java/buildscripts/kokoro/android-interop.sh (revision e07d83d3ffcef9ecfc9f7f475418ec639ff0e5fe)
1#!/bin/bash
2
3set -exu -o pipefail
4if [[ -f /VERSION ]]; then
5  cat /VERSION
6fi
7
8# Install gRPC and codegen for the Android interop app
9# (a composite gradle build can't find protoc-gen-grpc-java)
10
11cd github/grpc-java
12
13export GRADLE_OPTS=-Xmx512m
14export LDFLAGS=-L/tmp/protobuf/lib
15export CXXFLAGS=-I/tmp/protobuf/include
16export LD_LIBRARY_PATH=/tmp/protobuf/lib
17export OS_NAME=$(uname)
18
19echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
20
21# Proto deps
22buildscripts/make_dependencies.sh
23
24# Build Android with Java 11, this adds it to the PATH
25sudo update-java-alternatives --set java-1.11.0-openjdk-amd64
26# Unset any existing JAVA_HOME env var to stop Gradle from using it
27unset JAVA_HOME
28
29GRADLE_FLAGS="-Pandroid.useAndroidX=true"
30
31# Build and run interop instrumentation tests on Firebase Test Lab
32cd android-interop-testing
33../gradlew assembleDebug $GRADLE_FLAGS
34../gradlew assembleDebugAndroidTest $GRADLE_FLAGS
35gcloud firebase test android run \
36  --type instrumentation \
37  --app build/outputs/apk/debug/grpc-android-interop-testing-debug.apk \
38  --test build/outputs/apk/androidTest/debug/grpc-android-interop-testing-debug-androidTest.apk \
39  --environment-variables \
40      server_host=grpc-test.sandbox.googleapis.com,server_port=443,test_case=all \
41  --device model=Nexus6P,version=27,locale=en,orientation=portrait \
42  --device model=Nexus6P,version=26,locale=en,orientation=portrait \
43  --device model=Nexus6P,version=25,locale=en,orientation=portrait \
44  --device model=Nexus6P,version=24,locale=en,orientation=portrait \
45  --device model=Nexus6P,version=23,locale=en,orientation=portrait \
46  --device model=Nexus6,version=22,locale=en,orientation=portrait \
47  --device model=Nexus6,version=21,locale=en,orientation=portrait
48
49# Build and run binderchannel instrumentation tests on Firebase Test Lab
50cd ../binder
51../gradlew assembleDebugAndroidTest $GRADLE_FLAGS
52gcloud firebase test android run \
53  --type instrumentation \
54  --app ../android-interop-testing/build/outputs/apk/debug/grpc-android-interop-testing-debug.apk \
55  --test build/outputs/apk/androidTest/debug/grpc-binder-debug-androidTest.apk \
56  --device model=Nexus6P,version=27,locale=en,orientation=portrait \
57  --device model=Nexus6P,version=26,locale=en,orientation=portrait \
58  --device model=Nexus6P,version=25,locale=en,orientation=portrait \
59  --device model=Nexus6P,version=24,locale=en,orientation=portrait \
60  --device model=Nexus6P,version=23,locale=en,orientation=portrait \
61  --device model=Nexus6,version=22,locale=en,orientation=portrait \
62  --device model=Nexus6,version=21,locale=en,orientation=portrait
63