TestRail: QA Test Case Management installation on Linux

By | 03/22/2019
 

TestRail – Test Case Management Software for QA and Development Teams.

Well – that’s all needed as a description)

Below – its installation on Debian Linux with NGINX, Let’s Encrypt, PHP-FPM, MariaDB, and Exim.

Project’s homepage – www.gurock.com/testrail

Installation official documentation – here>>>.

Setup will be on an AWS EC2.

LEMP and SSL

Login to the EC2:

[simterm]

$ ssh [email protected] -i bttrm-testrail-eu-west-1.pem

[/simterm]

Update packages list and installed packages:

[simterm]

root@ip-172-31-25-137:/home/admin# apt update && apt upgrade

[/simterm]

Let’s Encrypt

Install Let’s Encrypt client:

[simterm]

root@ip-172-31-25-137:/home/admin# apt install -y git unzip
root@ip-172-31-25-137:/home/admin# git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt

[/simterm]

Obtain a certificate using the standalone authenticator:

[simterm]

root@ip-172-31-25-137:/home/admin# /opt/letsencrypt/letsencrypt-auto certonly -d testrail.example.com
...
1: Spin up a temporary webserver (standalone)
2: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
...
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/testrail.example.comd/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/testrail.example.com/privkey.pem
   Your cert will expire on 2019-06-19. 
...

[/simterm]

NGINX

Install NGINX:

[simterm]

root@ip-172-31-25-137:/home/admin# apt -y install nginx

[/simterm]

Will configure it a bit later.

PHP

Add the PHP 7.2 repository:

[simterm]

root@ip-172-31-25-137:/home/admin# wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
OK
root@ip-172-31-25-137:/home/admin# echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
deb https://packages.sury.org/php/ stretch main

[/simterm]

Update the available packages list:

[simterm]

root@ip-172-31-25-137:/home/admin# apt update

[/simterm]

Install PHP and necessary for the TestRail modules:

[simterm]

root@ip-172-31-25-137:/home/admin# apt -y install php7.2 php7.2-fpm php7.2-mysql php7.2-curl php7.2-json php7.2-mbstring php7.2-xml php7.2-zip

[/simterm]

Find PHP configs:

[simterm]

root@ip-172-31-25-137:/home/admin# find /etc/ -name php.ini
/etc/php/7.2/cli/php.ini
/etc/php/7.2/fpm/php.ini

[/simterm]

Edit both /etc/php/7.2/fpm/php.ini and /etc/php/7.2/cli/php.ini and add libraries load:

...
extension=mysql.so
extension=curl.so
ionCube install

Download its archive:

[simterm]

root@ip-172-31-25-137:/home/admin# cd /tmp/
root@ip-172-31-25-137:/tmp# wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

[/simterm]

Unpack it and move to the /opt:

[simterm]

root@ip-172-31-25-137:/tmp# tar xfpz ioncube_loaders_lin_x86-64.tar.gz 
root@ip-172-31-25-137:/tmp# mv ioncube /opt/

[/simterm]

Add zend_extension to both ini-files as in the example above:

...
extension=mysql.so
extension=curl.so

zend_extension=/opt/ioncube/ioncube_loader_lin_7.2.so

NGINX virtual host configuration

Generate DF-key:

[simterm]

root@ip-172-31-25-137:/tmp# openssl dhparam -out /etc/nginx/dhparams.pem 2048

[/simterm]

Add a virtual host config /etc/nginx/conf.d/testrail.example.com:

server {

    listen 80;
    server_name testrail.example.com;

    # Lets Encrypt Webroot
    location ~ /.well-known {
        root /var/www/html;
        allow all;
    }

    location / {

        # office1
        allow 194.***.***.24/29;
        # office2
        allow 91.***.***.78/32;
        # arseny home
        allow 188.***.***.48/32;
        deny  all;

        return 301 https://testrail.example.com;
    }
}

server {

    listen       443 ssl;
    server_name  testrail.example.com;

    root /var/www/testrail.example.com;

    access_log  /var/log/nginx/testrail.example.com-access.log;
    error_log /var/log/nginx/testrail.example.com-error.log warn;

    # office1
    allow 194.***.***.24/29;
    # office2
    allow 91.***.***.78/32;
    # arseny home
    allow 188.***.***.48/32;
    deny  all;

    ssl_certificate /etc/letsencrypt/live/testrail.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/testrail.example.com/privkey.pem;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
    ssl_session_timeout 1d;
    ssl_stapling on;
    ssl_stapling_verify on;

    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|otf|ttf)\$ {
        try_files \$uri =404;
    }

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|woff)$ {
        access_log off;
        log_not_found off;
        expires max;
    }

    location ~ \.php(?:/|$) {
        try_files $uri =404;
        fastcgi_pass unix:/run/php/testrail.example.com.sock;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
        fastcgi_index index.php;
    }
}

