use of org.jenkinsci.plugins.workflow.cps.CpsThreadDump.ThreadInfo in project workflow-cps-plugin by jenkinsci.
the class CpsThreadDumpTest method simple.
@Test
public void simple() throws Exception {
p.setDefinition(new CpsFlowDefinition(StringUtils.join(asList("def foo() { bar() }", "def bar() {", " semaphore 'x'", "}", "foo()"), "\n")));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.waitForStart("x/1", b);
CpsThreadDumpAction action = b.getAction(CpsThreadDumpAction.class);
if (action == null) {
FlowExecutionOwner owner = b.asFlowExecutionOwner();
assertNotNull(owner);
CpsFlowExecution exec = (CpsFlowExecution) owner.getOrNull();
assertNotNull(exec);
assertFalse(exec.isComplete());
fail("not sure why CpsThreadDumpAction was missing here");
}
CpsThreadDump td = action.threadDumpSynchronous();
td.print(System.out);
{
// verify that we got the right thread dump
List<ThreadInfo> threads = td.getThreads();
assertEquals(1, threads.size());
ThreadInfo t = threads.get(0);
assertEquals("Thread #0", t.getHeadline());
assertStackTrace(t, "DSL.semaphore(waiting on x/1)", "WorkflowScript.bar(WorkflowScript:3)", "WorkflowScript.foo(WorkflowScript:1)", "WorkflowScript.run(WorkflowScript:5)");
}
SemaphoreStep.success("x/1", null);
j.waitForCompletion(b);
assertNull(b.getAction(CpsThreadDumpAction.class));
}
Aggregations