Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion regression-test/framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ under the License.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<version>5.10.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3753,35 +3753,35 @@ class Suite implements GroovyInterceptable {
throw new IllegalArgumentException("invalid caseElapseSeconds, ${caseElapseSeconds}")
}

long sleepSeconds = 0
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now()
LocalDateTime boundary

switch (caseSpanConstraint) {
case "NOT_CROSS_HOUR_BOUNDARY":
LocalDateTime nextHour = now.withMinute(0).withSecond(0).withNano(0).plusHours(1);
long secondsToNextHour = ChronoUnit.SECONDS.between(now, nextHour)

if (secondsToNextHour < caseElapseSeconds) {
sleepSeconds = secondsToNextHour
}
boundary = now.withMinute(0).withSecond(0).withNano(0).plusHours(1)
break

case "NOT_CROSS_DAY_BOUNDARY":
LocalDateTime startOfNextDay = now.toLocalDate().plusDays(1).atStartOfDay();
long secondsToNextDay = ChronoUnit.SECONDS.between(now, startOfNextDay)

if (secondsToNextDay < caseElapseSeconds) {
sleepSeconds = secondsToNextDay
}
boundary = now.toLocalDate().plusDays(1).atStartOfDay()
break
default:
throw new IllegalArgumentException("invalid caseSpanConstraint:${caseSpanConstraint}")
}

if (sleepSeconds > 0) {
logger.info("test sleeps ${sleepSeconds} to satisfy ${caseSpanConstraint}")
Thread.sleep(sleepSeconds * 1000)
long sleepMillis = calculateBoundarySleepMillis(now, boundary, caseElapseSeconds)
if (sleepMillis > 0) {
logger.info("test sleeps ${sleepMillis} ms to satisfy ${caseSpanConstraint}")
Thread.sleep(sleepMillis)
}
}

static long calculateBoundarySleepMillis(LocalDateTime now, LocalDateTime boundary, int caseElapseSeconds) {
long millisToBoundary = ChronoUnit.MILLIS.between(now, boundary)
if (millisToBoundary <= TimeUnit.SECONDS.toMillis(caseElapseSeconds)) {
// Cross the boundary by a full millisecond; truncated fractional milliseconds must not resume early.
return millisToBoundary + 1
}
return 0
}

void retryUntilHasSqlCache(String sql) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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.doris.regression.suite

import org.junit.jupiter.api.Test

import java.time.LocalDateTime
import java.util.concurrent.TimeUnit

import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertTrue

class SuiteBoundaryWaitTest {
@Test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Run these tests in the checked-in pipeline

The standard framework path never executes this class: run-regression-test.sh --compile reaches mvn clean package ... -DskipTests=true, and regression-test/pipeline/common/doris-utils.sh prepares the framework only through that entry point. I could not find any tracked workflow or pipeline command that invokes the framework's Maven test phase, so these methods compile but cannot fail CI and the boundary regression remains unprotected. Please wire the framework unit-test phase into a preset/automated path and verify all three tests appear in the Surefire results.

void waitCrossesBoundaryWhenRemainingTimeHasFractionalSecond() {
LocalDateTime now = LocalDateTime.parse("2026-07-16T22:59:40.285999999")
LocalDateTime nextHour = LocalDateTime.parse("2026-07-16T23:00:00")

long waitMillis = Suite.calculateBoundarySleepMillis(now, nextHour, 45)

assertTrue(now.plusNanos(TimeUnit.MILLISECONDS.toNanos(waitMillis)).isAfter(nextHour))
}

@Test
void waitCrossesBoundaryWhenExpectedDurationEndsExactlyAtBoundary() {
LocalDateTime now = LocalDateTime.parse("2026-07-16T22:59:15")
LocalDateTime nextHour = LocalDateTime.parse("2026-07-16T23:00:00")

long waitMillis = Suite.calculateBoundarySleepMillis(now, nextHour, 45)

assertTrue(now.plusNanos(TimeUnit.MILLISECONDS.toNanos(waitMillis)).isAfter(nextHour))
}

@Test
void noWaitWhenExpectedDurationFinishesBeforeBoundary() {
LocalDateTime now = LocalDateTime.parse("2026-07-16T22:59:14.999")
LocalDateTime nextHour = LocalDateTime.parse("2026-07-16T23:00:00")

assertEquals(0, Suite.calculateBoundarySleepMillis(now, nextHour, 45))
}
}
3 changes: 2 additions & 1 deletion run-regression-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ if ! test -f ${RUN_JAR:+${RUN_JAR}}; then

# Then package with retry
echo "Building package..."
execute_maven_with_retry "${MVN_CMD} clean package -B -DskipTests=true -Dmaven.javadoc.skip=true" || {
# Keep framework unit tests in the standard compile path so pipeline builds enforce framework regressions.
execute_maven_with_retry "${MVN_CMD} clean package -B -Dmaven.javadoc.skip=true" || {
echo "Failed to build package"
exit 1
}
Expand Down
Loading