private void timeoutIfStillRunning(Thread t) { if (t.isAlive()) { log.warn("Scenario timed out after " + scenarioTimeoutMillis + " millis, will interrupt"); stepProcessor.setInterruptingOnTimeout(true); t.interrupt(); // first try to interrupt to see if this can unblock/fail the scenario } }
private void runScenario( ExecutionToken executionToken, HandlerManager handlerManager, ScenarioToken scenario, boolean skip) throws Exception { executionListenerSupport.notifyScenarioStarted(executionToken, scenario); log.info(String.format("Processing scenario: %s", scenario.getName())); // reset the ChorusContext for the scenario ChorusContext.destroy(); handlerManager.setCurrentScenario(scenario); List<Object> handlerInstances = handlerManager.getOrCreateHandlersForScenario(); handlerManager.processStartOfScope(Scope.SCENARIO, handlerInstances); createTimeoutTasks( Thread .currentThread()); // will interrupt or eventually kill thread / interpreter if blocked log.debug("Running scenario steps for Scenario " + scenario); StepInvokerProvider p = getStepInvokers(handlerInstances); stepProcessor.runSteps(executionToken, p, scenario.getSteps(), skip); stopTimeoutTasks(); // the special start or end scenarios don't count in the execution stats if (!scenario.isStartOrEndScenario()) { updateExecutionStats(executionToken, scenario); } handlerManager.processEndOfScope(Scope.SCENARIO, handlerInstances); executionListenerSupport.notifyScenarioCompleted(executionToken, scenario); }