Files
zaza-openstack-tests/zaza/openstack/charm_tests/quagga/tests.py
T
Frode Nordahl f35da80f27 Unpin flake8, fix lint
Add Python 3.8 env in Travis CI test matrix.

At present the pinning of flake8 disallows running of lint on
Python 3.8 systems.

Update flake8 ignore-list to ignore W504 instead of W503, the PEP
guidance is that either is ok, but there must be local consistency.

There are more occurences of binary operator before line-break
than after in this repository, and we have also chosen to ignore
W504 in most of our other repositories.
2020-04-07 11:14:49 +02:00

64 lines
2.3 KiB
Python

#!/usr/bin/env python3
# Copyright 2018 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Encapsulating `quagga` testing."""
import logging
import re
import unittest
import zaza
class QuaggaTest(unittest.TestCase):
"""Class for `quagga` tests."""
@classmethod
def setUpClass(cls):
"""Run class setup for `quagga` tests."""
super(QuaggaTest, cls).setUpClass()
def test_bgp_peer_datapath(self):
"""Get peers from BGP neighbour list and ping them."""
status = zaza.model.get_status()
applications = (app for app in ['spine0', 'spine1', 'tor0', 'tor1',
'tor2', 'peer0', 'peer1']
if app in status.applications.keys())
for application in applications:
for unit in zaza.model.get_units(application):
bgp_sum = zaza.model.run_on_unit(
unit.entity_id,
'echo "sh bgp ipv4 unicast summary" | vtysh')['Stdout']
r = re.compile(r'^(\d+\.\d+\.\d+\.\d+)')
ip_list = []
for line in bgp_sum.splitlines():
m = r.match(line)
if m:
ip_list.append(m.group(1))
logging.info('unit {} neighbours {}'
.format(unit.entity_id, ip_list))
if not ip_list:
raise Exception('FAILED: Unit {} has no BGP peers.'
.format(unit.entity_id))
for ip in ip_list:
result = zaza.model.run_on_unit(
unit.entity_id,
'ping -c 3 {}'.format(ip))
logging.info(result['Stdout'])
if result['Code'] == '1':
raise Exception('FAILED')