Calcite: Fix nanoseconds flakiness in LocalDateTimeSupportTest. Speed up this test.
@@ -23,15 +23,19 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
+import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.function.Function;
+import org.apache.ignite.Ignite;
import org.apache.ignite.cache.QueryEntity;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.util.typedef.G;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -185,18 +189,14 @@ public class LocalDateTimeSupportTest extends AbstractBasicIntegrationTest {
}
/** {@inheritDoc} */
- @Override public void beforeTest() throws Exception {
- if (!G.allGrids().isEmpty())
- return;
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
- startGrids(nodeCount());
+ for (Ignite ig: G.allGrids()) {
+ IgniteCacheObjectProcessor objProc = ((IgniteEx)ig).context().cacheObjects();
- client = startClientGrid("client");
+ objProc.removeType(objProc.typeId(Data.class.getName()));
}
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
}
/** */
@@ -249,9 +249,9 @@ public class LocalDateTimeSupportTest extends AbstractBasicIntegrationTest {
LocalDateTime oldDateTime = LocalDateTime.of(1042, Month.APRIL, 1, 12, 45, 0);
LocalDate oldDate = LocalDate.of(1042, Month.APRIL, 1);
if (cls == LocalDateTime.class)
- return isOldDate ? oldDateTime : LocalDateTime.now();
+ return isOldDate ? oldDateTime : LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS);
else if (cls == LocalTime.class)
- return LocalTime.now();
+ return LocalTime.now().truncatedTo(ChronoUnit.MILLIS);
else if (cls == LocalDate.class)
return isOldDate ? oldDate : LocalDate.now();
else if (cls == Date.class)
@@ -260,8 +260,10 @@ public class LocalDateTimeSupportTest extends AbstractBasicIntegrationTest {
return isOldDate ? java.sql.Date.valueOf(oldDate) : java.sql.Date.valueOf(LocalDate.now());
else if (cls == java.sql.Time.class)
return java.sql.Time.valueOf(LocalTime.now());
- else if (cls == java.sql.Timestamp.class)
- return isOldDate ? convertToTimestamp(oldDateTime) : java.sql.Timestamp.valueOf(LocalDateTime.now());
+ else if (cls == java.sql.Timestamp.class) {
+ return isOldDate ? convertToTimestamp(oldDateTime)
+ : java.sql.Timestamp.valueOf(LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS));
+ }
else
throw new IllegalStateException();
}
