基于 HttpRunner 的接口自动化测试平台: HttpRunner
, djcelery
and Django
_. HttpRunner 手册: http://cn.httprunner.org/
安装 mysql 数据库服务端 (推荐 5.7+),并设置为 utf-8 编码,创建相应 HttpRunner 数据库,设置好相应用户名、密码,启动 mysql
修改:HttpRunnerManager/HttpRunnerManager/settings.py 里 DATABASES 字典相关配置
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'HttpRunner', # 新建数据库名
'USER': 'root', # 数据库登录名
'PASSWORD': 'lcc123456', # 数据库登录密码
'HOST': '127.0.0.1', # 数据库所在服务器ip地址
'PORT': '3306', # 监听端口 默认3306即可
}
}
安装 rabbitmq 消息中间件,启动服务,访问:http://host:15672/#/ host 即为你部署 rabbitmq 的服务器 ip 地址
username:guest、Password:guest, 成功登陆即可
service rabbitmq-server start
修改:HttpRunnerManager/HttpRunnerManager/settings.py 里 worker 相关配置
djcelery.setup_loader()
CELERY_ENABLE_UTC = True
CELERY_TIMEZONE = 'Asia/Shanghai'
BROKER_URL = 'amqp://guest:guest@127.0.0.1:5672//' # 127.0.0.1即为rabbitmq-server所在服务器ip地址
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
CELERY_RESULT_BACKEND = 'djcelery.backends.database:DatabaseBackend'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_RESULT_EXPIRES = 7200 # celery任务执行结果的超时时间,
CELERYD_CONCURRENCY = 10 # celery worker的并发数 也是命令行-c指定的数目 根据服务器配置实际更改 默认10
CELERYD_MAX_TASKS_PER_CHILD = 100 # 每个worker执行了多少任务就会死掉,我建议数量可以大一些,默认100
命令行窗口执行 pip install -r requirements.txt 安装工程所依赖的库文件
命令行窗口切换到 HttpRunnerManager 目录 生成数据库迁移脚本,并生成表结构
python manage.py makemigrations ApiManager #生成数据迁移脚本
python manage.py migrate #应用到db生成数据表
创建超级用户,用户后台管理数据库,并按提示输入相应用户名,密码,邮箱。 如不需用,可跳过此步骤
python manage.py createsuperuser
启动服务,
python manage.py runserver 0.0.0.0:8000
启动 worker, 如果选择同步执行并确保不会使用到定时任务,那么此步骤可忽略
python manage.py celery -A HttpRunnerManager worker --loglevel=info #启动worker
python manage.py celery beat --loglevel=info #启动定时任务监听器
celery flower #启动任务监控后台
访问:http://localhost:5555/dashboard 即可查看任务列表和状态
浏览器输入:http://127.0.0.1:8000/api/register/ 注册用户,开始尽情享用平台吧
浏览器输入http://127.0.0.1:8000/admin/ 输入步骤 6 设置的用户名、密码,登录后台运维管理系统,可后台管理数据
挺好的,真的挺好的,就是 django 不好维护
fuwuqi guale ?
这个我搭建完了,怎么不好用呢,我看现在不维护了是吗
支持 dubbo 接口么?
发送邮件如何设置
启动 worker 报错
sudo python manage.py celery -A HttpRunnerManager worker --loglevel=info
Traceback (most recent call last):
File "manage.py", line 22, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/init.py", line 371, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/dist-packages/django/core/management/init.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/init.py", line 216, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/init.py", line 36, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 665, in exec_module
File "", line 222, in _call_with_frames_removed
File "/usr/local/lib/python3.5/dist-packages/djcelery/management/commands/celery.py", line 11, in
class Command(CeleryCommand):
File "/usr/local/lib/python3.5/dist-packages/djcelery/management/commands/celery.py", line 23, in Command
preload_options)
TypeError: can only concatenate list (not "tuple") to list
步骤 6 报错
django.db.utils.OperationalError: (1366, "Incorrect string value: '\xE6\xA8\xA1\xE5\x9D\x97...' for column 'name' at row 1")
请问是为什么呢?还有步骤 6 生成得后台用户和密码是什么呢
有在 ubuntu 上装 rabbitmq 得吗?我装好之后无法通过浏览器访问怎么回事
卡在 Mysqlclient 1.3.12 的安装上过不去这一步了。
请问楼主,这个项目不开源了吗?
HttpRunner 版本升级的原因,升级到 HttpRunner-1.5.15 版本有问题
启动报这个错怎么解决呢
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/httprunner/init.py:5: RuntimeWarning: Monkey-patching not on the main thread; threading.main_thread().join() will hang from a greenlet
from gevent import monkey; monkey.patch_all()
异步生成报告之后报错
[2018-09-29 14:13:21,727: ERROR/MainProcess] Task ApiManager.tasks.main_hrun[5aeef755-44fd-42cf-a560-5a09917bedcd] raised unexpected: FileNotFoundError(2, 'No such file or directory')
Traceback (most recent call last):
File "/Users/yangyuexiong/Desktop/HttpRunnerManager-master/venv/lib/python3.6/site-packages/celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "/Users/yangyuexiong/Desktop/HttpRunnerManager-master/venv/lib/python3.6/site-packages/celery/app/trace.py", line 438, in protected_call
return self.run(*args, **kwargs)
File "/Users/yangyuexiong/Desktop/HttpRunnerManager-master/ApiManager/tasks.py", line 36, in main_hrun
report_path = add_test_reports(runner, report_name=report_name)
File "/Users/yangyuexiong/Desktop/HttpRunnerManager-master/ApiManager/utils/operation.py", line 447, in add_test_reports
with open(report_path, encoding='utf-8') as stream:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/yangyuexiong/Desktop/HttpRunnerManager-master/reports/1538201601.html'
执行 pipenv run python main-debug.py hrun -h 命令时
遇到报错 (null): can't open file 'main-debug.py': [Errno 2] No such file or directory
该怎么解决?
功能强大,还没能完全体验完,满足目前需要做的一个工具的需求。
这段时间落下了,更新了好多,补上补上
功能很强大的项目 测试必备
回头要好好研究下