TestLink+Jenkins在Ubuntu16.04搭建集成測試環境

序章

  • 目前TestLink的最新版本是1.9.19
  • TestLink-API-Python-client支持的TestLink最高版本是1.9.17
  • 若是後期要使用TestLink-API-Python-client和jenkins交互,那麼TestLink只能選擇1.9.17版本

TestLink 1.9.19 環境依賴包括:php

依賴項 版本要求
web服務 Apache 2.x
PHP 5.5以上,若是使用PHP 7.2.x會更好
數據庫 MySQL 5.7.x,MariaDB 10.1.x,Postgres 9.x,MS-SQL 201x
瀏覽器 Firefox,Chrome

1、安裝Apache

1.一、安裝Apache

apt-get update
apt-get install apache2

過程以下:html

root@duke:~# apt-get update
Get:1 file:/var/cuda-repo-9-0-local InRelease
Ign:1 file:/var/cuda-repo-9-0-local InRelease
Get:2 file:/var/cuda-repo-9-0-local Release [574 B]
Get:2 file:/var/cuda-repo-9-0-local Release [574 B]
Hit:3 http://mirrors.aliyun.com/ubuntu xenial InRelease
Hit:5 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease
Get:6 http://mirrors.aliyun.com/ubuntu xenial-backports InRelease [107 kB]
Hit:7 http://mirrors.aliyun.com/ubuntu xenial-security InRelease
Hit:8 http://archive.ubuntu.com/ubuntu xenial InRelease
Hit:9 http://ppa.launchpad.net/qameta/allure/ubuntu xenial InRelease
Hit:10 http://archive.canonical.com/ubuntu xenial InRelease
Hit:11 http://ppa.launchpad.net/yandex-qatools/allure-framework/ubuntu xenial InRelease
Hit:12 https://packages.gitlab.com/runner/gitlab-runner/ubuntu xenial InRelease
Fetched 107 kB in 3s (26.8 kB/s)
Reading package lists... Done
root@duke:~# apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0
0 upgraded, 9 newly installed, 0 to remove and 81 not upgraded.
Need to get 1,541 kB of archives.
After this operation, 6,373 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu xenial/main amd64 libapr1 amd64 1.5.2-3 [86.0 kB]
Get:2 http://mirrors.aliyun.com/ubuntu xenial/main amd64 libaprutil1 amd64 1.5.4-1build1 [77.1 kB]
。。。。。。
。。。。。。
Processing triggers for systemd (229-4ubuntu21.21) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for ufw (0.35-0ubuntu2) ...python

1.二、Apache安裝目錄信息

/var/www                      #Apache默認文檔根目錄
/etc/apache2                  #Apache配置存儲目錄
/etc/apache2/apache2.conf     #Apache配置文件

1.三、配置Apache

1.3.一、將「全局服務器名稱」設置爲「禁止語法警告」

若是不設置ServerName全球範圍內,你會檢查語法錯誤Apache配置時收到如下警告:mysql

apache2ctl configtest #檢查語法錯誤

過程以下:nginx

root@duke:/# apache2ctl configtest
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OKgit

修改/etc/apache2/apache2.conf配置文件,關閉語法警告
過程以下:github

root@duke:~# vi /etc/apache2/apache2.conf
# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.
# Include generic snippets of statements
IncludeOptional conf-enabled/.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/
.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
ServerName 192.168.0.157 #在最後一行添加,ip是當前主機IP
"/etc/apache2/apache2.conf" 223L, 7141C written
root@duke:~# apache2ctl configtest
Syntax OK
root@duke:~# systemctl restart apache2 重啓Apacheweb

1.3.二、調整防火牆以容許Web流量

  1. 查看防火牆管理列表
    ufw app list
    過程以下:

    root@duke:/# ufw app list
    可用應用程序:
    Apache
    Apache Full
    Apache Secure
    CUPS
    OpenLDAP LDAP
    OpenLDAP LDAPS
    OpenSSHsql

  2. 查看Apache Full使用的端口
    ufw app info "Apache Full"

    過程以下:shell

    root@duke:/# ufw app info "Apache Full"
    配置: Apache Full
    標題:Web Server (HTTP,HTTPS)
    描述: Apache v2 is the next generation of the omnipresent Apache web server.
    端口:80,443/tcp

  3. 防火牆開放Apache
    ufw allow in "Apache Full"

    root@duke:/# ufw allow in "Apache Full"
    防火牆規則已更新
    規則已更新(v6)

  4. 訪問Apache
    開放防火牆後就能夠嘗試登錄Apache服務器
    http://192.168.0.157/
    界面以下:

     

     

