Skip to content

Commit b1d47e2

Browse files
chingor13suztomo
authored andcommitted
build: split integration tests for split repositories (googleapis#11886)
Adds split integration and graalvm tests for the logging submodule and skips running integration tests and graalvm tests in the main integration/graalvm Kokoro jobs. Changes: * The primary "Integration" and "GraalVM" tests will not run the tests from the migrated repositories (added to an exclusion list) * The migrated repositories will have their own separate integration & graalvm tests * These tests will short-circuit "success" if the module hasn't been touched (determined based on whether that folder was touched)
1 parent 43cc3eb commit b1d47e2

File tree

6 files changed

+199
-33
lines changed

6 files changed

+199
-33
lines changed

.kokoro/build.sh

Lines changed: 91 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,17 @@ if [ -f "${KOKORO_GFILE_DIR}/secret_manager/java-bigqueryconnection-samples-secr
3333
source "${KOKORO_GFILE_DIR}/secret_manager/java-bigqueryconnection-samples-secrets"
3434
fi
3535

36-
if [[ -n "${BUILD_SUBDIR}" ]]
37-
then
38-
echo "Compiling and building all modules for ${BUILD_SUBDIR}"
39-
mvn clean install \
40-
-DskipTests \
41-
-Dclirr.skip \
42-
-Dflatten.skip \
43-
-Dcheckstyle.skip \
44-
-Djacoco.skip \
45-
-Denforcer.skip \
46-
--also-make \
47-
--projects "${BUILD_SUBDIR}"
48-
echo "Running in subdir: ${BUILD_SUBDIR}"
49-
pushd "${BUILD_SUBDIR}"
50-
fi
51-
5236
RETURN_CODE=0
5337

5438
case ${JOB_TYPE} in
5539
test)
40+
if [[ -n "${BUILD_SUBDIR}" ]]
41+
then
42+
echo "Compiling and building all modules for ${BUILD_SUBDIR}"
43+
install_modules "${BUILD_SUBDIR}"
44+
echo "Running in subdir: ${BUILD_SUBDIR}"
45+
pushd "${BUILD_SUBDIR}"
46+
fi
5647
echo "SUREFIRE_JVM_OPT: ${SUREFIRE_JVM_OPT}"
5748
retry_with_backoff 3 10 \
5849
mvn test \
@@ -67,6 +58,12 @@ case ${JOB_TYPE} in
6758
-Dmaven.wagon.http.retryHandler.count=5 \
6859
-T 1C ${SUREFIRE_JVM_OPT}
6960
RETURN_CODE=$?
61+
62+
if [[ -n "${BUILD_SUBDIR}" ]]
63+
then
64+
echo "restoring directory"
65+
popd
66+
fi
7067
echo "Finished running unit tests"
7168
;;
7269
integration)
@@ -85,6 +82,41 @@ case ${JOB_TYPE} in
8582
echo "No Integration Tests to run"
8683
fi
8784
;;
85+
integration-single)
86+
generate_modified_modules_list false
87+
if [[ "$(release_please_snapshot_pull_request)" == "true" ]]; then
88+
echo "Not running integration checks -- this is Release Please SNAPSHOT pull request."
89+
elif [[ ! " ${modified_module_list[*]} " =~ " ${BUILD_SUBDIR} " ]]; then
90+
echo "${BUILD_SUBDIR} not modified, skipping split integration test"
91+
else
92+
echo "${BUILD_SUBDIR} modified, running split integration test"
93+
echo "Compiling and building all modules for ${BUILD_SUBDIR}"
94+
install_modules "${BUILD_SUBDIR}"
95+
echo "Running in subdir: ${BUILD_SUBDIR}"
96+
pushd "${BUILD_SUBDIR}"
97+
echo "SUREFIRE_JVM_OPT: ${SUREFIRE_JVM_OPT}"
98+
echo "INTEGRATION_TEST_ARGS: ${INTEGRATION_TEST_ARGS}"
99+
mvn verify -Penable-integration-tests \
100+
${INTEGRATION_TEST_ARGS} \
101+
-B -ntp -fae \
102+
-DtrimStackTrace=false \
103+
-Dclirr.skip=true \
104+
-Denforcer.skip=true \
105+
-Dorg.slf4j.simpleLogger.showDateTime=true \
106+
-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
107+
-Dcheckstyle.skip=true \
108+
-Dflatten.skip=true \
109+
-Danimal.sniffer.skip=true \
110+
-Djacoco.skip=true \
111+
-DskipUnitTests=true \
112+
-Dmaven.wagon.http.retryHandler.count=5 \
113+
-T 1C ${SUREFIRE_JVM_OPT}
114+
115+
RETURN_CODE=$?
116+
popd
117+
printf "Finished integration tests for modules:\n%s\n" "${BUILD_SUBDIR}"
118+
fi
119+
;;
88120
graalvm-presubmit)
89121
generate_graalvm_presubmit_modules_list
90122
if [[ "$(release_please_snapshot_pull_request)" == "true" ]]; then
@@ -109,7 +141,44 @@ case ${JOB_TYPE} in
109141
echo "Not running GraalVM checks -- No changes in relevant modules"
110142
fi
111143
;;
144+
graalvm-single)
145+
generate_modified_modules_list false
146+
if [[ "$(release_please_snapshot_pull_request)" == "true" ]]; then
147+
echo "Not running GraalVM checks -- this is Release Please SNAPSHOT pull request."
148+
elif [[ ! " ${modified_module_list[*]} " =~ " ${BUILD_SUBDIR} " ]]; then
149+
echo "${BUILD_SUBDIR} not modified, skipping split GraalVM test"
150+
else
151+
echo "${BUILD_SUBDIR} modified, running split GraalVM test"
152+
echo "Compiling and building all modules for ${BUILD_SUBDIR}"
153+
install_modules "${BUILD_SUBDIR}"
154+
echo "Running in subdir: ${BUILD_SUBDIR}"
155+
pushd "${BUILD_SUBDIR}"
156+
echo "INTEGRATION_TEST_ARGS: ${INTEGRATION_TEST_ARGS}"
157+
mvn test -Pnative \
158+
${INTEGRATION_TEST_ARGS} \
159+
-B -ntp -fae \
160+
-DtrimStackTrace=false \
161+
-Dclirr.skip=true \
162+
-Denforcer.skip=true \
163+
-Dorg.slf4j.simpleLogger.showDateTime=true \
164+
-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
165+
-Dcheckstyle.skip=true \
166+
-Dflatten.skip=true \
167+
-Danimal.sniffer.skip=true
168+
169+
RETURN_CODE=$?
170+
popd
171+
printf "Finished GraalVM ITs for modules:\n%s\n" "${BUILD_SUBDIR}"
172+
fi
173+
;;
112174
lint)
175+
if [[ -n "${BUILD_SUBDIR}" ]]
176+
then
177+
echo "Compiling and building all modules for ${BUILD_SUBDIR}"
178+
install_modules "${BUILD_SUBDIR}"
179+
echo "Running in subdir: ${BUILD_SUBDIR}"
180+
pushd "${BUILD_SUBDIR}"
181+
fi
113182
if [ -n "${BASE_SHA}" ] && [ -n "${HEAD_SHA}" ]; then
114183
changed_file_list=$(git diff --name-only "${BASE_SHA}" "${HEAD_SHA}")
115184
echo "${changed_file_list}"
@@ -137,17 +206,17 @@ case ${JOB_TYPE} in
137206
-T 1.5C \
138207
com.spotify.fmt:fmt-maven-plugin:check
139208
mvn -B -ntp checkstyle:check@checkstyle
209+
210+
if [[ -n "${BUILD_SUBDIR}" ]]
211+
then
212+
echo "restoring directory"
213+
popd
214+
fi
140215
;;
141216
*) ;;
142217

