From 59d0a3b2f3fb20ef420b9c881abf3d99b6ca7614 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Wed, 2 Mar 2016 23:39:50 +0900 Subject: [PATCH 01/13] update requirements --- requirements/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 7513fdc4..9a86b04f 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,2 +1,4 @@ +ipaddress DataProperty +six<=1.8.0 thutils From 010f7c1dc96e7736bc2bc8c93e8c64f405039e4c Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Wed, 2 Mar 2016 23:40:07 +0900 Subject: [PATCH 02/13] update README --- README.rst | 48 ++++++++++++++++++++++++++++++++++-------------- misc/summary.txt | 2 +- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/README.rst b/README.rst index be45f717..c95d5007 100644 --- a/README.rst +++ b/README.rst @@ -12,7 +12,7 @@ Summary ======= Simple tc command wrapper. -Easy to set up traffic control of +Easy to setup traffic control of network bandwidth/latency/packet-loss to a network interface. Traffic control @@ -24,6 +24,8 @@ The following parameters can be set of network interfaces. - Network latency [milliseconds] - Packet loss rate [%] +Traffic control can specify the IP network and port to apply to. + Installation ============ @@ -54,24 +56,26 @@ tcset help usage: tcset [-h] [--version] [--logging] [--stacktrace] [--debug | --quiet] --device DEVICE [--rate RATE] [--delay DELAY] [--loss LOSS] - [--overwrite] + [--network NETWORK] [--port PORT] [--overwrite] optional arguments: - -h, --help show this help message and exit - --version show program's version number and exit - --debug for debug print. - --quiet suppress output of execution log message. + -h, --help show this help message and exit + --version show program's version number and exit + --debug for debug print. + --quiet suppress output of execution log message. Miscellaneous: - --logging output execution log to a file (tcset.log). - --stacktrace display stack trace when an error occurred. + --logging output execution log to a file (tcset.log). + --stacktrace display stack trace when an error occurred. Traffic Control: - --device DEVICE network device name - --rate RATE network bandwidth [K|M|G bps] - --delay DELAY round trip network delay [ms] (default=0) - --loss LOSS round trip packet loss rate [%] (default=0) - --overwrite overwrite existing setting + --device DEVICE network device name + --rate RATE network bandwidth to apply the limit [K|M|G bps] + --delay DELAY round trip network delay [ms] (default=0) + --loss LOSS round trip packet loss rate [%] (default=0) + --network NETWORK destination network of traffic control + --port PORT destination port of traffic control + --overwrite overwrite existing setting e.g. Set a limit on bandwidth up to 100Kbps ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -101,6 +105,20 @@ e.g. All of the above at onece # tcset --device eth0 --rate 100k --delay 100 --loss 0.1 +e.g. Specify the IP address of traffic control +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code:: console + + # tcset --device eth0 --delay 100 --network 192.168.0.10 + +e.g. Specify the IP network and port of traffic control +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code:: console + + # tcset --device eth0 --delay 100 --network 192.168.0.0/24 --port 80 + Delete traffic control (tcdel) ------------------------------ @@ -122,7 +140,7 @@ tcdel help --quiet suppress output of execution log message. Miscellaneous: - --logging output execution log to a file (tcset.log). + --logging output execution log to a file (tcdel.log). --stacktrace display stack trace when an error occurred. Traffic Control: @@ -147,7 +165,9 @@ Python packagge --------------- - `DataPropery `__ +- `ipaddress `__ - `thutils `__ +- `six `__ Python packagge: test dependencies ---------------------------------- diff --git a/misc/summary.txt b/misc/summary.txt index fde4edbc..77954093 100644 --- a/misc/summary.txt +++ b/misc/summary.txt @@ -1,3 +1,3 @@ Simple tc command wrapper. -Easy to set up traffic control of +Easy to setup traffic control of network bandwidth/latency/packet-loss to a network interface. From 73ed4fb01c253ab7fcd4356db50df292b509da24 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Wed, 2 Mar 2016 23:44:05 +0900 Subject: [PATCH 03/13] Add network/port options --- tcconfig/__init__.py | 250 ++++++++++++++++++++++++++++++------------- tcconfig/tcdel.py | 4 +- tcconfig/tcset.py | 25 ++++- 3 files changed, 198 insertions(+), 81 deletions(-) diff --git a/tcconfig/__init__.py b/tcconfig/__init__.py index 3935a32d..1516714e 100644 --- a/tcconfig/__init__.py +++ b/tcconfig/__init__.py @@ -1,87 +1,187 @@ +import ipaddress import dataproperty import thutils +import six VERSION = "0.1.4" -_MIN_LOSS_RATE = 0 -_MAX_LOSS_RATE = 99 -_MIN_DELAY_MS = 0 -_MAX_DELAY_MS = 10000 +class TrafficControl(object): + __MIN_LOSS_RATE = 0 # [%] + __MAX_LOSS_RATE = 99 # [%] -_MIN_BUFFER_BYTE = 1600 + __MIN_DELAY_MS = 0 # [millisecond] + __MAX_DELAY_MS = 10000 # [millisecond] + __MIN_BUFFER_BYTE = 1600 -def _validate_network_delay(delay_ms): - if delay_ms > _MAX_DELAY_MS: - raise ValueError( - "network delay is too high: expected<=%d[ms], value=%d[ms]" % ( - _MAX_DELAY_MS, delay_ms)) + __MIN_PORT = 0 + __MAX_PORT = 65535 - if delay_ms < _MIN_DELAY_MS: - raise ValueError( - "delay time is too low: expected>=%d[ms], value=%d[ms]" % ( - _MIN_DELAY_MS, delay_ms)) + def __init__(self, subproc_wrapper, device): + self.__subproc_wrapper = subproc_wrapper + self.__device = device - -def _validate_packet_loss_rate(loss_percent): - if loss_percent > _MAX_LOSS_RATE: - raise ValueError( - "packet loss rate is too high: expected<=%d[%%], value=%d[%%]" % ( - _MAX_LOSS_RATE, loss_percent)) - - if loss_percent < _MIN_LOSS_RATE: - raise ValueError( - "packet loss rate is too low: expected>=%d[%%], value=%d[%%]" % ( - _MIN_LOSS_RATE, loss_percent)) - - -def _set_delay_and_loss(subproc_wrapper, device, delay_ms, loss_percent): - _validate_network_delay(delay_ms) - _validate_packet_loss_rate(loss_percent) - - command_list = [ - "tc qdisc add", - "dev %s" % (device), - "root handle 1:0 netem", - ] - if loss_percent > 0: - command_list.append("loss %s%%" % (loss_percent)) - if delay_ms > 0: - command_list.append("delay %dms" % (delay_ms)) - - return subproc_wrapper.run(" ".join(command_list)) - - -def _set_rate(subproc_wrapper, device, rate): - if dataproperty.is_empty_string(rate): - return 0 - - rate_kbps = thutils.common.humanreadable_to_byte( - rate, kilo_size=1000) / 1000.0 - if rate_kbps <= 0: - raise ValueError("rate must be greater than zero") - - command_list = [ - "tc qdisc add", - "dev %s" % (device), - "parent 1:1", - "handle 10:", - "tbf", - "rate %dkbit" % (rate_kbps), - "buffer %d" % (max(rate_kbps, _MIN_BUFFER_BYTE)), # [byte] - "limit 10000", - ] - - return subproc_wrapper.run(" ".join(command_list)) - - -def set_tc(subproc_wrapper, device, rate, delay_ms, loss_percent): - _set_delay_and_loss(subproc_wrapper, device, delay_ms, loss_percent) - _set_rate(subproc_wrapper, device, rate) - - -def delete_tc(subproc_wrapper, device): - command = "tc qdisc del dev %s root" % (device) - return subproc_wrapper.run(command) + self.rate = None + self.delay_ms = None + self.loss_percent = None + self.network = None + self.port = None + + def validate(self): + if dataproperty.is_empty_string(self.__device): + raise ValueError("device name is empty") + + self.__validate_network_delay() + self.__validate_packet_loss_rate() + self.network = self.__validate_network() + self.__validate_port() + + def set_tc(self): + self.__make_qdisc() + self.__set_pre_network_filter() + self.__set_delay_and_loss() + self.__set_network_filter() + self.__set_rate() + + def delete_tc(self): + command = "tc qdisc del dev %s root" % (self.__device) + + return self.__subproc_wrapper.run(command) + + def __validate_network_delay(self): + if self.delay_ms is None: + return + + if self.delay_ms > self.__MAX_DELAY_MS: + raise ValueError( + "network delay is too high: expected<=%d[ms], value=%d[ms]" % ( + self.__MAX_DELAY_MS, self.delay_ms)) + + if self.delay_ms < self.__MIN_DELAY_MS: + raise ValueError( + "delay time is too low: expected>=%d[ms], value=%d[ms]" % ( + self.__MIN_DELAY_MS, self.delay_ms)) + + def __validate_packet_loss_rate(self): + if self.loss_percent is None: + return + + if self.loss_percent > self.__MAX_LOSS_RATE: + raise ValueError( + "packet loss rate is too high: expected<=%d[%%], value=%d[%%]" % ( + self.__MAX_LOSS_RATE, self.loss_percent)) + + if self.loss_percent < self.__MIN_LOSS_RATE: + raise ValueError( + "packet loss rate is too low: expected>=%d[%%], value=%d[%%]" % ( + self.__MIN_LOSS_RATE, self.loss_percent)) + + def __validate_network(self): + if dataproperty.is_empty_string(self.network): + return "" + + try: + ipaddress.IPv4Address(six.u(self.network)) + return self.network + "/32" + except ipaddress.AddressValueError: + pass + + ipaddress.IPv4Network(six.u(self.network)) + return self.network + + raise ValueError("unrecognizable network: " + self.network) + + def __validate_port(self): + if self.port is None: + return + + if self.port > self.__MAX_PORT: + raise ValueError( + "port number is too high: expected<=%d[%%], value=%d[%%]" % ( + self.__MAX_PORT, self.port)) + + if self.port < self.__MIN_PORT: + raise ValueError( + "port number is too low: expected>=%d[%%], value=%d[%%]" % ( + self.__MIN_PORT, self.port)) + + def __make_qdisc(self): + command_list = [ + "tc qdisc add", + "dev " + self.__device, + "root handle 1: prio", + ] + + return self.__subproc_wrapper.run(" ".join(command_list)) + + def __set_pre_network_filter(self): + if dataproperty.is_empty_string(self.network): + flowid = "1:1" + else: + flowid = "1:2" + + command_list = [ + "tc filter add", + "dev " + self.__device, + "protocol ip parent 1: prio 2 u32 match ip dst 0.0.0.0/0", + "flowid " + flowid + ] + + return self.__subproc_wrapper.run(" ".join(command_list)) + + def __set_delay_and_loss(self): + command_list = [ + "tc qdisc add", + "dev " + self.__device, + "parent 1:1 handle 10: netem", + ] + if self.loss_percent > 0: + command_list.append("loss %s%%" % (self.loss_percent)) + if self.delay_ms > 0: + command_list.append("delay %dms" % (self.delay_ms)) + + return self.__subproc_wrapper.run(" ".join(command_list)) + + def __set_network_filter(self): + if all([ + dataproperty.is_empty_string(self.network), + self.port is None, + ]): + return 0 + + command_list = [ + "tc filter add", + "dev " + self.__device, + "protocol ip parent 1: prio 1 u32", + "flowid 1:1", + ] + if dataproperty.is_not_empty_string(self.network): + command_list.append("match ip dst " + self.network) + if self.port is not None: + command_list.append("match ip dport %d" % (self.port)) + + return self.__subproc_wrapper.run(" ".join(command_list)) + + def __set_rate(self): + if dataproperty.is_empty_string(self.rate): + return 0 + + rate_kbps = thutils.common.humanreadable_to_byte( + self.rate, kilo_size=1000) / 1000.0 + if rate_kbps <= 0: + raise ValueError("rate must be greater than zero") + + command_list = [ + "tc qdisc add", + "dev " + self.__device, + "parent 10:1", + "handle 20:", + "tbf", + "rate %dkbit" % (rate_kbps), + "buffer %d" % (max(rate_kbps, self.__MIN_BUFFER_BYTE)), # [byte] + "limit 10000", + ] + + return self.__subproc_wrapper.run(" ".join(command_list)) diff --git a/tcconfig/tcdel.py b/tcconfig/tcdel.py index 6abb155d..59156ca3 100644 --- a/tcconfig/tcdel.py +++ b/tcconfig/tcdel.py @@ -33,9 +33,9 @@ def main(): thutils.common.verify_install_command(["tc"]) subproc_wrapper = thutils.subprocwrapper.SubprocessWrapper() - tcconfig.delete_tc(subproc_wrapper, options.device) + tc = tcconfig.TrafficControl(subproc_wrapper, options.device) - return 0 + return tc.delete_tc() if __name__ == '__main__': diff --git a/tcconfig/tcset.py b/tcconfig/tcset.py index e0977497..66e9cdcd 100644 --- a/tcconfig/tcset.py +++ b/tcconfig/tcset.py @@ -22,13 +22,19 @@ def parse_option(): help="network device name") group.add_argument( "--rate", - help="network bandwidth [K|M|G bps]") + help="network bandwidth to apply the limit [K|M|G bps]") group.add_argument( "--delay", type=float, default=0, help="round trip network delay [ms] (default=%(default)s)") group.add_argument( "--loss", type=float, default=0, help="round trip packet loss rate [%%] (default=%(default)s)") + group.add_argument( + "--network", + help="destination network of traffic control") + group.add_argument( + "--port", type=int, + help="destination port of traffic control") group.add_argument( "--overwrite", action="store_true", default=False, help="overwrite existing setting") @@ -44,12 +50,23 @@ def main(): thutils.common.verify_install_command(["tc"]) subproc_wrapper = thutils.subprocwrapper.SubprocessWrapper() + tc = tcconfig.TrafficControl(subproc_wrapper, options.device) + tc.rate = options.rate + tc.delay_ms = options.delay + tc.loss_percent = options.loss + tc.network = options.network + tc.port = options.port + + import logging + subproc_wrapper.command_log_level = logging.DEBUG + + tc.validate() if options.overwrite: - tcconfig.delete_tc(subproc_wrapper, options.device) + tc.delete_tc() - tcconfig.set_tc(subproc_wrapper, options.device, - options.rate, options.delay, options.loss) + tc.set_tc() + #tc.set_tc(options.rate, options.delay, options.loss, options.network) return 0 From 99088fb7ab9058433b2f9a311a762e2b38c4ef2a Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Wed, 2 Mar 2016 23:44:21 +0900 Subject: [PATCH 04/13] Add tests --- test/test_tcconfig.py | 108 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/test/test_tcconfig.py b/test/test_tcconfig.py index 67eec17f..c298471a 100644 --- a/test/test_tcconfig.py +++ b/test/test_tcconfig.py @@ -7,6 +7,7 @@ import itertools import pytest import thutils +import tcconfig @pytest.fixture @@ -36,12 +37,22 @@ class NormalTestValue: "--loss 0.1", "--loss 99", ] + NETWORK_LIST = [ + "", + "--network 192.168.0.10", + "--network 192.168.0.10/24", + ] + PORT_LIST = [ + "", + "--port 80", + ] OVERWRITE_LIST = [ "", "--overwrite", ] +#""" class Test_tcconfig: @pytest.mark.parametrize(["rate", "delay", "loss", "overwrite"], [ @@ -59,3 +70,100 @@ def test_smoke(self, subproc_wrapper, rate, delay, loss, overwrite): command = "tcdel --device %s" % (DEVICE) assert subproc_wrapper.run(command) == 0 +#""" + + +@pytest.fixture +def tc_obj(): + subproc_wrapper = thutils.subprocwrapper.SubprocessWrapper() + return tcconfig.TrafficControl(subproc_wrapper, "eth0") + + +@pytest.mark.parametrize(["value"], [ + [None], + [0], + [10000], +]) +def test_TrafficControl_validate_network_delay_normal(tc_obj, value): + tc_obj.delay_ms = value + tc_obj._TrafficControl__validate_network_delay() + + +@pytest.mark.parametrize(["value", "expected"], [ + [-1, ValueError], + [10001, ValueError], +]) +def test_TrafficControl_validate_network_delay_exception(tc_obj, value, expected): + tc_obj.delay_ms = value + with pytest.raises(expected): + tc_obj._TrafficControl__validate_network_delay() + + +@pytest.mark.parametrize(["value"], [ + [None], + [0], + [99], +]) +def test_TrafficControl_validate_packet_loss_rate_normal(tc_obj, value): + tc_obj.loss_percent = value + tc_obj._TrafficControl__validate_packet_loss_rate() + + +@pytest.mark.parametrize(["value", "expected"], [ + [-0.1, ValueError], + [99.1, ValueError], +]) +def test_TrafficControl_validate_packet_loss_rate_exception(tc_obj, value, expected): + tc_obj.loss_percent = value + with pytest.raises(expected): + tc_obj._TrafficControl__validate_packet_loss_rate() + + +@pytest.mark.parametrize(["value"], [ + [None], + [""], + + ["192.168.0.1"], + ["192.168.0.254"], + + ["192.168.0.1/32"], + ["192.168.0.0/24"], +]) +def test_TrafficControl_validate_network_normal(tc_obj, value): + tc_obj.network = value + tc_obj._TrafficControl__validate_network() + + +@pytest.mark.parametrize(["value", "expected"], [ + ["192.168.0.", ValueError], + ["192.168.0.256", ValueError], + + ["192.168.0.0/0", ValueError], + ["192.168.0.0/33", ValueError], + ["192.168.0.2/24", ValueError], + ["192.168.0.0000/24", ValueError], +]) +def test_TrafficControl_validate_network_exception(tc_obj, value, expected): + tc_obj.network = value + with pytest.raises(expected): + tc_obj._TrafficControl__validate_network() + + +@pytest.mark.parametrize(["value"], [ + [None], + [0], + [65535], +]) +def test_TrafficControl_validate_port_normal(tc_obj, value): + tc_obj.port = value + tc_obj._TrafficControl__validate_port() + + +@pytest.mark.parametrize(["value", "expected"], [ + [-1, ValueError], + [65536, ValueError], +]) +def test_TrafficControl_validate_port_exception(tc_obj, value, expected): + tc_obj.port = value + with pytest.raises(expected): + tc_obj._TrafficControl__validate_port() From 1f6af02d0edcae7a728584b86272b2fda0533d47 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Thu, 3 Mar 2016 00:40:41 +0900 Subject: [PATCH 05/13] initial commit --- requirements/test_requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements/test_requirements.txt diff --git a/requirements/test_requirements.txt b/requirements/test_requirements.txt new file mode 100644 index 00000000..e079f8a6 --- /dev/null +++ b/requirements/test_requirements.txt @@ -0,0 +1 @@ +pytest From 84a09c400a6c84c382378a1dfe5a706eeb91c5ad Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Thu, 3 Mar 2016 00:41:47 +0900 Subject: [PATCH 06/13] Remove unnecessary comments --- test/test_tcconfig.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_tcconfig.py b/test/test_tcconfig.py index c298471a..97aa1f22 100644 --- a/test/test_tcconfig.py +++ b/test/test_tcconfig.py @@ -5,6 +5,7 @@ ''' import itertools + import pytest import thutils import tcconfig @@ -52,7 +53,6 @@ class NormalTestValue: ] -#""" class Test_tcconfig: @pytest.mark.parametrize(["rate", "delay", "loss", "overwrite"], [ @@ -70,7 +70,6 @@ def test_smoke(self, subproc_wrapper, rate, delay, loss, overwrite): command = "tcdel --device %s" % (DEVICE) assert subproc_wrapper.run(command) == 0 -#""" @pytest.fixture From 892f54f29709b0ff75d5ac29409f63d1caa936a5 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Thu, 3 Mar 2016 00:42:42 +0900 Subject: [PATCH 07/13] update setup.py --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0455c0ae..9837b861 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,9 @@ with open(os.path.join(REQUIREMENT_DIR, "requirements.txt")) as f: install_requires = [line.strip() for line in f if line.strip()] +with open(os.path.join(REQUIREMENT_DIR, "test_requirements.txt")) as f: + tests_require = [line.strip() for line in f if line.strip()] + major, minor = sys.version_info[:2] if major == 2 and minor <= 5: install_requires.extend([ @@ -38,7 +41,7 @@ packages=setuptools.find_packages(exclude=['test*']), install_requires=install_requires, setup_requires=["pytest-runner"], - tests_require=["pytest"], + tests_require=tests_require, classifiers=[ "Development Status :: 4 - Beta", "Environment :: Console", From 853672912ea239c9a48749dc171a957826006b97 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Thu, 3 Mar 2016 00:43:27 +0900 Subject: [PATCH 08/13] Modify VERSION --- tcconfig/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tcconfig/__init__.py b/tcconfig/__init__.py index 1516714e..46ed8103 100644 --- a/tcconfig/__init__.py +++ b/tcconfig/__init__.py @@ -1,10 +1,16 @@ -import ipaddress +# encoding: utf-8 + +''' +@author: Tsuyoshi Hombashi +''' + import dataproperty -import thutils +import ipaddress import six +import thutils -VERSION = "0.1.4" +VERSION = "0.2.0" class TrafficControl(object): From 0d834a1f8dc3650d61356e1f5d86a27a5bb5c366 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Thu, 3 Mar 2016 00:43:46 +0900 Subject: [PATCH 09/13] Update tox.ini --- tox.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tox.ini b/tox.ini index 154ab29b..f7f6a9ee 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,8 @@ envlist = py{25,26,27,33,34} [testenv] deps = pytest + ipaddress + six thutils commands = python setup.py test From e74dae9c5d611b262ea1bca632b2c456d88acdb9 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Thu, 3 Mar 2016 01:26:21 +0900 Subject: [PATCH 10/13] Remove VERSION variable --- setup.py | 4 +--- tcconfig/__init__.py | 3 --- tcconfig/tcdel.py | 2 +- tcconfig/tcset.py | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 9837b861..35226f4f 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,6 @@ import setuptools import sys -import tcconfig - MISC_DIR = "misc" REQUIREMENT_DIR = "requirements" @@ -29,7 +27,7 @@ setuptools.setup( name="tcconfig", - version=tcconfig.VERSION, + version="0.2.0", author="Tsuyoshi Hombashi", author_email="gogogo.vm@gmail.com", url="https://github.com/thombashi/tcconfig", diff --git a/tcconfig/__init__.py b/tcconfig/__init__.py index 46ed8103..87e1c97c 100644 --- a/tcconfig/__init__.py +++ b/tcconfig/__init__.py @@ -10,9 +10,6 @@ import thutils -VERSION = "0.2.0" - - class TrafficControl(object): __MIN_LOSS_RATE = 0 # [%] __MAX_LOSS_RATE = 99 # [%] diff --git a/tcconfig/tcdel.py b/tcconfig/tcdel.py index 59156ca3..24b68329 100644 --- a/tcconfig/tcdel.py +++ b/tcconfig/tcdel.py @@ -14,7 +14,7 @@ def parse_option(): parser = thutils.option.ArgumentParserObject() - parser.make(version=tcconfig.VERSION) + parser.make(version="0.2.0") group = parser.add_argument_group("Traffic Control") group.add_argument( diff --git a/tcconfig/tcset.py b/tcconfig/tcset.py index 66e9cdcd..504b0346 100644 --- a/tcconfig/tcset.py +++ b/tcconfig/tcset.py @@ -14,7 +14,7 @@ def parse_option(): parser = thutils.option.ArgumentParserObject() - parser.make(version=tcconfig.VERSION) + parser.make(version="0.2.0") group = parser.add_argument_group("Traffic Control") group.add_argument( From ac5a49947b5e1e2f8fb0f5b31c23561cbbcf47a6 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Thu, 3 Mar 2016 01:37:26 +0900 Subject: [PATCH 11/13] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2f89aacf..c75e3021 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: python +sudo: required env: - TOXENV=py25 From a5e32620a7e5c0213ac1d263236993d743c00e0a Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Thu, 3 Mar 2016 21:56:09 +0900 Subject: [PATCH 12/13] update README --- README.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index c95d5007..80145d78 100644 --- a/README.rst +++ b/README.rst @@ -164,13 +164,16 @@ Linux package Python packagge --------------- +Dependency python packages are automatically installed during AAA +installation via pip. + - `DataPropery `__ - `ipaddress `__ -- `thutils `__ - `six `__ +- `thutils `__ -Python packagge: test dependencies ----------------------------------- +Test dependencies +~~~~~~~~~~~~~~~~~ - `pytest `__ - `pytest-runner `__ From fa7d3e008f4bfbfa3d7c3b931f3d4977e9be6812 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Thu, 3 Mar 2016 21:57:57 +0900 Subject: [PATCH 13/13] add @pytest.mark.xfail to inappropriate test for Travis CI --- .travis.yml | 1 - test/test_tcconfig.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c75e3021..2f89aacf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: python -sudo: required env: - TOXENV=py25 diff --git a/test/test_tcconfig.py b/test/test_tcconfig.py index 97aa1f22..98ca7b9d 100644 --- a/test/test_tcconfig.py +++ b/test/test_tcconfig.py @@ -55,6 +55,9 @@ class NormalTestValue: class Test_tcconfig: + # inappropriate test for Travis CI + # ruun locally: python setup.py test --addopts --runxfail + @pytest.mark.xfail @pytest.mark.parametrize(["rate", "delay", "loss", "overwrite"], [ opt_list for opt_list in itertools.product(