35 include_once(__DIR__.
'/../../../lib/php/Test/Agent/AgentTestMockHelper.php');
36 include_once(__DIR__.
'/SchedulerTestRunnerCli.php');
75 $this->testDb =
new TestPgDb(
"spdx2test");
76 $this->
dbManager = $this->testDb->getDbManager();
79 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
81 $this->agentDir = dirname(dirname(__DIR__));
89 $this->testDb->fullDestruct();
99 $sysConf = $this->testDb->getFossSysConf();
101 $this->testInstaller->init();
102 $this->testInstaller->cpRepo();
103 $this->testInstaller->install($this->agentDir);
111 $this->testInstaller->uninstall($this->agentDir);
112 $this->testInstaller->rmRepo();
113 $this->testInstaller->clear();
121 $this->testDb->createPlainTables(array(),
true);
122 $this->testDb->createInheritedTables();
123 $this->
dbManager->queryOnce(
"CREATE TABLE copyright_ars () INHERITS (ars_master)");
125 $this->testDb->createSequences(array(
'agent_agent_pk_seq',
'pfile_pfile_pk_seq',
'upload_upload_pk_seq',
126 'nomos_ars_ars_pk_seq',
'license_file_fl_pk_seq',
'license_ref_rf_pk_seq',
127 'license_ref_bulk_lrb_pk_seq',
'clearing_decision_clearing_decision_pk_seq',
128 'clearing_event_clearing_event_pk_seq'));
129 $this->testDb->createConstraints(array(
'agent_pkey',
'pfile_pkey',
'upload_pkey_idx',
130 'FileLicense_pkey',
'clearing_event_pkey'));
131 $this->testDb->alterTables(array(
'agent',
'pfile',
'upload',
'ars_master',
'license_ref_bulk',
'license_set_bulk',
132 'clearing_event',
'clearing_decision',
'license_file',
'highlight'));
134 $this->testDb->insertData(array(
'mimetype_ars',
'pkgagent_ars',
'ununpack_ars',
'decider_ars'),
true,__DIR__.
'/fo_report.sql');
135 $this->testDb->resetSequenceAsMaxOf(
'agent_agent_pk_seq',
'agent',
'agent_pk');
144 if (preg_match(
"/.*HEART: ([0-9]*).*/", $output, $matches)) {
145 return intval($matches[1]);
173 $this->
dbManager->queryOnce(
"ALTER TABLE uploadtree_a RENAME TO uploadtree_$uploadId", __METHOD__.
'.alterUploadtree');
174 $this->
dbManager->getSingleRow(
"UPDATE upload SET uploadtree_tablename=$1 WHERE upload_pk=$2",
175 array(
"uploadtree_$uploadId",$uploadId),__METHOD__.
'.alterUpload');
187 list($success,$output,$retCode) = $this->runnerCli->run($uploadId, $this->userId, $this->groupId, $jobId);
189 assertThat(
'cannot run runner', $success, equalTo(
true));
190 assertThat(
'report failed: "'.$output.
'"', $retCode, equalTo(0));
202 $row = $this->
dbManager->getSingleRow(
"SELECT upload_fk,job_fk,filepath FROM reportgen WHERE job_fk = $1", array($jobId),
204 assertThat($row, hasKeyValuePair(
'upload_fk', $uploadId));
205 assertThat($row, hasKeyValuePair(
'job_fk', $jobId));
206 $filepath = $row[
'filepath'];
207 assertThat($filepath, endsWith(
'.rdf'));
208 assertThat(file_exists($filepath),equalTo(
true));
230 $copyrightStatement =
'Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved';
231 assertThat(file_get_contents($filepath), stringContainsInOrder($copyrightStatement));
233 $email =
'condor-admin@cs.wisc.edu';
234 assertThat(file_get_contents($filepath), not(stringContainsInOrder($email)));
236 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
250 $verification = exec(
"java -jar $toolJarFile Verify $filepath");
251 assertThat($verification,equalTo(
'This SPDX Document is valid.'));
270 $jarFileBasename =
'spdx-tools-'.$version.
'-jar-with-dependencies.jar';
271 $jarFile = __DIR__.
'/'.$jarFileBasename;
272 if (!file_exists($jarFile)) {
273 $zipFileBasename=
'SPDXTools-'.$tag.
'.zip';
274 $zipFile=__DIR__.
'/'.$zipFileBasename;
275 if (!file_exists($zipFile)) {
276 file_put_contents($zipFile, fopen(
'https://github.com/spdx/tools/releases/download/'.$tag.
'/'.$zipFileBasename,
'r'));
279 $this->assertFileExists($zipFile,
'could not download SPDXTools');
281 system(
'unzip -n -d '.__DIR__.
' '.$zipFile);
282 rename (__DIR__.
'/SPDXTools-'.$tag.
'/'.$jarFileBasename, $jarFile);
284 $this->assertFileExists($jarFile,
'could not extract SPDXTools');
295 exec(
'which java', $lines, $returnVar);
296 $this->assertEquals(0,$returnVar,
'java required for this test');
testSpdxForSpecialUploadtreeTable()
Test SPDX2 agent for RDF.
runJobFromJobque($uploadId, $jobId)
Run jobs from queue.
getReportFilepathFromJob($uploadId, $jobId)
Get the file path for report from DB.
getHeartCount($output)
Get the heart count from agent.
pullSpdxTools()
Pull SPDX toolkit from github if not found.
rmRepo()
Teardown test repo.
setUpRepo()
Setup test repo.
tearDown()
Teardown test db.
Namespace to hold test cases for SPDX2 agent.
Tests for SPDX2 agent and scheduler interaction.
setUpTables()
Setup tables required for test.
testSpdxForNormalUploadtreeTable()
Test SPDX2 agent for RDF.
Handles scheduler interaction.
fo_dbManager * dbManager
fo_dbManager object
verifyJavaIsInstalled()
Verify if java is intalled on the system.
runAndTestReportRDF($uploadId=1)
Create RDF report and check it.
list_t type structure used to keep various lists. (e.g. there are multiple lists).
verifyRdf($filepath)
Use SPDX toolkit to verify RDF file format.