1.3.三、配置apache2.conf文件

修改:/etc/apache2/apache2.conf 配置文件,添加如下內容:

AddType application/x-httpd-php .php .htm .html
AddDefaultCharset UTF-8 
ServerName 192.168.0.157

過程以下:

root@duke:~# vi /etc/apache2/apache2.conf
# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.
# Include generic snippets of statements
IncludeOptional conf-enabled/.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/
.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
AddType application/x-httpd-php .php .htm .html
AddDefaultCharset UTF-8
ServerName 192.168.0.157 #在配置文件最後添加

"/etc/apache2/apache2.conf" 223L, 7141C written
root@duke:~# apache2ctl configtest
Syntax OK
root@duke:~# systemctl restart apache2 重啓Apache

1.四、Apache命令

啓動命令

/etc/init.d/apache2 start
或
systemctl start apache2

中止命令

/etc/init.d/apache2 stop
或
systemctl stop apache2

重啓命令

/etc/init.d/apache2 restart
或
systemctl restart apache2

2、安裝PHP和 PHP 擴展模塊

  • TestLink 支持 MySQL、PostgreSQL 和微軟的 SQL Server 數據庫,因爲採用mysql數據庫,因此須要安裝基於PHP的MySQL擴展模塊
  • Ubuntu16.04系統自帶了PHP 7.0.X版本,所以PHP5沒法正常安裝的
  • Ubuntu16.04系統軟件庫自帶了PHP 7.0.X版本,想要安裝PHP 7.2.x必須修改軟件庫

2.一、安裝PHP

2.1.一、卸載自帶PHP 7.0版本

apt-get purge php
apt-get purge php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-opcache php7.0-readline

執行過程以下:

root@duke:~# apt-get purge php
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-opcache php7.0-readline
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
php
0 upgraded, 0 newly installed, 1 to remove and 81 not upgraded.
After this operation, 11.3 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 307016 files and directories currently installed.)
Removing php (1:7.0+35ubuntu6.1) ...
root@duke:~# apt-get purge php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-opcache php7.0-readline
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
php-common
php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-opcache php7.0-readline*
0 upgraded, 0 newly installed, 8 to remove and 81 not upgraded.
After this operation, 14.1 MB disk space will be freed.
(Reading database ... 307013 files and directories currently installed.)
Removing php7.0 (7.0.33-0ubuntu0.16.04.4) ...
Removing php7.0-fpm (7.0.33-0ubuntu0.16.04.4) ...
apache2_invoke php7.0-fpm prerm: No action required
Purging configuration files for php7.0-fpm (7.0.33-0ubuntu0.16.04.4) ...
apache2_invoke php7.0-fpm postrm: No action required
dpkg: warning: while removing php7.0-fpm, directory '/etc/php/7.0/fpm/conf.d' not empty so not removed
Removing php7.0-cli (7.0.33-0ubuntu0.16.04.4) ...
Purging configuration files for php7.0-cli (7.0.33-0ubuntu0.16.04.4) ...
dpkg: warning: while removing php7.0-cli, directory '/etc/php/7.0/cli/conf.d' not empty so not removed
Removing php7.0-readline (7.0.33-0ubuntu0.16.04.4) ...
Purging configuration files for php7.0-readline (7.0.33-0ubuntu0.16.04.4) ...
Removing php7.0-opcache (7.0.33-0ubuntu0.16.04.4) ...
Purging configuration files for php7.0-opcache (7.0.33-0ubuntu0.16.04.4) ...
Removing php7.0-json (7.0.33-0ubuntu0.16.04.4) ...
Purging configuration files for php7.0-json (7.0.33-0ubuntu0.16.04.4) ...
Removing php7.0-common (7.0.33-0ubuntu0.16.04.4) ...
Purging configuration files for php7.0-common (7.0.33-0ubuntu0.16.04.4) ...
dpkg: warning: while removing php7.0-common, directory '/etc/php/7.0' not empty so not removed
Removing php-common (1:35ubuntu6.1) ...
Purging configuration files for php-common (1:35ubuntu6.1) ...
Processing triggers for man-db (2.7.5-1) ...

2.1.一、配置PHP 7.x.x版本庫

一、使用ppa增長源

