zhangxinyao88 commented on code in PR #20020:
URL: https://github.com/apache/hudi/pull/20020#discussion_r4129626542


##########
packaging/hudi-gcp-bundle/pom.xml:
##########
@@ -114,6 +182,22 @@
                   <pattern>org.openjdk.jol.</pattern>
                   
<shadedPattern>org.apache.hudi.org.openjdk.jol.</shadedPattern>
                 </relocation>
+                <relocation>
+                  <pattern>com.google.common.</pattern>
+                  
<shadedPattern>org.apache.hudi.com.google.common.</shadedPattern>
+                </relocation>
+                <relocation>
+                  <pattern>com.google.thirdparty.</pattern>
+                  
<shadedPattern>org.apache.hudi.com.google.thirdparty.</shadedPattern>
+                </relocation>
+                <relocation>
+                  <pattern>com.google.protobuf.</pattern>
+                  
<shadedPattern>org.apache.hudi.gcp.shaded.com.google.protobuf.</shadedPattern>

Review Comment:
   > Could we use one prefix for all of them, or add a comment explaining why 
they differ?
   
   I added a comment. `hudi-io` already uses 
`org.apache.hudi.com.google.protobuf`, so the GCP Protobuf and gRPC copies use 
a separate namespace.



##########
packaging/hudi-gcp-bundle/src/test/java/org/apache/hudi/gcp/bundle/ITGcpBundleCompatibility.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.gcp.bundle;
+
+import com.google.cloud.NoCredentials;
+import com.google.cloud.bigquery.BigQueryOptions;
+import com.google.cloud.storage.StorageOptions;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class ITGcpBundleCompatibility {
+
+  private enum ClasspathOrder {
+    HOST_FIRST,
+    BUNDLE_FIRST
+  }
+
+  @Test
+  void testHostDependenciesBeforeBundle() throws Exception {
+    runSmokeTest(ClasspathOrder.HOST_FIRST);
+  }
+
+  @Test
+  void testBundleBeforeHostDependencies() throws Exception {
+    runSmokeTest(ClasspathOrder.BUNDLE_FIRST);
+  }
+
+  private static void runSmokeTest(ClasspathOrder order) throws Exception {
+    String bundleJar = System.getProperty("gcp.bundle.jar");
+    String testClasses = System.getProperty("gcp.test.classes");
+    String hostProtobuf = System.getProperty("host.protobuf.jar");
+    String hostGuava = System.getProperty("host.guava.jar");
+    String hostJacksonCore = System.getProperty("host.jackson.core.jar");
+
+    List<String> orderedClasspath = new ArrayList<>();
+    orderedClasspath.add(testClasses);
+    if (order == ClasspathOrder.HOST_FIRST) {
+      orderedClasspath.add(hostProtobuf);
+      orderedClasspath.add(hostGuava);
+    }
+    orderedClasspath.add(bundleJar);
+    if (order == ClasspathOrder.BUNDLE_FIRST) {
+      orderedClasspath.add(hostProtobuf);
+      orderedClasspath.add(hostGuava);
+    }
+    orderedClasspath.add(hostJacksonCore);
+
+    Process process = new ProcessBuilder(
+        new File(System.getProperty("java.home"), 
"bin/java").getAbsolutePath(),
+        "-cp",
+        String.join(File.pathSeparator, orderedClasspath),
+        ITGcpBundleCompatibility.class.getName(),
+        "smoke")
+        .inheritIO()
+        .start();
+    assertEquals(0, process.waitFor(), "GCP bundle compatibility smoke test 
failed");
+  }
+
+  public static void main(String[] args) throws Exception {

Review Comment:
   > Could each go into its own small helper, like `verifyShadedProtobuf()` and 
`verifyHostGuava()`, so a failure points straight at the dependency that broke?
   
   I split the checks into separate helpers.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to