Tuesday, August 17, 2010

testlink-php-apache-mssql

For setting up testlink on windows there are some prerequisite software installations which we need to follow.
I used following versions of the softwares -
Apache Webserver - apache/2.2.16 webserver
PHP - php-5.2.14
MSSQL - mssql server 2005
Testlink - testlink_1.8.5

Steps:
  • Configure apache - php
  • Configure php - mssql
  • Install Testlink and configure with webserver
  • Integrate testlink with JIRA (Bug Tracking tool)
  • Configure SMTP server
Configure Apache - PHP

1. Download apache 2 version .msi file.
2. Install Apache webserver on windows  by double clicking the .msi file in the default path
3. Download and unzip the latest version of PHP in C:/
4. Rename/copy php.ini-recommended to php.ini and copy php.ini file in WINDOWS directory
5. Configure apache to load PHP as a module to parse PHP scripts.

Make following changes in httpd.conf file at "c:\Program Files\Apache Group\Apache\conf\"

Check Listen port (Default is 80)
If port 80 is already in use try some other port, check port 78

Add the following line after all the LoadModule statements:
LoadModule php5_module "c:/php/php5apache2_2.dll"

Search for "AddType" and add the following line
To support file types, like ".php" and ".phtml", simply add them to the list, like this: 

<IfModule mime_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule mime_module>

Search for 'DirectoryIndex' and update it as -
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

Configure PHP
Open php.ini file which is placed in WINDOWS directory and set the following -
  • doc_root = c:\apache\apache2\htdocs
  • extension_dir = c:\php\extensions
Now we need to test the configuration.

Test your Set up
1. Create test.php file with the following line: <?php phpinfo(); ?> and save it as "test.php" with double quotes in document root
2. Stop and Start apache 
3. Open browser and write http://localhost:80/test.php

After loading test.php, you should see some information about your PHP installation. Be sure to scroll all the way down to the bottom to see that there were no errors. Pay attention to "Configuration File (php.ini) Path" field. Field's value is current location of php.ini file and you should make appropriate changes in it.

PHP-MSSQL Configuration

Open php.ini file and make the following changes -

1. Directory in which the loadable extensions (modules) reside.
extension_dir = "c:/php/ext/"
2. uncomment line : 
extension=php_mssql.dll
3. Place "ntwdblib.dll" in WINDOWS directory
4. Stop and Start apache 
5. Test the connection by creating a file "testsql.php" and place it in document root "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\"

Code:
<?php

if (function_exists('mssql_connect')){
echo "Okay, fn is there";}
else
{echo "Hmmm .. fn is not even there";}

$connection = mssql_connect("localhost",<uname>,<pwd>);
OR
$connection = mssql_connect("localhost\SQLEXPRESS",<uname>,<pwd>);
<I have Microsoft SQL Server 2005 Express Edition so SQL host is identified as localhost\SQLEXPRESS only >

if (!$connection) { 
echo "Couldn't make a connection!"; 
exit; }
?>

Check error log files for any errors in apache\logs for mssql connection with PHP
Check again http://localhost:80/test.php and check if mssql configurations are appearing there. If appearing then mssql connection with PHP is successfull as look into log files for errors.

Testlink Setup

testlink documentation - 

1. Download 'testlink_1.8.5b.zip' file and unzip into document root folder.
2. Open URL - http://<yoursite>/testlink/install/index.php. for automatic installation
3. Click on New Installation
4. Check all the settings and provide database connection details. Also check 'config_db.inc.php' for the config details.
5. After successful installation open the browser and open url - http://<yoursite>/testlink
6. Login as admin/admin.
7. For any errors check testlink/logs directory

Testlink-JIRA configuration

Add following line to 'config.inc.php' and 'custom_config.inc.php' files
$g_interface_bugs='JIRA';

Open 'jira.cfg.php' in testlink\cfg folder and edit the details below -

/** The DB host to use when connecting to the JIRA db */
define('BUG_TRACK_DB_HOST', '<DB host>');

//DB host examples: 'dbhost' OR 'dbhost\SQLEXPRESS'
/** The name of the database that contains the jira tables */
define('BUG_TRACK_DB_NAME', '<DB Name>');

/** The DB type being used by jira */
define('BUG_TRACK_DB_USER', '<DB User>');

/** The DB password to use for connecting to the jira db */
define('BUG_TRACK_DB_PASS', '<DB pwd>');

/** link of the web server for jira */
//define('BUG_TRACK_HREF', "http://cura-jira-01:8080/secure/Dashboard.jspa"); 
define('BUG_TRACK_HREF', "http://cura-jira-01:8080/browse/"); 

/** The DB type to use for connecting to the bugtracking db */
define('BUG_TRACK_DB_TYPE', 'mssql');

/** link to the bugtracking system, for entering new bugs */
define('BUG_TRACK_ENTER_BUG_HREF',"http://cura-jira-01:8080/secure/CreateIssue.jspa?");

Stop and Start apache service and check if the defect link is appeared when a testcase is failed in Testlink.

SMTP Server Setup

Edit following in Config.inc.php -
/** [SMTP] */

// Developer Note:
// these config variable names has been choosed to maintain compatibility
// with code taken from Mantis.
// 
// SMTP server Configuration ("localhost" is enough in the most cases)
$g_smtp_host        = 'mail.curasoftware.co.in';   # SMTP server MUST BE configured  

# Configure using custom_config.inc.php
$g_tl_admin_email     = 'mrinalinid@curasoftware.com'; # for problem/error notification 
$g_from_email         = $g_tl_admin_email;  # email sender
$g_return_path_email  = 'mrinalinid@curasoftware.com'; 

# Urgent = 1, Not Urgent = 5, Disable = 0
$g_mail_priority = 5;   

# Taken from mantis for phpmailer config
define ("SMTP_SEND",2);
$g_phpMailer_method = SMTP_SEND;

// Configure only if SMTP server requires authentication
$g_smtp_username    = '';  # user  
$g_smtp_password    = '';  # password 

Check in php.ini file placed in WINDOWS directory for the following settings -

[mail function]
; For Win32 only.
SMTP = <mail server host>
smtp_port = 25

; For Win32 only.
sendmail_from = me@example.com

Install SMTP service

On the Start menu, click Control Panel, double-click Add or Remove Programs, and then click Add/Remove Windows Components.
In the Components list check IIS checkbox and click on Details.3. Check SMTP Service checkbox and click on OK button.
Click on Next button and Click on Finish button.
Check in Services if SMTP service is up and running.

Test if mail server is working for testlink.
1. Assign a testcase to a User and Select send mail checkbox. Click on Save button and check if mail is sent.