apt-get install python-software-properties
add-apt-repository ppa:ondrej/php
apt-get update

執行過程以下:

root@duke:~# apt-get install python-software-properties
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
python-apt python-pycurl
Suggested packages:
python-apt-dbg python-apt-doc python-pycurl-dbg python-pycurl-doc
The following NEW packages will be installed:
python-apt python-pycurl python-software-properties
0 upgraded, 3 newly installed, 0 to remove and 81 not upgraded.
Need to get 204 kB of archives.
After this operation, 937 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 python-apt amd64 1.1.0~beta1ubuntu0.16.04.4 [140 kB]
Get:2 http://mirrors.aliyun.com/ubuntu xenial/main amd64 python-pycurl amd64 7.43.0-1ubuntu1 [43.3 kB]
Get:3 http://mirrors.aliyun.com/ubuntu xenial-updates/universe amd64 python-software-properties all 0.96.20.8 [20.6 kB]
Fetched 204 kB in 0s (1,188 kB/s)
Selecting previously unselected package python-apt.
(Reading database ... 306870 files and directories currently installed.)
Preparing to unpack .../python-apt_1.1.0~beta1ubuntu0.16.04.4_amd64.deb ...
Unpacking python-apt (1.1.0~beta1ubuntu0.16.04.4) ...
Selecting previously unselected package python-pycurl.
Preparing to unpack .../python-pycurl_7.43.0-1ubuntu1_amd64.deb ...
Unpacking python-pycurl (7.43.0-1ubuntu1) ...
Selecting previously unselected package python-software-properties.
Preparing to unpack .../python-software-properties_0.96.20.8_all.deb ...
Unpacking python-software-properties (0.96.20.8) ...
Setting up python-apt (1.1.0~beta1ubuntu0.16.04.4) ...
Setting up python-pycurl (7.43.0-1ubuntu1) ...
Setting up python-software-properties (0.96.20.8) ...
root@duke:~# add-apt-repository ppa:ondrej/php
Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.

Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa

You can get more information about the packages at https://deb.sury.org

BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting

CAVEATS:

  1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
  2. If you are using apache2, you are advised to add ppa:ondrej/apache2
  3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline
    or ppa:ondrej/nginx

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see
https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or ctrl-c to cancel adding it
在此處按[ENTER]鍵
gpg: keyring `/tmp/tmp_6wjtp2o/secring.gpg' created
gpg: keyring `/tmp/tmp_6wjtp2o/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp_6wjtp2o/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
root@duke:~# apt-get update
Get:1 file:/var/cuda-repo-9-0-local InRelease
Ign:1 file:/var/cuda-repo-9-0-local InRelease
Get:2 file:/var/cuda-repo-9-0-local Release [574 B]
Get:2 file:/var/cuda-repo-9-0-local Release [574 B]
Hit:3 http://mirrors.aliyun.com/ubuntu xenial InRelease
Hit:4 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease
Get:5 http://mirrors.aliyun.com/ubuntu xenial-backports InRelease [107 kB]
Hit:7 http://mirrors.aliyun.com/ubuntu xenial-security InRelease
Hit:8 http://archive.canonical.com/ubuntu xenial InRelease
Hit:9 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:10 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease [23.9 kB]
Hit:11 https://packages.gitlab.com/runner/gitlab-runner/ubuntu xenial InRelease
Hit:12 http://ppa.launchpad.net/qameta/allure/ubuntu xenial InRelease
Hit:13 http://ppa.launchpad.net/yandex-qatools/allure-framework/ubuntu xenial InRelease
Get:14 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 Packages [52.3 kB]
Get:15 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main i386 Packages [52.1 kB]
Get:16 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main Translation-en [28.2 kB]
Fetched 263 kB in 20s (12.8 kB/s)
Reading package lists... Done

二、查看源中PHP7.3版本

apt list | grep php

不出意外,列表中已經包含PHP 7.3 版本,甚至有PHP 7.2版本

三、安裝PHP7.3

apt-get -y install php

執行過程以下:

root@duke:~# apt-get -y install php
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libapache2-mod-php7.3 libargon2-0 libpcre2-8-0 libsodium23 php-common php7.3 php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-readline
Suggested packages:
php-pear
The following NEW packages will be installed:
libapache2-mod-php7.3 libargon2-0 libpcre2-8-0 libsodium23 php php-common php7.3 php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-readline
0 upgraded, 12 newly installed, 0 to remove and 101 not upgraded.
Need to get 4,047 kB/4,226 kB of archives.
After this operation, 18.2 MB of additional disk space will be used.
。。。。。。
。。。。。。
Creating config file /etc/php/7.3/cli/php.ini with new version
Setting up libapache2-mod-php7.3 (7.3.6-1+ubuntu16.04.1+deb.sury.org+1) ...

