Skip to content

Commit

Permalink
Need more delay on GHA tests due to more thread contention
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Nov 20, 2024
1 parent d8cabf2 commit d464656
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions common/src/test/java/org/opensearch/sdk/SdkClientTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -352,21 +353,22 @@ public void testSearchDataObjectInterrupted() {
@Test
public void testExecutePrivilegedAsync() throws Exception {
PrivilegedAction<String> action = () -> "Test Result";
Executor executor = Executors.newSingleThreadExecutor();
Executor executor = Executors.newCachedThreadPool();
CompletionStage<String> result = sdkClientImpl.executePrivilegedAsync(action, executor);
CompletableFuture<String> future = result.toCompletableFuture();
verify(sdkClientImpl, timeout(1000)).executePrivilegedAsync(any(), any());
String actualResult = result.toCompletableFuture().get();
assertEquals("Test Result", actualResult);
assertEquals("Test Result", future.get(5, TimeUnit.SECONDS));
assertFalse(future.isCompletedExceptionally());
}

@Test
public void testExecutePrivilegedAsyncWithException() {
public void testExecutePrivilegedAsyncWithException() throws Exception {
PrivilegedAction<String> action = () -> { throw new RuntimeException("Test Exception"); };
Executor executor = Executors.newSingleThreadExecutor();
Executor executor = Executors.newCachedThreadPool();
CompletionStage<String> result = sdkClientImpl.executePrivilegedAsync(action, executor);
CompletableFuture<String> future = result.toCompletableFuture();
verify(sdkClientImpl, timeout(1000)).executePrivilegedAsync(any(), any());
assertThrows(ExecutionException.class, () -> future.get(5, TimeUnit.SECONDS));
assertTrue(future.isCompletedExceptionally());
assertThrows(ExecutionException.class, future::get);
}
}

0 comments on commit d464656

Please sign in to comment.