GNS3 / gns3-server

GNS3 server
GNU General Public License v3.0
798 stars 262 forks source link

Compiling on Windows #159

Closed boenrobot closed 9 years ago

boenrobot commented 9 years ago

Hi.

I'd like to help test repository level code of GNS3 (and if my Python self lessons pay off, maybe even make some small contributions) on Windows, starting off by running the unit tests of gns3-server.

I tried to just call python setup.py develop and then python setup.py test, but while all packages install fine, the tests don't seem to run. Things go south around this point (as seen from terminal)

reading manifest template 'MANIFEST.in'
warning: no files found matching 'INSTALL'
warning: no previously-included files matching '*' found under directory 'docs'
warning: no previously-included files matching '__pycache__' found under directory '*'
writing manifest file 'gns3_server.egg-info\SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "d:\projects\gns3\gns3-server\pytest-2.7.0-py3.3.egg\_pytest\config.py", line 513, in getconftestmodules
    return self._path2confmods[path]
KeyError: local('D:\\Projects\\GNS3\\gns3-server\\tests')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "d:\projects\gns3\gns3-server\pytest-2.7.0-py3.3.egg\_pytest\config.py", line 537, in importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('D:\\Projects\\GNS3\\gns3-server\\tests\\conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "d:\projects\gns3\gns3-server\pytest-2.7.0-py3.3.egg\_pytest\config.py", line 543, in importconftest
    mod = conftestpath.pyimport()
  File "C:\Python33\lib\site-packages\py-1.4.26-py3.3.egg\py\_path\local.py", line 641, in pyimport
    __import__(modname)
  File "D:\Projects\GNS3\gns3-server\tests\conftest.py", line 33, in <module>
    from gns3server.web.route import Route
  File "D:\Projects\GNS3\gns3-server\gns3server\web\route.py", line 28, in <module>
    from ..modules.vm_error import VMError
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\__init__.py", line 21, in <module>
    from .virtualbox import VirtualBox
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\virtualbox\__init__.py", line 32, in <module>
    from .virtualbox_vm import VirtualBoxVM
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\virtualbox\virtualbox_vm.py", line 35, in <module>
    from .telnet_server import TelnetServer  # TODO: port TelnetServer to asyncio
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\virtualbox\telnet_server.py", line 29, in <module>
    import win32pipe
ImportError: No module named 'win32pipe'
ERROR: could not load D:\Projects\GNS3\gns3-server\tests\conftest.py

Process finished with exit code 4

Judging by the readme file, I'm guessing GNS3 simply doesn't support running its tests on Windows, but is there at least maybe a way to compile GNS3 myself so I could test any attempted changes (and/or simply try out cutting edge code...)?

(P.S. I'm using the currently latest PyCharm EAP as my IDE, and Python 3.4.3)

julien-duponchelle commented 9 years ago

I think you need to install https://sourceforge.net/projects/pywin32/

Can you confirm that? I will complete the install process.

boenrobot commented 9 years ago

I installed that, and now I get a different error when running setup.py test:

reading manifest template 'MANIFEST.in'
warning: no files found matching 'INSTALL'
warning: no previously-included files matching '*' found under directory 'docs'
warning: no previously-included files matching '__pycache__' found under directory '*'
writing manifest file 'gns3_server.egg-info\SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "d:\projects\gns3\gns3-server\.eggs\pytest-2.7.0-py3.4.egg\_pytest\config.py", line 513, in getconftestmodules
    return self._path2confmods[path]
KeyError: local('D:\\Projects\\GNS3\\gns3-server\\tests')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "d:\projects\gns3\gns3-server\.eggs\pytest-2.7.0-py3.4.egg\_pytest\config.py", line 537, in importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('D:\\Projects\\GNS3\\gns3-server\\tests\\conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "d:\projects\gns3\gns3-server\.eggs\pytest-2.7.0-py3.4.egg\_pytest\config.py", line 543, in importconftest
    mod = conftestpath.pyimport()
  File "d:\projects\gns3\gns3-server\.eggs\py-1.4.26-py3.4.egg\py\_path\local.py", line 641, in pyimport
    __import__(modname)
  File "D:\Projects\GNS3\gns3-server\tests\conftest.py", line 33, in <module>
    from gns3server.web.route import Route
  File "D:\Projects\GNS3\gns3-server\gns3server\web\route.py", line 28, in <module>
    from ..modules.vm_error import VMError
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\__init__.py", line 29, in <module>
    from .iou import IOU
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\iou\__init__.py", line 27, in <module>
    from .iou_vm import IOUVM
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\iou\iou_vm.py", line 44, in <module>
    from .ioucon import start_ioucon
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\iou\ioucon.py", line 24, in <module>
    import fcntl
ImportError: No module named 'fcntl'
ERROR: could not load D:\Projects\GNS3\gns3-server\tests\conftest.py

Process finished with exit code 4

This time, it appears to be an IOU related issue... It seems like GNS3 doesn't skip compiling (and testing) IOU upon detecting Windows.

julien-duponchelle commented 9 years ago

I have push a fix in order to skip IOU test on Windows because IOU is not supported on Windows.

You can reopen the issue if you find something else.

Thanks!

boenrobot commented 9 years ago

After reinstalling the deps with that, more errors down the line:

running build_ext
Traceback (most recent call last):
  File "d:\projects\gns3\gns3-server\.eggs\pytest-2.7.0-py3.4.egg\_pytest\config.py", line 513, in getconftestmodules
    return self._path2confmods[path]
KeyError: local('D:\\Projects\\GNS3\\gns3-server\\tests')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "d:\projects\gns3\gns3-server\.eggs\pytest-2.7.0-py3.4.egg\_pytest\config.py", line 537, in importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('D:\\Projects\\GNS3\\gns3-server\\tests\\conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "d:\projects\gns3\gns3-server\.eggs\pytest-2.7.0-py3.4.egg\_pytest\config.py", line 543, in importconftest
    mod = conftestpath.pyimport()
  File "d:\projects\gns3\gns3-server\.eggs\py-1.4.26-py3.4.egg\py\_path\local.py", line 641, in pyimport
    __import__(modname)
  File "D:\Projects\GNS3\gns3-server\tests\conftest.py", line 35, in <module>
    from gns3server.handlers import *
  File "D:\Projects\GNS3\gns3-server\gns3server\handlers\__init__.py", line 34, in <module>
    from gns3server.handlers.api.iou_handler import IOUHandler
  File "D:\Projects\GNS3\gns3-server\gns3server\handlers\api\iou_handler.py", line 28, in <module>
    from ...modules.iou import IOU
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\iou\__init__.py", line 27, in <module>
    from .iou_vm import IOUVM
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\iou\iou_vm.py", line 44, in <module>
    from .ioucon import start_ioucon
  File "D:\Projects\GNS3\gns3-server\gns3server\modules\iou\ioucon.py", line 24, in <module>
    import fcntl
ImportError: No module named 'fcntl'
ERROR: could not load D:\Projects\GNS3\gns3-server\tests\conftest.py

Process finished with exit code 4

Seems like IOU's handler is included, which in turn unconditionally requires IOU.

In handlers\__init__.py, I tried to change

if sys.platform.startswith("linux") or hasattr(sys, "_called_from_test") or os.environ.get("PYTEST_BUILD_DOCUMENTATION") == "1":

to

if sys.platform.startswith("linux"): # or hasattr(sys, "_called_from_test") or os.environ.get("PYTEST_BUILD_DOCUMENTATION") == "1":

And the tests run with no compilation errors... But there are 17 tests failing. Here's the full output from terminal: https://gist.github.com/boenrobot/b85111eb0b8af3e92235

julien-duponchelle commented 9 years ago

Thanks it's fixed

boenrobot commented 9 years ago

The tests are now running, with the same 17 failures as from the above Gist.

Maybe I need to install VPCS and Qemu separately? I'm guessing Qemu would be found by the same means as from a "real" install (i.e. I'd assume installing the binary would be enough), but what about VPCS? IIRC, it's not checked in the PATH or anything, but is instead hardcoded to GNS3's folder... Or is it?

julien-duponchelle commented 9 years ago

It should use the PATH settings. You can take the binary from your GNS3 install (vpcs.exe is a compiled binary without dependencies)

boenrobot commented 9 years ago

I installed Qemu (in its default Program Files folder), added the folder with vpcs.exe to the PATH, restarted my computer, and still I get those same failures for some reason :-\ . I would've expected at least qemu_vm to not fail anymore.

I can see the cause for the test_project failure is again IOU, and the tests\handlers\api\test_vpcs.py:54 error is because "/" is assumed directory separator. But I don't know about the others.

julien-duponchelle commented 9 years ago

I just pushed fixe for all tests :)

julien-duponchelle commented 9 years ago

Now I have a windows machine for testing them

boenrobot commented 9 years ago

I retried with the latest commit, and now there are two errors left, both about test_logger.py, complaining about "caplog" not having been found... I do have Wireshark and WinPcap installed, so... What's that? Another tool? A wireshark binary that's not detected for some reason? The Wireshark folder certainly doesn't contain that.

julien-duponchelle commented 9 years ago

You need to install pytest-capturelog via pip.

On Tue, Apr 28, 2015 at 5:26 PM, Vasil Rangelov notifications@github.com wrote:

I retried with the latest commit, and now there are two errors left, both complaining about "caplog" not having been found... I do have Wireshark and WinPcap installed, so... What's that? Another tool? A wireshark binary that's not detected for some reason?

— Reply to this email directly or view it on GitHub https://github.com/GNS3/gns3-server/issues/159#issuecomment-97105283.

JULIEN DUPONCHELLE Software Engineer

E: julien@gns3.com LinkedIn http://linkedin.com/in/julienduponchelle/

http://www.linkedin.com/in/stephenguppy288, 200 – Rivercrest Drive SE Calgary, AB, T2T 2X5 Twitter http://www.twitter.com/gns3_official | Facebook https://www.facebook.com/gns3official | LinkedIn http://www.linkedin.com/company/gns3-net | Google+ https://plus.google.com/+Gns3Net/posts | CrunchBase http://www.crunchbase.com/organization/gns3

boenrobot commented 9 years ago

Yeah, about that... I was under the impression that doing python setup.py develop was supposed to install all packages in dev-requirements.txt, with pytest-capturelog being among them, but it doesn't seem to. Am I misinterpreting how it is supposed to work, or is there another issue going on?

I installed it "manually" via pip, and it works now... But I can't help feeling it should've been installed previously by setup.py.