Skip to content

Commit 4adb9f7

Browse files
fix: Update Java-Vision IT test cases (#8248)
* fix: Update java-vision IT Test Case Results * fix: Update invalid IT test cases results * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: check TEST_ALL var for truthy value * chore: Cleanup kokoro build file * fix: Use different string from module_list * chore: Don't exclude when building * chore: Only exclude module when building Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent e4760da commit 4adb9f7

File tree

3 files changed

+54
-75
lines changed

3 files changed

+54
-75
lines changed

.kokoro/build.sh

+48-67
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,66 @@ source ${scriptDir}/common.sh
2727
mkdir -p ${HOME}/.m2
2828
cp settings.xml ${HOME}/.m2
2929

30+
excluded_modules=('CoverageAggregator' 'google-cloud-gapic-bom')
31+
32+
function generate_modified_modules_list() {
33+
# Find the files changed from when the PR branched to the last commit
34+
# Filter for java modules and get all the unique elements
35+
# grep returns 1 (error code) and exits the pipeline if there is no match
36+
# If there is no match, it will return true so the rest of the commands can run
37+
modified_files=$(git diff --name-only $KOKORO_GITHUB_PULL_REQUEST_COMMIT $KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH)
38+
printf "Modified files:\n%s\n" "${modified_files}"
39+
40+
# If root pom.xml is touched, run ITs on all the modules
41+
root_pom_modified=$(echo "${modified_files}" | grep -e '^pom.xml$' || true)
42+
if [[ -n $root_pom_modified ]]; then
43+
module_list=$excluded_modules_string
44+
echo "Testing the entire monorepo"
45+
else
46+
directories=$(echo "${modified_files}" | grep -e 'java-.*' || true)
47+
printf "Files in java modules:\n%s\n" "${directories}"
48+
if [[ -n $directories ]]; then
49+
directories=$(echo "${directories}" | cut -d '/' -f1 | sort -u)
50+
for directory in $directories
51+
do
52+
dir_list+=($directory)
53+
done
54+
# Combine each entry with a comma
55+
module_list=$(IFS=, ; echo "${dir_list[*]}")
56+
printf "Module List:\n%s\n" "${module_list}"
57+
fi
58+
fi
59+
}
60+
3061
function assign_modules_to_job() {
3162
modules=$(mvn help:evaluate -Dexpression=project.modules | grep '<.*>.*</.*>' | sed -e 's/<.*>\(.*\)<\/.*>/\1/g')
32-
module_list=()
63+
maven_module_list=()
3364
num=0
3465
for module in $modules
3566
do
3667
# Add 1 as JOB_NUMBER is 1-indexed instead of 0-indexed
3768
mod_num=$((num % NUM_JOBS + 1))
3869
if [[ ! "${excluded_modules[*]}" =~ $module ]] && [[ $mod_num -eq $JOB_NUMBER ]]; then
39-
module_list+=($module)
70+
maven_module_list+=($module)
4071
fi
4172
num=$((num + 1))
4273
done
43-
module_list=$(IFS=, ; echo "${module_list[*]}")
74+
module_list=$(IFS=, ; echo "${maven_module_list[*]}")
4475
}
4576

46-
excluded_modules=('CoverageAggregator' 'google-cloud-gapic-bom')
77+
function generate_excluded_module_string() {
78+
excluded_modules_list=()
79+
for excluded_module in "${excluded_modules[@]}"
80+
do
81+
excluded_modules_list+=("!${excluded_module}")
82+
done
83+
excluded_modules_string=$(IFS=, ; echo "${excluded_modules_list[*]}")
84+
}
4785

48-
mvn -B -pl "!google-cloud-gapic-bom,!CoverageAggregator" \
86+
# Generate excluded_modules_string
87+
generate_excluded_module_string
88+
89+
mvn -B -pl "${excluded_modules_string}" \
4990
-ntp \
5091
-DtrimStackTrace=false \
5192
-Dclirr.skip=true \
@@ -70,65 +111,9 @@ fi
70111
RETURN_CODE=0
71112

72113
case ${JOB_TYPE} in
73-
test)
74-
mvn test -B -ntp -Dclirr.skip=true -Denforcer.skip=true
75-
RETURN_CODE=$?
76-
;;
77-
lint)
78-
mvn com.coveo:fmt-maven-plugin:check -B -ntp
79-
RETURN_CODE=$?
80-
;;
81-
javadoc)
82-
mvn javadoc:javadoc javadoc:test-javadoc -B -ntp
83-
RETURN_CODE=$?
84-
;;
85114
integration)
86-
TEST_ALL=false
87-
# Find the files changed from when the PR branched to the last commit
88-
# Filter for java modules and get all the unique elements
89-
# grep returns 1 (error code) and exits the pipeline if there is no match
90-
# If there is no match, it will return true so the rest of the commands can run
91-
modified_files=$(git diff --name-only $KOKORO_GITHUB_PULL_REQUEST_COMMIT $KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH)
92-
printf "Modified files:\n%s\n" "${modified_files}"
93-
94-
# If root pom.xml is touched, run ITs on all the modules
95-
root_pom_modified=$(echo "${modified_files}" | grep -e '^pom.xml$' || true)
96-
if [[ -n $root_pom_modified ]]; then
97-
TEST_ALL=true
98-
echo "Testing the entire monorepo"
99-
else
100-
directories=$(echo "${modified_files}" | grep -e 'java-.*' || true)
101-
printf "Files in java modules:\n%s\n" "${directories}"
102-
if [[ -n $directories ]]; then
103-
directories=$(echo "${directories}" | cut -d '/' -f1 | sort -u)
104-
dir_list=()
105-
for directory in $directories
106-
do
107-
dir_list+=($directory)
108-
done
109-
# Combine each entry with a comma
110-
module_list=$(IFS=, ; echo "${dir_list[*]}")
111-
fi
112-
printf "Module List:\n%s\n" "${module_list}"
113-
fi
114-
115-
if [ ${TEST_ALL} ]; then
116-
mvn -B ${INTEGRATION_TEST_ARGS} \
117-
-ntp \
118-
-Penable-integration-tests \
119-
-DtrimStackTrace=false \
120-
-Dclirr.skip=true \
121-
-Denforcer.skip=true \
122-
-Dcheckstyle.skip=true \
123-
-Dflatten.skip=true \
124-
-Danimal.sniffer.skip=true \
125-
-Djacoco.skip=true \
126-
-DskipUnitTests=true \
127-
-fae \
128-
-T 1C \
129-
verify
130-
RETURN_CODE=$?
131-
elif [[ -n $module_list ]]; then
115+
generate_modified_modules_list
116+
if [[ -n $module_list ]]; then
132117
printf "Running Integration Tests for:\n%s\n" "${module_list}"
133118
mvn -B ${INTEGRATION_TEST_ARGS} \
134119
-pl "${module_list}" \
@@ -232,10 +217,6 @@ case ${JOB_TYPE} in
232217
echo "no sample pom.xml found - skipping sample tests"
233218
fi
234219
;;
235-
clirr)
236-
mvn -B -ntp -Denforcer.skip=true clirr:check
237-
RETURN_CODE=$?
238-
;;
239220
*)
240221
;;
241222
esac

