Category Archives: Uncategorized

How to install TestLink on CentOS 6.3

Few days ago, QA guys asked me to install a tool that will make their work easier. This tool, Testlink, is an open-source management tool which includes test specification, planning, reporting, requirements tracking and collaborate with well-known bug trackers.

Below I will show you step-by-step how to install TestLink on CentOS 6.3, including the troubleshooting steps for most commonly faced issues.

1. Download Testlink. Check if a new version than I used bellow is available (http://sourceforge.net/projects/testlink/files/)
[codesyntax lang="bash"]

mkdir work
cd work
wget -c http://downloads.sourceforge.net/project/testlink/TestLink%201.9/TestLink%201.9.5/testlink-1.9.5.tar.gz
tar xfz testlink-1.9.5.tar.gz
mv testlink-1.9.5/* testlink-1.9.5/.[^.]* /var/www/html/
rm -fr ~/work/testlink-1.9.5
chown -R apache:apache /var/www/html/*

[/codesyntax]

2. Install required packages
[codesyntax lang="bash"]

yum install mysql-server php php-mysql php-gd

[/codesyntax]

Note: if you want authentication against ldap you will have to also install php-ldap package

3. Optimize php configuration for TestLink.
[codesyntax lang="bash"]

vim /etc/php.ini
:%s/max_execution_time = 30/max_execution_time = 120/g
:%s/session.gc_maxlifetime = 1400/session.gc_maxlifetime = 2400/g
:wq

[/codesyntax]

4. Set apache and mysql services to start at boot
[codesyntax lang="bash"]

chkconfig httpd on
chkconfig mysqld on

[/codesyntax]

5. Start apache and mysql services

[codesyntax lang="bash"]

service httpd start
service mysqld start

[/codesyntax]

6. Set mysql root password

[codesyntax lang="bash"]

mysqladmin -u root password YOURPASSWORD

[/codesyntax]

7. Open 80/tcp port in firewall. Add the following rule to /etc/sysconfig/iptables
[codesyntax lang="bash"]

vim /etc/sysconfig/iptables

[/codesyntax]
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
[codesyntax lang="bash"]

:wq

[/codesyntax]

My /etc/sysconfig/iptables on TestLink machine is:
[codesyntax lang="bash"]

cat /etc/sysconfig/iptables

[/codesyntax]

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

If you don't want to have firewall on TestLink machine you can disable it
[codesyntax lang="bash"]

chkconfig iptables off
service iptables stop

[/codesyntax]

8. Restart firewall in order to apply the new rule
[codesyntax lang="bash"]

service iptables restart

[/codesyntax]

9. Create directories used by TestLink for logs and to upload files
[codesyntax lang="bash"]

mkdir -p /var/testlink/logs/
mkdir -p /var/testlink/upload_area/
chown apache:apache -R /var/testlink/

[/codesyntax]

11. Assuming all steps were carried out on a machine called testlink.test.org then open a browser and navigate to TestLink page http://testlink.test.org and setup first configuration.

Note: if you don't have a working DNS or this machine doesn't have a proper record in DNS server then you should navigate by the machine's IP: http://x.x.x.x/

12. Click "New installation"

13. Check I agree to the terms set out in this license and click Continue

14. A new checking report will be displayed. In this report shouldn't be fatal errors (maybe some warnings at most). If so, press Continue

15. Fill database access form and press Process TestLink Setup! button

Database host: localhost
Database name: testlink
Database admin login: root
Database admin password: YOURPASSWORD TestLink DB login: testlink
TestLink DB password: TESTLINK_PASSWORD

16. Remove Install directory
[codesyntax lang="bash"]

rm -fr /var/www/html/install/

[/codesyntax]

17. Modify the email settings
[codesyntax lang="bash"]

vim /var/www/html/custom_config.inc.php
:%s/\[smtp_host_not_configured]\/localhost/g
:%s/\[testlink_sysadmin_email_not_configured\]/root/g
:%s/\[from_email_not_configured\]/root/g
:%s/\[return_path_email_not_configured\]/root/g
:wq

[/codesyntax]

19. Set an alias for root, so all emails to root to go the new alias - this step is optional
[codesyntax lang="bash"]

vim /etc/aliases
root: testlink_admin@test.org
:wq

[/codesyntax]

[codesyntax lang="bash"]

newaliases

[/codesyntax]

Note: In my case I have postfix configured as smarthost, so I going to use localhost as email server. I am not going to cover postfix configuration here.

20. Login into application using default credentials (user: admin / password: admin)

21. Change admin default password

22. If TestLink mailing functionality is not working and you see in logs some error like bellow it's very likely that selinux is the issue there. One possible approach is to disable it

[>>][510fe10b8186e953397877][DEFAULT][/lostPassword.php][13/Feb/4 16:25:47]
        [13/Feb/4 16:25:47][WARNING][<nosession>][GUI]
                E_WARNING
fsockopen(): unable to connect to 127.0.0.1:25 (Permission denied) - in /var/www/html/third_party/phpmailer/class.smtp.php - Line 132
        [13/Feb/4 16:25:47][WARNING][<nosession>][GUI]
                E_NOTICE
Undefined variable: note - in /var/www/html/lostPassword.php - Line 49

[codesyntax lang="bash"]

vim /etc/sysconfig/selinux
:%s/SELINUX=enforcing/SELINUX=disabled/g
:wq

[/codesyntax]

[codesyntax lang="bash"]

reboot

[/codesyntax]

Links:

Redmine - Upgrade to 1.4.4 on a debian squeeze

This document describes how to upgrade Redmine. The procedure was tested for upgrade from version 1.0.1 to 1.4.4, but it might works on other Redmine versions.
In this procedure I used a basic install of a debian squeeze (the only service installed was openssh-server). I am assuming the server has network connectivity and its IP is 10.34.133.220.

Please note:
- please announce all people BEFORE starting this procedure
- the Apache server on production environment MUST be stopped so after the upgrade the database be in sync.
- this version of Redmine needs ruby version 1.8.7 or 1.9.3 (I am going to use the debian squeeze default ruby package which has version 1.8.7)
- all rsync-ed files in this procedure are attached

1. Login to the remote machine
[codesyntax lang="bash"]

ssh root@10.34.133.220

[/codesyntax]

2. Configure hostname
[codesyntax lang="bash"]

echo "workflow-vm" > /etc/hostname

[/codesyntax]

3. Install all required packages for Redmine installation
[codesyntax lang="bash"]

aptitude install apache2 mysql-server ruby libmysqlclient-dev libmagickcore-dev libmagickwand-dev imagemagick locate less rubygems sudo postfix mercurial cvs subversion darcs git libapache2-mod-passenger libxslt1-dev vim less

[/codesyntax]

4. Configure and test postfix
[codesyntax lang="bash"]

scp root@workflow-sandbox-vm.test.org:/etc/mailname /etc/
scp root@workflow-sandbox-vm.test.org:/etc/postfix/main.cf /etc/postfix/

echo "root: user@test.org" >> /etc/aliases

vim /etc/mailname
:%s/workflow-sandbox-vm.test.org/workflow-vm.test.org
:wq

vim /etc/postfix/main.cf
:%s/workflow-sandbox-vm.test.org/workflow-vm.test.org
:wq

newaliases
/etc/init.d/postfix restart

echo "test from new redmine server" | mail -s "test from new redmine server" "user@test.org"

[/codesyntax]

5. Configuring mysql database
[codesyntax lang="bash"]

mysql -Bsu root -pmysql123 -e "drop database redmine;"
mysql -Bsu root -pmysql123 -e "drop user redmine@localhost;"
mysql -Bsu root -pmysql123 -e "create database redmine character set utf8;"
mysql -Bsu root -pmysql123 -e "create user 'redmine'@'localhost' identified by 'redmine';"
mysql -Bsu root -pmysql123 -e "grant all privileges on redmine.* to 'redmine'@'localhost';"
mysql -Bsu root -pmysql123 -e "flush privileges;"
# dump mysql database from production environment and importing it to our machine
# maybe it is a good idea to use dbredmine as mysql server
# anyway for now we are going to use localhost as mysql server
mysqldump -hdbredmine redmine_default > ~/redmine_production.sql
mysql -u redmine -predmine redmine < ~/redmine_production.sql

[/codesyntax]

6. Configure gems
[codesyntax lang="bash"]

echo "gem: --no-rdoc --no-ri" > ~/.gemrc

[/codesyntax]

7. Downloading and installing Redmine
[codesyntax lang="bash"]

wget -c http://rubyforge.org/frs/download.php/76255/redmine-1.4.4.tar.gz
tar xfz redmine-1.4.4.tar.gz
mv redmine-1.4.4 /usr/share/redmine
cd /usr/share/
chown -R root:root /usr/share/redmine
chown www-data /usr/share/redmine/config/environment.rb
ln -s /usr/share/redmine/public /var/www/redmine

[/codesyntax]

8. Configuring Redmine
[codesyntax lang="bash"]

cp redmine/config/database.yml.example redmine/config/database.yml
vim redmine/config/database.yml
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: redmine
encoding: utf8
:wq
scp root@workflow-sandbox-vm.test.org:/usr/share/redmine/config/configuration.yml redmine/config/configuration.yml

[/codesyntax]

9. Installing required gems for Redmine
[codesyntax lang="bash"]

gem install bundler
cd redmine
/var/lib/gems/1.8/bin/bundle install --without development test postgresql sqlite
ln -s /var/lib/gems/1.8/bin/rake /usr/bin/

[/codesyntax]

10. Attachments
[codesyntax lang="bash"]

rm -fr /usr/share/redmine/files
mkdir -p /var/lib/redmine/default/files
ln -s /var/lib/redmine/default/files /usr/share/redmine/files
# copying attachments from production environment
rsync -avz --stats --progress root@10.99.0.241:/var/lib/redmine/default/files/*  /usr/share/redmine/files

[/codesyntax]

11. Fixing permissions
[codesyntax lang="bash"]

mkdir public/plugin_assets
chown -R www-data:www-data files log tmp public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets

[/codesyntax]

12. Configuring Apache web server

[codesyntax lang="bash"]

vim /etc/apache2/sites-available/redmine
<VirtualHost *:443>
        ServerName workflow-vm.test.org
        ServerAlias workflow.test.org workflow
        DocumentRoot /var/www

        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/wildcard-internal-ca-test.org.crt
        SSLCertificateKeyFile /etc/apache2/ssl/wildcard-internal-ca-test.org.key

ServerAdmin ionut@vendio.ro
LogLevel warn
ErrorLog /var/log/apache2/redmine_error
CustomLog /var/log/apache2/redmine_access combined
<Directory /var/www/redmine>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
</Directory>
</VirtualHost>
:wq

[/codesyntax]

[codesyntax lang="bash"]

vim /etc/apache2/ports.conf
:%s/NameVirtualHost \*:80/NameVirtualHost \*:443
:%s/Listen 80/#Listen 80
:wq

[/codesyntax]

[codesyntax lang="bash"]

rsync -avz --stats --progress root@workflow-sandbox-vm.test.org:/etc/apache2/ssl /etc/apache2

mv /etc/apache2/sites-enabled/000-default /tmp

a2ensite redmine
a2enmod passenger
a2enmod ssl

[/codesyntax]

13. Installing and migrating Redmine plugins
[codesyntax lang="bash"]

 cd vendor/plugins

[/codesyntax]

13.1. Question plugin
[codesyntax lang="bash"]

rsync -avz --stats --progress root@10.99.0.241:/usr/share/redmine/vendor/plugins/question_plugin /usr/share/redmine/vendor/plugins/
rsync -avz --stats --progress root@10.99.0.241:/usr/share/redmine/app/views/mailer/_issue_text* /usr/share/redmine/app/views/mailer/
mv /usr/share/redmine/app/views/mailer/_issue_text_html.rhtml /usr/share/redmine/app/views/mailer/_issue_text_html.erb
mv /usr/share/redmine/app/views/mailer/_issue_text_plain.rhtml /usr/share/redmine/app/views/mailer/_issue_text_plain.erb

[/codesyntax]

13.2. Redmine Status plugin
[codesyntax lang="bash"]

 rsync -avz --stats --progress root@workflow-sandbox-vm.test.org:/usr/share/redmine/vendor/plugins/redmine_status /usr/share/redmine/vendor/plugins/

[/codesyntax]

13.3. Redmine Stuff to do plugin
[codesyntax lang="bash"]

rsync -avz --stats --progress root@workflow-sandbox-vm.test.org:/usr/share/redmine/vendor/plugins/stuff_to_do_plugin /usr/share/redmine/vendor/plugins/
rsync -avz --stats --progress root@workflow-sandbox-vm.test.org:/usr/share/redmine/lib/ar_condition.rb /usr/share/redmine/lib/

[/codesyntax]

14. Fixing permissions for log file
[codesyntax lang="bash"]

cd /usr/share/redmine
chown www-data:www-data log/production.log

[/codesyntax]

15. Final steps to get Redmine working
[codesyntax lang="bash"]

rake generate_session_store
rake db:migrate RAILS_ENV=production
rake db:migrate_plugins RAILS_ENV=production
rake tmp:cache:clear
rake tmp:sessions:clear

[/codesyntax]

16. Restart Apache web server
[codesyntax lang="bash"]

 /etc/init.d/apache2 restart

[/codesyntax]

Files:
question plugin: question_plugin.tar.gz
redmine status plugin: redmine_status.tar.gz
stuff to do plugin: stuff_to_do_plugin.tar.gz