diff --git a/ryu/tests/integrated/bgp/base.py b/ryu/tests/integrated/bgp/base.py index 8d4bb6fe..39186bb6 100644 --- a/ryu/tests/integrated/bgp/base.py +++ b/ryu/tests/integrated/bgp/base.py @@ -16,6 +16,7 @@ from __future__ import absolute_import +import logging import unittest from ryu.tests.integrated.common import docker_base as ctn_base @@ -23,16 +24,17 @@ from ryu.tests.integrated.common import ryubgp from ryu.tests.integrated.common import quagga -class BgpSpeakerTestBase(unittest.TestCase): +LOG = logging.getLogger(__name__) + +class BgpSpeakerTestBase(unittest.TestCase): + images = [] + containers = [] + bridges = [] checktime = 120 @classmethod def setUpClass(cls): - cls.images = [] - cls.containers = [] - cls.bridges = [] - cls.brdc1 = ctn_base.Bridge(name='brdc1', subnet='192.168.10.0/24') cls.bridges.append(cls.brdc1) @@ -72,7 +74,7 @@ class BgpSpeakerTestBase(unittest.TestCase): try: ctn.stop() except ctn_base.CommandError as e: - pass + LOG.exception('Exception when stopping containers: %s', e) ctn.remove() for br in cls.bridges: br.delete() diff --git a/ryu/tests/integrated/bgp/base_ip6.py b/ryu/tests/integrated/bgp/base_ip6.py index c68a2738..ebe4e5b6 100644 --- a/ryu/tests/integrated/bgp/base_ip6.py +++ b/ryu/tests/integrated/bgp/base_ip6.py @@ -16,6 +16,7 @@ from __future__ import absolute_import +import logging import unittest from ryu.tests.integrated.common import docker_base as ctn_base @@ -23,16 +24,17 @@ from ryu.tests.integrated.common import ryubgp from ryu.tests.integrated.common import quagga -class BgpSpeakerTestBase(unittest.TestCase): +LOG = logging.getLogger(__name__) + +class BgpSpeakerTestBase(unittest.TestCase): + images = [] + containers = [] + bridges = [] checktime = 120 @classmethod def setUpClass(cls): - cls.images = [] - cls.containers = [] - cls.bridges = [] - cls.brdc1 = ctn_base.Bridge(name='brip6dc1', subnet='2001:10::/32') cls.bridges.append(cls.brdc1) @@ -72,7 +74,7 @@ class BgpSpeakerTestBase(unittest.TestCase): try: ctn.stop() except ctn_base.CommandError as e: - pass + LOG.exception('Exception when stopping containers: %s', e) ctn.remove() for br in cls.bridges: br.delete() diff --git a/ryu/tests/integrated/bgp/test_basic.py b/ryu/tests/integrated/bgp/test_basic.py index 63211911..7c6c8cf5 100644 --- a/ryu/tests/integrated/bgp/test_basic.py +++ b/ryu/tests/integrated/bgp/test_basic.py @@ -18,8 +18,8 @@ from __future__ import absolute_import import time -from . import base from ryu.tests.integrated.common import docker_base as ctn_base +from . import base class BgpSpeakerBasicTest(base.BgpSpeakerTestBase): @@ -29,7 +29,8 @@ class BgpSpeakerBasicTest(base.BgpSpeakerTestBase): self.r1.start_ryubgp(retry=True) def test_check_neighbor_established(self): - for i in range(0, self.checktime): + neighbor_state = ctn_base.BGP_FSM_IDLE + for _ in range(0, self.checktime): neighbor_state = self.q1.get_neighbor_state(self.r1) if neighbor_state == ctn_base.BGP_FSM_ESTABLISHED: break @@ -37,7 +38,8 @@ class BgpSpeakerBasicTest(base.BgpSpeakerTestBase): self.assertEqual(neighbor_state, ctn_base.BGP_FSM_ESTABLISHED) def test_check_rib_nexthop(self): - for i in range(0, self.checktime): + neighbor_state = ctn_base.BGP_FSM_IDLE + for _ in range(0, self.checktime): neighbor_state = self.q1.get_neighbor_state(self.r1) if neighbor_state == ctn_base.BGP_FSM_ESTABLISHED: break diff --git a/ryu/tests/integrated/bgp/test_ip6_basic.py b/ryu/tests/integrated/bgp/test_ip6_basic.py index 9b27e3cf..288e9e68 100644 --- a/ryu/tests/integrated/bgp/test_ip6_basic.py +++ b/ryu/tests/integrated/bgp/test_ip6_basic.py @@ -18,8 +18,8 @@ from __future__ import absolute_import import time -from . import base_ip6 as base from ryu.tests.integrated.common import docker_base as ctn_base +from . import base_ip6 as base class BgpSpeakerBasicTest(base.BgpSpeakerTestBase): @@ -29,7 +29,8 @@ class BgpSpeakerBasicTest(base.BgpSpeakerTestBase): self.r1.start_ryubgp(retry=True) def test_check_neighbor_established(self): - for i in range(0, self.checktime): + neighbor_state = ctn_base.BGP_FSM_IDLE + for _ in range(0, self.checktime): neighbor_state = self.q1.get_neighbor_state(self.r1) if neighbor_state == ctn_base.BGP_FSM_ESTABLISHED: break @@ -37,7 +38,8 @@ class BgpSpeakerBasicTest(base.BgpSpeakerTestBase): self.assertEqual(neighbor_state, ctn_base.BGP_FSM_ESTABLISHED) def test_check_rib_nexthop(self): - for i in range(0, self.checktime): + neighbor_state = ctn_base.BGP_FSM_IDLE + for _ in range(0, self.checktime): neighbor_state = self.q1.get_neighbor_state(self.r1) if neighbor_state == ctn_base.BGP_FSM_ESTABLISHED: break