Linux下测试tempest,pycharm 远程调试 tempest

本地windows 下面 tempest pip依赖不好装,而且和部分服务之间有防火墙之类的需要打通,很不方便。所以考虑直接本地编辑代码,远端运行代码。记录一下整个在pycharm里面设置的过程。

在 file -> setting -> project 解释器里面增加remote 解释器:

9117d1b9d6ed

Paste_Image.png

9117d1b9d6ed

Paste_Image.png

远程linux服务器的信息

root@cnsrc-cns-tempest-ci:~/tempest_netease/tempest-ci/tempest# ip a

1: lo: mtu 16436 qdisc noqueue state UNKNOWN

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0: mtu 1400 qdisc pfifo_fast state UP qlen 1000

link/ether fa:16:3e:cd:d1:a4 brd ff:ff:ff:ff:ff:ff

inet 10.180.65.60/23 brd 10.180.65.255 scope global eth0

inet6 fe80::f816:3eff:fecd:d1a4/64 scope link

valid_lft forever preferred_lft forever

3: eth1: mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether fa:16:3e:f2:57:f4 brd ff:ff:ff:ff:ff:ff

inet 115.236.127.192/24 brd 115.236.127.255 scope global eth1

inet6 fe80::f816:3eff:fef2:57f4/64 scope link

valid_lft forever preferred_lft forever

root@cnsrc-cns-tempest-ci:~/tempest_netease/tempest-ci/tempest#

9117d1b9d6ed

Paste_Image.png

下面这个配置很重要, Local Path 是本地 py 文件存储的地方(默认为当前工程所在地方), Remote Path 为远程 Linux 的目录,编辑本地的 py 文件后,在调试时,远程的 python 环境不会直接运行你本地文件夹的 py 文件,而是访问 Linux 自己的目录,这个目录就是这里设置的,接下来就是配置这连个文件夹同步即可。

9117d1b9d6ed

Paste_Image.png

9117d1b9d6ed

Paste_Image.png

进行deployment 的配置

9117d1b9d6ed

Paste_Image.png

配置sftp选项,相当于两边目录同步设置

9117d1b9d6ed

Paste_Image.png

配置mapping

9117d1b9d6ed

Paste_Image.png

option里面,配置这个选项,本地 ctrl +s 就能保存并同步到远端。(或者选择always,pycharm就能一直自动帮你同步到远端)

9117d1b9d6ed

Paste_Image.png

代码也可以手工上传,一般第一次进行同步的时候可以手工上传一遍,之后就选择自动同步了。

9117d1b9d6ed

Paste_Image.png

测试一下,在服务器端命令行下执行nosetest:

root@cnsrc-cns-tempest-ci:~/tempest_netease/tempest-ci/tempest# nosetests -sv tempest/api/network/test_ports.py:PortsTestJSON.test_create_update_port_with_second_ip

tempest.api.network.test_ports.PortsTestJSON.test_create_update_port_with_second_ip[gate,smoke] ... ok

----------------------------------------------------------------------

Ran 1 test in 17.497s

OK

root@cnsrc-cns-tempest-ci:~/tempest_netease/tempest-ci/tempest#

下面配置pycharm端的runner设置:

pycharm端的runner配置为nosetest

选择对应的文件

D:\demo\tempest-ci\tempest\tempest\api\network\test_ports.py

9117d1b9d6ed

Paste_Image.png

跑过的话效果如下:

9117d1b9d6ed

Paste_Image.png

如果测试某一个具体的方法,可以这样指定(测试具体的类,或者具体的目录类似):

9117d1b9d6ed

Paste_Image.png

打断点,debug看堆栈信息也可以使用了。

9117d1b9d6ed

image

这比用 pdb 一个一个在文件中打断点方便不少。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值