java-vision/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ If you are using Maven without BOM, add this to your dependencies:
5050
If you are using Gradle 5.x or later, add this to your dependencies:
5151

5252
```Groovy
53-
implementation platform('com.google.cloud:libraries-bom:26.0.0')
53+
implementation platform('com.google.cloud:libraries-bom:26.1.0')
5454
5555
implementation 'com.google.cloud:google-cloud-vision'
5656
```
5757
If you are using Gradle without BOM, add this to your dependencies:
5858

5959
```Groovy
60-
implementation 'com.google.cloud:google-cloud-vision:3.0.1'
60+
implementation 'com.google.cloud:google-cloud-vision:3.1.0'
6161
```
6262

6363
If you are using SBT, add this to your dependencies:
6464

6565
```Scala
66-
libraryDependencies += "com.google.cloud" % "google-cloud-vision" % "3.0.1"
66+
libraryDependencies += "com.google.cloud" % "google-cloud-vision" % "3.1.0"
6767
```
6868

6969
## Authentication

java-vision/google-cloud-vision/src/test/java/com/google/cloud/vision/it/ITSystemTest.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ public void detectSafeSearchGcsTest() throws IOException {
473473
}
474474

475475
@Test
476-
public void detectWebEntitiesGcsTest() throws IOException {
476+
public void detectWebEntitiesGcsTest() {
477477
ImageSource imgSource =
478478
ImageSource.newBuilder().setGcsImageUri(SAMPLE_BUCKET + "landmark/pofa.jpg").build();
479479
Image img = Image.newBuilder().setSource(imgSource).build();
@@ -492,7 +492,7 @@ public void detectWebEntitiesGcsTest() throws IOException {
492492
actual.add(entity.getDescription());
493493
}
494494
}
495-
assertThat(actual).contains("The Palace Of Fine Arts");
495+
assertThat(actual).contains("Palace of Fine Arts");
496496
}
497497

498498
@Test
@@ -547,14 +547,12 @@ public void detectWebEntitiesIncludeGeoResultsGcsTest() {
547547
imageAnnotatorClient.batchAnnotateImages(ImmutableList.of(request));
548548
List<AnnotateImageResponse> responses = response.getResponsesList();
549549
List<String> actual = new ArrayList<>();
550-
System.out.println("WebEntitiesGeo SIZE");
551-
System.out.println(actual.size());
552550
for (AnnotateImageResponse imgResponse : responses) {
553551
for (WebDetection.WebEntity entity : imgResponse.getWebDetection().getWebEntitiesList()) {
554552
actual.add(entity.getDescription());
555553
}
556554
}
557-
assertThat(actual).contains("The Palace Of Fine Arts");
555+
assertThat(actual).contains("Palace of Fine Arts");
558556
}
559557

560558
@Test

0 commit comments

Comments
 (0)