Skip to content

Commit 016b470

Browse files
authored
Preparation for enabling travis ci ... (#156)
* prepare for enabling travis ci and fix an issue that cause test to hang if fork join pool only has single thread * add new line in travis file
1 parent 0f5a543 commit 016b470

File tree

5 files changed

+45
-19
lines changed

5 files changed

+45
-19
lines changed

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: java
2+
3+
sudo: required
4+
5+
env:
6+
- SKIP_DOCKER_SERVICE=true # used to skip docker service tests in WorkflowTest for now.
7+
8+
before_install:
9+
- pushd /tmp
10+
- wget http://www-us.apache.org/dist/thrift/0.9.3/thrift-0.9.3.tar.gz
11+
- tar xfz thrift-0.9.3.tar.gz
12+
- cd thrift-0.9.3
13+
- ./configure --enable-libs=no --enable-tests=no --enable-tutorial=no --with-cpp=no --with-c_glib=no --with-java=yes --with-ruby=no --with-erlang=no --with-go=no --with-nodejs=no
14+
- make -j2 && sudo make install
15+
- popd

build.gradle

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ compileJava {
6060
".*/generated-sources/.*" << "-Werror"
6161
}
6262

63-
license {
64-
header = project.file('license-header.txt')
65-
exclude '**/com/uber/cadence/*.java'
66-
}
67-
6863
compileTestJava {
6964
options.encoding = 'UTF-8'
7065
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-XepExcludedPaths:" +
@@ -99,3 +94,12 @@ publishing {
9994
mavenLocal()
10095
}
10196
}
97+
98+
test {
99+
testLogging {
100+
events "passed", "skipped", "failed"
101+
exceptionFormat "full"
102+
// Uncomment the following line if you want to see test logs in gradlew run.
103+
// showStandardStreams true
104+
}
105+
}

src/main/java/com/uber/cadence/internal/testservice/TestWorkflowService.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public final class TestWorkflowService implements IWorkflowService {
106106
// key->WorkflowId
107107
private final Map<WorkflowId, TestWorkflowMutableState> executionsByWorkflowId = new HashMap<>();
108108

109+
private final ForkJoinPool forkJoinPool = new ForkJoinPool(4);
110+
109111
public void close() {
110112
store.close();
111113
}
@@ -565,17 +567,15 @@ public void StartWorkflowExecution(
565567
public void GetWorkflowExecutionHistory(
566568
GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler)
567569
throws TException {
568-
ForkJoinPool.commonPool()
569-
.execute(
570-
() -> {
571-
try {
572-
GetWorkflowExecutionHistoryResponse result =
573-
GetWorkflowExecutionHistory(getRequest);
574-
resultHandler.onComplete(result);
575-
} catch (TException e) {
576-
resultHandler.onError(e);
577-
}
578-
});
570+
forkJoinPool.execute(
571+
() -> {
572+
try {
573+
GetWorkflowExecutionHistoryResponse result = GetWorkflowExecutionHistory(getRequest);
574+
resultHandler.onComplete(result);
575+
} catch (TException e) {
576+
resultHandler.onError(e);
577+
}
578+
});
579579
}
580580

581581
@Override

src/test/java/com/uber/cadence/internal/testing/WorkflowTestingTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@
6868
import org.junit.rules.TestWatcher;
6969
import org.junit.rules.Timeout;
7070
import org.junit.runner.Description;
71+
import org.slf4j.Logger;
72+
import org.slf4j.LoggerFactory;
7173

7274
public class WorkflowTestingTest {
75+
private static final Logger log = LoggerFactory.getLogger(WorkflowTestingTest.class);
7376

7477
@Rule public Timeout globalTimeout = Timeout.seconds(5);
7578

@@ -84,7 +87,7 @@ protected void failed(Throwable e, Description description) {
8487

8588
private static final String TASK_LIST = "test-workflow";
8689

87-
private static TestWorkflowEnvironment testEnvironment;
90+
private TestWorkflowEnvironment testEnvironment;
8891

8992
@Before
9093
public void setUp() {
@@ -469,7 +472,7 @@ public void testConcurrentDecision() throws ExecutionException, InterruptedExcep
469472
CompletableFuture<String> result = WorkflowClient.execute(workflow::workflow1, "input1");
470473
workflow.ProcessSignal("signalInput");
471474
assertEquals("signalInput-input1", result.get());
472-
System.out.println(testEnvironment.getDiagnostics());
475+
log.info(testEnvironment.getDiagnostics());
473476
}
474477

475478
public interface TestCancellationActivity {

src/test/java/com/uber/cadence/workflow/WorkflowTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ public class WorkflowTest {
103103

104104
@Parameters(name = "{1}")
105105
public static Object[] data() {
106-
return new Object[][] {{true, "Docker"}, {false, "TestService"}};
106+
if (Boolean.parseBoolean(System.getenv("SKIP_DOCKER_SERVICE"))) {
107+
return new Object[][] {{false, "TestService"}};
108+
} else {
109+
return new Object[][] {{true, "Docker"}, {false, "TestService"}};
110+
}
107111
}
108112

109113
@Rule public TestName testName = new TestName();

0 commit comments

Comments
 (0)