Integration Testlink/Mantis

Ask community to help.

Moderators: Amaradana, TurboPT, TL Developers

maryegra
TestLink user
Posts: 11
Joined: Tue Oct 13, 2009 3:46 pm

Integration Testlink/Mantis

Post by maryegra »

I tried to set up bugtracking system (Mantis 1.1.8) integration in Testlink 1.8.4, taking the steps below:

1. In mantis config_inc.php I added the following lines:
# --- anonymous login -----------
# Allow anonymous login
$g_allow_anonymous_login = ON;
$g_anonymous_account = 'mar';

2. In <my testlink main directory>\cfg\mantis.cfg.php. I added the following lines:

//Set the bug tracking system Interface to MANTIS 0.19.1
//also tested with MANTIS 1.0.0.a3

/** The DB host to use when connecting to the mantis db */
define('BUG_TRACK_DB_HOST', 'extremo'); //It´s my localhost name

/** The name of the database that contains the mantis tables */
define('BUG_TRACK_DB_NAME', 'mantisdb'); //It´s my mantis database

/** The DB type being used by mantis
values: mysql,mssql,postgres
*/
define('BUG_TRACK_DB_TYPE', 'mysql');

/** The DB password and user to use for connecting to the mantis db */
define('BUG_TRACK_DB_USER', 'mantis');
define('BUG_TRACK_DB_PASS', 'maryebra');
//I allowed this user to access mantis db by the following mysql instruction:
// mysql> grant all on mantisbd.* to ‘mantis’@’extremo’ identified by ‘maryebra’

#define('BUG_TRACK_DB_CHARSET',"windows-1250");
// define('BUG_TRACK_DB_CHARSET',"gb2312");
// define('BUG_TRACK_DB_CHARSET',"UTF-8");

define('BUG_TRACK_HREF', "http://extremo/mantis/view.php?id=");

/** link to the bugtracking system, for entering new bugs */
define('BUG_TRACK_ENTER_BUG_HREF',"http://extremo/mantis/");


3. I copied the following line from config.inc.php to custom_config.inc.php.

$g_interface_bugs='MANTIS'

Then when I go to execute a test case in testlink and check that the test case was failed, there is no sign about that the BTS is enabled; the bug management is not available. I don´t know what happens, so I will be very grateful if you give me any answer.
eeijlar
Advanced user
Posts: 28
Joined: Mon Apr 06, 2009 4:25 pm

Post by eeijlar »

First thing you need to do is check that PHP is connecting to the MYSQL database properly. Create a php file in your www root folder like this:

Code: Select all

<?
phpinfo();
?>
Load up that page and see if the MySQL connection is ok to the database. It should be listed.[/code]
maryegra
TestLink user
Posts: 11
Joined: Tue Oct 13, 2009 3:46 pm

Post by maryegra »

I´ve just done it and it seems that the mysql connection is ok. The page shows the following information about mysql:


mysql

MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 5.0.51a

Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off

I don´t see any problem here...where else do you think the problem with the bugtracking connection could be??

Thank you very much!!!
eeijlar
Advanced user
Posts: 28
Joined: Mon Apr 06, 2009 4:25 pm

Post by eeijlar »

maryegra wrote:I´ve just done it and it seems that the mysql connection is ok. The page shows the following information about mysql:


mysql

MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 5.0.51a

Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off

I don´t see any problem here...where else do you think the problem with the bugtracking connection could be??

Thank you very much!!!
Ok, in that case now you need to check if PHP can access the mysql database:

In the same place that you created the phpinfo() file create a file with the following information:

Code: Select all

<?
$username="username";
$password="password";
$database="your_database";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

 echo "<html><head><title>MySQL PHP Test</title></head><body>";
    echo "<center><h2>MySQL PHP Test</h2><br>";
    echo "<table border=1 cellspacing='0' width='50%'>\n<tr>\n";
    echo "<td><b>Table</b></td>\n<td><b>Table Data</b</td>\n</tr>\n";
 echo "<tr><td colspan='2'></td</tr></table>";
    echo "<br><em></em><br></center></body></html>\n";


mysql_close();

?>
Update the code above to use the username and password, and database for MANTIS. Load that page and see what happens. If there are no errors then PHP is connecting to the database.

Check the Apache error logs and see if there is anything there.
maryegra
TestLink user
Posts: 11
Joined: Tue Oct 13, 2009 3:46 pm

Post by maryegra »

I,ve created a file with the following information:

Code: Select all

<?
$username="mantis";
$password="maryebra";
$database="mantisdb";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

 echo "<html><head><title>MySQL PHP Test</title></head><body>";
    echo "<center><h2>MySQL PHP Test</h2><br>";
    echo "<table border=1 cellspacing='0' width='50%'>\n<tr>\n";
    echo "<td><b>Table</b></td>\n<td><b>Table Data</b</td>\n</tr>\n";
 echo "<tr><td colspan='2'></td</tr></table>";
    echo "<br><em></em><br></center></body></html>\n";


