This is an automated email from the ASF dual-hosted git repository.

xuba pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b23e5363 [AMORO-3853] Stabilize continuous optimizing tests on Java 
17 (#4142)
7b23e5363 is described below

commit 7b23e5363642c49fdc8f4f355dbd2464e9d84f05
Author: Xu Bai <[email protected]>
AuthorDate: Thu Apr 2 15:38:37 2026 +0800

    [AMORO-3853] Stabilize continuous optimizing tests on Java 17 (#4142)
    
    * Stabilize continuous optimizing tests on Java 17
    
    * Remove unnecessary truncation of nanoseconds in RandomRecordGenerator
    
    * spotless
---
 .../optimizing/flow/RandomRecordGenerator.java      | 21 +++++++++++++++------
 .../flow/TestKeyedContinuousOptimizing.java         |  4 +++-
 .../flow/TestUnKeyedContinuousOptimizing.java       |  4 +++-
 amoro-common/pom.xml                                | 12 ++++++++++++
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git 
a/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/RandomRecordGenerator.java
 
b/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/RandomRecordGenerator.java
index af3f3fbbb..85a1a0c33 100644
--- 
a/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/RandomRecordGenerator.java
+++ 
b/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/RandomRecordGenerator.java
@@ -33,6 +33,7 @@ import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -45,6 +46,12 @@ import java.util.stream.Collectors;
 
 public class RandomRecordGenerator {
 
+  private static final LocalDate BASE_DATE = LocalDate.of(2026, 1, 1);
+  private static final LocalDateTime BASE_LOCAL_DATE_TIME =
+      LocalDateTime.of(2026, 1, 1, 12, 0, 0, 123_456_000);
+  private static final OffsetDateTime BASE_OFFSET_DATE_TIME =
+      OffsetDateTime.of(BASE_LOCAL_DATE_TIME, ZoneOffset.UTC);
+
   private final Random random;
 
   private final Schema primary;
@@ -120,7 +127,6 @@ public class RandomRecordGenerator {
 
   public Record randomRecord(int primaryValue) {
     Record record = GenericRecord.create(schema);
-    Random random = new Random();
     List<Types.NestedField> columns = schema.columns();
     Map<Integer, Object> partitionValue = null;
     if (partitionValues != null) {
@@ -148,7 +154,6 @@ public class RandomRecordGenerator {
 
   public Record randomRecord() {
     Record record = GenericRecord.create(schema);
-    Random random = new Random();
     List<Types.NestedField> columns = schema.columns();
     Map<Integer, Object> partitionValue = null;
     if (partitionValues != null) {
@@ -170,7 +175,7 @@ public class RandomRecordGenerator {
       case INTEGER:
         return random.nextInt();
       case STRING:
-        return UUID.randomUUID().toString();
+        return new UUID(random.nextLong(), random.nextLong()).toString();
       case LONG:
         return random.nextLong();
       case FLOAT:
@@ -180,13 +185,17 @@ public class RandomRecordGenerator {
       case BOOLEAN:
         return random.nextBoolean();
       case DATE:
-        return LocalDate.now().minusDays(random.nextInt(10000));
+        return BASE_DATE.minusDays(random.nextInt(10000));
       case TIMESTAMP:
         Types.TimestampType timestampType = (Types.TimestampType) type;
         if (timestampType.shouldAdjustToUTC()) {
-          return OffsetDateTime.now().minusDays(random.nextInt(10000));
+          return BASE_OFFSET_DATE_TIME
+              .minusDays(random.nextInt(10000))
+              .plusNanos(random.nextInt(1_000_000) * 1_000L);
         } else {
-          return LocalDateTime.now().minusDays(random.nextInt(10000));
+          return BASE_LOCAL_DATE_TIME
+              .minusDays(random.nextInt(10000))
+              .plusNanos(random.nextInt(1_000_000) * 1_000L);
         }
       case DECIMAL:
         Types.DecimalType decimalType = (Types.DecimalType) type;
diff --git 
a/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/TestKeyedContinuousOptimizing.java
 
b/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/TestKeyedContinuousOptimizing.java
index a1f3c2c20..56ecae7f1 100644
--- 
a/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/TestKeyedContinuousOptimizing.java
+++ 
b/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/TestKeyedContinuousOptimizing.java
@@ -48,6 +48,8 @@ import java.util.List;
 @RunWith(Parameterized.class)
 public class TestKeyedContinuousOptimizing extends TableTestBase {
 
+  private static final long DATA_SEED = 1L;
+
   @ClassRule public static TestHMS TEST_HMS = new TestHMS();
 
   public TestKeyedContinuousOptimizing(
@@ -102,7 +104,7 @@ public class TestKeyedContinuousOptimizing extends 
TableTestBase {
             partitionCount,
             primaryUpperBound,
             writeTargetFileSize,
-            null);
+            DATA_SEED);
 
     // init checker
     DataConcurrencyChecker dataConcurrencyChecker = new 
DataConcurrencyChecker(view);
diff --git 
a/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/TestUnKeyedContinuousOptimizing.java
 
b/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/TestUnKeyedContinuousOptimizing.java
index fe5e30e56..434231293 100644
--- 
a/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/TestUnKeyedContinuousOptimizing.java
+++ 
b/amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/TestUnKeyedContinuousOptimizing.java
@@ -48,6 +48,8 @@ import java.util.List;
 @RunWith(Parameterized.class)
 public class TestUnKeyedContinuousOptimizing extends TableTestBase {
 
+  private static final long DATA_SEED = 1L;
+
   @ClassRule public static TestHMS TEST_HMS = new TestHMS();
 
   public TestUnKeyedContinuousOptimizing(
@@ -97,7 +99,7 @@ public class TestUnKeyedContinuousOptimizing extends 
TableTestBase {
     // Need move file to hive scene
 
     UnKeyedTableDataView view =
-        new UnKeyedTableDataView(table, partitionCount, writeTargetFileSize, 
null);
+        new UnKeyedTableDataView(table, partitionCount, writeTargetFileSize, 
DATA_SEED);
 
     // init checker
     DataConcurrencyChecker dataConcurrencyChecker = new 
DataConcurrencyChecker(view);
diff --git a/amoro-common/pom.xml b/amoro-common/pom.xml
index 2b21ff999..dd85842c4 100644
--- a/amoro-common/pom.xml
+++ b/amoro-common/pom.xml
@@ -194,6 +194,18 @@
                     </java>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <excludes>src/main/gen-java/**</excludes>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+            </plugin>
         </plugins>
         <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
     </build>

Reply via email to