eating config file /etc/php/7.3/apache2/php.ini with new version
apache2_invoke: Enable module php7.3
Setting up php7.3 (7.3.6-1+ubuntu16.04.1+deb.sury.org+1) ...
Setting up php (2:7.3+69+ubuntu16.04.1+deb.sury.org+2+php7.3) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...

四、安裝PHP7.2 擴展模塊

apt-get install  php7.3-mysql php7.3-ldap php7.3-gd php7.3-curl php-mysql php-ldap php-gd php-curl

執行過程以下:

root@duke:~# apt-get install php7.3-mysql php7.3-ldap php7.3-gd php7.3-curl php-mysql php-ldap php-gd php-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
php7.2-ldap php7.2-mysql
0 upgraded, 2 newly installed, 0 to remove and 99 not upgraded.
Need to get 140 kB of archives.
After this operation, 556 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 php7.2-ldap amd64 7.2.19-1+ubuntu16.04.1+deb.sury.org+1 [23.1 kB]
Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 php7.2-mysql amd64 7.2.19-1+ubuntu16.04.1+deb.sury.org+1 [117 kB]
Fetched 140 kB in 2s (62.9 kB/s)
Selecting previously unselected package php7.2-ldap.
(Reading database ... 307082 files and directories currently installed.)
Preparing to unpack .../php7.2-ldap_7.2.19-1+ubuntu16.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.2-ldap (7.2.19-1+ubuntu16.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.2-mysql.
Preparing to unpack .../php7.2-mysql_7.2.19-1+ubuntu16.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.2-mysql (7.2.19-1+ubuntu16.04.1+deb.sury.org+1) ...
Processing triggers for libapache2-mod-php7.2 (7.2.19-1+ubuntu16.04.1+deb.sury.org+1) ...
Setting up php7.2-ldap (7.2.19-1+ubuntu16.04.1+deb.sury.org+1) ...

Creating config file /etc/php/7.2/mods-available/ldap.ini with new version
Setting up php7.2-mysql (7.2.19-1+ubuntu16.04.1+deb.sury.org+1) ...

Creating config file /etc/php/7.2/mods-available/mysqlnd.ini with new version

Creating config file /etc/php/7.2/mods-available/mysqli.ini with new version

Creating config file /etc/php/7.2/mods-available/pdo_mysql.ini with new version
Processing triggers for libapache2-mod-php7.2 (7.2.19-1+ubuntu16.04.1+deb.sury.org+1) ...

五、查看PHP安裝版本

php -v

執行過程以下:

root@duke:/etc/php/7.2# php -v
PHP 7.3.6-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 31 2019 11:26) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.6, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.6-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

六、PHP性能優化
爲使 TestLink 達到最佳性能,建議對 PHP 配置進行優化。
須要修改 PHP 配置文件 /etc/php/7.3/apache2/php.ini 中的參數:

  • session.gc_maxlifetime
    單位爲秒。該參數指定的時間間隔以後,存儲的數據會被標示爲'garbage',進而被垃圾回收進程清理掉。默認爲 24 分鐘(即 1440 秒)。TestLink 在進行安裝以前會檢查該參數,若是設置等於小於 10 分鐘,TestLink 安裝程序會強制用戶去擴展該值。若是大 10 分鐘,只給出警告信息。若是大於推薦的 30 分鐘,安裝程序校驗爲成功。
    建議設置爲:session.gc_maxlifetime = 1860
  • max_execution_time
    每一個 php 腳本最大執行時間,單位爲秒,默認爲 30s,
    TestLink 推薦設置爲 120s

  • max_input_vars
    從PHP 5.3.9開始提供。默認值:1000
    若是測試用例超過100個,那麼可能引起TestLink限制執行測試用例個數問題。
    建議修改成10000

  • memory_limit
    若是要從xml文件導入測試用例或更新用例,默認值 memory_limit = 128M 可能致使導入失敗,緣由在於系統可能會耗盡內存
    建議memory_limit值爲256MB

執行過程以下:

