This is an automated email from the ASF dual-hosted git repository.
terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new c59499508d8 stabilize process operation lock registry test (#40351)
c59499508d8 is described below
commit c59499508d899c693e2012a48d52812d4655ac3f
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Oct 23 00:52:21 2026 +0800
stabilize process operation lock registry test (#40351)
* Refactor MCPRegistryMetadataCommand
* Fix FirebirdExecuteStatementPacketTest
* stabilize process operation lock registry test
---
.../lock/ProcessOperationLockRegistryTest.java | 37 ++++------------------
1 file changed, 7 insertions(+), 30 deletions(-)
diff --git
a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockRegistryTest.java
b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockRegistryTest.java
index 614e502b020..341cb5a0cfa 100644
---
a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockRegistryTest.java
+++
b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockRegistryTest.java
@@ -17,42 +17,19 @@
package org.apache.shardingsphere.infra.executor.sql.process.lock;
-import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.junit.jupiter.api.Assertions.assertTrue;
class ProcessOperationLockRegistryTest {
@Test
- void assertLockAndNotify() {
+ void assertWaitUntilReleaseReady() {
+ ProcessOperationLockRegistry registry =
ProcessOperationLockRegistry.getInstance();
String lockId = "foo_id";
- long startMillis = System.currentTimeMillis();
- Executors.newFixedThreadPool(1).submit(() -> {
- Awaitility.await().pollDelay(50L, TimeUnit.MILLISECONDS).until(()
-> true);
- ProcessOperationLockRegistry.getInstance().notify(lockId);
- });
- waitUntilReleaseReady(lockId);
- long currentMillis = System.currentTimeMillis();
- assertThat(currentMillis, greaterThanOrEqualTo(startMillis + 50L));
- assertThat(currentMillis, lessThanOrEqualTo(startMillis + 5000L));
- }
-
- private void waitUntilReleaseReady(final String lockId) {
-
ProcessOperationLockRegistry.getInstance().waitUntilReleaseReady(lockId, 1, new
ProcessOperationLockReleaseStrategy() {
-
- private final AtomicBoolean firstTime = new AtomicBoolean(true);
-
- @Override
- public boolean isReadyToRelease() {
- return !firstTime.getAndSet(false);
- }
- });
+ assertTrue(registry.waitUntilReleaseReady(lockId, 1, () -> {
+ registry.notify(lockId);
+ return false;
+ }));
}
}