mysql_close();

?>
I´ve updated the code with my own username, password and mantis database and the page displayed was:

{\rtf1\ansi\ansicpg1252\deff0\deflang3082{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\f0\fs20 ";\par echo "
MySQL PHP Test

";\par echo "\\n\\n";\par echo "\\n\\n\\n";\par echo "
Table Table Data
";\par echo "

\\n";\par \par \par mysql_close();\par \par ?> \par } �

I really don´t know what happens!!!But I suspect that it´s not the expected result! :cry:
eeijlar
Advanced user
Posts: 28
Joined: Mon Apr 06, 2009 4:25 pm

Post by eeijlar »

Sorry you need to change the tag at the top from <? to <?php

It doesn't know that it's a php file. Make sure the file has a .php extension too..
maryegra
TestLink user
Posts: 11
Joined: Tue Oct 13, 2009 3:46 pm

Post by maryegra »

ok!!!!the problem was the extension of the file, I saved as a php file but not as txt...anyway I think everything It´s ok, the page displayed shows an empty table like this one:

MySQL PHP Test

Table Table Data
eeijlar
Advanced user
Posts: 28
Joined: Mon Apr 06, 2009 4:25 pm

Post by eeijlar »

maryegra wrote:ok!!!!the problem was the extension of the file, I saved as a php file but not as txt...anyway I think everything It´s ok, the page displayed shows an empty table like this one:

MySQL PHP Test

Table Table Data
Ok, so it can connect to the database.. Now let's see if it can get some data:

Code: Select all

$id="put bug id in here";

$query = "SELECT status FROM mantis_bug_table WHERE id='" . $id."'";

$result = mysql_query($query);
Then put this in the html bit:

Code: Select all

echo "<td>Bug Id</td><td>". $result"</td>";
maryegra
TestLink user
Posts: 11
Joined: Tue Oct 13, 2009 3:46 pm

Post by maryegra »

It shows in the page the following text:

Bug IdResource id #3

When I put in the code

$id="2";

It doesn´t mind what i put there, if I put $id="3"; it shows the same; so I think something is wrong here. I´ve seen the real value of the bug (with id= 2) status in the database and it´s 10.

So php is not able to get data from the database. What can I do?
eeijlar
Advanced user
Posts: 28
Joined: Mon Apr 06, 2009 4:25 pm

Post by eeijlar »

maryegra wrote:It shows in the page the following text:

Bug IdResource id #3

When I put in the code

$id="2";

It doesn´t mind what i put there, if I put $id="3"; it shows the same; so I think something is wrong here. I´ve seen the real value of the bug (with id= 2) status in the database and it´s 10.

So php is not able to get data from the database. What can I do?
Sorry, I'm not clear on what is happening. Can you tell me the value of $result on this line:

echo "<td>Bug Id</td><td>". $result"</td>";

Check your apache logs for more details.
eeijlar
Advanced user
Posts: 28
Joined: Mon Apr 06, 2009 4:25 pm

Post by eeijlar »

Also run this query manually from mysql and see what comes out:

Code: Select all

SELECT status FROM mantis_bug_table WHERE id='3';
maryegra
TestLink user
Posts: 11
Joined: Tue Oct 13, 2009 3:46 pm

Post by maryegra »

I´ve done it and it returns status = 80; and that´s not what apears in the php page..what happens??why the page can not show this value?what can I do?
eeijlar
Advanced user
Posts: 28
Joined: Mon Apr 06, 2009 4:25 pm

Post by eeijlar »

Check your apache logs to see if there is an SQL error. You are looking for a file called error_log.

Try this command from your command prompt:

Code: Select all

locate error_log
There will be a number of log files output. You are looking for the one with httpd in the path. Then look at the log file and see if there is anything output there.
maryegra
TestLink user
Posts: 11
Joined: Tue Oct 13, 2009 3:46 pm

Post by maryegra »

I don´t find any sql error in error.log (it´s at the same folder that httpd.pid) that is located in Apache Software Foundation\Apache2.2\logs it shows the following error:

Wed Oct 21 13:23:27 2009] [error] [client 127.0.0.1] PHP Notice: Use of undefined constant localhost - assumed 'localhost' in C:\\Archivos de programa\\Apache Software Foundation\\Apache2.2\\htdocs\\mysqlPHPtest.php on line 6

nothing about mysql in that log file
eeijlar
Advanced user
Posts: 28
Joined: Mon Apr 06, 2009 4:25 pm

Post by eeijlar »

There is an error in your php script though... sorry, localhost should be 'localhost', with quotes.
Post Reply