143218
esac
144219

145-
if [[ -n "${BUILD_SUBDIR}" ]]
146-
then
147-
echo "restoring directory"
148-
popd
149-
fi
150-
151220
if [ "${REPORT_COVERAGE}" == "true" ]; then
152221
bash ${KOKORO_GFILE_DIR}/codecov.sh
153222
fi

.kokoro/common.sh

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
excluded_modules=('gapic-libraries-bom' 'google-cloud-jar-parent' 'google-cloud-pom-parent' 'java-vertexai')
16+
excluded_modules=(
17+
'gapic-libraries-bom'
18+
'google-cloud-jar-parent'
19+
'google-cloud-pom-parent'
20+
'java-vertexai'
21+
'java-logging'
22+
)
1723

1824
function retry_with_backoff {
1925
attempts_left=$1
@@ -56,10 +62,8 @@ function retry_with_backoff {
5662
# Given a folder containing a maven multi-module, assign the variable 'submodules' to a
5763
# comma-delimited list of <folder>/<submodule>.
5864
function parse_submodules() {
59-
pushd "$1" >/dev/null
60-
6165
submodules_array=()
62-
mvn_submodules=$(mvn help:evaluate -Dexpression=project.modules)
66+
mvn_submodules=$(mvn help:evaluate -Dexpression=project.modules -pl "$1")
6367
if mvn_submodules=$(grep '<.*>.*</.*>' <<< "$mvn_submodules"); then
6468
mvn_submodules=$(sed -e 's/<.*>\(.*\)<\/.*>/\1/g' <<< "$mvn_submodules")
6569
for submodule in $mvn_submodules; do
@@ -77,8 +81,6 @@ function parse_submodules() {
7781
echo "${submodules_array[*]}"
7882
)
7983
export submodules
80-
81-
popd >/dev/null
8284
}
8385

8486
# Given a list of folders containing maven multi-modules, assign the variable 'all_submodules' to a
@@ -155,6 +157,13 @@ function release_please_snapshot_pull_request() {
155157
fi
156158
}
157159

160+
# Sets bash variables for maven_modules and modified_module_list
161+
# maven_modules is the list of all maven submodules of the root pom
162+
# modified_module_list is the subset of maven_modules that have been touched
163+
# in the current pull request
164+
#
165+
# The first positional argument is a value true/false. If true (default), then
166+
# exclude modules from the global exclusion list.
158167
function generate_modified_modules_list() {
159168
# Find the files changed from when the PR branched to the last commit
160169
# Filter for java modules and get all the unique elements
@@ -167,11 +176,19 @@ function generate_modified_modules_list() {
167176
# Generate the list of valid maven modules
168177
maven_modules_list=$(mvn help:evaluate -Dexpression=project.modules | grep '<.*>.*</.*>' | sed -e 's/<.*>\(.*\)<\/.*>/\1/g')
169178
maven_modules=()
170-
for module in $maven_modules_list; do
171-
if [[ ! " ${excluded_modules[*]} " =~ " ${module} " ]]; then
172-
maven_modules+=("${module}")
173-
fi
174-
done
179+
180+
# If the first argument is "true" (default), then use the module exclusion list
181+
use_exclusion_list=${1:-true}
182+
if [[ "${use_exclusion_list}" == "true" ]]; then
183+
echo "Excluding modules from the global exclusion list"
184+
for module in $maven_modules_list; do
185+
if [[ ! " ${excluded_modules[*]} " =~ " ${module} " ]]; then
186+
maven_modules+=("${module}")
187+
fi
188+
done
189+
else
190+
maven_modules=(${maven_modules_list[*]})
191+
fi
175192

176193
modified_module_list=()
177194
# If either parent pom.xml is touched, run ITs on all the modules

.kokoro/dependencies.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export MAVEN_OPTS=$(determineMavenOpts)
5151

5252
if [[ -n "${BUILD_SUBDIR}" ]]
5353
then
54+
echo "Compiling and building all modules for ${BUILD_SUBDIR}"
55+
install_modules "${BUILD_SUBDIR}"
5456
echo "Running in subdir: ${BUILD_SUBDIR}"
5557
pushd "${BUILD_SUBDIR}"
5658
fi
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
env_vars: {
5+
key: "TRAMPOLINE_IMAGE"
6+
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.56.1"
7+
}
8+
9+
env_vars: {
10+
key: "JOB_TYPE"
11+
value: "graalvm-single"
12+
}
13+
14+
# TODO: remove this after we've migrated all tests and scripts
15+
env_vars: {
16+
key: "GCLOUD_PROJECT"
17+
value: "cloud-java-ci-test"
18+
}
19+
20+
env_vars: {
21+
key: "GOOGLE_CLOUD_PROJECT"
22+
value: "cloud-java-ci-test"
23+
}
24+
25+
env_vars: {
26+
key: "GOOGLE_APPLICATION_CREDENTIALS"
27+
value: "secret_manager/cloud-java-ci-it-service-account"
28+
}
29+
30+
env_vars: {
31+
key: "SECRET_MANAGER_KEYS"
32+
value: "cloud-java-ci-it-service-account, java-bigqueryconnection-samples-secrets"
33+
}
34+
35+
env_vars: {
36+
key: "BUILD_SUBDIR"
37+
value: "java-logging"
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
env_vars: {
5+
key: "TRAMPOLINE_IMAGE"
6+
value: "gcr.io/cloud-devrel-kokoro-resources/java11"
7+
}
8+
9+
env_vars: {
10+
key: "JOB_TYPE"
11+
value: "integration-single"
12+
}
13+
14+
# TODO: remove this after we've migrated all tests and scripts
15+
env_vars: {
16+
key: "GCLOUD_PROJECT"
17+
value: "cloud-java-ci-test"
18+
}
19+
20+
env_vars: {
21+
key: "GOOGLE_CLOUD_PROJECT"
22+
value: "cloud-java-ci-test"
23+
}
24+
25+
env_vars: {
26+
key: "GOOGLE_APPLICATION_CREDENTIALS"
27+
value: "secret_manager/cloud-java-ci-it-service-account"
28+
}
29+
30+
env_vars: {
31+
key: "SECRET_MANAGER_KEYS"
32+
value: "cloud-java-ci-it-service-account, java-bigqueryconnection-samples-secrets"
33+
}
34+
35+
env_vars: {
36+
key: "BUILD_SUBDIR"
37+
value: "java-logging"
38+
}

renovate.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
".kokoro/nightly/graalvm-native*.cfg",
3939
".kokoro/nightly/graalvm-sub-jobs/native*/common.cfg",
4040
".kokoro/presubmit/graalvm-native*.cfg",
41+
".kokoro/presubmit/*-graalvm-native-presubmit.cfg",
4142
"owl-bot-postprocessor/synthtool/gcp/templates/java-library/.kokoro/presubmit/graalvm-native*.cfg",
4243
".github/workflows/ci.yaml",
4344
".github/workflows/generated_files_sync.yaml",
@@ -49,6 +50,7 @@
4950
"managerFilePatterns": [
5051
"/^.kokoro/nightly/graalvm-native.*.cfg$/",
5152
"/^.kokoro/presubmit/graalvm-native.*.cfg$/",
53+
"/^.kokoro/presubmit/*-graalvm-native-presubmit.cfg$/",
5254
"/^.kokoro/nightly/graalvm-sub-jobs/native.*/common.cfg$/",
5355
"/^owl-bot-postprocessor/synthtool/gcp/templates/java-library/.kokoro/presubmit/graalvm-native.*.cfg$/"
5456
],

0 commit comments

Comments
 (0)