Skip to content

Commit 94d1dd2

Browse files
fix: confirm owlbot-copy succeeeded to transfer java files (#2235)
* fix: confirm owlbot-copy succeeeded * use v2 of iam in IT * keep iam v1 and skip PP test * format fixes
1 parent 445477f commit 94d1dd2

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

library_generation/test/generate_library_integration_test.sh

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fi
8585
grep -v '^ *#' < "${proto_path_list}" | while IFS= read -r line; do
8686
proto_path=$(echo "$line" | cut -d " " -f 1)
8787
repository_path=$(echo "$line" | cut -d " " -f 2)
88-
is_handwritten=$(echo "$line" | cut -d " " -f 3)
88+
skip_postprocessing=$(echo "$line" | cut -d " " -f 3)
8989
# parse destination_path
9090
pushd "${output_folder}"
9191
echo "Checking out googleapis-gen repository..."
@@ -110,8 +110,8 @@ grep -v '^ *#' < "${proto_path_list}" | while IFS= read -r line; do
110110
service_yaml=${service_yaml},
111111
include_samples=${include_samples}."
112112
pushd "${output_folder}"
113-
if [ "${is_handwritten}" == "true" ]; then
114-
echo 'this is a handwritten library'
113+
if [ "${skip_postprocessing}" == "true" ]; then
114+
echo 'this library is not intended for postprocessing test'
115115
popd # output folder
116116
continue
117117
else
@@ -126,7 +126,7 @@ grep -v '^ *#' < "${proto_path_list}" | while IFS= read -r line; do
126126
# generate GAPIC client library
127127
echo "Generating library from ${proto_path}, to ${destination_path}..."
128128
generation_start=$(date "+%s")
129-
if [ $enable_postprocessing == "true" ]; then
129+
if [ "${enable_postprocessing}" == "true" ]; then
130130
if [[ "${repository_path}" == "null" ]]; then
131131
# we need a repository to compare the generated results with. Skip this
132132
# library
@@ -173,9 +173,14 @@ grep -v '^ *#' < "${proto_path_list}" | while IFS= read -r line; do
173173
echo "Generate library finished."
174174
echo "Compare generation result..."
175175
if [ $enable_postprocessing == "true" ]; then
176+
if [ $(find "${output_folder}/workspace" -name '*.java' | wc -l) -eq 0 ];
177+
then
178+
echo 'no java files found in workspace. This probably means that owlbot copy failed'
179+
exit 1
180+
fi
176181
echo "Checking out repository..."
177182
pushd "${target_folder}"
178-
SOURCE_DIFF_RESULT=0
183+
source_diff_result=0
179184
git diff \
180185
--ignore-space-at-eol \
181186
-r \
@@ -184,34 +189,34 @@ grep -v '^ *#' < "${proto_path_list}" | while IFS= read -r line; do
184189
':!*pom.xml' \
185190
':!*README.md' \
186191
':!*package-info.java' \
187-
|| SOURCE_DIFF_RESULT=$?
192+
|| source_diff_result=$?
188193

189-
POM_DIFF_RESULT=$(compare_poms "${target_folder}")
194+
pom_diff_result=$(compare_poms "${target_folder}")
190195
popd # target_folder
191-
if [[ ${SOURCE_DIFF_RESULT} == 0 ]] && [[ ${POM_DIFF_RESULT} == 0 ]] ; then
196+
if [[ ${source_diff_result} == 0 ]] && [[ ${pom_diff_result} == 0 ]] ; then
192197
echo "SUCCESS: Comparison finished, no difference is found."
193198
# Delete google-cloud-java to allow a sparse clone of the next library
194199
rm -rdf google-cloud-java
195-
elif [ ${SOURCE_DIFF_RESULT} != 0 ]; then
200+
elif [ ${source_diff_result} != 0 ]; then
196201
echo "FAILURE: Differences found in proto path: ${proto_path}."
197202
exit "${SOURCE_DIFF_RESULT}"
198-
elif [ ${POM_DIFF_RESULT} != 0 ]; then
203+
elif [ ${pom_diff_result} != 0 ]; then
199204
echo "FAILURE: Differences found in generated poms"
200-
exit "${POM_DIFF_RESULT}"
205+
exit "${pom_diff_result}"
201206
fi
202-
elif [ $enable_postprocessing == "false" ]; then
207+
elif [ "${enable_postprocessing}" == "false" ]; then
203208
# include gapic_metadata.json and package-info.java after
204209
# resolving https://github.com/googleapis/sdk-platform-java/issues/1986
205-
SOURCE_DIFF_RESULT=0
210+
source_diff_result=0
206211
diff --strip-trailing-cr -r "googleapis-gen/${proto_path}/${destination_path}" "${output_folder}/${destination_path}" \
207212
-x "*gradle*" \
208213
-x "gapic_metadata.json" \
209-
-x "package-info.java" || SOURCE_DIFF_RESULT=$?
210-
if [ ${SOURCE_DIFF_RESULT} == 0 ] ; then
214+
-x "package-info.java" || source_diff_result=$?
215+
if [ ${source_diff_result} == 0 ] ; then
211216
echo "SUCCESS: Comparison finished, no difference is found."
212217
else
213218
echo "FAILURE: Differences found in proto path: ${proto_path}."
214-
exit "${SOURCE_DIFF_RESULT}"
219+
exit "${source_diff_result}"
215220
fi
216221
fi
217222

library_generation/test/resources/proto_path_list.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is used in integration test against `generate_library.sh`.
22
# Format:
3-
# proto_path repository_path is_handwritten
3+
# proto_path repository_path skip_postprocessing_test
44
# google/bigtable/admin/v2 java-bigtable true
55
# google/bigtable/v2 java-bigtable true
66
google/cloud/apigeeconnect/v1 java-apigee-connect false
@@ -17,7 +17,8 @@ google/cloud/redis/v1 java-redis false
1717
google/cloud/redis/v1beta1 java-redis false
1818
# google/example/library/v1 google-cloud-example-library-v1-java null false
1919
google/devtools/containeranalysis/v1 java-containeranalysis false
20-
google/iam/v1 java-iam false
20+
google/iam/v1 java-iam true
21+
google/iam/v2 java-iam false
2122
google/iam/credentials/v1 java-iamcredentials false
2223
google/logging/v2 java-logging true
2324
google/pubsub/v1 java-pubsub true

0 commit comments

Comments
 (0)