From 381125a3a91ea1737a254eb9c2a259203fb2a62a Mon Sep 17 00:00:00 2001
From: Esun Kim <veblush@google.com>
Date: Thu, 11 Apr 2024 11:03:46 -0700
Subject: [PATCH] [Test] Fix protobuf-at-head test (#36332)

When updating protobuf, ensure upb and utf8_range versions match the updated protobuf version.

Internal b/332754839

Closes #36332

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36332 from veblush:fix-protobuf-at-head e13e7bc57a9e563b4a99f6dfc7ec2e3768865f34
PiperOrigin-RevId: 623878964
---
 .../linux/grpc_build_submodule_at_head.sh          | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/internal_ci/linux/grpc_build_submodule_at_head.sh b/tools/internal_ci/linux/grpc_build_submodule_at_head.sh
index 365bcf1284d..8450499c272 100755
--- a/tools/internal_ci/linux/grpc_build_submodule_at_head.sh
+++ b/tools/internal_ci/linux/grpc_build_submodule_at_head.sh
@@ -69,9 +69,21 @@ then
   src/abseil-cpp/preprocessed_builds.yaml.gen.py
 fi
 
+if [ "${SUBMODULE_NAME}" == "protobuf" ]
+then
+  # update upb
+  rm -rf third_party/upb/upb
+  cp -r third_party/protobuf/upb third_party/upb
+  tools/codegen/core/gen_upb_api.sh
+  # update utf8_range
+  rm -rf third_party/utf8_range
+  cp -r third_party/protobuf/third_party/utf8_range third_party/utf8_range/
+fi
+
 tools/buildgen/generate_projects.sh
 
 # commit so that changes are passed to Docker
-git -c user.name='foo' -c user.email='foo@google.com' commit -a -m 'Update submodule' --allow-empty
+git add -A
+git -c user.name='foo' -c user.email='foo@google.com' commit -m 'Update submodule' --allow-empty
 
 tools/run_tests/run_tests_matrix.py -f linux --exclude c sanity basictests_arm64 openssl dbg --inner_jobs 16 -j 2 --internal_ci --build_only