您的位置:首页 > 其它

构建基于Trac的自动测试系统(二):安装相关的Trac插件

2009-07-27 18:24 501 查看
Trac系统本身是一个专注于软件项目开发过程的管理系统,但我感兴趣的是自动集成测试。要把它打造成自动测试系统还需要一些Trac插件的配合。最重要的当然是bitten。Trac的插件都是标准的Python模块。Trac插件有两种安装方式:全局安装或者针对特定项目安装。针对特定项目安装trac插件可以在管理界面的plugins下操作,插件模块被安装到d:\trac\vmcepc\plugins目录下,只在该项目里加载。全局安装的方法跟标准的安装Python模块的方法相同,但是我这里由于没有通过正常方法安装Python,常用的"setup.py install"之类不能直接用。work around是你可以在另外一台机器上安装python,在它上面装trac插件,然后把相关目录拷贝到trac server的C:\Program Files\VisualSVN Server\trac\python\Lib\site-packages目录下,并在easy-install.pth中添加相应路径。如果你下载的trac插件是egg文件则更简单,直接把egg文件拷贝到C:\Program Files\VisualSVN Server\trac\python\Lib\site-packages目录,在easy-install.pth中添加相应路径即可。当然绝大部分trac插件还需要在trac.ini中做些配置才能工作。

安装bitten插件。bitten是Continuous Integration Server的核心,分为Build Slave和Build Master。Build Master做为Trac的插件和Trac系统集成,Build Slave做为Python模块安装在Build Machine上,可以从Trac Server上下载编译脚本(build receipt)自动进行Build。

下载地址:http://bitten.edgewall.org/

在Build Machine上安装Python 2.5,下载bitten并解压,进入bitten目录,运行"setup.py install"安装bitten,然后把C:\Program Files\VisualSVN Server\trac\python\Lib\site-packages\Bitten-0.6dev_r571-py2.5.egg(我目前用的版本)拷贝到Trac Server的C:\Program Files\VisualSVN Server\trac\python\Lib\site-packages目录,编辑easy-install.pth添加bitt模块路径:

import sys; sys.__plen = len(sys.path)

./setuptools-0.6c8-py2.5.egg

./genshi-0.5.1-py2.5-win32.egg

./trac-0.11-py2.5.egg

./Bitten-0.6dev_r571-py2.5.egg

import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)



在d:\trac\vmcepc\conf\trac.ini中添加


[components]

bitten.* = enabled



在DOS下运行trac-admin更新配置:


"C:\Program Files\VisualSVN Server\trac\trac-admin.bat" d:\trac\vmcepc upgrade

现在Bitten插件安装好了,以admin身份登录Trac界面应该能看到导航栏多了"Build Status"一项。在Admin-->Permission中可以给用户设置权限。给anonymous加上BUILD_VIEW权限,这样匿名用户也能看到Build状态,另外可以给Build Engineer添加BUILD_ADMIN权限。

还有其它一些Trac插件也很有用:比如AccountManager可以通过web管理trac用户;TracDownloader可以发布软件;Discussion可以创建项目讨论组。

安装AccountManager插件。

下载地址:http://trac-hacks.org/wiki/AccountManagerPlugin。安装方法类似bitten。装完后编辑trac.ini:

在components节添加:

[components]

acct_mgr.admin.* = enabled

acct_mgr.api.* = enabled

acct_mgr.db.* = enabled

acct_mgr.htfile.* = enabled

acct_mgr.http.* = enabled

acct_mgr.notification.* = enabled

acct_mgr.pwhash.* = enabled

acct_mgr.svnserve.* = enabled

acct_mgr.web_ui.* = enabled

trac.web.auth.loginmodule = disabled



配置account manager,用户密码管理使用HtPasswdStore,好处是整个Trac Server使用同一套用户/密码数据库:


[account-manager]

authentication_url =

force_passwd_change = true

hash_method = HtDigestHashMethod

htdigest_realm =

password_file = d:\repos\htpasswd

password_store = HtPasswdStore



启用AccountManager插件后,要禁止掉缺省的http验证方式,同时由于bitten只支持http验证方式,因此要给它保留http验证方式。编辑C:\Program Files\VisualSVN Server\conf\httpd-custom.conf如下:


LoadModule python_module "trac/python/mod_python_so.pyd"

LoadModule authz_user_module bin/mod_authz_user.so

<Location /trac>

SetHandler mod_python

PythonInterpreter main_interpreter

PythonHandler trac.web.modpython_frontend

PythonOption TracEnvParentDir d:\Trac

PythonOption TracUriRoot /trac

#AuthName "Trac"

#AuthType Basic

#AuthBasicProvider file

#AuthUserFile "d:/Repos/htpasswd"

#Require valid-user

</Location>

<LocationMatch "/trac/[^/]+/builds">

AuthName "Trac"

AuthType Basic

AuthBasicProvider file

AuthUserFile "d:/repos/htpasswd"

Require valid-user

</LocationMatch>

运行trac-admin更新配置,并重启Visual SVN Server。

安装TracDownloader插件。

下载地址:http://trac-hacks.org/wiki/TracDownloaderPlugin

Downloader插件需要PyCaptchaPILClear Silver三个Python模块支持。得先安装这三个模块。

编辑trac.ini,在components节添加:

[components]

tracdownloader.admin.downloaderadminpage = enabled

tracdownloader.web_ui.downloadermodule = enabled



创建文件上传目录:d:\trac\vmcepc\download

配置Downloader,:


[downloader]

captcha_font_border = 2

captcha_font_size = 35

captcha_num_of_letters = 4

files_dir = d:\trac\vmcepc\download

no_captcha = true

no_quest = true

注意目前的Downloader插件在Trac 0.11上有点bug。要自己改一下代码,具体可参考这个Ticket。如果你装的是egg,把egg后缀改为zip,解压可得到源代码。编辑C:\Program Files\VisualSVN Server\trac\python\Lib\site-packages\TracDownloader-0.1-trac-0.11.egg\tracdownloader\web_ui.py。

from trac.util.html import html

#

def get_navigation_items(self, req):

"""Downloader isinstance visible if user hasattr got permission """

if req.perm.has_permission('DOWNLOADER_DOWNLOAD'):

yield 'mainnav', 'downloader', html.a('Downloader', href = req.href.downloader())

#yield 'mainnav', 'downloader', Markup('<a href="%s">Downloader</a>',

# self.env.href.downloader())

运行trac-admin更新配置,并重启Visual SVN Server。

安装Discussion插件。 没有特别的地方,照着指南做就行。

下载地址:http://trac-hacks.org/wiki/DiscussionPlugin

运行trac-admin更新配置。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: