Skip to content

Commit

Permalink
Fix flaky ProcessNodeTests by removing orTimeout
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Sep 26, 2023
1 parent 90e95e3 commit 3fa4d0a
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,30 @@
*/
package org.opensearch.flowframework.template;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;

import org.opensearch.flowframework.workflow.WorkflowData;
import org.opensearch.flowframework.workflow.WorkflowStep;
import org.opensearch.test.OpenSearchTestCase;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

@ThreadLeakScope(Scope.NONE)
public class ProcessNodeTests extends OpenSearchTestCase {

private static ExecutorService executor;
private ExecutorService executor;

@BeforeClass
public static void setup() {
@Before
public void setup() {
executor = Executors.newFixedThreadPool(10);
}

@AfterClass
public static void cleanup() {
@After
public void cleanup() {
executor.shutdown();
}

Expand All @@ -60,12 +55,8 @@ public String getName() {
assertEquals(Collections.emptyList(), nodeA.predecessors());
assertEquals("A", nodeA.toString());

// TODO: This test is flaky on Windows. Disabling until thread pool is integrated
// https://github.com/opensearch-project/opensearch-ai-flow-framework/issues/42
CompletableFuture<WorkflowData> f = nodeA.execute();
assertEquals(f, nodeA.future());
f.orTimeout(15, TimeUnit.SECONDS);
assertTrue(f.isDone());
assertEquals(WorkflowData.EMPTY, f.get());
}
}

0 comments on commit 3fa4d0a

Please sign in to comment.