root@duke:~#vi /etc/php/7.3/apache2/php.ini
。。。。。。
。。。。。。
; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
; http://php.net/session.gc-maxlifetime
#session.gc_maxlifetime = 1440
session.gc_maxlifetime = 1860 ;將1440修改成1860

; NOTE: If you are using the subdirectory option for storing session files
; (see session.save_path above), then garbage collection does not
; happen automatically. You will need to do your own garbage
; collection through a shell script, cron entry, or some other method.
; For example, the following script would is the equivalent of
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
; find /path/to/sessions -cmin +24 -type f | xargs rm
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
。。。。。。
。。。。。。
;max_execution_time = 30
max_execution_time = 120 ;將30修改成120

; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; http://php.net/max-input-time
max_input_time = 60

; Maximum input variable nesting level
; http://php.net/max-input-nesting-level
;max_input_nesting_level = 64

; How many GET/POST/COOKIE input variables may be accepted
; max_input_vars = 1000 ;默認狀況下是註釋掉的,須要取消註釋
max_input_vars = 10000 ;將1000改成10000

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
;memory_limit = 128M ;默認值爲128M,須要修改成256M
memory_limit = 256M

3、安裝Mysql

3.一、安裝Mysql服務

apt-get install mysql-server

執行過程以下:

root@duke:~# apt install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7 mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
libipc-sharedcache-perl mailx tinyca
The following NEW packages will be installed:
libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7 mysql-server mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 8 newly installed, 0 to remove and 99 not upgraded.
Need to get 18.7 MB of archives.
After this operation, 161 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu xenial/main amd64 libaio1 amd64 0.3.110-2 [6,356 B]
Get:2 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-client-core-5.7 amd64 5.7.26-0ubuntu0.16.04.1 [6,388 kB]
Get:3 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-client-5.7 amd64 5.7.26-0ubuntu0.16.04.1 [1,834 kB]
Get:4 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-server-core-5.7 amd64 5.7.26-0ubuntu0.16.04.1 [7,471 kB]
Get:5 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 libevent-core-2.0-5 amd64 2.0.21-stable-2ubuntu0.16.04.1 [70.6 kB]
Get:6 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-server-5.7 amd64 5.7.26-0ubuntu0.16.04.1 [2,831 kB]
Get:7 http://mirrors.aliyun.com/ubuntu xenial/main amd64 libhtml-template-perl all 2.95-2 [60.4 kB]
Get:8 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-server all 5.7.26-0ubuntu0.16.04.1 [10.8 kB]
Fetched 18.7 MB in 0s (20.4 MB/s)
Preconfiguring packages ...


