Upload tox and fix pep8
Change-Id: I897b7dc1da11221f8a19459982aeae3edc41f643
This commit is contained in:
parent
66b440e214
commit
a4c4d2e094
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import sys
|
||||
from SocketServer import ThreadingMixIn
|
||||
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer
|
||||
from stetho.agent import api as agent_api
|
||||
|
@ -15,10 +15,8 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import tempfile
|
||||
import signal
|
||||
import shlex
|
||||
import subprocess
|
||||
import platform
|
||||
from threading import Timer
|
||||
@ -137,7 +135,7 @@ def get_interface(interface):
|
||||
return format_centos_6_5(inf)
|
||||
elif not cmp(linux_dist, '7.0'):
|
||||
return format_centos_7_0(inf)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
message = stdout.pop(0)
|
||||
return stdcode, message, None
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
from stetho.agent.common import log
|
||||
from stetho.agent.common import utils
|
||||
|
||||
@ -46,7 +45,7 @@ class IPerfDriver(object):
|
||||
parallel=None, bandwidth=None):
|
||||
"""iperf -D -c host -t 60
|
||||
"""
|
||||
cmd = ['iperf', '-c', host, '-p', str(port), '-t', str(timeout)]
|
||||
cmd = ['iperf', '-c', host, '-p', str(port), '-t', str(timeout)]
|
||||
if not (protocol, 'UDP'):
|
||||
cmd.append('-u')
|
||||
if parallel:
|
||||
|
@ -20,7 +20,6 @@ import sys
|
||||
|
||||
from cliff.command import Command
|
||||
from cliff.lister import Lister
|
||||
from json import JSONDecoder
|
||||
|
||||
LISTEN_PORT = 9698
|
||||
SETUP_LINK_IP_PRE = "192.168.100."
|
||||
@ -63,13 +62,11 @@ def setup_server(agent):
|
||||
log.debug('get agent:%s ip_address:%s' % (
|
||||
agent, AGENT_INFOS[agent]))
|
||||
else:
|
||||
log.error('Agent %s not configured. Please check it.' % (
|
||||
agent))
|
||||
log.error('Agent %s not configured. Please check it.' % (agent))
|
||||
sys.exit()
|
||||
log.debug('Begin create connection with http://%s:9698.' % (
|
||||
agent))
|
||||
server = jsonrpclib.Server('http://%s:%s' % (
|
||||
AGENT_INFOS[agent], LISTEN_PORT))
|
||||
log.debug('Begin create connection with http://%s:9698.' % (agent))
|
||||
server = jsonrpclib.Server('http://%s:%s' %
|
||||
(AGENT_INFOS[agent], LISTEN_PORT))
|
||||
log.debug('Create connection with %s success.' % (agent))
|
||||
return server
|
||||
|
||||
@ -93,7 +90,7 @@ class TearDownLink(Command):
|
||||
try:
|
||||
res = server.teardown_link(parsed_args.interface)
|
||||
except Exception as e:
|
||||
self.log.error('Error %s has occured.' % res)
|
||||
self.log.error('Error %s has occured because: ' % (res, e))
|
||||
|
||||
|
||||
class SetUpLink(Lister):
|
||||
|
@ -31,5 +31,5 @@ cfg.CONF([], project='stetho',
|
||||
AGENT_INFOS = {}
|
||||
all_agents = cfg.CONF.network_agents_info + cfg.CONF.compute_agents_info
|
||||
for agent in all_agents:
|
||||
item = {'agent-'+agent: cfg.CONF.managed_network_prefix+agent}
|
||||
item = {'agent-' + agent: cfg.CONF.managed_network_prefix + agent}
|
||||
AGENT_INFOS.update(item)
|
||||
|
@ -60,13 +60,11 @@ def setup_server(agent):
|
||||
log.debug('get agent:%s ip_address:%s' % (
|
||||
agent, AGENT_INFOS[agent]))
|
||||
else:
|
||||
log.error('Agent %s not configured. Please check it.' % (
|
||||
agent))
|
||||
log.error('Agent %s not configured. Please check it.' % (agent))
|
||||
sys.exit()
|
||||
log.debug('Begin create connection with http://%s:9698.' % (
|
||||
agent))
|
||||
server = jsonrpclib.Server('http://%s:%s' % (
|
||||
AGENT_INFOS[agent], LISTEN_PORT))
|
||||
log.debug('Begin create connection with http://%s:9698.' % (agent))
|
||||
server = jsonrpclib.Server('http://%s:%s' %
|
||||
(AGENT_INFOS[agent], LISTEN_PORT))
|
||||
log.debug('Create connection with %s success.' % (agent))
|
||||
return server
|
||||
|
||||
|
@ -17,7 +17,6 @@ Command-line interface to Stetho APIs
|
||||
"""
|
||||
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from cliff import app
|
||||
from cliff import commandmanager
|
||||
|
@ -17,7 +17,6 @@ import mock
|
||||
import unittest
|
||||
from stetho.agent import api
|
||||
from stetho.agent.common import utils as agent_utils
|
||||
from stetho.agent.drivers import iperf as iperf_driver
|
||||
|
||||
|
||||
class TestApi(unittest.TestCase):
|
||||
|
@ -74,7 +74,7 @@ class TestStethoClientMethods(unittest.TestCase):
|
||||
self.assertEqual(self.server.check_ports_on_br.called, True)
|
||||
|
||||
def test_check_iperf(self):
|
||||
iperf_server_r = {u'message': u'', u'code': 0, u'data': {u'pid': 1234}}
|
||||
iperf_server_r = {'message': '', u'code': 0, 'data': {'pid': 1234}}
|
||||
iperf_client_r = {
|
||||
'message': '',
|
||||
'code': 0,
|
||||
@ -85,11 +85,11 @@ class TestStethoClientMethods(unittest.TestCase):
|
||||
'server_ip': 'localhost'
|
||||
}
|
||||
}
|
||||
teardown_iperf_r = {u'message': u'', u'code': 0, u'data': {}}
|
||||
teardown_iperf_r = {'message': '', 'code': 0, 'data': {}}
|
||||
self.server.setup_iperf_server = mock.Mock(return_value=iperf_server_r)
|
||||
self.server.start_iperf_client = mock.Mock(return_value=iperf_client_r)
|
||||
self.server.teardown_iperf_server = mock.Mock(
|
||||
return_value=teardown_iperf_r)
|
||||
return_value=teardown_iperf_r)
|
||||
shell.main(['check-iperf', 'agent-64', 'agent-64'])
|
||||
self.assertEqual(self.server.setup_iperf_server.called, True)
|
||||
self.assertEqual(self.server.start_iperf_client.called, True)
|
||||
|
@ -1 +1,3 @@
|
||||
mock
|
||||
flake8
|
||||
unittest
|
||||
|
27
tox.ini
Normal file
27
tox.ini
Normal file
@ -0,0 +1,27 @@
|
||||
[tox]
|
||||
envlist = py26,py27,pep8
|
||||
|
||||
[testenv]
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
NOSE_WITH_OPENSTACK=1
|
||||
NOSE_OPENSTACK_COLOR=1
|
||||
NOSE_OPENSTACK_RED=0.05
|
||||
NOSE_OPENSTACK_YELLOW=0.025
|
||||
NOSE_OPENSTACK_SHOW_ELAPSED=1
|
||||
NOSE_OPENSTACK_STDOUT=1
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands =
|
||||
/usr/bin/find . -type f -name "*.pyc" -delete
|
||||
python setup.py testr --slowest --testr-args='{posargs}'
|
||||
nosetests {posargs}
|
||||
whitelist_externals = *
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8
|
||||
distribute = false
|
||||
|
||||
[flake8]
|
||||
ignore = H703,H102,E265,E262,H233
|
||||
show-source = true
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools,build,setup.py,tests/ci/*,scripts/*
|
Loading…
Reference in New Issue
Block a user