scenario_test: Wait for GoBGP starting up

For the stability of some scenario tests, this patch fixes to wait for
GoBGP starting up after restarting GoBGP daemon. Currently, there are
cases that CLI command can be called without checking whether GoBGP
daemon is surely started or not.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
This commit is contained in:
IWASE Yusuke
2018-05-15 08:26:42 +09:00
parent 3fc524a5f5
commit 2c388e0757
3 changed files with 11 additions and 7 deletions
+7 -1
View File
@@ -15,6 +15,7 @@
from __future__ import absolute_import
import collections
import json
from itertools import chain
from threading import Thread
@@ -27,7 +28,6 @@ from fabric.utils import indent
import netaddr
import toml
import yaml
import collections
from lib.base import (
wait_for_completion,
@@ -113,6 +113,12 @@ class GoBGPContainer(BGPContainer):
local(cmd, capture=True)
self.local("{0}/start.sh".format(self.SHARED_VOLUME), detach=True)
def start_gobgp(self, graceful_restart=False):
if self._is_running():
raise RuntimeError('GoBGP is already running')
self._start_gobgp(graceful_restart=graceful_restart)
self._wait_for_boot()
def stop_gobgp(self):
self.local("pkill -INT gobgpd")
+3 -4
View File
@@ -78,8 +78,7 @@ class GoBGPTestBase(unittest.TestCase):
self.assertTrue(p['stale'])
g1.routes = {}
g1._start_gobgp(graceful_restart=True)
time.sleep(3)
g1.start_gobgp(graceful_restart=True)
g1.add_route('10.10.20.0/24')
def test_03_neighbor_established(self):
@@ -134,7 +133,7 @@ class GoBGPTestBase(unittest.TestCase):
g2 = self.bgpds['g2']
g3 = self.bgpds['g3']
g1._start_gobgp()
g1.start_gobgp()
g1.del_peer(g2)
g1.del_peer(g3)
@@ -157,7 +156,7 @@ class GoBGPTestBase(unittest.TestCase):
g2.wait_for(expected_state=BGP_FSM_ACTIVE, peer=g1)
g3.wait_for(expected_state=BGP_FSM_ACTIVE, peer=g1)
g1._start_gobgp(graceful_restart=True)
g1.start_gobgp(graceful_restart=True)
count = 0
while (g1.get_neighbor_state(g2) != BGP_FSM_ESTABLISHED
@@ -110,8 +110,7 @@ class GoBGPTestBase(unittest.TestCase):
# withdrawn
self.assertTrue(len(g4.get_global_rib('10.0.0.0/24')) == 0)
g2._start_gobgp(graceful_restart=True)
time.sleep(2)
g2.start_gobgp(graceful_restart=True)
g2.local('gobgp global rib add 10.0.0.0/24')
g2.local('gobgp global rib add 10.10.0.0/24')