Selecting previously unselected package libaio1:amd64.
(Reading database ... 307104 files and directories currently installed.)
Preparing to unpack .../libaio1_0.3.110-2_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-2) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.26-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.26-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.26-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.26-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.26-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.26-0ubuntu0.16.04.1) ...
Selecting previously unselected package libevent-core-2.0-5:amd64.
Preparing to unpack .../libevent-core-2.0-5_2.0.21-stable-2ubuntu0.16.04.1_amd64.deb ...
Unpacking libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server-5.7.
Preparing to unpack .../mysql-server-5.7_5.7.26-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.26-0ubuntu0.16.04.1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../libhtml-template-perl_2.95-2_all.deb ...
Unpacking libhtml-template-perl (2.95-2) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.26-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.26-0ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu21.21) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up libaio1:amd64 (0.3.110-2) ...
Setting up mysql-client-core-5.7 (5.7.26-0ubuntu0.16.04.1) ...
Setting up mysql-client-5.7 (5.7.26-0ubuntu0.16.04.1) ...
Setting up mysql-server-core-5.7 (5.7.26-0ubuntu0.16.04.1) ...
Setting up libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Setting up mysql-server-5.7 (5.7.26-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
Setting up libhtml-template-perl (2.95-2) ...
Setting up mysql-server (5.7.26-0ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
Processing triggers for systemd (229-4ubuntu21.21) ...
Processing triggers for ureadahead (0.100.0-19) ...

3.二、配置Mysql

mysql5.7版本默認配置文件是 /etc/mysql/mysql.conf.d/mysqld.cnf

mysqladmin -u root -p shutdown
service mysql stop
vi /etc/mysql/mysql.conf.d/mysqld.cnf

修改bind-address配置項
將本地mysql訪問

bind-address = 127.0.0.1

修改成遠端mysql訪問,地址爲本機ip地址

#bind-address = 127.0.0.1

3.三、設置Mysql遠程root訪問

3.2章節只是配置了容許用戶訪問mysql服務器,可是root仍是不能正常訪問的
因此要經過修改mysql默認系統配置表,來讓root遠程訪問

mysql -uroot -proot
use mysql
SELECT user, host from mysql.user; 
update user set host='%' where user='root';

執行過程以下:

root@duke:/etc/mysql/mysql.conf.d# mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.26-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT user, host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| debian-sys-maint | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)

mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> SELECT user, host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | % |
| debian-sys-maint | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)

mysql> quit
Bye

3.四、重啓mysql

service mysql restart

3.五、檢查mysql啓動狀態

一、方法一

service mysql status

執行過程以下:

root@duke:~# service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since 三 2019-06-05 11:26 CST; 4min 8s ago
Process: 28886 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 28877 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 28885 (mysqld)
CGroup: /system.slice/mysql.service
└─28885 /usr/sbin/mysqld

6月 05 11:25 duke systemd[1]: Starting MySQL Community Server...
6月 05 11:26 duke systemd[1]: Started MySQL Community Server.

二、方法二

mysql -uroot -proot

執行過程以下:

root@duke:~# mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye

4、安裝TestLink

4.一、下載版本

一、TestLink
2019-6-5 最新版本是1.9.20,穩定版本是1.9.19,
【TestLink 在 sourceforge下載】:速度比git-hub快點
【TestLink 在 github下載】

二、TestLink-API-Python-client
可使用pip 直接安裝,命令以下

pip install TestLink-API-Python-client

也能夠下載源碼進行安裝:源碼下載

三、EX-Converter
用於將excel測試用例轉換xml,方便導入TestLink
【注意】:要使用TestLink的測試用例模板
【EX-Converter 在 sourceforge下載】

4.二、安裝版本

  1. 上傳版本包
    將下載的testlink-1.9.19.tar.gz安裝包上傳到安裝服務器上

  2. 解壓版本包

    tar zxvf testlink-1.9.19.tar.gz
  3. 版本部署
    testlink安裝是經過web進行,此處步驟是實如今web端能夠打開安裝頁面

    mv testlink-1.9.19 testlink
    cp -r testlink /var/www/html
    chmod -R 777 /var/www/html/testlink
    
  4. 版本安裝
    打開安裝頁面,192.168.0.157是實際安裝的服務器地址

    http://192.168.0.157/testlink/install/

    打開頁面以下:

  5. 進行新版本安裝
    點擊New installation按鈕

     

     勾選I agree to the terms set out in this license.

    點擊Continue按鈕

     

     

  6. 安裝報錯
    在安裝頁面會提示,部分數據庫和依賴庫沒有安裝,文件目錄不存在

     

  7. 解決問題

    • 數據庫只須要mysql便可,其餘的能夠不進行安裝
    • 須要建立/var/testlink/logs//var/testlink/upload_area 目錄
      mkdir -p /var/testlink/upload_area /var/testlink/logs
      chmod -R 777 /var/testlink
      
    • 須要安裝GD的依賴庫

      apt-get install php7.2-gd
    • 須要安裝CURL的依賴庫
      curl官網網址下載最新的安裝包,安裝過程可能會出現curl和libcurl不一致的狀況,如下給出安裝解決方法,以curl-7.65.1版本安裝爲例:

      • 未安裝openssl狀況
        wget https://curl.haxx.se/download/curl-7.65.1.tar.gz
        tar zxvf curl-7.65.1.tar.gz
        cd curl-7.65.1
        ./configure --disable-shared  #強制執行靜態庫編譯
        make
        make test (optional)
        make install
        apt-get install php7.3-curl php-curl
        
      • 安裝openssl狀況
        wget https://curl.haxx.se/download/curl-7.65.1.tar.gz
        tar zxvf curl-7.65.1.tar.gz
        cd curl-7.65.1
        ./configure --with-ssl=/opt/OpenSSL  #安裝openssl的安裝目錄
        make
        make test (optional)
        make install
        apt-get install php7.3-curl php-curl
        
    • 重啓apache
      service apache2 restart
      
  8. 繼續安裝
    通過上面操做後,從新登陸安裝TestLink頁面,繼續安裝TestLink,已經無報錯信息
    點擊Continue按鈕

  9. 配置數據庫
    進入數據庫配置管理頁面,按照下圖填寫

  10. 確認安裝
    配置網數據庫後,在配置頁面最下方,會有提示,TestLink的超級管理員帳號
    admin/admin
    點擊Process TestLink Setup按鈕

  11. 安裝成功

  12. 數據庫testlink用戶增長遠程訪問權限和所有數據庫操做權限

    mysql -uroot -proot
    use mysql
    SELECT user, host from mysql.user; 
    update user set host='%' where user='testlink';
    UPDATE mysql.user SET Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',Create_user_priv='Y',Event_priv='Y',Trigger_priv='Y',Create_tablespace_priv='Y' WHERE User='testlink';
    FLUSH PRIVILEGES;
    

    執行過程以下:

    root@duke:/var/www/html# mysql -uroot -proot
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 3
    Server version: 5.7.26-0ubuntu0.16.04.1 (Ubuntu)

    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    mysql> use mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    mysql> SELECT user, host from mysql.user;
    +------------------+-----------+
    | user | host |
    +------------------+-----------+
    | root | % |
    | debian-sys-maint | localhost |
    | mysql.session | localhost |
    | mysql.sys | localhost |
    | testlink | localhost |
    +------------------+-----------+
    5 rows in set (0.01 sec)

    mysql> update user set host='%' where user='testlink';
    Query OK, 1 row affected (0.02 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    mysql> SELECT user, host from mysql.user;
    +------------------+-----------+
    | user | host |
    +------------------+-----------+
    | root | % |
    | testlink | % |
    | debian-sys-maint | localhost |
    | mysql.session | localhost |
    | mysql.sys | localhost |
    +------------------+-----------+
    5 rows in set (0.00 sec)
    mysql>UPDATE mysql.user SET Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',Create_user_priv='Y',Event_priv='Y',Trigger_priv='Y',Create_tablespace_priv='Y' WHERE User='testlink';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
    mysql> quit
    Bye

  13. 後續數據庫配置

    • 備份testlink_create_udf0.sql文件爲init.sql
      cp /var/www/html/testlink/install/sql/mysql/testlink_create_udf0.sql /var/www/html/testlink/install/sql/mysql/init.sql
      
    • 修改init.sql
      init.sql文件中的YOUR_TL_DBNAME所有替換爲數據庫實例名稱testlink
    • 初始化sql文件
      mysql -utestlink -ptestlink  < /var/www/html/testlink/install/sql/mysql/init.sql
      
  14. 配置郵件服務配、安全告警、中文顯示
    修改

    vi /var/www/html/testlink/config.inc.php
    

    原生內容爲:

    / [LOCALIZATION] /

    / @var string Default localization for users */
    // The value must be available in $$tlCfg->locales (see cfg/const.inc.php).
    // Note: An attempt will be done to establish the default locale
    // automatically using $_SERVER['HTTP_ACCEPT_LANGUAGE']
    $tlCfg->default_language = 'en_GB';
    /

    • @var string How to warning user when security weak points exists.
      *
    • 'SCREEN': messages will displayed on login screen, and tl desktop
    • 'FILE': a file with a list is created but users are not notified via GUI
    • user will receive a message on screen. (default)
    • 'SILENT': same that FILE, but user will not receive message on screen.
      /
      $tlCfg->config_check_warning_mode = 'FILE';
      。。。。。。
      。。。。。。
      /
      [SMTP] /
      /*
    • @var string SMTP server name or IP address ("localhost" should work in the most cases)
    • Configure using custom_config.inc.php
    • @uses lib/functions/email_api.php
      **/

    $g_smtp_host = '[smtp_host_not_configured]'; # SMTP server MUST BE configured

    # Configure using custom_config.inc.php
    $g_tl_admin_email = '[testlink_sysadmin_email_not_configured]'; # for problem/error notification
    $g_from_email = '[from_email_not_configured]'; # email sender
    $g_return_path_email = '[return_path_email_not_configured]';

    /**

    • Email notification priority (low by default)
    • Urgent = 1, Not Urgent = 5, Disable = 0
      **/
      $g_mail_priority = 5;

    /**

    • Taken from mantis for phpmailer config
    • select the method to mail by:
    • PHPMAILER_METHOD_MAIL - mail()
    • PHPMAILER_METHOD_SENDMAIL - sendmail
    • PHPMAILER_METHOD_SMTP - SMTP
      /
      $g_phpMailer_method = PHPMAILER_METHOD_SMTP; *

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

    /**

    • This control the connection mode to SMTP server.
    • Can be '', 'ssl','tls'
    • @global string $g_smtp_connection_mode
      */
      $g_smtp_connection_mode = '';

    /**

    • The smtp port to use. The typical SMTP ports are 25 and 587. The port to use
    • will depend on the SMTP server configuration and hence others may be used.
    • @global int $g_smtp_port
      */
      $g_smtp_port = 25;

    /**

    修改成:

    / [LOCALIZATION] /

    / @var string Default localization for users /
    // The value must be available in $$tlCfg->locales (see cfg/const.inc.php).
    // Note: An attempt will be done to establish the default locale
    // automatically using $_SERVER['HTTP_ACCEPT_LANGUAGE']
    $tlCfg->default_language = 'zh_CN'; #語言配置
    /**

    • @var string How to warning user when security weak points exists.
      *
    • 'SCREEN': messages will displayed on login screen, and tl desktop
    • 'FILE': a file with a list is created but users are not notified via GUI
    • user will receive a message on screen. (default)
    • 'SILENT': same that FILE, but user will not receive message on screen.
      /
      $tlCfg->config_check_warning_mode = 'SILENT'; #告警配置
      。。。。。。
      。。。。。。
      /
      [SMTP] */

    /**

    • @var string SMTP server name or IP address ("localhost" should work in the most cases)
    • Configure using custom_config.inc.php
    • @uses lib/functions/email_api.php
      */
      $g_smtp_host = 'smtp.dilu.com'; # SMTP 服務必須配置

    # Configure using custom_config.inc.php
    $g_tl_admin_email = 'zhiwei.han@dilu.com'; # 問題錯誤通知郵箱
    $g_from_email = 'testlink@dilu.com'; # 收到郵件看到的發送地址
    $g_return_path_email = 'zhiwei.han@dilu.com'; # 若是收到郵件的人進行回覆的郵件地址

    /**

    • Email notification priority (low by default)
    • Urgent = 1, Not Urgent = 5, Disable = 0
      **/
      $g_mail_priority = 5;

    /**

    • Taken from mantis for phpmailer config
    • select the method to mail by:
    • PHPMAILER_METHOD_MAIL - mail()
    • PHPMAILER_METHOD_SENDMAIL - sendmail
    • PHPMAILER_METHOD_SMTP - SMTP
      */
      $g_phpMailer_method = PHPMAILER_METHOD_SMTP;

    /* Configure only if SMTP server requires authentication /
    $g_smtp_username = 'zhiwei.han@dilu.com'; # smtp發送的用戶名
    $g_smtp_password = 'hzwHL525'; # 發送用戶的密碼

    /**

    • This control the connection mode to SMTP server.
    • Can be '', 'ssl','tls'
    • @global string $g_smtp_connection_mode
      */
      $g_smtp_connection_mode = '';

    /**

    • The smtp port to use. The typical SMTP ports are 25 and 587. The port to use
    • will depend on the SMTP server configuration and hence others may be used.
    • @global int $g_smtp_port
      */
      $g_smtp_port = 465; #公司使用的郵箱smtp端口是465

    /**

  15. 進入testlink
    點擊Please Clicke ME!,進入testlink登陸頁面
    地址爲:http://192.168.0.157/testlink/

  16. 設置testlink爲中文

    • 點擊圖標進入設置頁面
    • 設置語言爲中文簡體,點擊保存
  17. 生成用戶密鑰(用於和jenkins連接)

    • 點擊 圖標進入設置頁面
    • API接口點擊生成新的密鑰

5、Jenkins配置

  1. 點擊系統管理

  2. 點擊插件管理

  3. 點擊可選插件

  4. 搜索testlink

  5. 勾選TestLink,點擊直接安裝

  6. 勾選安裝完成後重啓Jenkins(空閒時),等待重啓

  7. 重啓後,進入插件管理,點擊已安裝

  8. 搜索TestLink,查看到TestLink Plugin即表示安裝完成

  1. 點擊系統管理

  2. 點擊系統設置

  3. 找到TestLink,點擊新增

  4. 設置TestLink Plugin,以下

    • 名稱(TestLink版本):TestLink-1.9.19

    • URL(TestLink-API的地址):http://192.168.0.157/testlink/lib/api/xmlrpc/v1/xmlrpc.php

    • 開發密鑰(TestLink 具備權限的用戶祕鑰):7a6551179ee27605393ff0ecf951084d

  5. 保存應用

【參考】

IBM開源社區
CSDN --部署Testlink在Ubuntu16.04系統

相關文章
相關標籤/搜索