Testlink+trac整合

一、下软件
trac        python2.4    trac0.12
apache   httpd-2.4.1.tar.gz
mod_auth_mysql-3.0.0.tar.gz
mod_pthon
mysql     mysql-5.1.55.tar.gz
php        php-5.3.9.tar.gz
xmlrpc    xmlrpcplugin-r11482.zip    http://trac-hacks.org/wiki/XmlRpcPlugin#DownloadandSource
testlink   testlink-1.9.3

以下是gd
gd-2.0.33.tar.gz 
jpegsrc.v6b.tar.gz 
libpng-1.2.8.tar.tar 
zlib-1.2.3.tar.gz (md5:debc62758716a169df9f62e6ab2bc634)
freetype-2.1.10.tar.gz

二、安装
      先安装trac、apache、安装mod_auth_mysql-3.0.0.tar.gz
      apache和trac集成事最好使用mod_python
      这块比较复杂,很多年前搞的,这里忘了。这里不是主要。
三、环境搭建
     apache    ok
     trac0.12   ok
     php         ok
     mysql      ok
     gd          ok(gd安装看我以前gd的文档)

    先写一个php 测试页
    <?
     phpinfo();
    ?>
     查看
     
    
    
       以上都ok ,进行下一步
       
       
安装TESTLINK
   将下载的testlink拷贝/usr/local/apache2/htdocs下面。
      然后进行配置,配置很简单,这里不详细介绍。数据库使用本地的mysql


 开始集成TRAC
   增加testlink的config.inc.php也有人说增加testlink目录下的custom_config.inc.php
      增加代码:$g_interface_bugs = 'TRAC';
      我是增加的 config.inc.php
      修改testlink的cfg目录下的trac.cfg.php
      1)  define('BUG_TRACK_DB_HOST', 'http://127.0.0.1/trac/');     #trac路径,不要使用127.0.0.1。

      2)  把trac的项目与testlink的项目对应

      $g_interface_bugs_project_name_mapping = array(

      'ewayhrp' => 'test',   

      '<YourTLTestProjectName2>' => '<YourTracProject2>',

      );


      这里有几个项目,写几个,前面是testlink自己建的项目,后面是trac的项目。注意大小写。     
      
      修改字符集
      define('BUG_TRACK_DB_CHARSET', 'UTF-8');

      这里就是在testlink的小虫子里添加任务trac的任务的,但是,集成,还未开始。。。。

   TRAC安装XMLRPR
      
    
     注意,官方文档上说
      XmlRpcPlugin might not work with Apache and python 2.4 as explained in  TracInstall. Use python 2.5 if you want to run Trac with mod_python.
      也就是说,可能失败,当然,也就是可能成功。
      我用python2.4 apache成功集成api,并且调用成功!
      如果使用python2.4,方法不能按官方上面的。如下。
      现在源码包
       # python setup.py bdist_egg 
   ######## cp dist/*.egg /srv/trac/env/plugins
编译生成TracXMLRPC-1.1.2-py2.4.egg
easy_install TracXMLRPC-1.1.2-py2.4.egg
看到ok就完成。

     这种方法,2.4不建议使用。
     找一个项目
     You will also need to enable the plugin in your environments  trac.ini:
     [components] tracrpc.* = enabled 
   授权:把TICKET_VIEW(如果已经存在则不需要授,否则出错)和XML_RPC授给anonymous
     命令提示符进入<PythonDir>/scripts目录下,输入

      trac-admin /home/mypro/项目 permission add anonymous XML_RPC

      trac-admin /home/mypro/项目 permission add anonymous TICKET_VIEW
    (这两个其实不重要,前期可以先加,后面有解释)
   打开trac。会发现
    
打开开,可以发现很多api的方法。至于能不能用,先不管。

调试
   到这里,在使用testlink,可以发现,新建是可以打开的。但是testlinkk添加关联任务,会提示
       以匿名访问Trac的基础上实现的!但是,当Trac要求必须登录的话,testlinkk添加关联任务,会提示  这里是以后才发现的,先写在这里,告诉错误原因
     “ bug的ID在BTS中不存在”
     而在新建是可以打开的。
     这是因为,关联一定要用到api,而新建只是testlink-1.9.3\cfg\trac.cfg.php里面的连接而已
     关联调用的是testlink-1.9.3\lib\bugtracking\int_trac.php
    这个ticket.get是用xmlrpcclient调用的,
     testlink-1.9.3\third_party\xml-rpc\class-IXR.php
   这里一般不用改,只是让大家知道。。。
   ok,现在知道关联不成功。那么就两个原因,第一、要是是trac的api不能用(因为官方说python2.4可能不能用,心里很悬),第二、testlink的接口连接有问题,它没有调成功。
   先排查,写了一个测试api的程序。C#
   在写代码调试时,发现如果不输入apache的密码,报错,抓包告之没有权限(之前关联不成功是不是这个原因?心里嘀咕,搞完再说),所以在程序里,写了个用户和密码。随便用来一个ID
   调用成功!!!
   那么就是testlink没有调成功,而不是trac 的api问题  ,那么就将最可疑的地方加到testlink里面去,就是给它一个帐号密码。
   
    增加
      
