Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ case ${JOB_TYPE} in
echo "Not running GraalVM checks -- No changes in relevant modules"
fi
;;
graalvm-nightly)
# The nightly jobs test a fixed list of modules. See graalvm_nightly_modules in common.sh.
generate_graalvm_nightly_modules_list
printf "Running nightly GraalVM checks for:\n%s\n" "${module_list}"
setup_cloud "$module_list"
install_modules "$module_list"
run_graalvm_tests "$module_list"
;;
graalvm-single)
if [[ "$(release_please_snapshot_pull_request)" == "true" ]]; then
echo "Not running GraalVM checks -- this is Release Please SNAPSHOT pull request."
Expand Down
32 changes: 32 additions & 0 deletions .kokoro/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,38 @@ function generate_graalvm_modules_list() {
module_list="${modules_assigned_list[*]}"
}

# Modules that the nightly GraalVM jobs build and test as native images.
#
# Generated modules share one generator and one build setup, so the nightly
# tests a few of them instead of all of them:
# - java-aiplatform (gRPC) and java-compute (REST) are the two largest generated
# modules. Their native image builds need the most memory.
# - java-ftp is a small REST client with google.longrunning operations, numeric
# enums and the Locations mixin. java-compute has none of these.
#
# The remaining modules contain handwritten code with integration tests. They
# have no GraalVM job of their own, so the nightly is their only regular native
# image run.
graalvm_nightly_modules=(
'java-aiplatform'
'java-compute'
'java-ftp'
'java-containeranalysis'
'java-dns'
'java-notification'
'java-resourcemanager'
'java-samples'
'java-translate'
)

# Assigns the variable 'module_list' to a comma-delimited list of the modules
# in graalvm_nightly_modules.
function generate_graalvm_nightly_modules_list() {
# Join array into comma-delimited string without subshell:
local IFS=,
module_list="${graalvm_nightly_modules[*]}"
}

function install_modules() {
if [ -z "$1" ]; then
retry_with_backoff 3 10 \
Expand Down
37 changes: 37 additions & 0 deletions .kokoro/common_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,42 @@ java-bigquery/google-cloud-bigquery/Bar.java"
unset TEST_MODIFIED_FILES
}

# Test that the nightly GraalVM jobs can test every module in
# graalvm_nightly_modules: each one is a module of the root pom.xml and has
# tests that the 'native' Maven profile runs (IT*.java or *ClientTest.java).
function test_graalvm_nightly_modules {
pushd "${scriptDir}/.." >/dev/null

if (( ${#graalvm_nightly_modules[@]} == 0 )); then
echo "graalvm_nightly_modules is empty"
exit 1
fi

local root_modules
root_modules=$(extract_pom_modules pom.xml)
local module
for module in "${graalvm_nightly_modules[@]}"; do
if [[ ! " ${root_modules} " == *" ${module} "* ]]; then
echo "graalvm_nightly_modules has ${module}, which is not a module of the root pom.xml"
exit 1
fi
if ! find "${module}" -path '*/src/test/java/*' \( -name 'IT*.java' -o -name '*ClientTest.java' \) -print -quit 2>/dev/null | grep -q .; then
echo "graalvm_nightly_modules has ${module}, which has no tests that the native profile runs"
exit 1
fi
Comment on lines +439 to +450

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using grep -q in a pipeline (find ... | grep -q .) when pipefail is enabled can lead to flaky test failures. As soon as grep -q finds a match, it exits successfully and closes the pipe. If find attempts to write further output, it will receive a SIGPIPE (exit status 141), causing the entire pipeline to fail with a non-zero exit code under pipefail.

Additionally, -quit is a GNU find extension and is not portable (e.g., it will fail on macOS/BSD find unless GNU find is explicitly installed).

To make this check robust, portable, and safe under pipefail, you can use command substitution instead of a pipeline to check if any matching files exist.

Suggested change
local root_modules
root_modules=$(extract_pom_modules pom.xml)
local module
for module in "${graalvm_nightly_modules[@]}"; do
if [[ ! " ${root_modules} " == *" ${module} "* ]]; then
echo "graalvm_nightly_modules has ${module}, which is not a module of the root pom.xml"
exit 1
fi
if ! find "${module}" -path '*/src/test/java/*' \( -name 'IT*.java' -o -name '*ClientTest.java' \) -print -quit 2>/dev/null | grep -q .; then
echo "graalvm_nightly_modules has ${module}, which has no tests that the native profile runs"
exit 1
fi
local root_modules
root_modules=$(extract_pom_modules pom.xml)
local module
local has_tests
for module in "${graalvm_nightly_modules[@]}"; do
if [[ ! " ${root_modules} " == *" ${module} "* ]]; then
echo "graalvm_nightly_modules has ${module}, which is not a module of the root pom.xml"
exit 1
fi
has_tests=$(find "${module}" -path '*/src/test/java/*' \( -name 'IT*.java' -o -name '*ClientTest.java' \) 2>/dev/null)
if [[ -z "${has_tests}" ]]; then
echo "graalvm_nightly_modules has ${module}, which has no tests that the native profile runs"
exit 1
fi

done

generate_graalvm_nightly_modules_list
local expected
expected=$(printf '%s,' "${graalvm_nightly_modules[@]}")
if [[ "${module_list}" != "${expected%,}" ]]; then
echo "generate_graalvm_nightly_modules_list failed: got ${module_list}"
exit 1
fi

popd >/dev/null
}

test_find_all_poms_with_versioned_dependency
test_update_pom_dependency
test_parse_pom_version
Expand All @@ -435,3 +471,4 @@ test_should_test_all_modules
test_is_module_modified
test_is_upstream_module_modified
test_generate_modified_modules_list
test_graalvm_nightly_modules
12 changes: 1 addition & 11 deletions .kokoro/nightly/graalvm-sub-jobs/native-a/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ env_vars: {

env_vars: {
key: "JOB_TYPE"
value: "graalvm"
value: "graalvm-nightly"
}

env_vars: {
Expand Down Expand Up @@ -53,16 +53,6 @@ env_vars: {
value: "cloud-java-ci-it-service-account, java-bigqueryconnection-samples-secrets"
}

env_vars: {
key: "NUM_JOBS"
value: "20"
}

env_vars: {
key: "TEST_ALL_MODULES"
value: "true"
}

before_action {
fetch_keystore {
keystore_resource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "JOB_NUMBER"
value: "1"
}
# Kokoro reads the build config that is named after the job. All settings are in
# common.cfg.
#
# Each nightly job has this one child job. Kokoro retries a child job that it
# could not build, including one that never started, from the parent job.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 1 addition & 11 deletions .kokoro/nightly/graalvm-sub-jobs/native-b/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env_vars: {

env_vars: {
key: "JOB_TYPE"
value: "graalvm"
value: "graalvm-nightly"
}

# TODO: remove this after we've migrated all tests and scripts
Expand All @@ -53,16 +53,6 @@ env_vars: {
value: "cloud-java-ci-it-service-account, java-bigqueryconnection-samples-secrets"
}

env_vars: {
key: "NUM_JOBS"
value: "20"
}

env_vars: {
key: "TEST_ALL_MODULES"
value: "true"
}

before_action {
fetch_keystore {
keystore_resource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "JOB_NUMBER"
value: "1"
}
# Kokoro reads the build config that is named after the job. All settings are in
# common.cfg.
#
# Each nightly job has this one child job. Kokoro retries a child job that it
# could not build, including one that never started, from the parent job.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading