Added test to check all packages are latest
Added test to check that all packages on the nodes are latest and
are not upgradable. Added the possibility to skip some packages
in global_config if they should not be upgraded.
Problem description:
The 'test_check_package_versions' checks that the versions are
consistent across the nodes of the same group. But we have no
test that the actual versions are really correct and from correct
MCP release. I had the cloud that had some packages installed
from the wrong repositories, not from the required MCP release, so
the fix was to upgrade packages. So there is the need to have
the test to check that the packages are latest.
At the same time if several packages should not be upgraded and
have correct version even if Installed!=Candidate, there is
possibility to skip packages.
Currently the test is skipped by default ("skip_test": True in
global_config.yaml file). Set False to run the test.
Change-Id: Iddfab8b3d7fb4e72870aa0791e9da95a66f0ccfd
diff --git a/test_set/cvp-sanity/global_config.yaml b/test_set/cvp-sanity/global_config.yaml
index b1af7a4..4146147 100644
--- a/test_set/cvp-sanity/global_config.yaml
+++ b/test_set/cvp-sanity/global_config.yaml
@@ -71,6 +71,16 @@
{
"skipped_ifaces": ["lo", "virbr0", "docker_gwbridge", "docker0"]}
+# packages test 'test_packages_are_latest' setting
+# this can skip scecial packages
+# True value for 'skip_test' will skip this test. Set False to run the test.
+# TODO: remove default False value when prod env is fixed
+test_packages:
+ { # "skipped_packages": ["update-notifier-common", "wget"]
+ "skipped_packages": [""],
+ "skip_test": True
+ }
+
# specify what mcp version (tag) is deployed
drivetrain_version: ''
diff --git a/test_set/cvp-sanity/tests/test_packet_checker.py b/test_set/cvp-sanity/tests/test_packet_checker.py
index f76c339..e9448ee 100644
--- a/test_set/cvp-sanity/tests/test_packet_checker.py
+++ b/test_set/cvp-sanity/tests/test_packet_checker.py
@@ -1,6 +1,8 @@
import pytest
import json
+import utils
+
def test_check_package_versions(local_salt_client, nodes_in_group):
output = local_salt_client.cmd("L@"+','.join(nodes_in_group),
@@ -40,6 +42,27 @@
json.dumps(pkts_data, indent=4))
+def test_packages_are_latest(local_salt_client, nodes_in_group):
+ config = utils.get_configuration()
+ skip = config.get("test_packages")["skip_test"]
+ if skip:
+ pytest.skip("Test for the latest packages is disabled")
+ skipped_pkg = config.get("test_packages")["skipped_packages"]
+ info_salt = local_salt_client.cmd(
+ 'L@' + ','.join(nodes_in_group),
+ 'cmd.run', ['apt list --upgradable 2>/dev/null | grep -v Listing'],
+ expr_form='compound')
+ for node in nodes_in_group:
+ result = []
+ if info_salt[node]:
+ upg_list = info_salt[node].split('\n')
+ for i in upg_list:
+ if i.split('/')[0] not in skipped_pkg:
+ result.append(i)
+ assert not result, "Please check not latest packages at {}:\n{}".format(
+ node, "\n".join(result))
+
+
def test_check_module_versions(local_salt_client, nodes_in_group):
pre_check = local_salt_client.cmd(
"L@"+','.join(nodes_in_group),