mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Merge pull request #27 from dlintott/master
Override check_origin and fix test suite
This commit is contained in:
commit
90c8c4312c
17
.travis.yml
17
.travis.yml
@ -1,14 +1,19 @@
|
|||||||
language: python
|
language: python
|
||||||
|
|
||||||
python:
|
env:
|
||||||
- "3.3"
|
- TOX_ENV=py33
|
||||||
- "3.4"
|
- TOX_ENV=py34
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- sudo add-apt-repository ppa:gns3/ppa -y
|
||||||
|
- sudo apt-get update -q
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- "pip install -r requirements.txt --use-mirrors"
|
- pip install tox
|
||||||
- "pip install tox"
|
- sudo apt-get install vpcs dynamips
|
||||||
|
|
||||||
script: "python setup.py test"
|
script:
|
||||||
|
- tox -e $TOX_ENV
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
|
@ -52,6 +52,9 @@ class JSONRPCWebSocket(tornado.websocket.WebSocketHandler):
|
|||||||
self._session_id = str(uuid.uuid4())
|
self._session_id = str(uuid.uuid4())
|
||||||
self.zmq_router = zmq_router
|
self.zmq_router = zmq_router
|
||||||
|
|
||||||
|
def check_origin(self, origin):
|
||||||
|
return True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def session_id(self):
|
def session_id(self):
|
||||||
"""
|
"""
|
||||||
|
@ -23,5 +23,5 @@
|
|||||||
# or negative for a release candidate or beta (after the base version
|
# or negative for a release candidate or beta (after the base version
|
||||||
# number has been incremented)
|
# number has been incremented)
|
||||||
|
|
||||||
__version__ = "1.0beta1"
|
__version__ = "1.0beta2-dev1"
|
||||||
__version_info__ = (1, 0, 0, -99)
|
__version_info__ = (1, 0, 0, -99)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
netifaces
|
netifaces
|
||||||
tornado
|
tornado
|
||||||
pyzmq
|
pyzmq
|
||||||
netifaces-py3
|
|
||||||
jsonschema
|
jsonschema
|
||||||
|
10
setup.py
10
setup.py
@ -20,7 +20,7 @@ from setuptools import setup, find_packages
|
|||||||
from setuptools.command.test import test as TestCommand
|
from setuptools.command.test import test as TestCommand
|
||||||
|
|
||||||
|
|
||||||
class Tox(TestCommand):
|
class PyTest(TestCommand):
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
TestCommand.finalize_options(self)
|
TestCommand.finalize_options(self)
|
||||||
@ -29,8 +29,8 @@ class Tox(TestCommand):
|
|||||||
|
|
||||||
def run_tests(self):
|
def run_tests(self):
|
||||||
#import here, cause outside the eggs aren't loaded
|
#import here, cause outside the eggs aren't loaded
|
||||||
import tox
|
import pytest
|
||||||
errcode = tox.cmdline(self.test_args)
|
errcode = pytest.main(self.test_args)
|
||||||
sys.exit(errcode)
|
sys.exit(errcode)
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
@ -38,8 +38,8 @@ setup(
|
|||||||
version=__import__("gns3server").__version__,
|
version=__import__("gns3server").__version__,
|
||||||
url="http://github.com/GNS3/gns3-server",
|
url="http://github.com/GNS3/gns3-server",
|
||||||
license="GNU General Public License v3 (GPLv3)",
|
license="GNU General Public License v3 (GPLv3)",
|
||||||
tests_require=["tox"],
|
tests_require=["pytest"],
|
||||||
cmdclass={"test": Tox},
|
cmdclass={"test": PyTest},
|
||||||
author="Jeremy Grossmann",
|
author="Jeremy Grossmann",
|
||||||
author_email="package-maintainer@gns3.net",
|
author_email="package-maintainer@gns3.net",
|
||||||
description="GNS3 server to asynchronously manage emulators",
|
description="GNS3 server to asynchronously manage emulators",
|
||||||
|
@ -6,10 +6,9 @@ import os
|
|||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def hypervisor(request):
|
def hypervisor(request):
|
||||||
|
|
||||||
cwd = os.path.dirname(os.path.abspath(__file__))
|
dynamips_path = '/usr/bin/dynamips'
|
||||||
dynamips_path = os.path.join(cwd, "dynamips.stable")
|
|
||||||
print("\nStarting Dynamips Hypervisor: {}".format(dynamips_path))
|
print("\nStarting Dynamips Hypervisor: {}".format(dynamips_path))
|
||||||
manager = HypervisorManager(dynamips_path, "/tmp", "127.0.0.1", 9000)
|
manager = HypervisorManager(dynamips_path, "/tmp", "127.0.0.1")
|
||||||
hypervisor = manager.start_new_hypervisor()
|
hypervisor = manager.start_new_hypervisor()
|
||||||
|
|
||||||
def stop():
|
def stop():
|
||||||
|
@ -29,9 +29,9 @@ def test_router_exists(router_c7200):
|
|||||||
|
|
||||||
def test_npe(router_c7200):
|
def test_npe(router_c7200):
|
||||||
|
|
||||||
assert router_c7200.npe == "npe-400" # default value
|
assert router_c7200.npe == "npe-200" # default value
|
||||||
router_c7200.npe = "npe-200"
|
router_c7200.npe = "npe-400"
|
||||||
assert router_c7200.npe == "npe-200"
|
assert router_c7200.npe == "npe-400"
|
||||||
|
|
||||||
|
|
||||||
def test_midplane(router_c7200):
|
def test_midplane(router_c7200):
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from gns3server.modules.dynamips import Hypervisor
|
from gns3server.modules.dynamips import Hypervisor
|
||||||
import time
|
import time
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
def test_is_started(hypervisor):
|
def test_is_started(hypervisor):
|
||||||
@ -10,7 +9,7 @@ def test_is_started(hypervisor):
|
|||||||
|
|
||||||
def test_port(hypervisor):
|
def test_port(hypervisor):
|
||||||
|
|
||||||
assert hypervisor.port == 9000
|
assert hypervisor.port == 7200
|
||||||
|
|
||||||
|
|
||||||
def test_host(hypervisor):
|
def test_host(hypervisor):
|
||||||
@ -25,8 +24,7 @@ def test_working_dir(hypervisor):
|
|||||||
|
|
||||||
def test_path(hypervisor):
|
def test_path(hypervisor):
|
||||||
|
|
||||||
cwd = os.path.dirname(os.path.abspath(__file__))
|
dynamips_path = '/usr/bin/dynamips'
|
||||||
dynamips_path = os.path.join(cwd, "dynamips.stable")
|
|
||||||
assert hypervisor.path == dynamips_path
|
assert hypervisor.path == dynamips_path
|
||||||
|
|
||||||
|
|
||||||
@ -34,11 +32,10 @@ def test_stdout():
|
|||||||
|
|
||||||
# try to launch Dynamips on the same port
|
# try to launch Dynamips on the same port
|
||||||
# this will fail so that we can read its stdout/stderr
|
# this will fail so that we can read its stdout/stderr
|
||||||
cwd = os.path.dirname(os.path.abspath(__file__))
|
dynamips_path = '/usr/bin/dynamips'
|
||||||
dynamips_path = os.path.join(cwd, "dynamips.stable")
|
hypervisor = Hypervisor(dynamips_path, "/tmp", "127.0.0.1", 7200)
|
||||||
hypervisor = Hypervisor(dynamips_path, "/tmp", "172.0.0.1", 7200)
|
|
||||||
hypervisor.start()
|
hypervisor.start()
|
||||||
# give some time for Dynamips to start
|
# give some time for Dynamips to start
|
||||||
time.sleep(0.01)
|
time.sleep(0.1)
|
||||||
output = hypervisor.read_stdout()
|
output = hypervisor.read_stdout()
|
||||||
assert output
|
assert output
|
||||||
|
@ -7,10 +7,9 @@ import os
|
|||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def hypervisor_manager(request):
|
def hypervisor_manager(request):
|
||||||
|
|
||||||
cwd = os.path.dirname(os.path.abspath(__file__))
|
dynamips_path = '/usr/bin/dynamips'
|
||||||
dynamips_path = os.path.join(cwd, "dynamips.stable")
|
|
||||||
print("\nStarting Dynamips Hypervisor: {}".format(dynamips_path))
|
print("\nStarting Dynamips Hypervisor: {}".format(dynamips_path))
|
||||||
manager = HypervisorManager(dynamips_path, "/tmp", "127.0.0.1", 9000)
|
manager = HypervisorManager(dynamips_path, "/tmp", "127.0.0.1")
|
||||||
|
|
||||||
#manager.start_new_hypervisor()
|
#manager.start_new_hypervisor()
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import base64
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def router(request, hypervisor):
|
def router(request, hypervisor):
|
||||||
|
|
||||||
router = Router(hypervisor, "router", "c3725")
|
router = Router(hypervisor, "router", platform="c3725")
|
||||||
request.addfinalizer(router.delete)
|
request.addfinalizer(router.delete)
|
||||||
return router
|
return router
|
||||||
|
|
||||||
@ -127,9 +127,9 @@ def test_idlepc(router):
|
|||||||
|
|
||||||
def test_idlemax(router):
|
def test_idlemax(router):
|
||||||
|
|
||||||
assert router.idlemax == 1500 # default value
|
assert router.idlemax == 500 # default value
|
||||||
router.idlemax = 500
|
router.idlemax = 1500
|
||||||
assert router.idlemax == 500
|
assert router.idlemax == 1500
|
||||||
|
|
||||||
|
|
||||||
def test_idlesleep(router):
|
def test_idlesleep(router):
|
||||||
@ -172,7 +172,7 @@ def test_confreg(router):
|
|||||||
|
|
||||||
def test_console(router):
|
def test_console(router):
|
||||||
|
|
||||||
assert router.console == router.hypervisor.baseconsole + router.id
|
assert router.console == 2001
|
||||||
new_console_port = router.console + 100
|
new_console_port = router.console + 100
|
||||||
router.console = new_console_port
|
router.console = new_console_port
|
||||||
assert router.console == new_console_port
|
assert router.console == new_console_port
|
||||||
@ -180,7 +180,7 @@ def test_console(router):
|
|||||||
|
|
||||||
def test_aux(router):
|
def test_aux(router):
|
||||||
|
|
||||||
assert router.aux == router.hypervisor.baseaux + router.id
|
assert router.aux == 2501
|
||||||
new_aux_port = router.aux + 100
|
new_aux_port = router.aux + 100
|
||||||
router.aux = new_aux_port
|
router.aux = new_aux_port
|
||||||
assert router.aux == new_aux_port
|
assert router.aux == new_aux_port
|
||||||
|
@ -3,17 +3,28 @@ import os
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def no_iou():
|
||||||
|
cwd = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
iou_path = os.path.join(cwd, "i86bi_linux-ipbase-ms-12.4.bin")
|
||||||
|
|
||||||
|
if os.path.isfile(iou_path):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def iou(request):
|
def iou(request):
|
||||||
|
|
||||||
cwd = os.path.dirname(os.path.abspath(__file__))
|
cwd = os.path.dirname(os.path.abspath(__file__))
|
||||||
iou_path = os.path.join(cwd, "i86bi_linux-ipbase-ms-12.4.bin")
|
iou_path = os.path.join(cwd, "i86bi_linux-ipbase-ms-12.4.bin")
|
||||||
iou_device = IOUDevice(iou_path, "/tmp")
|
iou_device = IOUDevice("IOU1", iou_path, "/tmp")
|
||||||
iou_device.start()
|
iou_device.start()
|
||||||
request.addfinalizer(iou_device.delete)
|
request.addfinalizer(iou_device.delete)
|
||||||
return iou_device
|
return iou_device
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(no_iou(), reason="IOU Image not available")
|
||||||
def test_iou_is_started(iou):
|
def test_iou_is_started(iou):
|
||||||
|
|
||||||
print(iou.command())
|
print(iou.command())
|
||||||
@ -21,6 +32,7 @@ def test_iou_is_started(iou):
|
|||||||
assert iou.is_running()
|
assert iou.is_running()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(no_iou(), reason="IOU Image not available")
|
||||||
def test_iou_restart(iou):
|
def test_iou_restart(iou):
|
||||||
|
|
||||||
iou.stop()
|
iou.stop()
|
||||||
|
@ -6,9 +6,13 @@ import pytest
|
|||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def vpcs(request):
|
def vpcs(request):
|
||||||
|
|
||||||
cwd = os.path.dirname(os.path.abspath(__file__))
|
if os.path.isfile("/usr/bin/vpcs"):
|
||||||
vpcs_path = os.path.join(cwd, "vpcs")
|
vpcs_path = "/usr/bin/vpcs"
|
||||||
vpcs_device = VPCSDevice(vpcs_path, "/tmp")
|
else:
|
||||||
|
cwd = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
vpcs_path = os.path.join(cwd, "vpcs")
|
||||||
|
vpcs_device = VPCSDevice("VPCS1", vpcs_path, "/tmp")
|
||||||
|
vpcs_device.port_add_nio_binding(0, 'nio_tap:tap0')
|
||||||
vpcs_device.start()
|
vpcs_device.start()
|
||||||
request.addfinalizer(vpcs_device.delete)
|
request.addfinalizer(vpcs_device.delete)
|
||||||
return vpcs_device
|
return vpcs_device
|
||||||
|
Loading…
Reference in New Issue
Block a user