43 include_once(__DIR__.
'/../../../lib/php/Test/Agent/AgentTestMockHelper.php');
44 include_once(__DIR__.
'/SchedulerTestRunnerCli.php');
45 include_once(__DIR__.
'/SchedulerTestRunnerMock.php');
58 private $testInstaller;
65 private $clearingDecisionProcessor;
67 private $agentLicenseEventProcessor;
71 private $uploadPermDao;
73 private $highlightDao;
86 $this->testDb =
new TestPgDb(
"deciderSched");
87 $this->
dbManager = $this->testDb->getDbManager();
90 $logger = M::mock(
'Monolog\Logger');
91 $this->uploadPermDao = \Mockery::mock(UploadPermissionDao::class);
102 $container = M::mock(
'ContainerBuilder');
103 $container->shouldReceive(
'get')->withArgs(array(
'db.manager'))->andReturn($this->
dbManager);
105 $this->runnerMock =
new SchedulerTestRunnerMock($this->
dbManager, $agentDao, $this->clearingDao, $this->uploadDao, $this->highlightDao, $this->showJobsDao, $this->clearingDecisionProcessor, $this->agentLicenseEventProcessor);
114 $this->testDb->fullDestruct();
115 $this->testDb = null;
117 $this->licenseDao = null;
118 $this->highlightDao = null;
119 $this->showJobsDao = null;
120 $this->clearingDao = null;
129 $sysConf = $this->testDb->getFossSysConf();
131 $this->testInstaller->init();
132 $this->testInstaller->cpRepo();
140 $this->testInstaller->rmRepo();
141 $this->testInstaller->clear();
149 $this->testDb->createPlainTables(array(
'upload',
'upload_reuse',
'uploadtree',
'uploadtree_a',
'license_ref',
'license_ref_bulk',
150 'license_set_bulk',
'clearing_decision',
'clearing_decision_event',
'clearing_event',
'license_file',
'highlight',
151 'highlight_keyword',
'agent',
'pfile',
'ars_master',
'users',
'group_user_member',
'license_map',
'jobqueue',
'job'),
false);
152 $this->testDb->createSequences(array(
'agent_agent_pk_seq',
'pfile_pfile_pk_seq',
'upload_upload_pk_seq',
'nomos_ars_ars_pk_seq',
153 'license_file_fl_pk_seq',
'license_ref_rf_pk_seq',
'license_ref_bulk_lrb_pk_seq',
154 'clearing_decision_clearing_decision_pk_seq',
'clearing_event_clearing_event_pk_seq',
'FileLicense_pkey',
155 'jobqueue_jq_pk_seq',
'job_job_pk_seq'),
false);
156 $this->testDb->createViews(array(
'license_file_ref'),
false);
157 $this->testDb->createConstraints(array(
'agent_pkey',
'pfile_pkey',
'upload_pkey_idx',
'clearing_event_pkey',
'jobqueue_pkey'),
false);
158 $this->testDb->alterTables(array(
'agent',
'pfile',
'upload',
'ars_master',
'license_ref_bulk',
'license_set_bulk',
'clearing_event',
159 'clearing_decision',
'license_file',
'highlight',
'jobqueue',
'job'),
false);
160 $this->testDb->createInheritedTables();
161 $this->testDb->createInheritedArsTables(array(
'nomos',
'monk',
'copyright'));
163 $this->testDb->insertData(array(
'pfile',
'upload',
'uploadtree_a',
'users',
'group_user_member',
'agent',
'license_file',
164 'nomos_ars',
'monk_ars',
'copyright_ars'),
false);
165 $this->testDb->insertData_license_ref(80);
167 $this->testDb->resetSequenceAsMaxOf(
'agent_agent_pk_seq',
'agent',
'agent_pk');
178 if (preg_match(
"/.*HEART: ([0-9]*).*/", $output, $matches)) {
179 return intval($matches[1]);
188 $this->runnerDeciderScanWithNoEventsAndOnlyNomosShouldNotMakeADecision($this->runnerMock);
194 $this->runnerDeciderScanWithNoEventsAndOnlyNomosShouldNotMakeADecision($this->runnerCli);
197 private function runnerDeciderScanWithNoEventsAndOnlyNomosShouldNotMakeADecision($runner)
202 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
204 $licId1 = $licenseRef1->getId();
210 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
211 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
212 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,12,3)");
213 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
214 $this->
dbManager->queryOnce(
"INSERT INTO jobqueue (jq_pk, jq_job_fk, jq_type, jq_args, jq_starttime, jq_endtime, jq_endtext, jq_end_bits, jq_schedinfo, jq_itemsprocessed, jq_log, jq_runonpfile, jq_host, jq_cmd_args)" 215 .
" VALUES ($jobId, 2, 'decider', '2', '2014-08-07 09:57:27.718312+00', NULL, '', 0, NULL, 6, NULL, NULL, NULL, NULL)");
217 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId, $args=
'');
219 $this->assertTrue($success,
'cannot run runner');
220 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
224 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
225 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
226 assertThat($decisions, is(arrayWithSize(0)));
234 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkShouldMakeADecision($this->runnerMock);
240 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkShouldMakeADecision($this->runnerCli);
243 private function runnerDeciderScanWithNoEventsAndNomosContainedInMonkShouldMakeADecision($runner)
248 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
250 $licId1 = $licenseRef1->getId();
256 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
257 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
258 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,12,3)");
259 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
261 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId1,$pfile,$agentMonkId)");
262 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,11,2)");
263 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
264 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
266 $this->assertTrue($success,
'cannot run runner');
267 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
271 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
272 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
273 assertThat($decisions, is(arrayWithSize(1)));
281 $this->runnerDeciderScanWithNoEventsAndNomosNotContainedInMonkShouldNotMakeADecision($this->runnerMock);
287 $this->runnerDeciderScanWithNoEventsAndNomosNotContainedInMonkShouldNotMakeADecision($this->runnerCli);
290 private function runnerDeciderScanWithNoEventsAndNomosNotContainedInMonkShouldNotMakeADecision($runner)
295 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
297 $licId1 = $licenseRef1->getId();
303 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
304 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
305 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,10,3)");
306 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
308 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId1,$pfile,$agentMonkId)");
309 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,11,2)");
310 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
312 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
314 $this->assertTrue($success,
'cannot run runner');
315 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
319 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
320 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
321 assertThat($decisions, is(arrayWithSize(0)));
329 $this->runnerDeciderScanWithNoEventsAndNomosContainedInOneOfTwoEqualsMonkShouldMakeADecision($this->runnerMock);
335 $this->runnerDeciderScanWithNoEventsAndNomosContainedInOneOfTwoEqualsMonkShouldMakeADecision($this->runnerCli);
338 private function runnerDeciderScanWithNoEventsAndNomosContainedInOneOfTwoEqualsMonkShouldMakeADecision($runner)
343 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
345 $licId1 = $licenseRef1->getId();
351 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
352 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
353 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,10,3)");
354 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
356 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId1,$pfile,$agentMonkId)");
357 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,11,2)");
358 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
360 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12224,$licId1,$pfile,$agentMonkId)");
361 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,9,2)");
362 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,18,19)");
364 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
366 $this->assertTrue($success,
'cannot run runner');
367 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
371 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
372 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
373 assertThat($decisions, is(arrayWithSize(1)));
381 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithMappedLicenseShouldMakeADecision($this->runnerMock);
387 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithMappedLicenseShouldMakeADecision($this->runnerCli);
390 private function runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithMappedLicenseShouldMakeADecision($runner)
395 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
396 $licenseRef2 = $this->licenseDao->getLicenseByShortName(
"BSL-1.0")->getRef();
397 $licenseRef3 = $this->licenseDao->getLicenseByShortName(
"ZPL-1.1")->getRef();
399 $licId1 = $licenseRef1->getId();
400 $licId2 = $licenseRef2->getId();
401 $licId3 = $licenseRef3->getId();
407 $this->
dbManager->queryOnce(
"INSERT INTO license_map(rf_fk, rf_parent, usage) VALUES ($licId2, $licId1, ".LicenseMap::CONCLUSION.
")");
408 $this->
dbManager->queryOnce(
"INSERT INTO license_map(rf_fk, rf_parent, usage) VALUES ($licId3, $licId1, ".LicenseMap::CONCLUSION.
")");
410 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
411 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
412 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,10,3)");
413 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
415 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId2,$pfile,$agentMonkId)");
416 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,6,2)");
417 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
419 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12224,$licId3,$pfile,$agentMonkId)");
420 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,9,2)");
421 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,13,19)");
423 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
425 $this->assertTrue($success,
'cannot run runner');
426 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
430 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
431 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
432 assertThat($decisions, is(arrayWithSize(1)));
440 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchShouldNotMakeADecision($this->runnerMock);
446 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchShouldNotMakeADecision($this->runnerCli);
449 private function runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchShouldNotMakeADecision($runner)
454 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
455 $licenseRef2 = $this->licenseDao->getLicenseByShortName(
"BSL-1.0")->getRef();
456 $licenseRef3 = $this->licenseDao->getLicenseByShortName(
"ZPL-1.1")->getRef();
458 $licId1 = $licenseRef1->getId();
459 $licId2 = $licenseRef2->getId();
460 $licId3 = $licenseRef3->getId();
467 $this->
dbManager->queryOnce(
"INSERT INTO license_map(rf_fk, rf_parent, usage) VALUES ($licId2, $licId1, ".LicenseMap::CONCLUSION.
")");
469 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
470 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
471 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,10,3)");
472 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
474 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId2,$pfile,$agentMonkId)");
475 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,6,2)");
476 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
478 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12224,$licId3,$pfile,$agentOther)");
479 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,9,2)");
480 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,13,19)");
482 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
484 $this->assertTrue($success,
'cannot run runner');
485 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
489 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
490 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
491 assertThat($decisions, is(arrayWithSize(0)));
499 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchForSameLicenseShouldMakeADecision($this->runnerMock);
505 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchForSameLicenseShouldMakeADecision($this->runnerCli);
508 private function runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchForSameLicenseShouldMakeADecision($runner)
513 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
514 $licenseRef2 = $this->licenseDao->getLicenseByShortName(
"BSL-1.0")->getRef();
515 $licenseRef3 = $this->licenseDao->getLicenseByShortName(
"ZPL-1.1")->getRef();
517 $licId1 = $licenseRef1->getId();
518 $licId2 = $licenseRef2->getId();
519 $licId3 = $licenseRef3->getId();
526 $this->
dbManager->queryOnce(
"INSERT INTO license_map(rf_fk, rf_parent, usage) VALUES ($licId2, $licId1, ".LicenseMap::CONCLUSION.
")");
527 $this->
dbManager->queryOnce(
"INSERT INTO license_map(rf_fk, rf_parent, usage) VALUES ($licId3, $licId1, ".LicenseMap::CONCLUSION.
")");
529 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
530 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
531 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,10,3)");
532 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
534 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId2,$pfile,$agentMonkId)");
535 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,6,2)");
536 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
538 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12224,$licId3,$pfile,$agentOther)");
539 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,9,2)");
540 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,13,19)");
542 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
544 $this->assertTrue($success,
'cannot run runner');
545 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
549 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
550 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
551 assertThat($decisions, is(arrayWithSize(1)));
560 $this->runnerBulkReuseShouldScheduleMonkBulk($this->runnerMock);
563 private function runnerBulkReuseShouldScheduleMonkBulk($runner)
568 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
569 $licId1 = $licenseRef1->getId();
577 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
578 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentBulk)");
579 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,12,3)");
580 $this->
dbManager->queryOnce(
"INSERT INTO jobqueue (jq_pk, jq_job_fk, jq_type, jq_args, jq_starttime, jq_endtime, jq_endtext, jq_end_bits, jq_schedinfo, jq_itemsprocessed, jq_log, jq_runonpfile, jq_host, jq_cmd_args)" 581 .
" VALUES ($jobId, 2, 'decider', '123456', '2014-08-07 09:57:27.718312+00', NULL, '', 0, NULL, 6, NULL, NULL, NULL, NULL)");
583 $this->
dbManager->queryOnce(
"INSERT INTO jobqueue (jq_pk, jq_job_fk, jq_type, jq_args, jq_starttime, jq_endtime, jq_endtext, jq_end_bits, jq_schedinfo, jq_itemsprocessed, jq_log, jq_runonpfile, jq_host, jq_cmd_args)" 584 .
" VALUES ($jobId-1, $otherJob, 'monkbulk', '123456', '2014-08-07 09:22:22.718312+00', NULL, '', 0, NULL, 6, NULL, NULL, NULL, NULL)");
585 $this->
dbManager->queryOnce(
"INSERT INTO job (job_pk, job_queued, job_priority, job_upload_fk, job_user_fk, job_group_fk)" 586 .
" VALUES ($otherJob, '2014-08-07 09:22:22.718312+00', 0, 1, 2, $groupId)");
588 $this->
dbManager->queryOnce(
"INSERT INTO license_ref_bulk (lrb_pk, user_fk, group_fk, rf_text, upload_fk, uploadtree_fk) VALUES (123456, 2, $groupId, 'foo bar', 1, 7)");
589 $this->
dbManager->queryOnce(
"INSERT INTO license_set_bulk (lrb_fk, rf_fk, removing) VALUES (123456, $licId1, 'f')");
591 $this->
dbManager->queryOnce(
"INSERT INTO upload_reuse (upload_fk, reused_upload_fk, group_fk, reused_group_fk, reuse_mode)" 592 .
" VALUES (2, 1, $groupId, $groupId, 0)");
594 require_once
'HelperPluginMock.php';
595 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=2, $groupId, $jobId, $args=
'-r4');
597 $this->assertTrue($success,
'cannot run runner');
598 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
606 $this->runnerShouldMakeDecisionAsWipIfUnhandledScannerEvent($this->runnerMock);
609 private function runnerShouldMakeDecisionAsWipIfUnhandledScannerEvent($runner)
615 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
616 $licId1 = $licenseRef1->getId();
624 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
627 $this->
dbManager->queryOnce(
"INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added)" 628 .
" VALUES (2, $itemId, $pfile, $userId, $groupId, ".DecisionTypes::IDENTIFIED.
", ".DecisionScopes::ITEM.
", '2015-05-04 11:43:18.276425+02')");
629 $isWipBeforeDecider = $this->clearingDao->isDecisionWip($itemId, $groupId);
630 assertThat($isWipBeforeDecider, equalTo(
false));
632 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$monkAgentId)");
633 $this->
dbManager->queryOnce(
"INSERT INTO jobqueue (jq_pk, jq_job_fk, jq_type, jq_args, jq_starttime, jq_endtime, jq_endtext, jq_end_bits, jq_schedinfo, jq_itemsprocessed, jq_log, jq_runonpfile, jq_host, jq_cmd_args)" 634 .
" VALUES ($jobId, 2, 'decider', '2', '2015-06-07 09:57:27.718312+00', NULL, '', 0, NULL, 6, NULL, NULL, NULL, '-r8')");
636 list($success,$output,$retCode) = $runner->run($uploadId=1, $userId, $groupId, $jobId, $args=
'-r8');
638 $this->assertTrue($success,
'cannot run runner');
639 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
641 $isWip = $this->clearingDao->isDecisionWip($itemId, $groupId);
642 assertThat($isWip, equalTo(
true));
650 $this->runnerDeciderRealShouldMakeNoDecisionForIrrelevantFiles($this->runnerMock);
653 private function runnerDeciderRealShouldMakeNoDecisionForIrrelevantFiles($runner)
659 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
660 $licId1 = $licenseRef1->getId();
667 $itemTreeBounds =
new ItemTreeBounds($itemId,
'uploadtree_a', $uploadId=1, 15, 16);
669 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
672 $this->
dbManager->queryOnce(
"INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added)" 673 .
" VALUES (2, $itemId, $pfile, $userId, $groupId, ".DecisionTypes::IRRELEVANT.
", ".DecisionScopes::ITEM.
", '2015-05-04 11:43:18.276425+02')");
674 $lastDecision = $this->clearingDao->getRelevantClearingDecision($itemTreeBounds, $groupId);
675 $lastClearingId = $lastDecision->getClearingId();
677 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$monkAgentId)");
678 $this->
dbManager->queryOnce(
"INSERT INTO jobqueue (jq_pk, jq_job_fk, jq_type, jq_args, jq_starttime, jq_endtime, jq_endtext, jq_end_bits, jq_schedinfo, jq_itemsprocessed, jq_log, jq_runonpfile, jq_host, jq_cmd_args)" 679 .
" VALUES ($jobId, 2, 'decider', '2', '2015-06-07 09:57:27.718312+00', NULL, '', 0, NULL, 6, NULL, NULL, NULL, '-r8')");
681 list($success,$output,$retCode) = $runner->run($uploadId, $userId, $groupId, $jobId,
'');
683 $this->assertTrue($success,
'cannot run runner');
684 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
686 $newDecision = $this->clearingDao->getRelevantClearingDecision($itemTreeBounds, $groupId);
687 assertThat($newDecision->getClearingId(), equalTo($lastClearingId));
testDeciderMockScanWithNoEventsAndNomosContainedInOneOfTwoEqualsMonkShouldMakeADecision()
testDeciderRealScanWithNoEventsAndNomosContainedInOneOfTwoEqualsMonkShouldMakeADecision()
testDeciderMockScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchShouldNotMakeADecision()
testDeciderMockScanWithNoEventsAndNomosContainedInMonkShouldMakeADecision()
testDeciderRealBulkReuseShouldScheduleMonkBulk()
tearDown()
Destroy objects, database and repository.
setUp()
Setup the objects, database and repository.
testDeciderRealShouldMakeNoDecisionForIrrelevantFiles()
setUpRepo()
Setup test repository.
testDeciderMockScanWithNoEventsAndOnlyNomosShouldNotMakeADecision()
Utility functions to process ClearingDecision.
testDeciderMockScanWithNoEventsAndNomosContainedInMonkWithMappedLicenseShouldMakeADecision()
Handle events related to license findings.
Functions to process clearing events.
testDeciderRealScanWithNoEventsAndNomosNotContainedInMonkShouldNotMakeADecision()
testDeciderRealScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchForSameLicenseShouldMakeADecision()
getHeartCount($output)
Get the heart count value from the agent output.
testDeciderRealScanWithNoEventsAndOnlyNomosShouldNotMakeADecision()
Test cases for interaction between decider and scheduler.
rmRepo()
Destroy test repository.
fo_dbManager * dbManager
fo_dbManager object
testDeciderMockScanWithNoEventsAndNomosNotContainedInMonkShouldNotMakeADecision()
setUpTables()
Create test tables required by agent.
testDeciderRealShouldMakeDecisionAsWipIfUnhandledScannerEvent()
testDeciderRealScanWithNoEventsAndNomosContainedInMonkWithMappedLicenseShouldMakeADecision()
testDeciderMockScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchForSameLicenseShouldMakeADecision()
testDeciderRealScanWithNoEventsAndNomosContainedInMonkShouldMakeADecision()
testDeciderRealScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchShouldNotMakeADecision()