美文网首页python热爱者
pycharm 远程调试 tempest

pycharm 远程调试 tempest

作者: random233 | 来源:发表于2017-12-05 11:01 被阅读65次

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

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

Paste_Image.png Paste_Image.png

远程linux服务器的信息

root@cnsrc-cns-tempest-ci:~/tempest_netease/tempest-ci/tempest# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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#
Paste_Image.png

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

Paste_Image.png Paste_Image.png

进行deployment 的配置

Paste_Image.png

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

Paste_Image.png

配置mapping

Paste_Image.png

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

Paste_Image.png

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

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
Paste_Image.png

跑过的话效果如下:

Paste_Image.png

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

Paste_Image.png

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

image

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

相关文章

  • pycharm 远程调试 tempest

    本地windows 下面 tempest pip依赖不好装,而且和部分服务之间有防火墙之类的需要打通,很不方便。所...

  • CentOS7 desktop openstack queens

    引用 neutron通过pycharm调试Pycharm 下远程调试 Neutron 简介 远程代码同步 远程调试...

  • PyCharm 远程开发调试

    My Blog: PyCharm 远程开发调试 VS code与PyCharm在远程开发调试时的区别 上次已经介绍...

  • TVM安装(二):pycharm远程调试

    pycharm远程调试环境网上已经有很多答案,这里不重复,但在远程调试TVM时会有一个坑:pycharm不能读取远...

  • Pycharm 远程调试

    个人的文档,直接当图片上传了,里面的有些pycharm上的模块名称大小写等等都可能不一致,但你应该会知道对应的是什...

  • pycharm 远程调试

    1.前期准备 保证有一台 Linux (我用的是 ubuntu server 1404 ),系统自带 python...

  • pycharm远程调试

    今天在使用pycharm过程中,需要在虚拟机ubuntu环境下和windows环境下分别去跑一个小程序,检查下区别...

  • Pycharm远程调试

    动机 一些bug由于本地环境和线上环境的不一致可能导致本地无法复现 本地依赖和线上依赖版本不一致也可以导致一些问题...

  • pycharm 远程[Errno 2] No such file

    context pycharm上,远程调试代码的时候,点击run,会报错[Errno 2] No such fil...

  • PyCharm配置远程调试

    系统环境:win7 64位启动PyCharm

网友评论

    本文标题:pycharm 远程调试 tempest

    本文链接:https://www.haomeiwen.com/subject/pimqixtx.html