Skip to content

Commit

Permalink
Add simplified package checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Zhurba committed May 25, 2018
1 parent 656157d commit 11c449f
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cvp_checks/global_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,29 @@ groups: {
gtw: 'I@neutron:gateway'
}

simple_packages: {'mitaka': '{"galera": "25.3.10-1~u14.04+mcp1", "telegraf": "1.2", "zookeeper": "3.5", "kibana": "4.6.4", "kafka": "0.10.2.0", "ceph": "10.2.9", "glusterfs": "3.7", "mysql": "5.6.23", "ironic": "7.0", "glance": "12.0.0", "qemu": "2.5", "cassandra": "3.0.13", "git": "1:2.7.4-0ubuntu1", "redis": "3.2", "nova": "13.1.4", "grafana": "4.3.2", "keystone": "9.3.0", "etcd": "3.2.2", "neutron": "8.4.0", "designate": "4.0", "mongodb": "3.4", "influxdb": "1.3.3-1", "libvirt": "1.3.1", "heka": "0.10.1", "heat": "6.1.2", "haproxy": "1.6.3-1~u14.04+mcp1", "ceilometer": "6.1.5", "postgresql": "9.6.2", "nginx": "1.10.0-0ubuntu0.16.0", "opencontrail": "3.1.1", "prometheus": "1.6.3", "rabbitmq": "3.6.6-1~u14.04+mcp1", "elasticsearch": "2.4.5", "horizon": "9.1.2", "cinder": "8.1.1", "virtlet": "0.9.3", "reclass": "1.4.1", "salt": "2016.3"}',
# https://docs.mirantis.com/mcp/q3-17/mcp-release-notes/components-versions.html
'ocata':'{"galera": "25.3.14-1", "telegraf": "1.5", "zookeeper": "3.4.5", "kibana": "5.6.5", "kafka": "2.9.2-0.8.2.0-0contrail0", "ceph": "12.2.2-1enial", "glusterfs": "3.8.15", "mysql": "5.6.35", "ironic": "7.0", "glance": "14.0", "qemu": "2.5", "cassandra": "2.1.20", "git": "2.7.4", "redis": "2.8.4-2", "nova": "15.1.", "grafana": "4.5.2", "keystone": "11.0", "etcd": "2.2.5", "neutron": "10.0", "designate": "4.0", "mongodb": "3.4", "influxdb": "1.4.2", "libvirt": "1.3.1", "heka": "0.10.1", "heat": "8.0", "haproxy": "1.6.3", "ceilometer": "8.1", "postgresql": "9.6", "nginx": "1.10.3", "opencontrail": "3.2", "prometheus": "2.0.0", "rabbitmq": "3.6.5", "elasticsearch": "5.6.5", "horizon": "11.0", "cinder": "10.0", "virtlet": "0.9.3", "reclass": "1.4.1", "salt": "2016.3.8"}',
# https://docs.mirantis.com/mcp/q4-17/mcp-release-notes/components-versions.html
'pike': '{"galera": "25.3.14-1", "fluentd": "1.0.2", "telegraf": "1.5.3", "aodh": "5", "zookeeper": "3.4.5", "kibana": "5.6.5", "kafka": "2.9.2-0.8.2.0-0contrail0", "ceph": "12.2.4-1enial", "glusterfs": "3.8.15", "mysql": "5.6.35", "ironic": "9.1", "glance": "15.0", "grafana": "5.0.3", "qemu": "1:2.11+dfsg-1.1~u16.04+mcp1", "barbican": "5.0", "gnocchi": "4.0.4", "cassandra": "2.1.20", "git": "2.7.4", "redis": "2.8.4-2", "nova": "16.1", "keystone": "12.0", "etcd": "3.3", "neutron": "11.0", "designate": "5.0.1", "haproxy": "1.6.3", "manila": "5.0.1", "mongodb": "3.4", "influxdb": "1.4.2", "libvirt": "4.0.0-1.7~u16.04+mcp1", "heka": "0.10.1", "heat": "9.0", "tls": "1.2", "ceilometer": "9.0.5", "postgresql": "9.6", "nginx": "1.10.3", "opencontrail": "3.2", "prometheus": "2.2.1", "rabbitmq": "rabbitmq-server", "jenkins-master": "2.100", "elasticsearch": "5.6.5", "panko": "3.1", "horizon": "12.0", "cinder": "11.1", "virtlet": "1.0.0", "reclass": "1.4.1", "salt": "2016.3.8"}'
# https://docs.mirantis.com/mcp/q1-18/mcp-release-notes/components-versions.html
}