modified 
/../testlink/cfg/trac.cfg.php, added:
define('BUG_TRACK_XMLRPC_HOST', 'http://username:password@YourIpAddress');

    这里的username输入帐号,password输入密码,这个帐号最好搞一个管理员的(在服务器里面,无所谓安全不安全,如果都被入侵到这里来,你再怎么搞也无用)。
    修改
modified /../testlink/lib/bugtracking/int_trac.php:
$this->xmlrpcClient = new IXR_Client(BUG_TRACK_XMLRPC_HOST.$tracProjectName.'/login/xmlrpc');
    
modified 
/../testlink/third_party/xml-rpc/class-IXR.php

function query() {
$args = func_get_args();
$method = array_shift($args);
$request = new IXR_Request($method, $args);
$length = $request->getLength();
$xml = $request->getXml();
$r = "\r\n";
$credentials = "";
if ($this->user != "") {
$credentials = base64_encode($this->user . ":" . $this->pass);
}

$request = "POST {$this->path} HTTP/1.0$r";
$request .= "Host: {$this->server}$r";
if ($credentials != "") {$request .= "Authorization: Basic {$credentials}$r";}

function IXR_Client(
$server, $path = false, $port = 80, $timeout = false) {
if (!$path) {
// Assume we have been given a URL instead$bits = parse_url($server);
$this->server = $bits['host'];
$this->port = isset($bits['port']) ? $bits['port'] : 80;
$this->user = isset($bits['user']) ? $bits['user'] : '';
$this->pass = isset($bits['pass']) ? $bits['pass'] : '';
     再试试,ok,成功了!
     最早的是匿名访问Trac的基础上实现的,现在Trac要求必须登录的话,这样改就可以了!

完善
go字符
细心的人可以发现,使用testlink的时候,表图可能会有中文乱码。
一般 是字库的问题。Testlink缺省的字符集是拉丁文的字符集。
具体的操作步骤:1.下载一个字符集
              2.把字符集复制到testlink/third_**/pchart/Fonts/目录下
              3.修改config.inc.php文件,把$tlCfg->charts_font_path = TL_ABS_PATH . "third_**/pchart/Fonts/tahoma.ttf"这一句中的ttf文件修改成中文字符集的文件就OK了

 [SMTP]

第一种:修改config.inc.php中的[smtp],配置为默认本地发送,用hotmail用户做接收,调试成功!

// ----------------------------------------------------------------------------
/** [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_tl_admin_email = 'tl_admin@127.0.0.1';#按此配置即可
$g_from_email = 'testlink_system@127.0.0.1';#按此配置即可
$g_return_path_email = 'no_replay@127.0.0.1';#按此配置即可
//
# 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;

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

// ----------------------------------------------------------------------------

第二种:修改config.inc.php中的[smtp],配置为公司邮箱发送,用我公司邮箱调试成功!

// ----------------------------------------------------------------------------
/** [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 = 'smtp.corp.com'; # SMTP 服务必须配置,可配置你公司发送邮件服务器地址

# Configure using custom_config.inc.php
$g_tl_admin_email = 'test@corp.com'; #问题错误通知,配置你公司的邮箱
$g_from_email = 'test@corp.com'; # 收到邮件看到的发送地址

$g_return_path_email = 'test@corp.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;#使用SMTP协议进行发送

// Configure only if SMTP server requires authentication
$g_smtp_username = 'test@corp.com'; # smtp发送的用户名
$g_smtp_password = 'test'; # 发送用户的密码

// ----------------------------------------------------------------------------


网上别人的,公司有邮件服务器,所以用第二种,ok!


中文界面
修改testlink/config.inc.php
/* [LOCALIZATION] */

/** @var string Default localization for users */
// The value must be available in $g_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';


至此,大功完成!
附件送上测api的测试,c#,dll自己添加路径引用。over!

http://download.csdn.net/detail/yllzl/4273578

后面,再补充一个别的,我们登录testlink用的是mysql表里的用户,而apache的trac却是他的文件加密方式。
那么,我们可以使trac也调用mysql的表
<Location /trac>
    SetHandler mod_python
    PythonInterpreter main_interpreter
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnvParentDir /home/mypro
    PythonOption TracUriRoot /trac/
    PythonOption PYTHON_EGG_CACHE /tmp/egg-cache
    AuthType Basic
    AuthName "Trac myql uesr user login"
    AuthUserFile /home/svn/passwd
 
   # AuthMySQLAuthoritative on 
   # AuthBasicAuthoritative off   
   # AuthMySQLHost localhost
   # AuthMySQLUser root
   # AuthMySQLPassword *****
   # AuthMySQLDB bugfree2
   # AuthMySQLUserTable bf_TestUser
   # AuthMySQLNameField UserName
   # AuthMySQLPasswordField UserPassword
   # AuthMySQLPwEncryption md5  
Require valid-user   
</Location>
#是我以前bugfree2的数据库表,照样改下,#去掉!



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值