/** * * @param tx_caretaker_TestServiceInterface $testService * @param tx_caretaker_TestNode $node * @param tx_caretaker_NodeResult $latestTestResult * @param array $options * @return tx_caretaker_NodeResult */ protected function executeTestServiceRun($testService, $node, $latestTestResult, $options) { // check wether the test can be executed if ($testService && $testService->isExecutable()) { try { $result = $testService->runTest(); } catch (Exception $e) { $result = tx_caretaker_TestResult::create(tx_caretaker_Constants::state_error, 0, '{LLL:EXT:caretaker/locallang_fe.xml:service_exception}' . $e->getMessage); } // retry if not ok and retrying is enabled if ($result->getState() != 0 && $node->getTestRetry() > 0) { $round = 0; while ($round < $node->getTestRetry() && $result->getState() != 0) { // TODO make sleep time between retry configurable sleep(1); try { $result = $testService->runTest(); } catch (Exception $e) { $result = tx_caretaker_TestResult::create(tx_caretaker_Constants::state_error, 0, '{LLL:EXT:caretaker/locallang_fe.xml:service_exception}' . $e->getMessage); } $round++; } $result->addSubMessage(new tx_caretaker_ResultMessage('LLL:EXT:caretaker/locallang_fe.xml:retry_info', array('number' => $round))); } // save to repository after reading the previous result $resultRepository = tx_caretaker_TestResultRepository::getInstance(); $resultRepository->saveTestResultForNode($node, $result); // trigger notification $node->notify('updatedTestResult', $result, $latestTestResult); return $result; } else { $result = tx_caretaker_TestResult::undefined(); $result->addSubMessage(new tx_caretaker_ResultMessage('test service was not executable this time so the cached result is used')); $node->notify('cachedTestResult', $result, $latestTestResult); return $latestTestResult; } }