/** 
  * \brief upload testdata
  *    prepare testdata for delagent, upload one tar file and schedule all agents
  */
 function upload_testdata()
 {
     global $SYSCONF_DIR;
     $auth = "--user fossy --password fossy -c {$SYSCONF_DIR}";
     /**  upload a tar file to one specified path */
     $out = "";
     $pos = 0;
     $upload_path = "upload_path";
     $command = "cp2foss {$auth} ../../../pkgagent/agent_tests/testdata/fossology-1.2.0-1.el5.i386.rpm -f {$upload_path} -d upload_des -q all -v";
     $last = exec("{$command} 2>&1", $out, $rtn);
     sleep(10);
     // print_r($out);
     $repo_string = "Uploading to folder: '/{$upload_path}'";
     $repo_pos = strpos($out[7], $repo_string);
     $output_msg_count = count($out);
     $this->assertGreaterThan(0, $repo_pos);
     $scheduled_agent_info_1 = "agent_pkgagent is queued to run on";
     $scheduled_agent_info_2 = "agent_nomos is queued to run on";
     $scheduled_agent_info_3 = "agent_mimetype is queued to run on";
     $scheduled_agent_info_4 = "agent_copyright is queued to run on";
     $pos = false;
     $pos = strpos($out[$output_msg_count - 1], $scheduled_agent_info_1);
     $this->assertEquals(0, $pos);
     $pos = false;
     $pos = strpos($out[$output_msg_count - 2], $scheduled_agent_info_2);
     $this->assertEquals(0, $pos);
     $pos = false;
     $pos = strpos($out[$output_msg_count - 3], $scheduled_agent_info_3);
     $this->assertEquals(0, $pos);
     $pos = false;
     $pos = strpos($out[$output_msg_count - 4], $scheduled_agent_info_4);
     $this->assertEquals(0, $pos);
     $upload_id = 0;
     /** get upload id that you just upload for testing */
     if ($out && $out[11]) {
         $upload_id = get_upload_id($out[11]);
     } else {
         $this->assertFalse(TRUE);
     }
     $agent_status = 0;
     $agent_status = check_agent_status("ununpack", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status("copyright", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status("nomos", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status("mimetype", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status("pkgagent", $upload_id);
     $this->assertEquals(1, $agent_status);
 }
Example #2
0
 /**
  * \brief upload from url
  */
 function test_upload_from_url()
 {
     //global $SYSCONF_DIR;
     global $fossology_testconfig;
     global $cp2foss_path;
     fwrite(STDOUT, " ----> Running " . __METHOD__ . "\n");
     $test_dbh = connect_to_DB($fossology_testconfig);
     $auth = "--username fossy --password fossy -c {$fossology_testconfig}";
     /** upload a file to Software Repository */
     $out = "";
     $pos = 0;
     $command = "{$cp2foss_path} {$auth} http://www.fossology.org/testdata/rpms/fedora/10/SRPMS/fossology-1.1.0-1.fc10.src.rpm -d 'fossology des' -f 'fossology path' -n 'test package'";
     fwrite(STDOUT, "DEBUG: Executing '{$command}'\n");
     $last = exec("{$command} 2>&1", $out, $rtn);
     sleep(50);
     //print "DEBUG: output is:\n";
     //print_r($out);
     $upload_id = 0;
     /** get upload id that you just upload for testing */
     if ($out && $out[5]) {
         $upload_id = get_upload_id($out[5]);
     } else {
         $this->assertFalse(TRUE);
     }
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "ununpack", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     /** do not schedule nomos */
     $agent_status = check_agent_status($test_dbh, "nomos", $upload_id);
     $this->assertEquals(0, $agent_status);
     pg_close($test_dbh);
     fwrite(STDOUT, "DEBUG: Done running " . __METHOD__ . "\n");
 }
Example #3
0
 /** 
  * \brief schedule agents
  */
 function test_reschedule_agents()
 {
     global $fossology_testconfig;
     global $scheduler_path;
     global $cp2foss_path;
     global $fossjobs_path;
     fwrite(STDOUT, " ----> Running " . __METHOD__ . "\n");
     $test_dbh = connect_to_DB($fossology_testconfig);
     $out = "";
     /** 1. upload one dir, no any agents except wget/unpack/adj2nest */
     $auth = "--username fossy --password fossy -c {$fossology_testconfig}";
     $cp2foss_command = "{$cp2foss_path} -s {$auth} ./ -f fossjobs -d 'fossjobs testing'";
     // print "cp2foss_command is:$cp2foss_command\n";
     fwrite(STDOUT, "DEBUG: " . __METHOD__ . " Line: " . __LINE__ . "  executing '{$cp2foss_command}'\n");
     $last = exec("{$cp2foss_command} 2>&1", $out, $rtn);
     //print_r($out);
     $upload_id = 0;
     /** get upload id that you just upload for testing */
     if ($out && $out[5]) {
         $upload_id = get_upload_id($out[5]);
     } else {
         $this->assertFalse(TRUE);
     }
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "ununpack", $upload_id);
     $this->assertEquals(1, $agent_status);
     /** reschedule all rest of agent */
     $command = "{$fossjobs_path} {$auth} -U {$upload_id} -A agent_copyright,agent_mimetype,agent_nomos,agent_pkgagent -v";
     fwrite(STDOUT, "DEBUG: " . __METHOD__ . " Line: " . __LINE__ . "  executing '{$command}'\n");
     $last = exec("{$command} 2>&1", $out, $rtn);
     fwrite(STDOUT, "DEBUG: " . __METHOD__ . " Line: " . __LINE__ . "  Waiting 300 seconds for the agents to complete\n");
     sleep(300);
     //wait for the agents complete $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "nomos", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "copyright", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "pkgagent", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "mimetype", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $out = "";
     /** 2. upload one file, schedule copyright except wget/unpack/adj2nest */
     $cp2foss_command = "{$cp2foss_path} -s {$auth} ./test_fossjobs.php -f fossjobs -d 'fossjobs testing copyright' -q agent_copyright";
     fwrite(STDOUT, "DEBUG: " . __METHOD__ . " Line: " . __LINE__ . "  executing '{$cp2foss_command}'\n");
     $last = exec("{$cp2foss_command} 2>&1", $out, $rtn);
     //print_r($out);
     $upload_id = 0;
     /** get upload id that you just upload for testing */
     if ($out && $out[5]) {
         $upload_id = get_upload_id($out[5]);
     } else {
         $this->assertFalse(TRUE);
     }
     sleep(5);
     //wait for the agents complete
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "ununpack", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "copyright", $upload_id);
     $this->assertEquals(1, $agent_status);
     /** reschedule just nomos */
     $command = "{$fossjobs_path} {$auth} -U {$upload_id} -v -A agent_nomos";
     fwrite(STDOUT, "DEBUG: " . __METHOD__ . " Line: " . __LINE__ . "  executing '{$command}'\n");
     $last = exec("{$command} 2>&1", $out, $rtn);
     //print_r($out);
     sleep(5);
     //wait for the agents complete
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "nomos", $upload_id);
     $this->assertEquals(1, $agent_status);
     fwrite(STDOUT, "DEBUG: Done running " . __METHOD__ . "\n");
 }
Example #4
0
 /** 
 * \brief upload from server
 * 1. upload a file to Software Repository
 * 2. upload a dir to Software Repository
 * 3. upload a dir to one specified path
 *    schedule all agents, set the description for this upload.
 * 4. Loads every file under the corrent directory, except files in the Subversion directories.  The files are
        placed in the UI under the folder "test/exclude/s-u" 
 */
 function test_upload_from_server()
 {
     global $fossology_testconfig;
     global $cp2foss_path;
     global $PG_CONN;
     fwrite(STDOUT, " ----> Running " . __METHOD__ . "\n");
     $test_dbh = $PG_CONN;
     $auth = "--username fossy --password fossy -c {$fossology_testconfig} -s ";
     /** upload a file to Software Repository */
     $out = "";
     $pos = 0;
     $command = "{$cp2foss_path} {$auth} ./test_cp2foss.php";
     fwrite(STDOUT, "DEBUG: test_upload_from_server executing '{$command}'\n");
     $last = exec("{$command} 2>&1", $out, $rtn);
     $repo_string = "Uploading to folder: 'Software Repository'";
     $repo_pos = strpos($out[1], $repo_string);
     $output_msg_count = count($out);
     print "DEBUG: \$this->assertGreaterThan(0, {$repo_pos});\n";
     $this->assertGreaterThan(0, $repo_pos);
     print "DEBUG: \$this->assertEquals(4, {$output_msg_count});\n";
     $this->assertEquals(4, $output_msg_count);
     $upload_id = 0;
     /** get upload id that you just upload for testing */
     if ($out && $out[3]) {
         $upload_id = get_upload_id($out[3]);
         print "DEBUG: Upload_id is {$upload_id}\n";
     } else {
         print "DEBUG:  Did not get an upload_id!\n";
         $this->assertFalse(TRUE);
     }
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "ununpack", $upload_id);
     $this->assertEquals(1, $agent_status);
     /** upload a dir to Software Repository */
     $out = "";
     $pos = 0;
     $command = "{$cp2foss_path} {$auth} ./";
     fwrite(STDOUT, "DEBUG: test_upload_from_server executing '{$command}'\n");
     $last = exec("{$command} 2>&1", $out, $rtn);
     $repo_string = "Uploading to folder: 'Software Repository'";
     $repo_pos = strpos($out[1], $repo_string);
     $output_msg_count = count($out);
     $this->assertGreaterThan(0, $repo_pos);
     $this->assertEquals(4, $output_msg_count);
     $upload_id = 0;
     /** get upload id that you just upload for testing */
     if ($out && $out[3]) {
         $upload_id = get_upload_id($out[3]);
     } else {
         $this->assertFalse(TRUE);
     }
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "ununpack", $upload_id);
     $this->assertEquals(1, $agent_status);
     /**  upload a dir to one specified path */
     $out = "";
     $pos = 0;
     $upload_path = "upload_path";
     $command = "{$cp2foss_path} {$auth} ./ -f {$upload_path} -d upload_des -q all -v";
     fwrite(STDOUT, "DEBUG: Executing '{$command}'\n");
     $last = exec("{$command} 2>&1", $out, $rtn);
     $repo_string = "Uploading to folder: '/{$upload_path}'";
     $repo_pos = strpos($out[7], $repo_string);
     $output_msg_count = count($out);
     print "DEBUG: \$this->assertGreaterThan(0, {$repo_pos})\n";
     $this->assertGreaterThan(0, $repo_pos);
     $scheduled_agent_info_1 = "agent_pkgagent is queued to run on";
     $scheduled_agent_info_2 = "agent_nomos is queued to run on";
     $scheduled_agent_info_3 = "agent_monk is queued to run on";
     $scheduled_agent_info_4 = "agent_mimetype is queued to run on";
     $scheduled_agent_info_5 = "agent_copyright is queued to run on";
     $pos = false;
     $pos = strpos($out[$output_msg_count - 1], $scheduled_agent_info_1);
     $this->assertEquals(0, $pos);
     $pos = false;
     $pos = strpos($out[$output_msg_count - 2], $scheduled_agent_info_2);
     $this->assertEquals(0, $pos);
     $pos = false;
     $pos = strpos($out[$output_msg_count - 3], $scheduled_agent_info_3);
     $this->assertEquals(0, $pos);
     $pos = false;
     $pos = strpos($out[$output_msg_count - 4], $scheduled_agent_info_4);
     $this->assertEquals(0, $pos);
     $pos = false;
     $pos = strpos($out[$output_msg_count - 5], $scheduled_agent_info_5);
     $this->assertEquals(0, $pos);
     $upload_id = 0;
     /** get upload id that you just upload for testing */
     if ($out && $out[11]) {
         $upload_id = get_upload_id($out[11]);
     } else {
         $this->assertFalse(TRUE);
     }
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "ununpack", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "copyright", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "nomos", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "mimetype", $upload_id);
     $this->assertEquals(1, $agent_status);
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "pkgagent", $upload_id);
     $this->assertEquals(1, $agent_status);
     /** cp2foss --user USER --password PASSWORD -q all -A -f test/exclude -n 'test exclue dir'  \ 
         -d 'test des exclude dir' -X .svn -X ./ -v */
     $out = "";
     $pos = 0;
     $command = "{$cp2foss_path} {$auth} -q all -A -f test/exclude -n 'test exclue dir'  -d 'test des exclude dir' -X .svn ./ -v";
     fwrite(STDOUT, "DEBUG: Running {$command}\n");
     $last = exec("{$command} 2>&1", $out, $rtn);
     $upload_id = 0;
     /** get upload id that you just upload for testing */
     if ($out && $out[23]) {
         $upload_id = get_upload_id($out[23]);
     } else {
         $this->assertFalse(TRUE);
     }
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "ununpack", $upload_id);
     $this->assertEquals(1, $agent_status);
     pg_close($test_dbh);
     fwrite(STDOUT, "DEBUG: Done running " . __METHOD__ . "\n");
 }
 /**
  * \brief populate test data via upload from url
  */
 function upload_from_url()
 {
     //global $SYSCONF_DIR;
     global $fossology_testconfig;
     global $fo_cli_path;
     global $cp2foss_path;
     $test_dbh = connect_to_DB($fossology_testconfig);
     //$auth = "--user fossy --password fossy -c $SYSCONF_DIR";
     $auth = "--user fossy --password fossy -c {$fossology_testconfig}";
     /** upload a file to Software Repository */
     $out = "";
     $pos = 0;
     $command = "{$cp2foss_path} {$auth} http://www.fossology.org/rpms/fedora/10/i386/fossology-devel-1.1.0-1.fc10.i386.rpm -d 'fossology des' -f 'fossology path' -n 'test package' -q 'all'";
     fwrite(STDOUT, "DEBUG: Executing '{$command}'\n");
     $last = exec("{$command} 2>&1", $out, $rtn);
     /** wait for all the scheduled agents complete */
     sleep(100);
     $upload_id = 0;
     /** get upload id that you just upload for testing */
     if ($out && $out[5]) {
         $upload_id = get_upload_id($out[5]);
     } else {
         $this->assertFalse(TRUE);
     }
     $agent_status = 0;
     $agent_status = check_agent_status($test_dbh, "ununpack", $upload_id);
     $this->assertEquals(1, $agent_status);
     $uploadtree_id = get_uploadtree_id($test_dbh, $upload_id);
     // get uploadtree id
     pg_close($test_dbh);
     fwrite(STDOUT, "DEBUG: upload_id is:{$upload_id}\n");
     return array($upload_id, $uploadtree_id);
 }