You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2024/02/23 18:18:58 UTC

(pinot) branch master updated: Remove mercateo test-clock dependency (#12473)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4621aaf85b Remove mercateo test-clock dependency (#12473)
4621aaf85b is described below

commit 4621aaf85b70290b35e937b02caeb0525f50917a
Author: Xiang Fu <xi...@gmail.com>
AuthorDate: Sat Feb 24 02:18:52 2024 +0800

    Remove mercateo test-clock dependency (#12473)
---
 pinot-broker/pom.xml                               |  5 --
 .../instanceselector/InstanceSelectorTest.java     |  4 +-
 .../org/apache/pinot/common/utils/TestClock.java   | 56 ++++++++++++++++++++++
 pom.xml                                            |  6 ---
 4 files changed, 58 insertions(+), 13 deletions(-)

diff --git a/pinot-broker/pom.xml b/pinot-broker/pom.xml
index f62f89f40b..d1b3a981b4 100644
--- a/pinot-broker/pom.xml
+++ b/pinot-broker/pom.xml
@@ -139,10 +139,5 @@
       <artifactId>mockito-core</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>com.mercateo</groupId>
-      <artifactId>test-clock</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 </project>
diff --git a/pinot-broker/src/test/java/org/apache/pinot/broker/routing/instanceselector/InstanceSelectorTest.java b/pinot-broker/src/test/java/org/apache/pinot/broker/routing/instanceselector/InstanceSelectorTest.java
index 9dc29eba15..f4edc28e67 100644
--- a/pinot-broker/src/test/java/org/apache/pinot/broker/routing/instanceselector/InstanceSelectorTest.java
+++ b/pinot-broker/src/test/java/org/apache/pinot/broker/routing/instanceselector/InstanceSelectorTest.java
@@ -22,7 +22,6 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
-import com.mercateo.test.clock.TestClock;
 import java.time.Clock;
 import java.time.Duration;
 import java.time.Instant;
@@ -48,6 +47,7 @@ import org.apache.pinot.common.metadata.segment.SegmentZKMetadata;
 import org.apache.pinot.common.metrics.BrokerMetrics;
 import org.apache.pinot.common.request.BrokerRequest;
 import org.apache.pinot.common.request.PinotQuery;
+import org.apache.pinot.common.utils.TestClock;
 import org.apache.pinot.spi.config.table.RoutingConfig;
 import org.apache.pinot.spi.config.table.TableConfig;
 import org.apache.pinot.spi.config.table.TableType;
@@ -173,7 +173,7 @@ public class InstanceSelectorTest {
 
   @BeforeMethod
   public void setUp() {
-    _mutableClock = TestClock.fixed(Instant.now(), ZoneId.systemDefault());
+    _mutableClock = new TestClock(Instant.now(), ZoneId.systemDefault());
     _mocks = MockitoAnnotations.openMocks(this);
     when(_brokerRequest.getPinotQuery()).thenReturn(_pinotQuery);
     when(_pinotQuery.getQueryOptions()).thenReturn(null);
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/TestClock.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/TestClock.java
new file mode 100644
index 0000000000..e2f145f463
--- /dev/null
+++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/TestClock.java
@@ -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.pinot.common.utils;
+
+import java.time.Clock;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.ZoneId;
+
+
+public class TestClock extends Clock {
+
+  private Instant _currentTime;
+  private final ZoneId _zoneId;
+
+  public TestClock(Instant startTime, ZoneId zone) {
+    _currentTime = startTime;
+    _zoneId = zone;
+  }
+
+  @Override
+  public ZoneId getZone() {
+    return _zoneId;
+  }
+
+  @Override
+  public Clock withZone(ZoneId zone) {
+    return new TestClock(_currentTime, zone);
+  }
+
+  @Override
+  public Instant instant() {
+    return _currentTime;
+  }
+
+  // Method to fast-forward time
+  public void fastForward(Duration duration) {
+    _currentTime = _currentTime.plus(duration);
+  }
+}
diff --git a/pom.xml b/pom.xml
index fdcd63343d..6ba050387f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1280,12 +1280,6 @@
         <artifactId>ipaddress</artifactId>
         <version>5.3.4</version>
       </dependency>
-      <dependency>
-        <groupId>com.mercateo</groupId>
-        <artifactId>test-clock</artifactId>
-        <version>1.0.4</version>
-        <scope>test</scope>
-      </dependency>
 
       <dependency>
         <groupId>net.openhft</groupId>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org