Check syntax and reload config files:

[simterm]

root@ip-172-31-25-137:/tmp# nginx -t && service nginx reload

[/simterm]

PHP-FPM configuration

Create a pool’s config file /etc/php/7.2/fpm/pool.d/testrail.example.com.conf:

[testrail.example.com]

user = www-data
group = www-data

listen = /run/php/testrail.example.com.sock

listen.owner = www-data
listen.group = www-data

pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

Restart FPM and check if the new pool started:

[simterm]

root@ip-172-31-25-137:/tmp# service php7.2-fpm restart
root@ip-172-31-25-137:/tmp# ps aux | grep fpm
root     15008  0.5  2.7 400684 28368 ?        Ss   11:00   0:00 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
www-data 15010  0.0  0.6 400676  6904 ?        S    11:00   0:00 php-fpm: pool testrail.example.com
www-data 15011  0.0  0.6 400676  6904 ?        S    11:00   0:00 php-fpm: pool testrail.example.com
www-data 15012  0.0  0.6 400676  6904 ?        S    11:00   0:00 php-fpm: pool www
www-data 15013  0.0  0.6 400676  6904 ?        S    11:00   0:00 php-fpm: pool www

[/simterm]

PHP test

Create a working directory:

[simterm]

root@ip-172-31-25-137:/tmp# mkdir -p /var/www/testrail.example.com

[/simterm]

Create the /var/www/testrail.example.com/info.php file:

<?php
phpinfo()
?>

Check in a browser:

MySQL

Install it:

[simterm]

root@ip-172-31-25-137:/tmp# apt -y install mariadb-server

[/simterm]

Run initial config:

[simterm]

root@ip-172-31-25-137:/tmp# mysql_secure_installation

[/simterm]

Create a database and user:

[simterm]

MariaDB [(none)]> CREATE DATABASE testrail DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL ON testrail.* TO 'testrail'@'localhost' identified by 'uo***8a';
Query OK, 0 rows affected (0.00 sec)

[/simterm]

TestRail installation

Get your trial here>>>.

You’ll get an email with the download link and trial-key.

Download archive:

[simterm]

root@ip-172-31-25-137:/tmp# wget https://secure.gurock.com/downloads/testrail/testrail-latest-ion70.zip

[/simterm]

Unpack it and move to the project’s directory:

[simterm]

root@ip-172-31-25-137:/tmp# unzip testrail-latest-ion70.zip 
root@ip-172-31-25-137:/tmp# cp -r testrail/* /var/www/testrail.example.com/
root@ip-172-31-25-137:/tmp# chown -R www-data:www-data /var/www/testrail.example.com/

[/simterm]

Open your URL in a browser and proceed with the installation there:

Configure the database connection details:

Create logs directory:

[simterm]

root@ip-172-31-25-137:/tmp# mkdir /var/www/testrail.example.com/logs
root@ip-172-31-25-137:/tmp# chown -R www-data:www-data /var/www/testrail.example.com/

[/simterm]

Set your project’s details:

An email will be set later, skip it for now:

Add an admin user, the trial key was sent in an email:

Ready:

Log in:

Cron jobs

Now – add a cronjob to run TestRail’s tasks.

Check if task.php works:

[simterm]

root@ip-172-31-25-137:/home/admin# php /var/www/testrail.example.com/task.php
root@ip-172-31-25-137:/home/admin# echo $?
0

[/simterm]

If no errors here – it can be added to a crontab:

* * * * * www-data /usr/bin/php /var/www/testrail.example.com/task.php

Exim and email settings

To send emails – a local Exim will be used.

Install it:

[simterm]

root@ip-172-31-25-137:/home/admin# apt -y install exim4-base

[/simterm]

Configure it:

[simterm]

root@ip-172-31-25-137:/home/admin# dpkg-reconfigure exim4-config

[/simterm]

Check if email sending works:

[simterm]

root@ip-172-31-25-137:/home/admin# echo "Exim test" | mailx -s "Exim test" [email protected]

[/simterm]

Go to the TestRail admin page – Administration > Site Settings > Email:

Done.