FrankChen021 commented on code in PR #19810: URL: https://github.com/apache/druid/pull/19810#discussion_r3686775683
########## indexing-service/src/test/java/org/apache/druid/indexing/worker/executor/ExecutorLifecycleTest.java: ########## @@ -0,0 +1,82 @@ +/* + * 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.druid.indexing.worker.executor; + +import org.apache.druid.indexing.common.actions.TaskActionClientFactory; +import org.apache.druid.indexing.common.config.TaskConfig; +import org.apache.druid.indexing.overlord.TaskRunner; +import org.apache.druid.jackson.DefaultObjectMapper; +import org.apache.druid.java.util.common.ISE; +import org.joda.time.Period; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; + +import java.io.File; +import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; + +public class ExecutorLifecycleTest +{ + @Test + public void testAcquireTaskFileLockRetriesUntilSuccess() throws Exception + { + final ExecutorLifecycle lifecycle = createLifecycle(Period.seconds(1)); + final FileChannel channel = Mockito.mock(FileChannel.class); + final FileLock lock = Mockito.mock(FileLock.class); + Mockito.when(channel.tryLock()).thenReturn(null, lock); + + Assert.assertSame(lock, lifecycle.acquireTaskFileLock(channel, new File("task.lock"))); + Mockito.verify(channel, Mockito.times(2)).tryLock(); Review Comment: Thanks. This test intentionally exercises exactly one real retry interval, while the zero-timeout test covers the no-wait path. Adding a production sleep abstraction solely to avoid this 100 ms test delay would expand the production surface for little benefit. The observed CI flake was an unrelated Surefire fork/JVM-handshake failure after 20,742 successful tests; this test itself passed. Keeping the focused retry test as-is. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
