Skip to content

Commit

Permalink
mobile/ci: Deflake Android tests (envoyproxy#30161)
Browse files Browse the repository at this point in the history
Signed-off-by: Fredy Wijaya <[email protected]>
  • Loading branch information
fredyw authored Oct 13, 2023
1 parent 1a9e559 commit 6ef1bb4
Show file tree
Hide file tree
Showing 14 changed files with 337 additions and 162 deletions.
79 changes: 20 additions & 59 deletions .github/workflows/mobile-android_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,76 +21,37 @@ jobs:
permissions:
contents: read

kotlintestsmac:
javatestslinux:
if: ${{ needs.env.outputs.mobile_android_tests == 'true' }}
needs: env
permissions:
contents: read
packages: read
# revert to //test/kotlin/... once fixed
# https://github.com/envoyproxy/envoy-mobile/issues/1932
name: kotlin_tests_mac
runs-on: macos-12
name: java_tests_linux
runs-on: ${{ needs.env.outputs.agent_ubuntu }}
timeout-minutes: 90
steps:
- name: Pre-cleanup
# Using the defaults in
# https://github.com/envoyproxy/toolshed/blob/main/gh-actions/diskspace/action.yml.
uses: envoyproxy/toolshed/gh-actions/[email protected]
- uses: actions/checkout@v4
- name: 'Java setup'
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0
with:
java-version: '8'
java-package: jdk
architecture: x64
distribution: zulu
- name: 'Install dependencies'
run: |
cd mobile
./ci/mac_ci_setup.sh
- name: 'Run Kotlin library tests'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd mobile
./bazelw test \
--build_tests_only \
--config=mobile-remote-ci-macos \
--define=signal_trace=disabled \
//test/kotlin/io/...
javatestsmac:
if: ${{ needs.env.outputs.mobile_android_tests == 'true' }}
needs: env
permissions:
contents: read
packages: read
name: java_tests_mac
runs-on: macos-12
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
- name: 'Java setup'
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0
with:
java-version: '8'
java-package: jdk
architecture: x64
distribution: zulu
- name: 'Install dependencies'
run: |
cd mobile
./ci/mac_ci_setup.sh
- name: 'Run Java library tests'
- name: Add safe directory
run: git config --global --add safe.directory /__w/envoy/envoy
- name: 'Run Kotlin library integration tests'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CC: /opt/llvm/bin/clang
CXX: /opt/llvm/bin/clang++
run: |
cd mobile
./bazelw test \
--build_tests_only \
--config test-android \
--define envoy_mobile_listener=enabled \
--config=mobile-remote-ci-macos \
--define=signal_trace=disabled \
--define=system-helper=android \
//test/java/...
docker run --volume="${PWD}:/source" --workdir="/source/mobile" \
-e GITHUB_TOKEN -e CC -e CXX ${{ needs.env.outputs.build_image_ubuntu_mobile }} \
./bazelw test \
--build_tests_only \
--config=test-android \
--config=mobile-remote-ci \
--define=signal_trace=disabled \
//test/java/...
kotlintestslinux:
if: ${{ needs.env.outputs.mobile_android_tests == 'true' }}
Expand Down
10 changes: 4 additions & 6 deletions mobile/bazel/kotlin_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ def jvm_flags(lib_name):

# A basic macro to make it easier to declare and run kotlin tests which depend on a JNI lib
# This will create the native .so binary (for linux) and a .jnilib (for macOS) look up
def envoy_mobile_jni_kt_test(name, srcs, native_deps = [], deps = [], repository = "", exec_properties = {}):
lib_name = native_lib_name(native_deps[0])[3:]
def envoy_mobile_jni_kt_test(name, srcs, native_lib_name, native_deps = [], deps = [], repository = "", exec_properties = {}):
_internal_kt_test(
name,
srcs,
deps,
data = native_deps,
jvm_flags = jvm_flags(lib_name),
jvm_flags = jvm_flags(native_lib_name),
repository = repository,
exec_properties = exec_properties,
)
Expand All @@ -76,8 +75,7 @@ def envoy_mobile_kt_test(name, srcs, deps = [], repository = "", exec_properties
_internal_kt_test(name, srcs, deps, repository = repository, exec_properties = exec_properties)

# A basic macro to run android based (robolectric) tests with native dependencies
def envoy_mobile_android_test(name, srcs, deps = [], native_deps = [], repository = "", exec_properties = {}):
lib_name = native_lib_name(native_deps[0])[3:]
def envoy_mobile_android_test(name, srcs, native_lib_name, deps = [], native_deps = [], repository = "", exec_properties = {}):
android_library(
name = name + "_test_lib",
custom_package = "io.envoyproxy.envoymobile.test",
Expand Down Expand Up @@ -114,6 +112,6 @@ def envoy_mobile_android_test(name, srcs, deps = [], native_deps = [], repositor
manifest = repository + "//bazel:test_manifest.xml",
custom_package = "io.envoyproxy.envoymobile.tests",
test_class = "io.envoyproxy.envoymobile.bazel.EnvoyMobileTestSuite",
jvm_flags = jvm_flags(lib_name),
jvm_flags = jvm_flags(native_lib_name),
exec_properties = exec_properties,
)
36 changes: 28 additions & 8 deletions mobile/test/java/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/kotlin/io/envoyproxy/envoymobile:envoy_lib",
],
Expand All @@ -34,8 +39,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/kotlin/io/envoyproxy/envoymobile:envoy_lib",
"//test/java/io/envoyproxy/envoymobile/engine/testing",
Expand All @@ -53,8 +63,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/kotlin/io/envoyproxy/envoymobile:envoy_lib",
"//test/java/io/envoyproxy/envoymobile/engine/testing",
Expand All @@ -72,8 +87,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/kotlin/io/envoyproxy/envoymobile:envoy_lib",
"//test/java/io/envoyproxy/envoymobile/engine/testing",
Expand Down
18 changes: 14 additions & 4 deletions mobile/test/java/io/envoyproxy/envoymobile/engine/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ envoy_mobile_jni_kt_test(
],
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/kotlin/io/envoyproxy/envoymobile:envoy_interfaces_lib",
"//test/java/io/envoyproxy/envoymobile/engine/testing",
Expand Down Expand Up @@ -44,8 +49,13 @@ envoy_mobile_android_test(
],
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/java/io/envoyproxy/envoymobile/engine:envoy_base_engine_lib",
"//library/java/io/envoyproxy/envoymobile/engine:envoy_engine_lib",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
":testing",
"//library/kotlin/io/envoyproxy/envoymobile:envoy_lib",
Expand Down
9 changes: 7 additions & 2 deletions mobile/test/java/io/envoyproxy/envoymobile/utilities/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ envoy_mobile_android_test(
],
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/java/io/envoyproxy/envoymobile/engine:envoy_base_engine_lib",
"//library/java/io/envoyproxy/envoymobile/engine:envoy_engine_lib",
Expand Down
36 changes: 28 additions & 8 deletions mobile/test/java/org/chromium/net/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/java/io/envoyproxy/envoymobile/engine:envoy_base_engine_lib",
"//library/java/io/envoyproxy/envoymobile/engine:envoy_engine_lib",
Expand All @@ -48,8 +53,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/java/io/envoyproxy/envoymobile/engine:envoy_base_engine_lib",
"//library/java/io/envoyproxy/envoymobile/engine:envoy_engine_lib",
Expand All @@ -72,8 +82,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/java/io/envoyproxy/envoymobile/engine:envoy_base_engine_lib",
"//library/java/io/envoyproxy/envoymobile/engine:envoy_engine_lib",
Expand All @@ -96,8 +111,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/java/io/envoyproxy/envoymobile/engine:envoy_base_engine_lib",
"//library/java/io/envoyproxy/envoymobile/engine:envoy_engine_lib",
Expand Down
9 changes: 7 additions & 2 deletions mobile/test/java/org/chromium/net/impl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
"//library/java/io/envoyproxy/envoymobile/engine:envoy_base_engine_lib",
"//library/java/io/envoyproxy/envoymobile/engine:envoy_engine_lib",
Expand Down
29 changes: 22 additions & 7 deletions mobile/test/java/org/chromium/net/testing/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@envoy//bazel:envoy_build_system.bzl", "envoy_package")
load("@build_bazel_rules_android//android:rules.bzl", "android_library")
load("@envoy//bazel:envoy_build_system.bzl", "envoy_package")
load("@envoy_mobile//bazel:kotlin_test.bzl", "envoy_mobile_android_test")

licenses(["notice"]) # Apache 2
Expand Down Expand Up @@ -62,8 +62,13 @@ envoy_mobile_android_test(
],
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
":testing",
"//library/java/io/envoyproxy/envoymobile/engine:envoy_base_engine_lib",
Expand All @@ -85,8 +90,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
":testing",
"//library/kotlin/io/envoyproxy/envoymobile:envoy_lib",
Expand All @@ -104,8 +114,13 @@ envoy_mobile_android_test(
},
native_deps = [
"//test/common/jni:libenvoy_jni_with_test_extensions.so",
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
] + select({
"@platforms//os:macos": [
"//test/common/jni:libenvoy_jni_with_test_extensions_jnilib",
],
"//conditions:default": [],
}),
native_lib_name = "envoy_jni_with_test_extensions",
deps = [
":testing",
"//library/kotlin/io/envoyproxy/envoymobile:envoy_lib",
Expand Down
Loading

0 comments on commit 6ef1bb4

Please sign in to comment.