exclude_packages: [ 'python-neutron-lib', 'python-glance-store',
'python-neutronclient', 'python-glanceclient',
'python-pymysql', 'python-designateclient',
'python-cinderclient', 'python-mysqldb',
'python-heatclient', 'glance-store-common',
'python-novaclient', 'python-ironic-lib',
'python-ironicclient', 'python-elasticsearch-curator',
'python-elasticsearch', 'prometheus-relay',
'influxdb-relay', 'postgresql-client-common',
'python-horizon-neutron-lbaasv2-panel', 'ipxe-qemu',
'libvirt-exporter', 'libdbd-mysql', 'elasticsearch-curator',
'postgresql-common', 'python-gitdb', 'python-github',
'python-aodhclient', 'python-psycopg2',
'libdbd-mysql-perl', 'libdbd-mysql:amd64', 'python-influxdb']

# mtu test setting
# this test may skip groups (see example)
test_mtu:
Expand Down
98 changes: 98 additions & 0 deletions cvp_checks/tests/test_simple_packages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import pytest
import json
import os
from cvp_checks import utils
import lxml, requests
from bs4 import BeautifulSoup


packages = {}

# without SIMPLE_PACKAGES env varibale, we are not going to
# collect versions for packages
if 'SIMPLE_PACKAGES' in os.environ.keys():
config = utils.get_configuration()
packages = json.loads(config['simple_packages'][os.environ['SIMPLE_PACKAGES']])
not_used_packages = json.loads(config['simple_packages'][os.environ['SIMPLE_PACKAGES']])
try:
# let's use latest by default
version = 'latest'
if os.environ['SIMPLE_PACKAGES'] == 'mitaka':
# mitaka docs are obsolete, let's use config only
version = 'q0-17'
if os.environ['SIMPLE_PACKAGES'] == 'ocata':
version = 'q4-17'
if os.environ['SIMPLE_PACKAGES'] == 'pike':
version = 'q1-18'
# get page
page = requests.get("https://docs.mirantis.com/mcp/{}/mcp-release-notes/"
"components-versions.html".format(version))

soup = BeautifulSoup(page.content, 'lxml')
table = soup.find("table")

# parse table with versions
for row in table.findAll("tr"):
cells = row.findAll("td")
flag = 0
comments = ''
if cells == []:
continue
for comp in packages:
# remove this when document is updated
if len(cells) > 3:
comments = cells[3].text
cells = [cell.text.replace('<td>_|</td>','').lower() for cell in cells]
# will be simplified after updating doc
version = cells[2].replace('x','').strip('.').split(",")[0].split(" ")[0]
if comp == cells[1] or comp in comments:
if packages[comp] != version:
print "\nVersion update for {}".format (comp)
packages[comp] = version
flag = 1
if comp in not_used_packages:
del not_used_packages[comp]
continue
if flag == 0:
print "Component/service {0} from site is not found in config".format(cells[1].text)
print "Packages in config, that are not found on site:"
print not_used_packages

except Exception:
print "\nCannot get info from Mirantis web site!"

print "\nPackages to check on environment"
print packages


def test_simple_packages(local_salt_client):
if 'SIMPLE_PACKAGES' not in os.environ.keys():
pytest.skip("This test will be skipped (full package verification will be conducted)")
packages_exclude = config['exclude_packages']
active_nodes = utils.get_active_nodes()
nodes_packages = local_salt_client.cmd(
utils.list_to_target_string(active_nodes, 'or'),
'lowpkg.list_pkgs',
expr_form='compound')
not_verified = packages.keys()
pkts_data = []
for name in packages.keys():
row = []
ver = packages[name]
# iterate by list of nodes
for node in nodes_packages.keys():
compare_on_this_node = [pack for pack in nodes_packages[node].keys() if pack not in packages_exclude and name in pack and 'salt-formula-' not in pack]
if compare_on_this_node:
# so we have a list of packages, matched by mask and not excluded
if name in not_verified:
not_verified.remove(name)
for pack in compare_on_this_node:
if ver not in nodes_packages[node][pack]:
row.append("{0}: Wrong version. Expected {1}={2}, but has {3} for {4}".format(node, name, ver, nodes_packages[node][pack], pack))
if row != []:
pkts_data.append(row)
print "NOT Verified packages"
print not_verified
assert len(pkts_data) <= 1, \
"Several problems found: {0}".format(
json.dumps(pkts_data, indent=4))
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pytest==3.0.6
beautifulsoup4
lxml
requests
flake8
PyYAML

0 comments on commit 11c449f

Please sign in to comment.