34 include_once(__DIR__.
'/../../../lib/php/Test/Agent/AgentTestMockHelper.php');
35 include_once(__DIR__.
'/SchedulerTestRunnerCli.php');
36 include_once(__DIR__.
'/SchedulerTestRunnerMock.php');
49 private $testInstaller;
56 private $clearingDecisionProcessor;
58 private $agentLicenseEventProcessor;
62 private $uploadPermDao;
64 private $highlightDao;
68 private $copyrightDao;
70 private $compatibilityDao;
79 protected function setUp() : void
81 $this->testDb =
new TestPgDb(
"deciderSched");
82 $this->
dbManager = $this->testDb->getDbManager();
83 $this->testDb->setupSysconfig();
86 $logger = M::mock(
'Monolog\Logger');
87 $this->uploadPermDao = \Mockery::mock(UploadPermissionDao::class);
97 $this->copyrightDao = M::mock(CopyrightDao::class);
98 $this->compatibilityDao = M::mock(CompatibilityDao::class);
100 $this->compatibilityDao->shouldReceive(
'getCompatibilityForFile')->andReturn(
true);
103 $container = M::mock(
'ContainerBuilder');
104 $container->shouldReceive(
'get')->withArgs(array(
'db.manager'))->andReturn($this->
dbManager);
107 $this->clearingDao, $this->uploadDao, $this->highlightDao,
108 $this->showJobsDao, $this->copyrightDao, $this->compatibilityDao,
109 $this->licenseDao, $this->clearingDecisionProcessor,
110 $this->agentLicenseEventProcessor);
119 $this->testDb->fullDestruct();
120 $this->testDb =
null;
122 $this->licenseDao =
null;
123 $this->highlightDao =
null;
124 $this->showJobsDao =
null;
125 $this->clearingDao =
null;
126 $this->copyrightDao =
null;
135 $sysConf = $this->testDb->getFossSysConf();
137 $this->testInstaller->init();
138 $this->testInstaller->cpRepo();
146 $this->testInstaller->rmRepo();
147 $this->testInstaller->clear();
155 $this->testDb->createPlainTables(array(
'upload',
'upload_reuse',
'uploadtree',
'uploadtree_a',
'license_ref',
'license_ref_bulk',
156 'license_set_bulk',
'clearing_decision',
'clearing_decision_event',
'clearing_event',
'license_file',
'highlight',
157 'highlight_keyword',
'agent',
'pfile',
'ars_master',
'users',
'group_user_member',
'license_map',
'jobqueue',
'job',
158 'report_info',
'license_rules'),
false);
159 $this->testDb->createSequences(array(
'agent_agent_pk_seq',
'pfile_pfile_pk_seq',
'upload_upload_pk_seq',
'nomos_ars_ars_pk_seq',
160 'license_file_fl_pk_seq',
'license_ref_rf_pk_seq',
'license_ref_bulk_lrb_pk_seq',
161 'clearing_decision_clearing_decision_pk_seq',
'clearing_event_clearing_event_pk_seq',
'FileLicense_pkey',
162 'jobqueue_jq_pk_seq',
'job_job_pk_seq',
'license_rules_lr_pk_seq'),
false);
163 $this->testDb->createViews(array(
'license_file_ref'),
false);
164 $this->testDb->createConstraints(array(
'agent_pkey',
'pfile_pkey',
'upload_pkey_idx',
'clearing_event_pkey',
'jobqueue_pkey',
'license_rules_pkey'),
false);
165 $this->testDb->alterTables(array(
'agent',
'pfile',
'upload',
'ars_master',
'license_ref_bulk',
'license_set_bulk',
'clearing_event',
166 'clearing_decision',
'license_file',
'license_ref',
'highlight',
'jobqueue',
'job',
'license_rules'),
false);
167 $this->testDb->createInheritedTables();
168 $this->testDb->createInheritedArsTables(array(
'nomos',
'monk',
'copyright'));
170 $this->testDb->insertData(array(
'pfile',
'upload',
'uploadtree_a',
'users',
'group_user_member',
'agent',
'license_file',
171 'nomos_ars',
'monk_ars',
'copyright_ars'),
false);
172 $this->testDb->insertData_license_ref(80);
174 $this->testDb->resetSequenceAsMaxOf(
'agent_agent_pk_seq',
'agent',
'agent_pk');
185 if (preg_match(
"/.*HEART: ([0-9]*).*/", $output, $matches)) {
186 return intval($matches[1]);
195 $this->runnerDeciderScanWithNoEventsAndOnlyNomosShouldNotMakeADecision($this->runnerMock);
201 $this->runnerDeciderScanWithNoEventsAndOnlyNomosShouldNotMakeADecision($this->runnerCli);
204 private function runnerDeciderScanWithNoEventsAndOnlyNomosShouldNotMakeADecision($runner)
209 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
211 $licId1 = $licenseRef1->getId();
217 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
218 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
219 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,12,3)");
220 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
221 $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)"
222 .
" VALUES ($jobId, 2, 'decider', '2', '2014-08-07 09:57:27.718312+00', NULL, '', 0, NULL, 6, NULL, NULL, NULL, NULL)");
224 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId, $args=
'');
226 $this->assertTrue($success,
'cannot run runner');
227 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
231 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
232 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
233 assertThat($decisions, is(arrayWithSize(0)));
241 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkShouldMakeADecision($this->runnerMock);
247 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkShouldMakeADecision($this->runnerCli);
250 private function runnerDeciderScanWithNoEventsAndNomosContainedInMonkShouldMakeADecision($runner)
255 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
257 $licId1 = $licenseRef1->getId();
263 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
264 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
265 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,12,3)");
266 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
268 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId1,$pfile,$agentMonkId)");
269 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,11,2)");
270 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
271 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
273 $this->assertTrue($success,
'cannot run runner');
274 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
278 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
279 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
280 assertThat($decisions, is(arrayWithSize(1)));
288 $this->runnerDeciderScanWithNoEventsAndNomosNotContainedInMonkShouldNotMakeADecision($this->runnerMock);
294 $this->runnerDeciderScanWithNoEventsAndNomosNotContainedInMonkShouldNotMakeADecision($this->runnerCli);
297 private function runnerDeciderScanWithNoEventsAndNomosNotContainedInMonkShouldNotMakeADecision($runner)
302 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
304 $licId1 = $licenseRef1->getId();
310 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
311 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
312 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,10,3)");
313 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
315 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId1,$pfile,$agentMonkId)");
316 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,11,2)");
317 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
319 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
321 $this->assertTrue($success,
'cannot run runner');
322 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
326 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
327 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
328 assertThat($decisions, is(arrayWithSize(0)));
336 $this->runnerDeciderScanWithNoEventsAndNomosContainedInOneOfTwoEqualsMonkShouldMakeADecision($this->runnerMock);
342 $this->runnerDeciderScanWithNoEventsAndNomosContainedInOneOfTwoEqualsMonkShouldMakeADecision($this->runnerCli);
345 private function runnerDeciderScanWithNoEventsAndNomosContainedInOneOfTwoEqualsMonkShouldMakeADecision($runner)
350 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
352 $licId1 = $licenseRef1->getId();
358 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
359 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
360 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,10,3)");
361 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
363 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId1,$pfile,$agentMonkId)");
364 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,11,2)");
365 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
367 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12224,$licId1,$pfile,$agentMonkId)");
368 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,9,2)");
369 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,18,19)");
371 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
373 $this->assertTrue($success,
'cannot run runner');
374 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
378 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
379 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
380 assertThat($decisions, is(arrayWithSize(1)));
388 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithMappedLicenseShouldMakeADecision($this->runnerMock);
394 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithMappedLicenseShouldMakeADecision($this->runnerCli);
397 private function runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithMappedLicenseShouldMakeADecision($runner)
402 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
403 $licenseRef2 = $this->licenseDao->getLicenseByShortName(
"BSL-1.0")->getRef();
404 $licenseRef3 = $this->licenseDao->getLicenseByShortName(
"ZPL-1.1")->getRef();
406 $licId1 = $licenseRef1->getId();
407 $licId2 = $licenseRef2->getId();
408 $licId3 = $licenseRef3->getId();
414 $this->
dbManager->queryOnce(
"INSERT INTO license_map(rf_fk, rf_parent, usage) VALUES ($licId2, $licId1, ".LicenseMap::CONCLUSION.
")");
415 $this->
dbManager->queryOnce(
"INSERT INTO license_map(rf_fk, rf_parent, usage) VALUES ($licId3, $licId1, ".LicenseMap::CONCLUSION.
")");
417 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
418 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
419 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,10,3)");
420 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
422 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId2,$pfile,$agentMonkId)");
423 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,6,2)");
424 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
426 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12224,$licId3,$pfile,$agentMonkId)");
427 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,9,2)");
428 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,13,19)");
430 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
432 $this->assertTrue($success,
'cannot run runner');
433 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
437 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
438 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
439 assertThat($decisions, is(arrayWithSize(1)));
447 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchShouldNotMakeADecision($this->runnerMock);
453 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchShouldNotMakeADecision($this->runnerCli);
456 private function runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchShouldNotMakeADecision($runner)
461 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
462 $licenseRef2 = $this->licenseDao->getLicenseByShortName(
"BSL-1.0")->getRef();
463 $licenseRef3 = $this->licenseDao->getLicenseByShortName(
"ZPL-1.1")->getRef();
465 $licId1 = $licenseRef1->getId();
466 $licId2 = $licenseRef2->getId();
467 $licId3 = $licenseRef3->getId();
474 $this->
dbManager->queryOnce(
"INSERT INTO license_map(rf_fk, rf_parent, usage) VALUES ($licId2, $licId1, ".LicenseMap::CONCLUSION.
")");
476 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
477 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
478 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,10,3)");
479 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
481 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId2,$pfile,$agentMonkId)");
482 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,6,2)");
483 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
485 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12224,$licId3,$pfile,$agentOther)");
486 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,9,2)");
487 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,13,19)");
489 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
491 $this->assertTrue($success,
'cannot run runner');
492 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
496 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
497 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
498 assertThat($decisions, is(arrayWithSize(0)));
506 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchForSameLicenseShouldMakeADecision($this->runnerMock);
512 $this->runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchForSameLicenseShouldMakeADecision($this->runnerCli);
515 private function runnerDeciderScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchForSameLicenseShouldMakeADecision($runner)
520 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
521 $licenseRef2 = $this->licenseDao->getLicenseByShortName(
"BSL-1.0")->getRef();
522 $licenseRef3 = $this->licenseDao->getLicenseByShortName(
"ZPL-1.1")->getRef();
524 $licId1 = $licenseRef1->getId();
525 $licId2 = $licenseRef2->getId();
526 $licId3 = $licenseRef3->getId();
533 $this->
dbManager->queryOnce(
"INSERT INTO license_map(rf_fk, rf_parent, usage) VALUES ($licId2, $licId1, ".LicenseMap::CONCLUSION.
")");
534 $this->
dbManager->queryOnce(
"INSERT INTO license_map(rf_fk, rf_parent, usage) VALUES ($licId3, $licId1, ".LicenseMap::CONCLUSION.
")");
536 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
537 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentNomosId)");
538 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,10,3)");
539 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,18,3)");
541 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12223,$licId2,$pfile,$agentMonkId)");
542 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,6,2)");
543 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12223,13,19)");
545 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12224,$licId3,$pfile,$agentOther)");
546 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,9,2)");
547 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12224,13,19)");
549 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=6, $groupId=4, $jobId=31, $args=
"");
551 $this->assertTrue($success,
'cannot run runner');
552 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
556 $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
557 $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
558 assertThat($decisions, is(arrayWithSize(1)));
567 $this->runnerBulkReuseShouldScheduleMonkBulk($this->runnerMock);
570 private function runnerBulkReuseShouldScheduleMonkBulk($runner)
575 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
576 $licId1 = $licenseRef1->getId();
584 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
585 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$agentBulk)");
586 $this->
dbManager->queryOnce(
"INSERT INTO highlight (fl_fk,start,len) VALUES(12222,12,3)");
587 $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)"
588 .
" VALUES ($jobId, 2, 'decider', '123456', '2014-08-07 09:57:27.718312+00', NULL, '', 0, NULL, 6, NULL, NULL, NULL, NULL)");
590 $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)"
591 .
" VALUES ($jobId-1, $otherJob, 'monkbulk', '123456', '2014-08-07 09:22:22.718312+00', NULL, '', 0, NULL, 6, NULL, NULL, NULL, NULL)");
592 $this->
dbManager->queryOnce(
"INSERT INTO job (job_pk, job_queued, job_priority, job_upload_fk, job_user_fk, job_group_fk)"
593 .
" VALUES ($otherJob, '2014-08-07 09:22:22.718312+00', 0, 1, 2, $groupId)");
595 $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, 1)");
596 $this->
dbManager->queryOnce(
"INSERT INTO license_set_bulk (lrb_fk, rf_fk, removing) VALUES (123456, $licId1, 'f')");
598 $this->
dbManager->queryOnce(
"INSERT INTO upload_reuse (upload_fk, reused_upload_fk, group_fk, reused_group_fk, reuse_mode)"
599 .
" VALUES (2, 1, $groupId, $groupId, 0)");
601 require_once
'HelperPluginMock.php';
602 list($success,$output,$retCode) = $runner->run($uploadId=2, $userId=2, $groupId, $jobId, $args=
'-r4');
604 $this->assertTrue($success,
'cannot run runner');
605 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
613 $this->runnerShouldMakeDecisionAsWipIfUnhandledScannerEvent($this->runnerMock);
616 private function runnerShouldMakeDecisionAsWipIfUnhandledScannerEvent($runner)
622 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
623 $licId1 = $licenseRef1->getId();
631 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
634 $this->
dbManager->queryOnce(
"INSERT INTO clearing_decision (uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added)"
635 .
" VALUES ($itemId, $pfile, $userId, $groupId, ".DecisionTypes::IDENTIFIED.
", ".DecisionScopes::ITEM.
", '2015-05-04 11:43:18.276425+02')");
636 $isWipBeforeDecider = $this->clearingDao->isDecisionCheck($itemId, $groupId, DecisionTypes::WIP);
637 assertThat($isWipBeforeDecider, equalTo(
false));
639 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$monkAgentId)");
640 $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)"
641 .
" VALUES ($jobId, 2, 'decider', '2', '2015-06-07 09:57:27.718312+00', NULL, '', 0, NULL, 6, NULL, NULL, NULL, '-r8')");
643 list($success,$output,$retCode) = $runner->run($uploadId=1, $userId, $groupId, $jobId, $args=
'-r8');
645 $this->assertTrue($success,
'cannot run runner');
646 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
648 $isWip = $this->clearingDao->isDecisionCheck($itemId, $groupId, DecisionTypes::WIP);
649 assertThat($isWip, equalTo(
true));
657 $this->runnerDeciderRealShouldMakeNoDecisionForIrrelevantFiles($this->runnerMock);
660 private function runnerDeciderRealShouldMakeNoDecisionForIrrelevantFiles($runner)
666 $licenseRef1 = $this->licenseDao->getLicenseByShortName(
"SPL-1.0")->getRef();
667 $licId1 = $licenseRef1->getId();
674 $itemTreeBounds =
new ItemTreeBounds($itemId,
'uploadtree_a', $uploadId=1, 15, 16);
676 $this->
dbManager->queryOnce(
"DELETE FROM license_file");
679 $this->
dbManager->queryOnce(
"INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added)"
680 .
" VALUES (2, $itemId, $pfile, $userId, $groupId, ".DecisionTypes::IRRELEVANT.
", ".DecisionScopes::ITEM.
", '2015-05-04 11:43:18.276425+02')");
681 $lastDecision = $this->clearingDao->getRelevantClearingDecision($itemTreeBounds, $groupId);
682 $lastClearingId = $lastDecision->getClearingId();
684 $this->
dbManager->queryOnce(
"INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,$licId1,$pfile,$monkAgentId)");
685 $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)"
686 .
" VALUES ($jobId, 2, 'decider', '2', '2015-06-07 09:57:27.718312+00', NULL, '', 0, NULL, 6, NULL, NULL, NULL, '-r8')");
688 list($success,$output,$retCode) = $runner->run($uploadId, $userId, $groupId, $jobId,
'');
690 $this->assertTrue($success,
'cannot run runner');
691 $this->assertEquals($retCode, 0,
'decider failed (did you make test?): '.$output);
693 $newDecision = $this->clearingDao->getRelevantClearingDecision($itemTreeBounds, $groupId);
694 assertThat($newDecision->getClearingId(), equalTo($lastClearingId));
Test cases for interaction between decider and scheduler.
testDeciderRealShouldMakeNoDecisionForIrrelevantFiles()
testDeciderMockScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchForSameLicenseShouldMakeADecision()
testDeciderRealBulkReuseShouldScheduleMonkBulk()
testDeciderRealScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchForSameLicenseShouldMakeADecision()
setUp()
Setup the objects, database and repository.
testDeciderMockScanWithNoEventsAndNomosContainedInMonkWithMappedLicenseShouldMakeADecision()
testDeciderRealScanWithNoEventsAndOnlyNomosShouldNotMakeADecision()
testDeciderMockScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchShouldNotMakeADecision()
getHeartCount($output)
Get the heart count value from the agent output.
testDeciderRealScanWithNoEventsAndNomosContainedInMonkShouldMakeADecision()
rmRepo()
Destroy test repository.
testDeciderMockScanWithNoEventsAndOnlyNomosShouldNotMakeADecision()
testDeciderMockScanWithNoEventsAndNomosNotContainedInMonkShouldNotMakeADecision()
setUpRepo()
Setup test repository.
tearDown()
Destroy objects, database and repository.
setUpTables()
Create test tables required by agent.
testDeciderRealShouldMakeDecisionAsWipIfUnhandledScannerEvent()
testDeciderRealScanWithNoEventsAndNomosContainedInMonkWithButWithOtherAgentMatchShouldNotMakeADecision()
testDeciderMockScanWithNoEventsAndNomosContainedInOneOfTwoEqualsMonkShouldMakeADecision()
testDeciderMockScanWithNoEventsAndNomosContainedInMonkShouldMakeADecision()
testDeciderRealScanWithNoEventsAndNomosContainedInOneOfTwoEqualsMonkShouldMakeADecision()
testDeciderRealScanWithNoEventsAndNomosNotContainedInMonkShouldNotMakeADecision()
testDeciderRealScanWithNoEventsAndNomosContainedInMonkWithMappedLicenseShouldMakeADecision()
Handle events related to license findings.
Utility functions to process ClearingDecision.
Functions to process clearing events.
Wrapper class for license map.
fo_dbManager * dbManager
fo_dbManager object