Skip to content

Commit 222fe15

Browse files
committed
Fix issue#685
1 parent 030ec23 commit 222fe15

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

sentinel-core/src/test/java/com/alibaba/csp/sentinel/slots/statistic/metric/OccupiableBucketLeapArrayTest.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.alibaba.csp.sentinel.slots.statistic.base.WindowWrap;
77
import com.alibaba.csp.sentinel.slots.statistic.data.MetricBucket;
88
import com.alibaba.csp.sentinel.slots.statistic.metric.occupy.OccupiableBucketLeapArray;
9+
import com.alibaba.csp.sentinel.test.AbstractTimeBasedTest;
910
import com.alibaba.csp.sentinel.util.TimeUtil;
1011

1112
import org.junit.Test;
@@ -17,7 +18,7 @@
1718
*
1819
* @author jialiang.linjl
1920
*/
20-
public class OccupiableBucketLeapArrayTest {
21+
public class OccupiableBucketLeapArrayTest extends AbstractTimeBasedTest {
2122

2223
private final int windowLengthInMs = 200;
2324
private final int intervalInSec = 2;
@@ -122,6 +123,14 @@ public void testWindowAfterOneInterval() {
122123
sum += bucket.pass();
123124
}
124125
assertEquals(sum, 2 * intervalInSec * 1000 / windowLengthInMs - 1);
126+
127+
/**
128+
* https://github.com/alibaba/Sentinel/issues/685
129+
*
130+
* Here we could not use exactly current time, because the following result is related with the above elapse.
131+
* So we use the beginning current time to ensure.
132+
*/
133+
setCurrentMillis(currentTime);
125134
assertEquals(leapArray.currentWaiting(), 10);
126135
}
127136
}

0 commit comments

Comments
 (0)