예제 #1
0
 * (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * @category    Application
 * @author      Ralf Claussnitzer <*****@*****.**>
 * @author      Henning Gerhardt <*****@*****.**>
 * @copyright   Copyright (c) 2010
 *              Saechsische Landesbibliothek - Staats- und Universitaetsbibliothek Dresden (SLUB)
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id$
 */
define('APPLICATION_ENV', 'production');
// basic bootstrapping
require_once dirname(__FILE__) . '/../common/bootstrap.php';
// set up job runner
$jobrunner = new Opus_Job_Runner();
$jobrunner->setLogger(Zend_Registry::get('Zend_Log'));
// no waiting between jobs
$jobrunner->setDelay(0);
// set a limit of 100 index jobs per run
$jobrunner->setLimit(100);
$indexWorker = new Qucosa_Job_Worker_IndexOpusDocument();
$indexWorker->setIndex(Zend_Registry::get('Qucosa_Search_Index'));
$indexWorker->setFileBasePathPattern(Zend_Registry::get('Zend_Config')->file->destinationPath . '/$documentId');
$jobrunner->registerWorker($indexWorker);
// run processing
$jobrunner->run();
 public function testCheckconsistencyActionResult()
 {
     $this->enableAsyncIndexmaintenanceMode();
     $this->assertEquals(0, Opus_Job::getCountForLabel(Opus_Job_Worker_ConsistencyCheck::LABEL), 'missing cleanup of jobs table');
     $this->getRequest()->setMethod('POST');
     $this->dispatch('/admin/indexmaintenance/checkconsistency');
     $this->assertResponseCode(302);
     $this->assertResponseLocationHeader($this->getResponse(), '/admin/indexmaintenance');
     $this->assertEquals(1, Opus_Job::getCountForLabel(Opus_Job_Worker_ConsistencyCheck::LABEL), 'consistency check job was not stored in database');
     /*
      * check if job was scheduled for execution
      */
     $this->resetResponse();
     $this->resetRequest();
     $this->dispatch('/admin/indexmaintenance/index');
     $this->assertResponseCode(200, 'foo');
     $baseUrl = $this->getRequest()->getBaseUrl();
     $body = $this->getResponse()->getBody();
     $this->assertContains('div class="opprogress"', $body);
     $this->assertNotContains("action=\"{$baseUrl}/admin/indexmaintenance/checkconsistency\"", $body);
     // TODO $this->assertContains("action=\"$baseUrl/admin/indexmaintenance/checkfulltexts\"", $body);
     // TODO $this->assertContains("action=\"$baseUrl/admin/indexmaintenance/optimizeindex\"", $body);
     /*
      * run job immediately and check for result
      */
     $jobrunner = new Opus_Job_Runner();
     $jobrunner->setLogger(Zend_Registry::get('Zend_Log'));
     $worker = new Opus_Job_Worker_ConsistencyCheck();
     $jobrunner->registerWorker($worker);
     $jobrunner->run();
     $jobs = Opus_Job::getByLabels(array(Opus_Job_Worker_ConsistencyCheck::LABEL));
     if (count($jobs) > 0) {
         $job = $jobs[0];
         $message = 'at least one unexpected job found (Label: \'%s\', State: \'%s\', Data: \'%s\', Errors: \'%s\\, SHA1 Hash: \'%s\')';
         $label = $job->getLabel();
         $state = $job->getState();
         $data = $job->getData();
         $errors = $job->getErrors();
         $hash = $job->getSha1Id();
         $this->fail(sprintf($message, $label, $state, $data, $errors, $hash));
     }
     $this->assertEquals(0, Opus_Job::getCountForLabel(Opus_Job_Worker_ConsistencyCheck::LABEL), 'consistency check job was not removed from database after execution');
     $this->resetResponse();
     $this->resetRequest();
     $this->dispatch('/admin/indexmaintenance/index');
     $this->assertResponseCode(200, 'bar');
     $baseUrl = $this->getRequest()->getBaseUrl();
     $body = $this->getResponse()->getBody();
     $this->assertNotContains('div class="opprogress"', $body);
     $this->assertContains('pre class="opoutput"', $body);
     $this->assertContains("action=\"{$baseUrl}/admin/indexmaintenance/checkconsistency\"", $body);
     // TODO $this->assertContains("action=\"$baseUrl/admin/indexmaintenance/checkfulltexts\"", $body);
     // TODO $this->assertContains("action=\"$baseUrl/admin/indexmaintenance/optimizeindex\"", $body);
 }
 private function runJobImmediately()
 {
     $this->assertEquals(1, Opus_Job::getCountForLabel(Opus_Job_Worker_ConsistencyCheck::LABEL));
     $jobrunner = new Opus_Job_Runner();
     $jobrunner->setLogger(Zend_Registry::get('Zend_Log'));
     $worker = new Opus_Job_Worker_ConsistencyCheck();
     $jobrunner->registerWorker($worker);
     $jobrunner->run();
     $this->assertEquals(0, Opus_Job::getCountForLabel(Opus_Job_Worker_ConsistencyCheck::LABEL));
 }