diff options
author | Naoto Hanaue <hanaue.naoto@po.ntts.co.jp> | 2015-09-02 17:43:39 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-09-04 22:15:12 +0900 |
commit | 03789fa0cee9a11bf272d202c74bf03f2ad0ec51 (patch) | |
tree | f6c5a5cc80b7f5df60586ea36f338c3020e170ce /test/scenario_test/lib/base.py | |
parent | 52c96558a2fd993cd0ce380785740198ffa00c62 (diff) |
scenario_test: add zebra test
Diffstat (limited to 'test/scenario_test/lib/base.py')
-rw-r--r-- | test/scenario_test/lib/base.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/scenario_test/lib/base.py b/test/scenario_test/lib/base.py index 7f73516b..42cdc0e1 100644 --- a/test/scenario_test/lib/base.py +++ b/test/scenario_test/lib/base.py @@ -86,6 +86,8 @@ def make_gobgp_ctn(tag='gobgp', local_gobgp_path='', from_image='golang:1.4'): c << 'RUN go install github.com/osrg/gobgp/gobgpd' c << 'RUN go get github.com/osrg/gobgp/gobgp' c << 'RUN go install github.com/osrg/gobgp/gobgp' + c << 'RUN apt-get update' + c << 'RUN apt-get install -qy --no-install-recommends quagga telnet' rindex = local_gobgp_path.rindex('gobgp') if rindex < 0: @@ -133,6 +135,7 @@ class Bridge(object): name = ctn.next_if_name() self.ctns.append(ctn) if self.with_ip: + ctn.pipework(self, self.next_ip_address(), name) else: ctn.pipework(self, '0/0', name) @@ -312,6 +315,30 @@ class BGPContainer(Container): def get_neighbor_state(self, peer_id): raise Exception('implement get_neighbor() method') + def get_reachablily(self, prefix, timeout=20): + version = netaddr.IPNetwork(prefix).version + addr = prefix.split('/')[0] + if version == 4: + ping_cmd = 'ping' + elif version == 6: + ping_cmd = 'ping6' + else: + raise Exception('unsupported route family: {0}'.format(version)) + cmd = '/bin/{0} -c 1 -w 1 {1}'.format(ping_cmd, addr) + + interval = 1 + count = 0 + while True: + res = self.local(cmd, capture=True) + print colors.yellow(res) + if '0% packet loss' in res: + break + time.sleep(interval) + count += interval + if count >= timeout: + raise Exception('timeout') + return True + def wait_for(self, expected_state, peer, timeout=120): interval = 1 count = 0 @@ -329,6 +356,10 @@ class BGPContainer(Container): if count >= timeout: raise Exception('timeout') + def add_static_route(self, network, next_hop): + cmd = '/sbin/ip route add {0} via {1}'.format(network, next_hop) + self.local(cmd) + def create_config(self): raise Exception('implement create_config() method') |